/* BookFromAI — application stylesheet.
   Dark-first "cinematic library" chrome + a warm paper reading canvas.
   Design tokens mirror the product design system. */

:root {
  --font-ui: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-read: 'Newsreader', Georgia, 'Times New Roman', serif;

  --ink: #100E0C; --surface: #1A1714; --surface-2: #241F1B; --surface-3: #2C2621;
  --line: #332C26; --line-2: #443B33;
  --text: #F4EFE6; --text-2: #BDB3A5; --text-3: #948A7C;
  --gold: #E0A55E; --gold-2: #EEBE80; --gold-ink: #2A1C08;
  --teal: #74B7A4; --teal-ink: #0E1C18;
  --danger: #E0876B;
  --gold-dim: rgba(224,165,94,.14); --teal-dim: rgba(116,183,164,.16); --neutral-dim: rgba(244,239,230,.08);
  --paper: #F6F1E7; --paper-2: #ECE5D6; --paper-ink: #2A251E; --paper-ink-2: #6B6355; --paper-line: #DDD3C0;
  --sepia: #EFE2CB; --sepia-ink: #3B3020;
  --read-dark: #14120F; --read-dark-ink: #DCD4C6;

  --radius-card: 14px; --radius-btn: 10px; --radius-input: 10px; --radius-cover: 6px;
  --shadow-cover: 0 14px 30px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.4);

  --bg: var(--ink); --fg: var(--text); --panel: var(--surface); --panel-2: var(--surface-2);
  --border: var(--line); --border-2: var(--line-2);
  --muted: var(--text-2); --muted-2: var(--text-3);
}

