/* ════════════════════════════════════════════════════════════════════
   PROBE探针图书馆 — mobile reader styles
   Body reading first: restrained, low-saturation, "read long without
   fatigue". Latent-space motion appears only on covers / detail /
   interludes — never behind running text. Gold #F69155 as accent only.
   ════════════════════════════════════════════════════════════════════ */

:root {
  --gold:        #F69155;
  --gold-deep:   #D96E33;
  --gold-soft:   #FBE7D4;
  --latent-a:    #1B2A4A;
  --latent-b:    #2E1B4A;

  /* reader settings (overridden by JS) */
  --rs-fs:   19px;     /* body font size */
  --rs-lh:   1.92;     /* line height */
  --rs-mar:  26px;     /* page side margin */
  --rs-bright: 1;      /* brightness multiplier */

  /* pagination geometry (set by engine) */
  --page-w: 320px;
  --page-h: 600px;
  --col-gap: 48px;

  --font-serif: 'Noto Serif SC','Songti SC','Newsreader', serif;
  --font-sans:  'Noto Sans SC','PingFang SC','Newsreader', system-ui, sans-serif;
  --font-kai:   'Kaiti SC','STKaiti','Noto Serif SC', serif;
  --font-latin: 'Newsreader', Georgia, serif;
  --font-ui:    'Noto Sans SC','PingFang SC', system-ui, -apple-system, sans-serif;
  --font-mono:  'Spline Sans Mono','JetBrains Mono', ui-monospace, monospace;
  --font-read:  var(--font-serif);
}

/* ── themes ──────────────────────────────────────────────────────── */
[data-theme="paper"] {
  --r-bg:#F5F1E8; --r-bg-2:#EFE9DC; --r-ink:#2A241B; --r-ink-soft:#6E6453;
  --r-faint:#A89C86; --r-rule:rgba(42,36,27,.12); --r-rule-2:rgba(42,36,27,.07);
  --r-accent:#C2641E; --r-accent-block:rgba(246,145,85,.16); --r-hl:rgba(194,100,30,.16);
  --r-chrome:#FBF8F2; --r-chrome-ink:#3A3225; --r-term:#B4611E;
}
[data-theme="green"] {
  --r-bg:#D8E5D2; --r-bg-2:#CDDCC6; --r-ink:#24302180; --r-ink:#26301F; --r-ink-soft:#566048;
  --r-faint:#8A957C; --r-rule:rgba(38,48,31,.12); --r-rule-2:rgba(38,48,31,.06);
  --r-accent:#A85A1E; --r-accent-block:rgba(168,90,30,.14); --r-hl:rgba(168,90,30,.15);
  --r-chrome:#E0EBDA; --r-chrome-ink:#33402B; --r-term:#9C5418;
}
[data-theme="white"] {
  --r-bg:#FCFCFB; --r-bg-2:#F3F3F1; --r-ink:#1E1E1E; --r-ink-soft:#5E5E5E;
  --r-faint:#A0A0A0; --r-rule:rgba(0,0,0,.1); --r-rule-2:rgba(0,0,0,.05);
  --r-accent:#D96E33; --r-accent-block:rgba(246,145,85,.16); --r-hl:rgba(217,110,51,.15);
  --r-chrome:#FFFFFF; --r-chrome-ink:#262626; --r-term:#C9621F;
}
[data-theme="night"] {
  --r-bg:#0E0E14; --r-bg-2:#15151E; --r-ink:#E8E2D6; --r-ink-soft:#9A948A;
  --r-faint:#5C5850; --r-rule:rgba(232,226,214,.12); --r-rule-2:rgba(232,226,214,.06);
  --r-accent:#F69155; --r-accent-block:rgba(246,145,85,.14); --r-hl:rgba(246,145,85,.20);
  --r-chrome:#14141C; --r-chrome-ink:#E8E2D6; --r-term:#F6A86E;
}

/* ════════════════════════════════════════════════════════════════════
   RESET
   ════════════════════════════════════════════════════════════════════ */
