/* novel-library — calm reading UI. Themes: light / sepia / dark (data-theme on <html>). */

:root {
  --sans: "Pretendard JP Variable", "Pretendard JP", -apple-system, BlinkMacSystemFont, system-ui, "Apple SD Gothic Neo",
    "Noto Sans KR", "Noto Sans JP", "Malgun Gothic", sans-serif;
  --serif: "Noto Serif KR", "Nanum Myeongjo", "NanumMyeongjo", "AppleMyungjo", "Noto Serif JP", "Hiragino Mincho ProN",
    "Yu Mincho", "YuMincho", "Batang", "Source Han Serif", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs: 18px;
  --lh: 1.85;
  --measure: 680px;
  --rbar-h: 52px;
  --banner-h: 0px;
  --radius: 10px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  --bg: #f7f5f0;
  --surface: #fffdf9;
  --raise: #ffffff;
  --ink: #24221f;
  --ink-2: #4b4741;
  --muted: #7b756c;
  --line: #e7e2d8;
  --line-2: #d8d1c4;
  --accent: #a3462c;
  --accent-ink: #ffffff;
  --accent-soft: rgba(163, 70, 44, .09);
  --tint: rgba(60, 50, 30, .045);
  --ja-bg: #f0ece4;
  --shadow: 0 1px 2px rgba(40, 30, 10, .05), 0 8px 28px rgba(40, 30, 10, .08);
  --ok: #3f7a52;
  --warn: #a8701a;
  --bad: #b23a2e;
  color-scheme: light;
}
:root[data-theme="sepia"] {
  --bg: #f3ead8;
  --surface: #f8f1e2;
  --raise: #fbf6ea;
  --ink: #3b3024;
  --ink-2: #554737;
  --muted: #806f59;
  --line: #e4d7bc;
  --line-2: #d6c6a6;
  --accent: #97481f;
  --accent-soft: rgba(151, 72, 31, .1);
  --tint: rgba(90, 60, 20, .055);
  --ja-bg: #ece1c9;
}
:root[data-theme="dark"] {
  --bg: #161615;
  --surface: #1d1d1b;
  --raise: #242422;
  --ink: #dcd8d0;
  --ink-2: #bcb7ad;
  --muted: #8b867d;
  --line: #2d2c29;
  --line-2: #3a3935;
  --accent: #e0896a;
  --accent-ink: #1a1512;
  --accent-soft: rgba(224, 137, 106, .12);
  --tint: rgba(255, 245, 225, .04);
  --ja-bg: #22211f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  --ok: #79b48a;
  --warn: #d6a253;
  --bad: #e07a6e;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  font-feature-settings: "palt" 0;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
a { color: inherit; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
h1, h2, h3 { line-height: 1.3; letter-spacing: -.01em; margin: 0; }
p { margin: 0; }
button { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: .88em; }
code { background: var(--tint); padding: .1em .35em; border-radius: 4px; }
[hidden] { display: none !important; }
:lang(ja) { word-break: normal; line-break: strict; overflow-wrap: break-word; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.count { color: var(--muted); font-weight: 500; font-size: .8em; margin-left: .3em; }
.inline { display: inline; margin: 0; }

/* ---- shell -------------------------------------------------------------- */
.shell { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 20; }
.shell-in { max-width: 1080px; margin: 0 auto; padding: 0 20px; height: 56px; display: flex; align-items: center; gap: 16px; }
.brand { font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; gap: 10px; font-size: 16px; }
.brand-mark, .login-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px;
  background: var(--ink); color: var(--bg); font-size: 15px; font-weight: 600;
}
.shell-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.shell-nav a, .linkbtn {
  text-decoration: none; padding: 6px 10px; border-radius: 8px; color: var(--ink-2); font-size: 14px;
  background: none; border: 0; cursor: pointer;
}
.shell-nav a:hover, .linkbtn:hover { background: var(--tint); color: var(--ink); }
.shell-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.page { max-width: 1080px; margin: 0 auto; padding: 28px 20px 80px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 26px; margin-bottom: 4px; }
.flash { background: var(--accent-soft); border: 1px solid var(--line); color: var(--ink); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.crumbs { font-size: 13px; color: var(--muted); display: flex; gap: 8px; margin-bottom: 18px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
.empty { text-align: center; padding: 64px 16px; display: grid; gap: 10px; justify-items: center; }
.err-code { font-size: 40px; font-weight: 700; color: var(--muted); }
.h2 { font-size: 22px; }

/* ---- buttons, badges ---------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px;
  padding: 8px 16px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface);
  text-decoration: none; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { opacity: .9; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 34px; padding: 5px 12px; font-size: 13px; }
.btn.full { width: 100%; }
.btn-sub { font-weight: 400; opacity: .7; font-size: .9em; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; }
.iconbtn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 9px; border: 0;
  background: transparent; cursor: pointer; color: var(--ink-2); font-size: 22px; line-height: 1; flex: none;
  text-decoration: none;
}
.iconbtn:hover { background: var(--tint); color: var(--ink); }
.iconbtn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.chip {
  border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 4px 12px;
  font-size: 13px; cursor: pointer; color: var(--ink-2); line-height: 1.5;
}
.chip:hover { border-color: var(--muted); color: var(--ink); }
.badge {
  display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  padding: 2px 8px; border-radius: 999px; background: var(--tint); color: var(--ink-2); white-space: nowrap; line-height: 1.6;
}
.badge.sample { background: var(--accent-soft); color: var(--accent); }
.st-reviewed { background: rgba(63, 122, 82, .12); color: var(--ok); }
.st-translated { background: rgba(168, 112, 26, .12); color: var(--warn); }
.st-translating { background: var(--tint); color: var(--ink-2); }
.st-ocr_only { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-2); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.actions.end { justify-content: flex-end; }

/* ---- progress ----------------------------------------------------------- */
.progress { display: grid; gap: 6px; }
.progress-bar { height: 4px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.progress-label { font-size: 12.5px; color: var(--muted); }
.progress-label strong { color: var(--ink-2); font-weight: 600; }

/* ---- covers & shelf ----------------------------------------------------- */
.cover {
  aspect-ratio: 3 / 4; border-radius: 6px; overflow: hidden; background: var(--ja-bg);
  box-shadow: 0 0 0 1px var(--line), 0 6px 16px rgba(40, 30, 10, .08); display: grid; place-items: center;
}
.cover img { width: 100%; height: 100%; object-fit: cover; object-position: right top; display: block; }
.cover-blank { font-size: 40px; color: var(--muted); font-family: var(--serif); }
.cover.lg { width: 168px; flex: none; }
.shelf { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.book-card {
  display: flex; gap: 18px; padding: 18px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; transition: border-color .15s, box-shadow .15s;
}
.book-card:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.book-card-cover { width: 104px; flex: none; }
.book-card-body { display: flex; flex-direction: column; gap: 14px; min-width: 0; flex: 1; }
.book-card-titles h2 { font-size: 18px; margin-top: 2px; }
.book-card-titles h2 a { text-decoration: none; }
.book-card-titles .badge { margin-bottom: 6px; }
.orig { color: var(--muted); font-size: 14px; margin-top: 2px; }
.book-card-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lastread { font-size: 13px; color: var(--ink-2); flex: 1 1 100%; display: flex; min-width: 0; gap: 4px; }
.lastread-ch { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ---- book page ---------------------------------------------------------- */
.sample-note { background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 13px; padding: 8px 14px; border-radius: 9px; margin-bottom: 18px; }
.book-hero { display: flex; gap: 28px; align-items: flex-start; margin-bottom: 36px; }
.book-hero-body { flex: 1; min-width: 0; display: grid; gap: 6px; }
.book-hero h1 { font-size: 28px; }
.book-hero .progress { margin-top: 14px; max-width: 360px; }
.block { margin-top: 34px; }
.block > h2 { font-size: 16px; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.toc { list-style: none; margin: 0; padding: 0; }
.toc-item > a, .toc-item > div {
  display: flex; align-items: center; gap: 14px; padding: 12px 10px; border-radius: 9px; text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.toc-item.open > a:hover { background: var(--tint); }
.toc-item.locked > div { color: var(--muted); cursor: not-allowed; }
.toc-no { width: 24px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; flex: none; }
.toc-titles { display: grid; flex: 1; min-width: 0; }
.toc-ko { font-weight: 600; }
.toc-item.locked .toc-ko { font-weight: 500; }
.toc-ja { font-size: 12.5px; color: var(--muted); }
.toc.compact .toc-item > a, .toc.compact .toc-item > div { padding: 10px 12px; border-bottom: 0; }
.toc.compact .toc-item.current > a { background: var(--accent-soft); }
.toc.compact .toc-item.current .toc-ko { color: var(--accent); }
.bm-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.bm { display: flex; align-items: flex-start; gap: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.bm > a, .bm > div { flex: 1; min-width: 0; display: grid; gap: 2px; padding: 10px 12px; text-decoration: none; }
.bm > a:hover { background: var(--tint); border-radius: 10px; }
.bm-ch { font-size: 12px; color: var(--muted); font-weight: 600; }
.bm-snip { font-size: 14px; }
.bm-note { font-size: 13px; color: var(--accent); }
.bm-date { font-size: 11.5px; color: var(--muted); }
.bm-del { font-size: 18px; width: 34px; height: 34px; margin: 4px; }
.dl-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.log-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 13.5px; }
.log-list li { display: flex; gap: 10px; align-items: baseline; padding: 6px 2px; flex-wrap: wrap; }
.log-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; transform: translateY(-1px); }
.log-list .fail .log-dot { background: var(--bad); }
.log-list .fail .log-msg { color: var(--bad); }
.log-when { color: var(--muted); font-variant-numeric: tabular-nums; }
.log-ver { color: var(--ink-2); }
.log-msg { flex: 1 1 280px; min-width: 0; }

/* ---- status table ------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.status-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.status-table th, .status-table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.status-table thead th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.status-table tbody tr:last-child > * { border-bottom: 0; }
.status-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.status-table th[scope="row"] { font-weight: 600; min-width: 180px; }
.result { font-weight: 600; }
.result.ok { color: var(--ok); }
.result.fail { color: var(--bad); }

/* ---- login -------------------------------------------------------------- */
.login-page .page { min-height: 100vh; display: grid; place-items: center; }
.login-box { width: min(360px, 100%); display: grid; gap: 10px; }
.login-mark { width: 40px; height: 40px; font-size: 20px; border-radius: 10px; }
.login-box h1 { font-size: 22px; margin-top: 8px; }
.login-box form { display: grid; gap: 14px; margin-top: 14px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
input {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 9px; padding: 10px 12px; min-height: 44px; width: 100%;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

/* ======================================================================== */
/* reader                                                                   */
/* ======================================================================== */
.reader.is-sample { --banner-h: 30px; }
.rbar {
  position: fixed; inset: 0 0 auto 0; z-index: 30; height: var(--rbar-h);
  background: color-mix(in srgb, var(--bg) 97%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.rbar-in { height: 100%; display: flex; align-items: center; gap: 2px; padding: 0 6px; max-width: 1400px; margin: 0 auto; }
.rbar-title { flex: 1; min-width: 0; display: grid; line-height: 1.25; padding: 0 6px; }
.rbar-book { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rbar-ch { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aa { font-weight: 700; font-size: 17px; letter-spacing: -.04em; }
.aa small { font-size: 12px; }
.rprogress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; }
.rprogress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .12s linear; }
.contrast-toggle { display: none; }
.sample-banner {
  position: fixed; top: var(--rbar-h); left: 0; right: 0; z-index: 29; height: var(--banner-h);
  display: grid; place-items: center; font-size: 12.5px; font-weight: 600; letter-spacing: .02em;
  background: var(--accent); color: var(--accent-ink);
}
.rmain { padding: calc(var(--rbar-h) + var(--banner-h) + 36px) 20px 40px; }
.chapter {
  max-width: var(--measure); margin: 0 auto; font-size: var(--fs); line-height: var(--lh);
  color: var(--ink); letter-spacing: -.003em;
}
[data-font="serif"] .chapter, [data-font="serif"] .ch-nav { font-family: var(--serif); }
.ch-title { font-size: 1.45em; line-height: 1.4; font-weight: 700; letter-spacing: -.015em; margin: .4em 0 1.6em; }
[data-font="serif"] .ch-title { font-weight: 600; }
.seg { margin: 0 0 calc(var(--fs) * .95); position: relative; scroll-margin-top: calc(var(--rbar-h) + var(--banner-h) + 16px); }
.seg .ko { border-radius: 8px; margin: 0 -10px; padding: 1px 10px; cursor: pointer; transition: background .15s; -webkit-tap-highlight-color: transparent; position: relative; }
.seg .ko p { white-space: pre-line; }
.seg .ko:focus-visible { outline-offset: 0; }
@media (hover: hover) { .seg .ko:hover { background: var(--tint); } }
.seg.open > .ko { background: var(--accent-soft); }
.seg.open > .ko::before, .seg.flash > .ko::before {
  content: ""; position: absolute; left: -2px; top: 6px; bottom: 6px; width: 3px; border-radius: 3px; background: var(--accent);
}
.seg.flash > .ko { animation: flash 1.6s var(--ease); }
@keyframes flash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }
.seg.marked > .ko::after {
  content: ""; position: absolute; left: -16px; top: .45em; width: 8px; height: 13px; background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 74%, 0 100%); opacity: .85;
}
.seg.heading .ch-title { margin: 0; }
.seg.heading { margin: .4em 0 1.6em; }
.brk { height: calc(var(--fs) * var(--lh) * 1.2); }
.brk::after { content: "＊"; display: block; text-align: center; color: var(--line-2); font-size: .8em; line-height: calc(var(--fs) * var(--lh) * 1.2); }

.ja-panel {
  display: none; margin: 8px 0 4px; padding: 12px 14px 10px; background: var(--ja-bg); border-radius: 10px;
  font-size: max(14px, calc(var(--fs) * .86)); line-height: 1.85; color: var(--ink-2);
}
.seg.open > .ja-panel { display: block; animation: rise .18s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.ja + .ja { margin-top: .6em; }
.ja-text { white-space: pre-line; font-feature-settings: "palt" 0; }
.ja-heading .ja-text { font-weight: 600; }
.ja-flags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; font-size: 12px; line-height: 1.5; }
.flag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px; }
.flag.corr { background: var(--tint); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line-2); cursor: pointer; }
.flag.unsure { background: rgba(168, 112, 26, .14); color: var(--warn); }
.flag-corr summary { list-style: none; display: inline; }
.flag-corr summary::-webkit-details-marker { display: none; }
.flag-corr[open] { flex-basis: 100%; }
.ocr-orig { display: block; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.ja-note { color: var(--muted); }
.ja-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

.ch-nav { max-width: var(--measure); margin: 64px auto 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ch-nav a {
  display: grid; gap: 2px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none;
  font-weight: 600; font-size: 15px; background: var(--surface);
}
.ch-nav a:hover { border-color: var(--line-2); }
.ch-nav-next { text-align: right; grid-column: 2; }

/* contrast (side-by-side) mode — PC only */
@media (min-width: 1100px) {
  .contrast-toggle { display: inline-grid; }
  .reader.contrast .chapter, .reader.contrast .ch-nav { max-width: min(calc(var(--measure) * 2 + 56px), 1320px); }
  .reader.contrast .seg { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 56px; align-items: start; }
  .reader.contrast .seg > .ja-panel {
    display: block; margin: 0; padding: 1px 0 0 22px; background: none; border-radius: 0; border-left: 1px solid var(--line);
    animation: none; min-height: 100%; position: relative;
  }
  .reader.contrast .seg .ja-actions {
    opacity: 0; transition: opacity .15s; margin: 0; position: absolute; right: 0; top: -2px; z-index: 1;
    padding: 0 0 4px 28px; background: linear-gradient(to right, transparent, var(--bg) 24px);
  }
  .reader.contrast .seg:hover .ja-actions, .reader.contrast .seg.open .ja-actions, .reader.contrast .seg:focus-within .ja-actions { opacity: 1; }
  .reader.contrast .seg.heading > .ja-panel { font-size: 1.1em; }
  .reader.contrast .brk { grid-column: 1 / -1; }
}

/* scrim, drawer, sheets */
.scrim { position: fixed; inset: 0; background: rgba(10, 8, 5, .32); z-index: 40; animation: fade .18s; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; top: 0; bottom: 0; right: 0; width: min(380px, 90vw); z-index: 41; background: var(--surface);
  border-left: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column;
  animation: slide .22s var(--ease);
}
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 0 14px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs [role="tab"] { border: 0; background: none; padding: 10px 10px 12px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs [role="tab"][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.drawer-body { overflow-y: auto; padding: 12px; flex: 1; overscroll-behavior: contain; }
.sheet {
  position: fixed; z-index: 42; background: var(--raise); border: 1px solid var(--line); box-shadow: var(--shadow);
  left: 0; right: 0; bottom: 0; border-radius: 16px 16px 0 0; padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
  animation: up .22s var(--ease); max-height: 85vh; overflow-y: auto;
}
@keyframes up { from { transform: translateY(16px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet-head h2 { font-size: 15px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.set-label { font-size: 14px; color: var(--ink-2); font-weight: 600; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; }
.stepper button { border: 0; background: none; min-width: 48px; height: 38px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.stepper button:hover { background: var(--tint); }
.stepper output { min-width: 58px; text-align: center; font-variant-numeric: tabular-nums; font-size: 14px; border-inline: 1px solid var(--line); line-height: 38px; }
.seg-ctl { display: flex; border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg-ctl button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; font-size: 13.5px; color: var(--ink-2); }
.seg-ctl button[aria-checked="true"] { background: var(--ink); color: var(--bg); font-weight: 600; }
.seg-ctl .serif { font-family: var(--serif); }
.sw::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2); vertical-align: -1px; }
.sw-light::before { background: #f7f5f0; }
.sw-sepia::before { background: #f3ead8; }
.sw-dark::before { background: #1d1d1b; }
.bm-sheet-snip { font-size: 14px; color: var(--ink-2); background: var(--tint); padding: 10px 12px; border-radius: 9px; margin: 6px 0 12px; max-height: 6.5em; overflow: hidden; }
.field { margin-bottom: 4px; }
@media (min-width: 720px) {
  .sheet { left: auto; right: 16px; top: calc(var(--rbar-h) + 8px); bottom: auto; width: 360px; border-radius: 14px; padding: 8px 18px 14px; }
  .bm-sheet { right: 50%; transform: translateX(50%); top: 22vh; width: 420px; animation: none; }
}

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 999px; font-size: 13.5px; box-shadow: var(--shadow);
  animation: up .2s var(--ease);
}

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 50; background: #131211; color: #eee; display: flex; flex-direction: column; animation: fade .15s; }
.lb-top, .lb-bottom { display: flex; align-items: center; gap: 8px; padding: 8px 10px; flex: none; }
.lb-top { padding-top: calc(8px + env(safe-area-inset-top)); flex-wrap: wrap; }
.lb-bottom { justify-content: center; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.lightbox .iconbtn { color: #ddd; }
.lightbox .iconbtn:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.lightbox .iconbtn:disabled { opacity: .3; cursor: default; background: none; }
.lightbox .chip { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .18); color: #ddd; }
.lightbox .chip:hover { border-color: rgba(255, 255, 255, .4); color: #fff; }
.lb-tabs { display: flex; gap: 4px; overflow-x: auto; }
.lb-tabs button { border: 1px solid rgba(255, 255, 255, .18); background: none; color: #bbb; border-radius: 8px; padding: 4px 10px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.lb-tabs button[aria-selected="true"] { background: #eee; color: #111; border-color: #eee; font-weight: 600; }
.lb-meta { flex: 1; min-width: 0; font-size: 12.5px; color: #aaa; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-meta b { color: #eee; font-weight: 600; }
.lb-close { margin-left: auto; }
.lb-stage { flex: 1; position: relative; overflow: hidden; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.lb-stage.dragging { cursor: grabbing; }
.lb-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.lb-canvas img { display: block; width: 100%; height: 100%; background: #fff; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); pointer-events: none; }
.lb-canvas svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.lb-canvas rect { fill: rgba(255, 186, 40, .22); stroke: #f0a020; stroke-width: 2; vector-effect: non-scaling-stroke; }
.lb-loading { position: absolute; inset: 0; display: grid; place-items: center; color: #999; font-size: 14px; pointer-events: none; }
.no-scroll { overflow: hidden; }

/* ---- responsive --------------------------------------------------------- */
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .shell-in { padding: 0 12px; gap: 8px; }
  .brand { font-size: 15px; }
  .shell-nav a, .linkbtn { padding: 6px 8px; font-size: 13.5px; }
  .page { padding: 20px 14px 64px; }
  .page-head h1 { font-size: 22px; }
  .shelf { grid-template-columns: 1fr; }
  .book-card { padding: 14px; gap: 14px; }
  .book-card-cover { width: 84px; }
  .book-hero { gap: 16px; }
  .cover.lg { width: 104px; }
  .book-hero h1 { font-size: 21px; }
  .rmain { padding-left: 18px; padding-right: 18px; padding-top: calc(var(--rbar-h) + var(--banner-h) + 24px); }
  .seg .ko { margin: 0 -8px; padding: 1px 8px; }
  .seg.marked > .ko::after { left: -10px; width: 6px; height: 11px; }
  .ch-nav { margin-top: 48px; }
  .status-table th, .status-table td { padding: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