/* Light "day" theme for the app chrome (opt-in). */
:root[data-theme="light"] {
  --bg: #F6F1E7; --fg: #2A251E; --panel: #FBF8F1; --panel-2: #EFE9DC;
  --border: #E1D8C6; --border-2: #D4C9B4;
  --muted: #6B6355; --muted-2: #8B8271;
  --neutral-dim: rgba(42,37,30,.05);
  --shadow-cover: 0 14px 30px rgba(42,28,8,.22), 0 2px 6px rgba(42,28,8,.14);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* overflow-x: clip (not hidden) stops any stray wide element from making the
   page pannable/zoomable sideways on phones — the main cause of the mobile
   layout "jumping" — without creating a scroll container that would break the
   sticky nav. */
body {
  margin: 0; font-family: var(--font-ui); background: var(--bg); color: var(--fg);
  -webkit-font-smoothing: antialiased; line-height: 1.5; min-height: 100vh;
  overflow-x: clip; overflow-wrap: break-word;
}
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-2); }
h1, h2, h3, h4, p { margin: 0; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.wide { max-width: 1360px; }
.narrow { max-width: 560px; }

/* ---- Navigation ---- */
.nav {
  position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(140%) blur(12px); border-bottom: 1px solid var(--border);
}
.nav-inner { display: flex; align-items: center; gap: 20px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: -.01em; color: var(--fg); }
.brand-ai { color: var(--gold); }
.brand-mark { flex: none; width: 30px; height: 30px; border-radius: 8px; background: var(--gold); color: var(--gold-ink); display: flex; align-items: center; justify-content: center; }
.nav-links { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.nav-link { color: var(--muted); font-weight: 500; padding: 8px 12px; border-radius: 8px; font-size: 15px; }
.nav-link:hover { color: var(--fg); background: var(--neutral-dim); }
.nav-link.active { color: var(--fg); }
.nav-spacer { flex: 1; }
.nav-actions { display: flex; align-items: center; gap: 10px; }
.nav-mobile-only { display: none !important; }
.nav-link-btn { background: transparent; border: 0; font-family: inherit; cursor: pointer; text-align: left; width: 100%; }
.nav-toggle { display: none; background: transparent; border: 0; color: var(--fg); cursor: pointer; padding: 8px; }

/* ---- Buttons ---- */
.btn { font-family: var(--font-ui); font-weight: 600; font-size: 15px; border-radius: var(--radius-btn);
  border: 1px solid transparent; padding: 11px 18px; cursor: pointer; display: inline-flex; align-items: center;
  gap: 8px; line-height: 1; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; }
.btn-primary { background: var(--gold); color: var(--gold-ink); }
.btn-primary:hover { background: var(--gold-2); color: var(--gold-ink); }
.btn-secondary { background: transparent; color: var(--fg); border-color: var(--border-2); }
.btn-secondary:hover { border-color: var(--muted-2); background: var(--neutral-dim); color: var(--fg); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--fg); background: var(--neutral-dim); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(224,135,107,.4); }
.btn-danger:hover { background: rgba(224,135,107,.12); }
.danger-details > summary { list-style: none; }
.danger-details > summary::-webkit-details-marker { display: none; }
.danger-details[open] > summary { display: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 8px 13px; font-size: 13px; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }

/* ---- Cards & surfaces ---- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-card); }
.card-pad { padding: 24px; }
.card-danger { border-color: rgba(224,135,107,.35); }
.divider { height: 1px; background: var(--border); width: 100%; }
.eyebrow { font-family: var(--font-display); font-weight: 600; letter-spacing: .14em; text-transform: uppercase; font-size: 12px; color: var(--gold); }
.sec-title { font-family: var(--font-display); font-weight: 600; font-size: 26px; letter-spacing: -.01em; color: var(--fg); }
.sec-note { font-size: 15px; color: var(--muted); line-height: 1.55; max-width: 640px; }
.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.display { font-family: var(--font-display); font-weight: 600; letter-spacing: -.02em; }
.serif { font-family: var(--font-read); }

/* ---- Badges & chips ---- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; line-height: 1; }
.b-preview { background: var(--teal-dim); color: var(--teal); }
.b-sub { background: var(--gold-dim); color: var(--gold-2); }
.b-lib { background: var(--neutral-dim); color: var(--muted); }
.b-new { background: transparent; color: var(--muted); border: 1px solid var(--border-2); }
.b-ai { background: rgba(116,183,164,.10); color: var(--teal); border: 1px solid rgba(116,183,164,.3); letter-spacing: .04em; }
.chip { font-family: var(--font-ui); font-size: 14px; font-weight: 500; color: var(--muted); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 9px 15px; cursor: pointer; display: inline-flex; gap: 7px; align-items: center; text-decoration: none; }
.chip:hover { border-color: var(--border-2); color: var(--fg); }
.chip.active { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.chip-sm { font-size: 13px; padding: 6px 12px; }
.b-age { background: transparent; color: var(--fg); border: 1px solid var(--border-2); font-family: var(--font-display); letter-spacing: .02em; }
.agechip { position: absolute; bottom: 10px; right: 10px; z-index: 1; font-family: var(--font-display); font-size: 11.5px; font-weight: 700;
  line-height: 1; padding: 5px 7px; border-radius: 6px; background: rgba(16,14,12,.72); color: #F4EFE6;
  border: 1px solid rgba(244,239,230,.28); backdrop-filter: blur(4px); }
.cover-lg .agechip, .book-detail .agechip, .listen-cover .agechip { bottom: 12px; right: 12px; font-size: 13px; padding: 6px 9px; }

/* ---- Forms ---- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, .textarea, .select { width: 100%; background: var(--panel-2); border: 1px solid var(--border-2);
  border-radius: var(--radius-input); color: var(--fg); font-family: var(--font-ui); font-size: 15px; padding: 12px 14px; }
.textarea { min-height: 140px; resize: vertical; font-family: var(--font-read); line-height: 1.6; }
.input::placeholder { color: var(--muted-2); }
.input:focus, .textarea:focus, .select:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: transparent; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); cursor: pointer; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted-2); }
.search-wrap .input { padding-left: 40px; }

/* ---- Alerts / flash ---- */
.alert { border-radius: var(--radius-btn); padding: 12px 16px; font-size: 14px; margin-bottom: 18px; border: 1px solid transparent; }
.alert-success { background: var(--teal-dim); color: var(--teal); border-color: rgba(116,183,164,.3); }
.alert-error { background: rgba(224,135,107,.12); color: var(--danger); border-color: rgba(224,135,107,.35); }
.alert-info { background: var(--neutral-dim); color: var(--muted); border-color: var(--border); }

/* ---- Book covers & grid ---- */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 26px; }
.book-card { display: flex; flex-direction: column; gap: 12px; }
.cover { position: relative; aspect-ratio: 2/3; border-radius: var(--radius-cover); box-shadow: var(--shadow-cover);
  overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 16px; color: #fff;
  font-family: var(--font-read); }