*,*::before,*::after { box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html,body { margin:0; height:100%; }
body {
  background:#08080C;
  font-family:var(--font-ui);
  color:#fff;
  display:grid; place-items:center;
  min-height:100svh;
  overflow:hidden;
}
button { font:inherit; color:inherit; background:none; border:none; cursor:pointer; padding:0; }
a { color:inherit; text-decoration:none; }
:focus-visible { outline:2px solid var(--gold); outline-offset:2px; }

/* ════════════════════════════════════════════════════════════════════
   DEVICE FRAME  (phone bezel — the app is the mobile web inside)
   ════════════════════════════════════════════════════════════════════ */
.device {
  position:relative;
  width:402px; height:858px;
  background:#0a0a0f;
  border-radius:54px;
  padding:13px;
  box-shadow:
    0 0 0 2px #2a2a30,
    0 0 0 11px #121216,
    0 40px 90px -20px rgba(0,0,0,.8),
    0 0 120px -30px rgba(246,145,85,.10);
  flex:0 0 auto;
}
.device::after { /* side button */
  content:''; position:absolute; right:-13px; top:200px; width:4px; height:78px;
  background:#16161a; border-radius:0 3px 3px 0;
}
.screen {
  position:relative; width:100%; height:100%;
  background:var(--r-bg);
  border-radius:42px; overflow:hidden;
  transition:background .4s ease;
}
/* brightness veil */
.screen::after {
  content:''; position:absolute; inset:0; z-index:60; pointer-events:none;
  background:#000; opacity:calc(1 - var(--rs-bright)); transition:opacity .25s ease;
}

@media (max-width:430px), (max-height:900px) {
  body { align-items:flex-start; }
  .device {
    width:100vw; height:100svh; border-radius:0; padding:0;
    box-shadow:none;
  }
  .device::after { display:none; }
  .screen { border-radius:0; }
}

/* status bar */
.statusbar {
  position:absolute; top:0; left:0; right:0; height:46px; z-index:55;
  display:flex; align-items:center; justify-content:space-between;
  padding:0 28px; font-family:var(--font-ui);
  color:var(--r-ink); font-size:14px; font-weight:600;
  pointer-events:none;
}
.statusbar__time { letter-spacing:.02em; }
.statusbar__right { display:flex; align-items:center; gap:6px; }
.statusbar__right svg { width:17px; height:13px; display:block; }
.statusbar.is-hidden { opacity:0; transition:opacity .3s; }

/* the app surface fills the screen */
.app { position:absolute; inset:0; font-family:var(--font-ui); }
.scroll { position:absolute; inset:0; overflow-y:auto; -webkit-overflow-scrolling:touch; }

/* ════════════════════════════════════════════════════════════════════
   screen transitions (router) — slide
   ════════════════════════════════════════════════════════════════════ */
.view { position:absolute; inset:0; background:var(--r-bg); }

/* ════════════════════════════════════════════════════════════════════
   LIBRARY  (书架)
   ════════════════════════════════════════════════════════════════════ */
.lib { position:absolute; inset:0; background:var(--r-bg); color:var(--r-ink); }
.lib__scroll { position:absolute; inset:0; overflow-y:auto; padding:54px 22px 40px; }
.lib__top { display:flex; align-items:center; justify-content:space-between; margin-bottom:6px; }
.lib__name { font-family:var(--font-serif); font-size:25px; font-weight:600; letter-spacing:.01em; }
.lib__name b { color:var(--gold); }
.lib__globe { width:40px;height:40px;border-radius:50%; display:grid;place-items:center; color:var(--r-ink-soft); border:1px solid var(--r-rule); }
.lib__globe svg { width:19px;height:19px; }
.lib__search {
  margin:16px 0 8px; height:42px; border-radius:21px; background:var(--r-bg-2);
  display:flex; align-items:center; gap:10px; padding:0 16px; color:var(--r-faint); font-size:14px;
}
.lib__search svg { width:16px;height:16px; }
.lib__cats { display:flex; gap:9px; margin:16px 0 22px; overflow-x:auto; padding-bottom:4px; }
.chip { flex:0 0 auto; padding:7px 15px; border-radius:16px; font-size:13px; background:var(--r-bg-2); color:var(--r-ink-soft); }
.chip.is-on { background:var(--r-accent); color:#fff; }

.shelf { display:grid; grid-template-columns:1fr 1fr; gap:20px 18px; }
.bookcard { cursor:pointer; }
.bookcard__cover {
  position:relative; width:100%; aspect-ratio:3/4.3; border-radius:10px; overflow:hidden;
  box-shadow:0 10px 26px -10px rgba(0,0,0,.55), 0 2px 6px rgba(0,0,0,.25);
}
.bookcard__cover canvas { position:absolute; inset:0; width:100%; height:100%; display:block; }
.bookcard__spine { position:absolute; left:0; top:0; bottom:0; width:5px; background:linear-gradient(180deg, rgba(255,255,255,.18), rgba(0,0,0,.25)); }
.bookcard__title { position:absolute; left:12px; right:12px; top:20px; font-family:var(--font-serif); color:#F4EBDD; font-weight:600; font-size:15px; line-height:1.3; text-shadow:0 2px 12px rgba(0,0,0,.6); }
.bookcard__title .amt { color:var(--gold); }
.bookcard__author { position:absolute; left:12px; bottom:14px; font-size:11px; color:rgba(244,235,221,.72); letter-spacing:.04em; }
.bookcard__soon { position:absolute; top:10px; right:10px; background:rgba(0,0,0,.5); color:#fff; font-size:10px; padding:3px 7px; border-radius:6px; backdrop-filter:blur(4px); }
.bookcard__meta { margin-top:9px; }
.bookcard__bt { font-family:var(--font-serif); font-size:13.5px; font-weight:600; color:var(--r-ink); line-height:1.35; }
.bookcard__bw { font-size:11px; color:var(--r-faint); margin-top:3px; }

/* ════════════════════════════════════════════════════════════════════
   BOOK DETAIL
   ════════════════════════════════════════════════════════════════════ */
.detail { position:absolute; inset:0; background:var(--r-bg); color:var(--r-ink); }
.detail__scroll { position:absolute; inset:0; overflow-y:auto; padding-bottom:120px; }
.detail__hero {
  position:relative; padding:54px 24px 30px; text-align:center; overflow:hidden;
}
.detail__heroveil { position:absolute; inset:0; z-index:0;
  background:radial-gradient(120% 80% at 50% 0%, rgba(46,27,74,.28), transparent 60%); }
.detail__back { position:absolute; top:54px; left:18px; z-index:5; width:38px;height:38px;border-radius:50%;
  display:grid;place-items:center; color:var(--r-ink); background:var(--r-bg-2); }
.detail__back svg { width:18px;height:18px; }
.detail__cover {
  position:relative; z-index:1; width:188px; aspect-ratio:3/4.3; margin:6px auto 0; border-radius:12px; overflow:hidden;
  box-shadow:0 24px 50px -14px rgba(0,0,0,.6), 0 4px 12px rgba(0,0,0,.3);
}
.detail__cover canvas { position:absolute; inset:0; width:100%;height:100%; display:block; }
.detail__title { position:relative; z-index:1; margin-top:26px; font-family:var(--font-serif); font-size:24px; font-weight:600; line-height:1.3; }
.detail__title .amt { color:var(--gold); }
.detail__sub { position:relative; z-index:1; margin-top:12px; font-size:14px; color:var(--r-ink-soft); line-height:1.6; max-width:30em; margin-inline:auto; }
.detail__author { position:relative; z-index:1; margin-top:16px; display:inline-flex; align-items:center; gap:7px; font-size:14px; color:var(--r-ink); }
.detail__author b { font-family:var(--font-serif); font-weight:600; }
.verified { display:inline-flex; width:16px;height:16px; border-radius:50%; background:var(--gold); color:#fff; align-items:center; justify-content:center; }
.verified svg { width:10px;height:10px; }

/* word-of-mouth */
.wom { margin:30px 22px 0; padding:22px; border-radius:16px; background:var(--r-bg-2); }
.wom__top { display:flex; align-items:center; gap:18px; }
.wom__score { text-align:center; }
.wom__num { font-family:var(--font-mono); font-size:34px; font-weight:600; color:var(--r-accent); line-height:1; }
.wom__lbl { font-size:11px; color:var(--r-ink-soft); margin-top:5px; letter-spacing:.05em; }
.wom__laurel { flex:1; }
.wom__crown { display:inline-flex; align-items:center; gap:7px; font-family:var(--font-serif); font-weight:600; font-size:15px; color:var(--r-ink); }
.wom__crown svg { width:18px;height:18px; color:var(--gold); }
.wom__reviews { font-size:12px; color:var(--r-ink-soft); margin-top:7px; }
.wom__bar { display:flex; height:7px; border-radius:4px; overflow:hidden; margin-top:16px; background:var(--r-rule); }
.wom__bar i { display:block; height:100%; }
.wom__bar .a { background:var(--gold); }
.wom__bar .n { background:var(--r-faint); }
.wom__bar .s { background:var(--r-rule); }
.wom__keys { display:flex; justify-content:space-between; margin-top:9px; font-size:11px; color:var(--r-ink-soft); }
.wom__keys span i { font-style:normal; color:var(--r-ink); font-weight:600; }

.stats { display:flex; margin:24px 22px 0; padding:18px 0; border-top:1px solid var(--r-rule); border-bottom:1px solid var(--r-rule); }
.stat { flex:1; text-align:center; }
.stat + .stat { border-inline-start:1px solid var(--r-rule); }
.stat__v { font-family:var(--font-mono); font-size:18px; font-weight:600; color:var(--r-ink); }
.stat__l { font-size:11px; color:var(--r-ink-soft); margin-top:5px; }

.detail__blurb { margin:24px 24px 0; }
.detail__blurb h4 { font-family:var(--font-serif); font-size:15px; font-weight:600; margin:0 0 10px; color:var(--r-ink); }
.detail__blurb p { font-family:var(--font-serif); font-size:15px; line-height:1.85; color:var(--r-ink-soft); margin:0; text-align:justify; }
.detail__tocbtn { margin:22px 24px 0; padding:16px 18px; border-radius:14px; background:var(--r-bg-2); display:flex; align-items:center; justify-content:space-between; }
.detail__tocbtn span { font-size:14px; color:var(--r-ink); }
.detail__tocbtn b { font-family:var(--font-serif); font-weight:600; }
.detail__tocbtn svg { width:18px;height:18px; color:var(--r-faint); }

/* sticky CTA */
.detail__cta {
  position:absolute; left:0; right:0; bottom:0; z-index:10;
  padding:14px 22px calc(20px + env(safe-area-inset-bottom));
  background:linear-gradient(180deg, transparent, var(--r-bg) 28%);
}
.detail__swipe { text-align:center; font-size:12px; color:var(--r-faint); margin-bottom:10px; letter-spacing:.08em; }
.btn-primary {
  width:100%; height:54px; border-radius:27px; background:var(--gold); color:#fff;
  font-family:var(--font-serif); font-size:17px; font-weight:600; letter-spacing:.04em;
  display:flex; align-items:center; justify-content:center; gap:8px;
  box-shadow:0 10px 26px -8px rgba(246,145,85,.6);
}
.detail__row2 { display:flex; gap:10px; margin-top:10px; }
.btn-ghost { flex:1; height:46px; border-radius:23px; border:1px solid var(--r-rule); color:var(--r-ink-soft); font-size:14px; display:flex; align-items:center; justify-content:center; gap:7px; }
.btn-ghost svg { width:16px;height:16px; }
.btn-ghost.is-on { color:var(--r-accent); border-color:var(--r-accent); }

/* ════════════════════════════════════════════════════════════════════
   READER  (核心)
   ════════════════════════════════════════════════════════════════════ */
.reader { position:absolute; inset:0; background:var(--r-bg); color:var(--r-ink);
  font-family:var(--font-read); filter:saturate(.96); }

/* minimal top chapter tag (silent state) */
.reader__tag {
  position:absolute; top:0; left:0; right:0; height:46px; z-index:20;
  display:flex; align-items:flex-end; justify-content:center; padding-bottom:6px;
  font-family:var(--font-ui); font-size:11.5px; color:var(--r-faint); letter-spacing:.02em;
  pointer-events:none; white-space:nowrap; overflow:hidden;
}

/* pagination viewport */
.reader__clip { position:absolute; top:46px; left:0; right:0; bottom:34px; overflow:hidden; }
.reader__host {
  height:var(--page-h); width:var(--page-w);
  column-width:var(--page-w); column-gap:var(--col-gap); column-fill:auto;
  padding:0; margin:0 auto;
  transform:translateX(0);
  transition:transform .34s cubic-bezier(.4,.0,.2,1);
}
.reader__host.no-anim { transition:none; }
[dir="rtl"] .reader__host { /* RTL flips column flow naturally */ }

/* scroll mode */
.reader.is-scroll .reader__clip { overflow-y:auto; }
.reader.is-scroll .reader__host { height:auto; width:var(--page-w); column-width:auto; column-count:1; transform:none !important; transition:none; padding-bottom:60px; }

/* reading typography */
.reader__host { font-size:var(--rs-fs); line-height:var(--rs-lh); color:var(--r-ink); }
.rp {
  margin:0 0 .92em; text-align:justify; text-justify:inter-character;
  hanging-punctuation:allow-end last; word-break:break-word;
}
.rp.lead { text-indent:0; }
.rp:not(.lead):not(.after-h) { text-indent:2em; }
.rp.lead::first-letter { /* subtle, not a giant drop cap for mobile */ }
.rh {
  font-family:var(--font-serif); font-weight:600; font-size:1.04em; color:var(--r-ink);
  margin:1.7em 0 .8em; letter-spacing:.01em;
}
.rq { margin:1.3em 0; padding-inline-start:14px; border-inline-start:2px solid var(--r-accent); }
.rq p { font-style:italic; color:var(--r-ink); margin:0; line-height:1.7; }
.rq cite { display:block; margin-top:8px; font-style:normal; font-family:var(--font-ui); font-size:.7em; letter-spacing:.08em; color:var(--r-faint); }
.rf { margin:1.4em 0; padding:16px; border-radius:10px; background:var(--r-bg-2); text-align:center; }
.rf .rf__cap { margin-top:10px; font-family:var(--font-ui); font-size:.66em; letter-spacing:.06em; color:var(--r-faint); }
.rf .katex { color:var(--r-ink); font-size:1.05em; }

/* chapter title — soft accent block */
.rchap { break-inside:avoid; margin:6px 0 1.4em; }
.rchap__ey { font-family:var(--font-ui); font-size:.62em; letter-spacing:.22em; text-transform:uppercase; color:var(--r-accent); margin-bottom:12px; }
.rchap__block {
  display:inline-block; border-radius:10px; padding:12px 16px; background:var(--r-accent-block);
}
.rchap__t { font-family:var(--font-serif); font-weight:600; font-size:1.42em; line-height:1.3; color:var(--r-ink); }

/* inline key term */
.term { color:var(--r-term); border-bottom:1px dotted var(--r-term); cursor:pointer; padding-bottom:1px; }
/* highlight (划线) */
.hl { background:var(--r-hl); border-bottom:1px dashed var(--r-accent); border-radius:2px; cursor:pointer; }

/* page number */
.reader__page { position:absolute; left:0; right:0; bottom:0; height:34px; z-index:20;
  display:flex; align-items:center; justify-content:center; gap:10px;
  font-family:var(--font-mono); font-size:11px; color:var(--r-faint); pointer-events:none; }
.reader__page .pct { opacity:.7; }

/* tap zones */
.reader__zones { position:absolute; inset:46px 0 34px; z-index:15; display:flex; }
.reader__zone { flex:1; }
[dir="rtl"] .reader__zones { flex-direction:row-reverse; }

/* edge page-turn hint arrows (faint) */
.reader__edge { position:absolute; top:50%; z-index:16; transform:translateY(-50%); color:var(--r-faint); opacity:.0; transition:opacity .2s; pointer-events:none; }
.reader__edge svg { width:22px;height:22px; }

/* ── invoked top bar ─────────────────────────────────────────────── */
.rbar { position:absolute; left:0; right:0; z-index:40; background:var(--r-chrome); color:var(--r-chrome-ink);
  transition:transform .32s cubic-bezier(.4,0,.2,1); }
.rbar--top { top:0; padding:46px 12px 12px; display:flex; align-items:center; gap:6px;
  box-shadow:0 1px 0 var(--r-rule); transform:translateY(-100%); }
.rbar--top.is-on { transform:translateY(0); }
.rbar__btn { width:40px;height:40px;border-radius:50%; display:grid;place-items:center; color:var(--r-chrome-ink); }
.rbar__btn svg { width:21px;height:21px; }
.rbar__readers { flex:1; display:flex; align-items:center; gap:6px; font-size:12px; color:var(--r-ink-soft); justify-content:center; }
.rbar__readers b { color:var(--r-accent); font-family:var(--font-mono); font-weight:600; }

.rbar--bottom { bottom:0; padding:10px 6px calc(12px + env(safe-area-inset-bottom)); display:flex;
  box-shadow:0 -1px 0 var(--r-rule); transform:translateY(100%); }
.rbar--bottom.is-on { transform:translateY(0); }
.rkey { flex:1; display:flex; flex-direction:column; align-items:center; gap:5px; padding:6px 0; color:var(--r-chrome-ink); font-size:11px; }
.rkey svg { width:23px;height:23px; }
.rkey.is-active { color:var(--r-accent); }

/* floating 听 / Ai */
.rfloat { position:absolute; right:14px; top:calc(env(safe-area-inset-top,0px) + 96px); z-index:35; display:flex; flex-direction:column; gap:10px;
  transition:opacity .3s, transform .3s; }
[dir="rtl"] .rfloat { right:auto; left:14px; }
.rfloat.is-hidden { opacity:0; transform:translateY(-10px); pointer-events:none; }
.rfab { width:50px;height:50px;border-radius:25px; background:var(--r-chrome); color:var(--r-chrome-ink);
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:1px;
  box-shadow:0 6px 18px -4px rgba(0,0,0,.4), 0 0 0 1px var(--r-rule); font-size:10px; }
.rfab svg { width:20px;height:20px; }
.rfab--ai { background:var(--gold); color:#fff; box-shadow:0 8px 20px -4px rgba(246,145,85,.6); font-family:var(--font-serif); font-weight:600; }
.rfab--ai b { font-size:17px; line-height:1; }

/* ════════════════════════════════════════════════════════════════════
   BOTTOM SHEET (drawer) — TOC / AI / Search ; Settings ; panels
   ════════════════════════════════════════════════════════════════════ */
.scrim { position:absolute; inset:0; z-index:70; background:rgba(0,0,0,.42);
  opacity:0; visibility:hidden; transition:opacity .3s, visibility .3s; }
.scrim.is-on { opacity:1; visibility:visible; }

.sheet {
  position:absolute; left:0; right:0; bottom:0; z-index:75; background:var(--r-chrome); color:var(--r-chrome-ink);
  border-radius:20px 20px 0 0; box-shadow:0 -10px 40px rgba(0,0,0,.4);
  transform:translateY(100%); transition:transform .36s cubic-bezier(.32,.72,0,1);
  max-height:86%; display:flex; flex-direction:column;
  padding-bottom:env(safe-area-inset-bottom);
}
.sheet.is-on { transform:translateY(0); }
.sheet__grip { width:38px; height:4px; border-radius:2px; background:var(--r-rule); margin:10px auto 4px; flex:0 0 auto; }

/* drawer tabs */
.dtabs { display:flex; padding:6px 16px 0; gap:6px; flex:0 0 auto; border-bottom:1px solid var(--r-rule); }
.dtab { flex:1; padding:12px 0; text-align:center; font-size:14px; color:var(--r-ink-soft); position:relative; }
.dtab.is-on { color:var(--r-accent); font-weight:600; }
.dtab.is-on::after { content:''; position:absolute; bottom:-1px; left:50%; transform:translateX(-50%); width:28px; height:2px; background:var(--r-accent); border-radius:2px; }
.dbody { overflow-y:auto; padding:8px 0 14px; flex:1 1 auto; }

/* TOC list */
.toc__pos { display:flex; align-items:center; justify-content:space-between; padding:12px 20px; font-size:12px; color:var(--r-ink-soft); }
.toc__pos b { color:var(--r-accent); font-family:var(--font-mono); }
.toc__tools { display:flex; gap:14px; }
.toc__tools button { color:var(--r-ink-soft); font-size:12px; display:flex; align-items:center; gap:4px; }
.toc__tools svg { width:14px;height:14px; }
.tvol { }
.tvol__h { display:flex; align-items:center; gap:10px; padding:13px 20px; font-family:var(--font-serif); font-size:14.5px; font-weight:600; color:var(--r-ink); }
.tvol__h .rom { width:22px;height:22px;border-radius:6px; background:var(--r-bg-2); display:grid;place-items:center; font-size:12px; color:var(--r-accent); flex:0 0 auto; }
.tvol__chev { margin-inline-start:auto; color:var(--r-faint); transition:transform .25s; }
.tvol.is-open .tvol__chev { transform:rotate(90deg); }
[dir="rtl"] .tvol.is-open .tvol__chev { transform:rotate(-90deg); }
.tvol__body { display:grid; grid-template-rows:0fr; transition:grid-template-rows .3s ease; }
.tvol.is-open .tvol__body { grid-template-rows:1fr; }
.tvol__inner { overflow:hidden; }
.tpart { padding:6px 20px 2px 52px; font-size:11px; color:var(--r-faint); letter-spacing:.02em; }
[dir="rtl"] .tpart { padding:6px 52px 2px 20px; }
.tchap { display:flex; align-items:center; justify-content:space-between; padding:11px 20px 11px 52px; font-size:14px; color:var(--r-ink-soft); }
[dir="rtl"] .tchap { padding:11px 52px 11px 20px; }
.tchap.is-active { color:var(--r-accent); }
.tchap__pg { font-family:var(--font-mono); font-size:11px; color:var(--r-faint); }
.tchap.is-active .tchap__pg { color:var(--r-accent); }
.tchap__bm { color:var(--gold); margin-inline-start:8px; }

/* AI outline cards */
.aicard { margin:12px 18px; padding:16px; border-radius:14px; background:var(--r-bg-2); }
.aicard__h { display:flex; align-items:baseline; justify-content:space-between; gap:10px; }
.aicard__t { font-family:var(--font-serif); font-size:15px; font-weight:600; color:var(--r-ink); }
.aicard__pg { font-family:var(--font-mono); font-size:11px; color:var(--r-faint); flex:0 0 auto; }
.aicard__s { font-size:13px; line-height:1.7; color:var(--r-ink-soft); margin:10px 0 12px; }
.aicard__pts { display:flex; flex-direction:column; gap:7px; }
.aipt { display:flex; gap:9px; font-size:12.5px; color:var(--r-ink); align-items:flex-start; }
.aipt::before { content:''; width:5px;height:5px;border-radius:50%; background:var(--r-accent); margin-top:7px; flex:0 0 auto; }
.aibadge { display:inline-flex; align-items:center; gap:5px; margin:14px 18px 4px; font-size:11px; color:var(--r-faint); }
.aibadge b { color:var(--r-accent); font-family:var(--font-serif); }

/* search */
.srch { padding:14px 18px 6px; }
.srch__box { height:42px; border-radius:21px; background:var(--r-bg-2); display:flex; align-items:center; gap:10px; padding:0 16px; }
.srch__box svg { width:16px;height:16px; color:var(--r-faint); }
.srch__box input { flex:1; background:none; border:none; outline:none; font-family:var(--font-ui); font-size:14px; color:var(--r-ink); }
.srch__hint { padding:10px 20px; font-size:12px; color:var(--r-faint); }
.sres { padding:12px 20px; border-bottom:1px solid var(--r-rule-2); }
.sres__c { font-size:11px; color:var(--r-accent); margin-bottom:5px; }
.sres__t { font-family:var(--font-serif); font-size:14px; line-height:1.6; color:var(--r-ink); }
.sres__t mark { background:var(--r-hl); color:var(--r-accent); padding:0 1px; }

/* ════════════════════════════════════════════════════════════════════
   SETTINGS PANEL
   ════════════════════════════════════════════════════════════════════ */
.set { padding:6px 20px 20px; }
.set__row { padding:15px 0; border-bottom:1px solid var(--r-rule-2); }
.set__row:last-child { border-bottom:none; }
.set__lbl { font-size:13px; color:var(--r-ink-soft); margin-bottom:11px; display:flex; align-items:center; justify-content:space-between; }
.set__lbl b { color:var(--r-ink); font-family:var(--font-mono); font-weight:600; }
.stepper { display:flex; align-items:center; gap:0; height:42px; border-radius:21px; background:var(--r-bg-2); overflow:hidden; }
.stepper button { flex:1; height:100%; display:grid; place-items:center; color:var(--r-ink); font-size:18px; }
.stepper button:active { background:var(--r-rule); }
.stepper .v { flex:2; text-align:center; font-family:var(--font-mono); font-size:14px; color:var(--r-ink); border-inline:1px solid var(--r-rule); }
.segs { display:flex; gap:8px; }
.seg { flex:1; height:40px; border-radius:12px; background:var(--r-bg-2); color:var(--r-ink-soft); font-size:13px; display:flex; align-items:center; justify-content:center; }
.seg.is-on { background:var(--r-accent); color:#fff; }
.seg--font { font-size:15px; }

.themes { display:flex; gap:12px; }
.theme-sw { flex:1; cursor:pointer; }
.theme-sw__chip { height:54px; border-radius:12px; border:2px solid transparent; display:grid; place-items:center; font-family:var(--font-serif); font-size:14px; }
.theme-sw.is-on .theme-sw__chip { border-color:var(--r-accent); }
.theme-sw__lbl { text-align:center; font-size:11px; color:var(--r-ink-soft); margin-top:6px; }
.tp-paper { background:#F5F1E8; color:#2A241B; }
.tp-green { background:#D8E5D2; color:#26301F; }
.tp-white { background:#FCFCFB; color:#1E1E1E; }
.tp-night { background:#0E0E14; color:#E8E2D6; }

.range { -webkit-appearance:none; appearance:none; width:100%; height:6px; border-radius:3px; background:var(--r-rule); outline:none; }
.range::-webkit-slider-thumb { -webkit-appearance:none; width:22px;height:22px;border-radius:50%; background:var(--r-accent); box-shadow:0 2px 6px rgba(0,0,0,.3); cursor:pointer; }
.range::-moz-range-thumb { width:22px;height:22px;border-radius:50%; background:var(--r-accent); border:none; }
.bright-row { display:flex; align-items:center; gap:12px; }
.bright-row svg { width:18px;height:18px; color:var(--r-faint); flex:0 0 auto; }

/* progress sheet (进度) */
.prog { padding:24px 24px 30px; }
.prog__pct { text-align:center; font-family:var(--font-mono); font-size:30px; font-weight:600; color:var(--r-accent); }
.prog__sub { text-align:center; font-size:12px; color:var(--r-ink-soft); margin-top:6px; }
.prog__track { margin:26px 0 8px; }
.prog__row { display:flex; justify-content:space-between; margin-top:24px; }
.prog__row button { display:flex; flex-direction:column; align-items:center; gap:6px; font-size:12px; color:var(--r-ink-soft); }
.prog__row svg { width:20px;height:20px; }

/* ════════════════════════════════════════════════════════════════════
   SELECTION MENU / TERM POPOVER / SHARE CARD / TTS / AI
   ════════════════════════════════════════════════════════════════════ */
.selmenu { position:absolute; z-index:90; background:#1c1c22; color:#fff; border-radius:12px;
  display:flex; box-shadow:0 10px 30px rgba(0,0,0,.5); transform:translate(-50%,-100%); padding:4px; gap:2px;
  font-family:var(--font-ui); }
.selmenu::after { content:''; position:absolute; bottom:-6px; left:50%; transform:translateX(-50%); border:6px solid transparent; border-top-color:#1c1c22; border-bottom:0; }
.selmenu button { padding:9px 13px; font-size:13px; border-radius:9px; display:flex; flex-direction:column; align-items:center; gap:3px; color:#eee; }
.selmenu button svg { width:17px;height:17px; }
.selmenu button:active { background:rgba(255,255,255,.12); }

.pop { position:absolute; z-index:90; width:260px; background:var(--r-chrome); color:var(--r-chrome-ink);
  border-radius:14px; padding:16px; box-shadow:0 12px 36px rgba(0,0,0,.45); transform:translate(-50%,-100%);
  border:1px solid var(--r-rule); }
.pop__t { font-family:var(--font-serif); font-weight:600; font-size:16px; color:var(--r-accent); margin-bottom:8px; display:flex; align-items:center; gap:7px; }
.pop__t svg { width:15px;height:15px; }
.pop__d { font-size:13px; line-height:1.7; color:var(--r-ink-soft); }
.pop::after { content:''; position:absolute; bottom:-7px; left:50%; transform:translateX(-50%); border:7px solid transparent; border-top-color:var(--r-chrome); border-bottom:0; }

/* TTS / AI panels reuse .sheet */
.tts { padding:18px 24px 28px; }
.tts__title { font-family:var(--font-serif); font-size:17px; font-weight:600; text-align:center; color:var(--r-ink); }
.tts__chap { text-align:center; font-size:12px; color:var(--r-ink-soft); margin-top:6px; }
.tts__wave { display:flex; align-items:center; justify-content:center; gap:3px; height:46px; margin:18px 0; }
.tts__wave i { width:3px; border-radius:2px; background:var(--r-accent); opacity:.6; }
.tts__ctrls { display:flex; align-items:center; justify-content:center; gap:30px; margin:10px 0 20px; }
.tts__play { width:60px;height:60px;border-radius:30px; background:var(--gold); color:#fff; display:grid;place-items:center; box-shadow:0 8px 20px -4px rgba(246,145,85,.6); }
.tts__play svg { width:26px;height:26px; }
.tts__ico { color:var(--r-ink-soft); } .tts__ico svg { width:24px;height:24px; }
.tts__opts { display:flex; gap:10px; }
.tts__opts .seg { font-size:12px; }

.aiask { padding:16px 18px 22px; display:flex; flex-direction:column; height:100%; }
.aiask__head { font-family:var(--font-serif); font-size:16px; font-weight:600; color:var(--r-ink); display:flex; align-items:center; gap:8px; }
.aiask__head b { color:var(--gold); }
.aiask__sub { font-size:12px; color:var(--r-ink-soft); margin:4px 0 14px; }
.aiask__log { flex:1; overflow-y:auto; display:flex; flex-direction:column; gap:12px; padding-bottom:10px; min-height:120px; }
.bubble { max-width:84%; padding:11px 14px; border-radius:14px; font-size:13.5px; line-height:1.65; }
.bubble--u { align-self:flex-end; background:var(--r-accent); color:#fff; border-bottom-right-radius:4px; }
.bubble--a { align-self:flex-start; background:var(--r-bg-2); color:var(--r-ink); border-bottom-left-radius:4px; font-family:var(--font-serif); }
.aiask__chips { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:10px; }
.aiask__chip { font-size:12px; padding:7px 12px; border-radius:14px; background:var(--r-bg-2); color:var(--r-ink-soft); }
.aiask__bar { display:flex; gap:9px; align-items:center; }
.aiask__bar input { flex:1; height:44px; border-radius:22px; background:var(--r-bg-2); border:none; outline:none; padding:0 16px; font-family:var(--font-ui); font-size:14px; color:var(--r-ink); }
.aiask__send { width:44px;height:44px;border-radius:22px; background:var(--gold); color:#fff; display:grid;place-items:center; flex:0 0 auto; }
.aiask__send svg { width:20px;height:20px; }

/* share excerpt card */
.sharewrap { position:absolute; inset:0; z-index:95; background:rgba(0,0,0,.6); display:grid; place-items:center; padding:24px;
  opacity:0; visibility:hidden; transition:opacity .3s,visibility .3s; }
.sharewrap.is-on { opacity:1; visibility:visible; }
.qcard { position:relative; width:100%; max-width:330px; aspect-ratio:3/4; border-radius:18px; overflow:hidden;
  background:linear-gradient(160deg,#12121b,#1d1530); box-shadow:0 30px 60px rgba(0,0,0,.6); }
.qcard canvas { position:absolute; inset:0; width:100%;height:100%; }
.qcard__in { position:absolute; inset:0; z-index:2; padding:30px 26px; display:flex; flex-direction:column; }
.qcard__mark { font-family:var(--font-serif); font-size:60px; color:var(--gold); line-height:.6; opacity:.7; }
.qcard__q { font-family:var(--font-serif); font-size:19px; line-height:1.7; color:#F4EBDD; margin-top:14px; flex:1; }
.qcard__src { font-size:12px; color:rgba(244,235,221,.7); letter-spacing:.04em; }
.qcard__brand { display:flex; align-items:center; gap:8px; margin-top:16px; padding-top:14px; border-top:1px solid rgba(255,255,255,.12); }
.qcard__flame { width:18px;height:18px; background:radial-gradient(120% 120% at 50% 12%, #FFB683, #F69155 38%, #B8501F); clip-path:polygon(50% 0%,64% 30%,96% 38%,70% 60%,80% 96%,50% 76%,20% 96%,30% 60%,4% 38%,36% 30%); }
.qcard__bn { font-family:var(--font-ui); font-size:11px; letter-spacing:.2em; color:#F4EBDD; text-transform:uppercase; }
.share__close { position:absolute; top:18px; right:18px; z-index:96; width:40px;height:40px;border-radius:50%; background:rgba(255,255,255,.14); color:#fff; display:grid;place-items:center; }

/* toast */
.toast { position:absolute; left:50%; bottom:120px; transform:translateX(-50%) translateY(10px); z-index:100;
  background:rgba(20,20,26,.95); color:#fff; padding:10px 18px; border-radius:20px; font-size:13px;
  opacity:0; visibility:hidden; transition:opacity .25s, transform .25s, visibility .25s; white-space:nowrap; }
.toast.is-on { opacity:1; visibility:visible; transform:translateX(-50%) translateY(0); }

/* lang menu (small) */
.langsheet { padding:6px 0 10px; }
.langrow { display:flex; align-items:center; justify-content:space-between; padding:13px 22px; font-size:15px; color:var(--r-ink); }
.langrow.is-on { color:var(--r-accent); }
.langrow small { font-family:var(--font-latin); font-size:11px; color:var(--r-faint); letter-spacing:.06em; text-transform:uppercase; }

/* reduced motion */
@media (prefers-reduced-motion:reduce) {
  .reader__host, .rbar, .sheet, .scrim, .rfloat { transition:none !important; }
}

/* real cover image (Nano-Banana generated) — fills the canvas cover slot */
.cover-img { width: 100%; height: 100%; object-fit: cover; display: block; }