.cover .kicker { font-family: var(--font-ui); font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; opacity: .72; }
.cover .ct { font-size: 22px; line-height: 1.12; font-weight: 600; }
.cover .cb { font-family: var(--font-ui); font-size: 11px; font-weight: 600; opacity: .72; }
.cover-lg { aspect-ratio: 2/3; }
.lockchip { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 999px;
  background: rgba(16,14,12,.62); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; color: var(--gold-2); }
.book-card .bt { font-size: 15px; font-weight: 600; color: var(--fg); line-height: 1.25; }
.book-card .ba { font-size: 13px; color: var(--muted-2); }
.book-meta { font-size: 13px; color: var(--muted-2); }

/* ---- Hero ---- */
.hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center; padding: 56px 0 24px; }
.hero h1 { font-family: var(--font-display); font-weight: 600; font-size: 52px; letter-spacing: -.025em; line-height: 1.02; }
.hero p { font-size: 18px; color: var(--muted); margin-top: 20px; max-width: 520px; }
.hero-actions { display: flex; gap: 12px; margin-top: 28px; flex-wrap: wrap; }
.hero-cover { display: flex; justify-content: center; }
.hero-cover .cover { width: 300px; }
.hero-cover { flex-direction: column; align-items: center; gap: 14px; }
/* Generic hero illustration shown until there's a recommendation: an open
   book whose right page turns into an audio waveform (read or listen). */
.hero-art { width: 100%; max-width: 420px; aspect-ratio: 5/4; justify-self: center; }
.hero-art .ha-glow { fill: var(--gold-dim); }
.hero-art .ha-page { fill: var(--panel-2); stroke: var(--border-2); stroke-width: 2; stroke-linejoin: round; }
.hero-art .ha-spine { stroke: var(--border-2); stroke-width: 2; }
.hero-art .ha-text path { stroke: var(--muted-2); stroke-width: 5; stroke-linecap: round; opacity: .55; }
.hero-art .ha-wave rect { fill: var(--gold); transform-box: fill-box; transform-origin: center; animation: ha-bar 2.4s ease-in-out infinite; }
.hero-art .ha-wave rect:nth-child(2n) { animation-delay: -.6s; }
.hero-art .ha-wave rect:nth-child(3n) { animation-delay: -1.3s; }
.hero-art .ha-spark path { fill: var(--gold-2); opacity: .8; }
@keyframes ha-bar { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.55); } }
@media (prefers-reduced-motion: reduce) { .hero-art .ha-wave rect { animation: none; } }

/* ---- Sections ---- */
.section { padding: 40px 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 16px; }
.stat { padding: 20px 22px; }
.stat .n { font-family: var(--font-display); font-weight: 700; font-size: 30px; color: var(--fg); }
.stat .l { font-size: 13px; color: var(--muted-2); margin-top: 4px; }
.steps { display: grid; grid-template-columns: repeat(3,1fr); gap: 20px; }

/* ---- Footer ---- */
.footer { border-top: 1px solid var(--border); margin-top: 64px; padding: 40px 0; color: var(--muted-2); font-size: 14px; }
.footer-inner { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.footer a { color: var(--muted); }
.social-links { display: flex; gap: 8px; margin-top: 16px; }
.social-links a { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); transition: color .15s, border-color .15s, background .15s; }
.social-links a:hover, .social-links a:focus-visible { color: var(--fg); border-color: var(--border-2); background: var(--panel-2); }

/* ---- Auth layout ---- */
.auth-wrap { max-width: 440px; margin: 56px auto; }
.auth-card { padding: 32px; }
.auth-title { font-family: var(--font-display); font-weight: 600; font-size: 28px; letter-spacing: -.01em; }
.oauth-row { display: flex; flex-direction: column; gap: 10px; }
.oauth-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; }

/* ---- Two-factor ---- */
.qr-img { display: block; width: 205px; height: 205px; image-rendering: pixelated; border-radius: 8px; background: #fff; }
.totp-secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; letter-spacing: .04em; word-break: break-all; color: var(--fg); }
.code-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 20px; letter-spacing: .12em; text-align: center; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 24px; margin: 0; padding: 16px 20px;
  list-style: none; background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-input);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 16px; letter-spacing: .04em; }
.or-divider { display: flex; align-items: center; gap: 12px; color: var(--muted-2); font-size: 13px; margin: 20px 0; }
.or-divider::before, .or-divider::after { content: ""; height: 1px; background: var(--border); flex: 1; }

/* ---- Book detail ---- */
.book-detail { display: grid; grid-template-columns: 280px 1fr; gap: 48px; padding: 40px 0; align-items: start; }
.book-detail .cover { width: 280px; }
.chapter-list { display: flex; flex-direction: column; margin-top: 8px; }
.chapter-row { display: flex; align-items: center; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--border); }
.chapter-row .num { font-family: var(--font-display); font-size: 13px; color: var(--muted-2); width: 28px; }
.chapter-row .cttl { flex: 1; font-family: var(--font-read); font-size: 17px; color: var(--fg); }
.chapter-row .cmeta { font-size: 13px; color: var(--muted-2); }
.chapter-row.locked .cttl { color: var(--muted-2); }
.pill-list { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Reader (paper canvas) ---- */
.reader { --rbg: var(--paper); --rfg: var(--paper-ink); --rmuted: var(--paper-ink-2); --rline: var(--paper-line); }
.reader[data-mode="sepia"] { --rbg: var(--sepia); --rfg: var(--sepia-ink); --rmuted: #6a5a3f; --rline: #e0cfa8; }
.reader[data-mode="dark"] { --rbg: var(--read-dark); --rfg: var(--read-dark-ink); --rmuted: #9a9084; --rline: #2a2620; }
.reader { background: var(--rbg); color: var(--rfg); min-height: 100vh; }
.reader-bar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--rbg) 90%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--rline); }
.reader-bar-inner { display: flex; align-items: center; gap: 14px; height: 58px; max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.reader-bar a, .reader-bar button { color: var(--rmuted); }
/* Back link = arrow + book title, one generous tap target. Hover keeps the
   reader palette (the global .icon-btn hover used the chrome's light text
   colour, which made the arrow vanish on the paper canvas). */
.reader-back { flex: 0 1 auto; margin-right: auto; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 7px 10px 7px 6px;
  margin-left: -6px; border-radius: 10px; text-decoration: none; }
.reader-back svg { flex: none; }
.reader-back .rtitle { flex: 0 1 auto; min-width: 0; }
.reader-bar .reader-back:hover { color: var(--rfg); background: color-mix(in srgb, var(--rfg) 8%, transparent); }
.reader-bar .reader-back:hover .rtitle { text-decoration: underline; text-underline-offset: 3px; }
.listen-bar .reader-back { color: var(--muted); }
.listen-bar .reader-back:hover { color: var(--fg); background: var(--neutral-dim); }
.reader-bar .rtitle { font-family: var(--font-read); font-weight: 600; color: var(--rfg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-body { max-width: 680px; margin: 0 auto; padding: 48px 24px 160px; }
.reader-body .chnum { font-family: var(--font-display); text-transform: uppercase; letter-spacing: .14em; font-size: 12px; color: var(--rmuted); }
.reader-body h1 { font-family: var(--rfont); font-weight: 600; font-size: calc(34px * var(--rscale)); letter-spacing: -.01em; margin: 10px 0 28px; }
.reader-body p { font-family: var(--rfont); font-size: calc(19px * var(--rscale)); line-height: 1.75; color: var(--rfg); margin-bottom: 22px; }
.reader-modes { display: inline-flex; background: transparent; border: 1px solid var(--rline); border-radius: 999px; padding: 3px; gap: 2px; }
.reader-modes button { border: 0; background: transparent; color: var(--rmuted); border-radius: 999px; padding: 6px 10px; cursor: pointer; font-size: 12px; }
.reader-modes button.active { background: var(--gold); color: var(--gold-ink); }
.reader-modes { flex: none; }
/* Reader typography: text size (--rscale) and font family (--rfont). */
.reader { --rscale: 1; --rfont: var(--font-read); }
.reader[data-font="sans"] { --rfont: var(--font-ui); }
.reader[data-font="legible"] { --rfont: 'Atkinson Hyperlegible', Verdana, sans-serif; }
.reader-type { position: relative; flex: none; }
.reader-type-btn { border: 1px solid var(--rline); background: transparent; border-radius: 999px; height: 34px; min-width: 42px; padding: 0 10px;
  cursor: pointer; font-family: var(--font-read); font-size: 15px; font-weight: 600; }
.reader-bar .reader-type-btn:hover, .reader-bar .reader-type-btn[aria-expanded="true"] { color: var(--rfg); background: color-mix(in srgb, var(--rfg) 8%, transparent); }
.reader-type-pop { position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; width: 232px; padding: 10px; border-radius: 14px;
  background: var(--rbg); color: var(--rfg); border: 1px solid var(--rline); box-shadow: 0 12px 32px rgba(0,0,0,.18); display: flex; flex-direction: column; gap: 10px; }
.reader-type-pop[hidden] { display: none; }
.rt-size { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rt-size button { width: 44px; height: 36px; border-radius: 10px; border: 1px solid var(--rline); background: transparent; cursor: pointer;
  font-family: var(--font-read); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.reader-bar .rt-size button:hover:not(:disabled) { color: var(--rfg); background: color-mix(in srgb, var(--rfg) 8%, transparent); }
.rt-size button:disabled { opacity: .4; cursor: default; }
.rt-size-val { font-family: var(--font-display); font-size: 13px; color: var(--rmuted); font-variant-numeric: tabular-nums; }
.rt-fonts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; border: 1px solid var(--rline); border-radius: 999px; padding: 3px; }
.rt-fonts button { border: 0; background: transparent; border-radius: 999px; padding: 6px 4px; cursor: pointer; font-size: 13px; }
.rt-fonts [data-reader-font="serif"] { font-family: var(--font-read); }
.rt-fonts [data-reader-font="sans"] { font-family: var(--font-ui); }
.rt-fonts [data-reader-font="legible"] { font-family: 'Atkinson Hyperlegible', Verdana, sans-serif; }
.reader-bar .rt-fonts button.active { background: var(--gold); color: var(--gold-ink); }

/* Content protection (best effort — a web page can't truly block screenshots):
   no selection/callout on the text, and app.js blurs it while the page is
   hidden or unfocused and around screenshot shortcuts. Printing is blanked. */
.reader-protected { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.reader-protected { transition: filter .12s ease; }
.reader-shielded .reader-protected { filter: blur(16px); }
@media print {
  .reader-protected, .reader-bar, .player { display: none !important; }
  .reader::after { content: "Printing is disabled for this book."; display: block; padding: 48px; font: 16px var(--font-ui); }
}
.reader-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 40px; }
.reader-nav .reader-page-ind { font-family: var(--font-display); font-size: 12.5px; letter-spacing: .06em; color: var(--rmuted); white-space: nowrap; }
/* Secondary nav buttons sit on the paper/sepia/dark reading canvas, so they must
   use the reader palette — not the global dark-theme --fg (invisible on paper). */
.reader-nav .btn-secondary { color: var(--rfg); border-color: var(--rline); }
.reader-nav .btn-secondary:hover { color: var(--rfg); border-color: var(--rmuted); background: color-mix(in srgb, var(--rfg) 8%, transparent); }

/* ---- Listen (audio-first) page ---- */
.listen { min-height: 100vh; background: var(--bg); color: var(--fg); padding-bottom: 120px; }
.listen-bar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.listen-bar-inner { display: flex; align-items: center; gap: 14px; height: 58px; max-width: 900px; margin: 0 auto; padding: 0 20px; }
.listen-bar .rtitle { font-family: var(--font-read); font-weight: 600; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listen-stage { max-width: 560px; margin: 0 auto; padding: 40px 20px 0; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.listen-cover.cover { width: 220px; }
.listen-now { text-align: center; }
.listen-now .chnum { font-family: var(--font-display); text-transform: uppercase; letter-spacing: .14em; font-size: 12px; color: var(--muted-2); }
.listen-now h1 { font-family: var(--font-read); font-weight: 600; font-size: 28px; letter-spacing: -.01em; margin: 8px 0 6px; color: var(--fg); }
.listen-now .listen-book { color: var(--muted); font-size: 14px; }
.listen .chapter-row .cttl a { color: inherit; text-decoration: none; }
.listen .chapter-row .cttl a:hover { color: var(--gold); }
.listen .chapter-row.current { border-left: 2px solid var(--gold); padding-left: 10px; }
.listen .chapter-row.current .cttl { color: var(--gold); font-weight: 600; }

/* Paywall */
.paywall { max-width: 560px; margin: 60px auto; text-align: center; padding: 40px 32px; }
.paywall h2 { font-family: var(--font-display); font-size: 28px; margin-bottom: 12px; color: var(--fg); }
/* The card stays dark on every reader mode, so its copy must not inherit the
   paper/sepia ink from .reader-body p (dark-on-dark). */
.reader-body .paywall p { color: var(--muted); }

/* ---- Audio player ---- */
.player { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--surface-2);
  border-top: 1px solid var(--line-2); padding: 10px 0; }
.player[hidden] { display: none; }
.player-inner { max-width: 1100px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 16px; }
.player .titles { min-width: 0; flex: 0 1 auto; }
.player-controls, .player-speed { flex: none; }
.player .pt { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .ps { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-controls { display: flex; align-items: center; gap: 6px; }
.icon-btn { background: transparent; border: 0; color: var(--text-2); cursor: pointer; padding: 8px; border-radius: 999px; display: inline-flex; }
.icon-btn:hover { color: var(--text); background: var(--neutral-dim); }
/* Theme toggle shows the current theme: sun in dark (default), moon in light. */
.theme-icon-moon { display: none; }
:root[data-theme="light"] .theme-icon-sun { display: none; }
:root[data-theme="light"] .theme-icon-moon { display: inline; }
.icon-btn.play { background: var(--gold); color: var(--gold-ink); width: 42px; height: 42px; align-items: center; justify-content: center; }
.icon-btn.play:hover { background: var(--gold-2); }
.player-progress { flex: 1 1 160px; display: flex; align-items: center; gap: 10px; min-width: 160px; }
.player-progress .time { font-family: var(--font-display); font-size: 12px; color: var(--text-3); width: 42px; text-align: center; }
input[type="range"].seek { min-width: 0; -webkit-appearance: none; appearance: none; height: 4px; background: var(--line-2); border-radius: 999px; flex: 1; cursor: pointer; }
input[type="range"].seek::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 999px; background: var(--gold); }
input[type="range"].seek::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 999px; background: var(--gold); }
.player input.vol { width: 80px; flex: none; }
.player-speed { font-family: var(--font-display); font-size: 13px; font-weight: 600; min-width: 40px; justify-content: center; padding: 6px 8px; }
.player-speed.active { color: var(--gold); }
/* Mobile-only handle that collapses the player to free up reading space. */
.player-toggle { display: none; position: absolute; top: -26px; right: 16px;
  width: 56px; height: 26px; align-items: center; justify-content: center; padding: 0;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line-2); border-bottom: 0;
  border-radius: 10px 10px 0 0; cursor: pointer; }
.player-toggle svg { transition: transform .2s ease; }
.player.collapsed .player-toggle svg { transform: rotate(180deg); }

/* ---- Tables (admin) ---- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted-2); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px; border-bottom: 1px solid var(--border); color: var(--fg); }
.table tr:hover td { background: var(--neutral-dim); }
.table-wrap { overflow-x: auto; }

/* ---- Pricing ---- */
.price-card { max-width: 420px; margin: 0 auto; padding: 32px; text-align: center; }
.price { font-family: var(--font-display); font-weight: 700; font-size: 46px; color: var(--fg); }
.price small { font-size: 16px; color: var(--muted-2); font-weight: 500; }
.feature-list { text-align: left; display: flex; flex-direction: column; gap: 12px; margin: 24px 0; }
.feature-list li { list-style: none; display: flex; gap: 10px; color: var(--muted); }
.feature-list .ok { color: var(--teal); }

.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; max-width: 760px; margin: 0 auto; align-items: stretch; }
.plan { position: relative; text-align: center; display: flex; flex-direction: column; }
.plan.featured { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.plan .plan-name { font-family: var(--font-display); font-weight: 600; letter-spacing: .04em; color: var(--fg); }
.plan .price { margin-top: 10px; }
.plan .plan-sub { color: var(--muted-2); font-size: 13.5px; margin-top: 4px; min-height: 20px; }
.plan .feature-list { margin: 20px 0; flex: 1; }
.plan-badge { position: absolute; top: -12px; right: 20px;
  background: var(--gold); color: #1b1206; font-weight: 700; font-size: 11.5px; letter-spacing: .04em;
  padding: 4px 12px; border-radius: 999px; text-transform: uppercase; white-space: nowrap; }
.plan-foot { text-align: center; color: var(--muted-2); font-size: 12.5px; margin-top: 18px; }
@media (max-width: 720px) { .plans { grid-template-columns: 1fr; } }

/* ---- Utilities ---- */
.row { display: flex; align-items: center; gap: 12px; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.text-center { text-align: center; }
.gap-8 { gap: 8px; } .gap-16 { gap: 16px; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 24px; padding: 32px 0; }
  .hero h1 { font-size: 40px; }
  .hero-cover { order: -1; }
  .hero-cover .cover { width: 220px; }
  .hero-art { display: none; }
  .book-detail { grid-template-columns: 1fr; gap: 28px; }
  .book-detail .cover { width: 200px; margin: 0 auto; }
  .steps { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .container { padding: 0 16px; }
  .nav-inner { gap: 10px; height: 60px; }
  .nav-actions { gap: 6px; }
  .nav-desktop-only { display: none !important; }
  .nav-mobile-only { display: block !important; }
  .nav-links { display: none; }
  .nav-toggle { display: inline-flex; }
  .nav.open .nav-links { display: flex; position: absolute; top: 60px; left: 0; right: 0; flex-direction: column;
    background: var(--panel); border-bottom: 1px solid var(--border); padding: 12px 16px; gap: 2px; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: 18px; }
  .player-inner { flex-wrap: wrap; justify-content: center; gap: 10px; }
  .player-controls { flex-basis: 100%; justify-content: center; }
  .player .titles { flex-basis: 100%; text-align: center; }
  .player .vol { display: none; }
  .player-toggle { display: inline-flex; }
  .player.collapsed { padding: 0; }
  .player.collapsed .player-inner { display: none; }
  .reader-body h1 { font-size: calc(28px * var(--rscale)); }
  .reader-body p { font-size: calc(18px * var(--rscale)); }
  .reader-body { padding: 32px 18px 160px; }
  .reader-bar-inner { padding: 0 14px; gap: 8px; }
  .reader-nav { flex-wrap: wrap; }
  .reader-nav .reader-page-ind { order: -1; flex-basis: 100%; text-align: center; }
  .reader-nav .btn { flex: 1 1 0; justify-content: center; padding-left: 12px; padding-right: 12px; }
  .hero h1 { font-size: 34px; }
}
@media (max-width: 380px) {
  .brand { font-size: 17px; gap: 8px; }
  .brand-mark { width: 28px; height: 28px; }
  .nav-actions .icon-btn { padding: 6px; }
}
