/* ─────────────────────────────────────────────────────────────────────
   ASHFALL — Reader styles
   Bleu nuit électrique · Luxe Glacial · Vingt-Deux Veilles
   ─────────────────────────────────────────────────────────────────── */

:root {
  /* ── Ashfall (default — electric midnight blue) */
  --bg: #050816;
  --bg-deep: #02030a;
  --surface: #090d1e;
  --surface-2: #0d1226;
  --ink: #dee4f0;
  --ink-soft: #98a3bd;
  --ink-mute: #5b6584;
  --ink-faint: #2c324a;
  --rule: rgba(222, 228, 240, 0.07);
  --rule-strong: rgba(222, 228, 240, 0.16);
  --accent: #6691ff;
  --accent-deep: #2854d8;
  --ember: #ffb469;
  --ember-warm: #ff8a3a;
  --blood: #c5365a;

  --serif: "Cormorant Garamond", "EB Garamond", "Spectral", "Iowan Old Style", Georgia, serif;
  --serif-alt: "EB Garamond", "Cormorant Garamond", "Spectral", Georgia, serif;
  --serif-modern: "Spectral", "EB Garamond", Georgia, serif;
  --display: var(--serif);
  --ui: "Inter Tight", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --page-w: 580px;
  --type-size: 19px;
  --line-h: 1.55;

  --turn: 480ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* alt themes */
.theme-marbre {
  --bg: #050506; --bg-deep: #000; --surface: #0a0a0c; --surface-2: #101012;
  --ink: #d8d2c4; --ink-soft: #a59e8e; --ink-mute: #625a4d; --ink-faint: #322d27;
  --rule: rgba(216, 210, 196, 0.07); --rule-strong: rgba(216, 210, 196, 0.15);
  --accent: #c7b58a;
}
.theme-beton {
  --bg: #d6d2c8; --bg-deep: #c5c1b7; --surface: #ddd9d0; --surface-2: #e4e1d9;
  --ink: #1a1816; --ink-soft: #4a463f; --ink-mute: #6a655a; --ink-faint: #989186;
  --rule: rgba(26, 24, 22, 0.10); --rule-strong: rgba(26, 24, 22, 0.22);
  --accent: #2a3e6b;
}
.theme-lecture {
  --bg: #ece2d0; --bg-deep: #ddd2bd; --surface: #f0e6d4; --surface-2: #f5eddd;
  --ink: #221a10; --ink-soft: #4a3e2c; --ink-mute: #6a5a44; --ink-faint: #a3957a;
  --rule: rgba(34, 26, 16, 0.09); --rule-strong: rgba(34, 26, 16, 0.20);
  --accent: #5a3a16;
}

/* reset */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-feature-settings: "kern", "liga", "onum";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

/* Atmospheric vignette: deep cobalt uplight + corner ember-flame glow */
body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 50% 8%, rgba(102, 145, 255, 0.06), transparent 60%),
    radial-gradient(ellipse 70% 55% at 50% 50%, transparent 0%, transparent 50%, rgba(2, 4, 16, 0.55) 100%);
  pointer-events: none;
  z-index: 1;
}
.theme-beton body::before, .theme-lecture body::before { display: none; }

/* ───────── reader frame ───────── */
.reader {
  position: fixed; inset: 0;
  display: grid;
  grid-template-rows: 56px 1fr 56px;
  z-index: 2;
}

.chrome-top, .chrome-bot {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 28px;
  font-family: var(--ui);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  position: relative;
  z-index: 4;
}
.chrome-top .crumb-l, .chrome-bot .crumb-l { justify-self: start; }
.chrome-top .crumb-c, .chrome-bot .crumb-c { justify-self: center; }
.chrome-top .crumb-r, .chrome-bot .crumb-r { justify-self: end; }
.chrome-top { border-bottom: 1px solid var(--rule); }
.chrome-bot { border-top: 1px solid var(--rule); }

.crumb-c .dot {
  display: inline-block; width: 3px; height: 3px;
  background: var(--ink-mute); border-radius: 50%;
  margin: 0 10px; vertical-align: middle;
}

.brand {
  font-family: var(--ui);
  font-weight: 500;
  letter-spacing: 0.36em;
  color: var(--ink-soft);
}

/* progress hairline */
.progress {
  position: absolute;
  left: 0; right: 0;
  bottom: 56px;
  height: 1px;
  background: transparent;
  z-index: 5;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--accent) 50%, transparent);
  width: 0%;
  transition: width var(--turn);
  opacity: 0.7;
}

/* ───────── stage ───────── */
.stage {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  perspective: 2400px;
  perspective-origin: 50% 50%;
}

/* page */
.page {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 24px 24px;
  transform-style: preserve-3d;
  transition: opacity 380ms cubic-bezier(0.4, 0.0, 0.2, 1),
              transform 460ms cubic-bezier(0.4, 0.0, 0.2, 1),
              filter 380ms ease;
  will-change: opacity, transform, filter;
  backface-visibility: hidden;
}
.page.show    { opacity: 1; transform: rotateY(0deg)   translateX(0)    translateZ(0); filter: none; }
.page.enter-r { opacity: 0; transform: rotateY(38deg)  translateX(60px) translateZ(-40px); transform-origin: left center; filter: brightness(0.85); }
.page.enter-l { opacity: 0; transform: rotateY(-38deg) translateX(-60px) translateZ(-40px); transform-origin: right center; filter: brightness(0.85); }
.page.exit-r  { opacity: 0; transform: rotateY(-38deg) translateX(-60px) translateZ(-40px); transform-origin: right center; filter: brightness(0.75); }
.page.exit-l  { opacity: 0; transform: rotateY(38deg)  translateX(60px) translateZ(-40px); transform-origin: left center; filter: brightness(0.75); }

/* subtle curl shadow during page turn */
.page.exit-r .page-inner,
.page.exit-l .page-inner {
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.4);
}

.page-inner {
  width: 100%;
  max-width: var(--page-w);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  position: relative;
  overflow-y: auto;
  scrollbar-width: none;
}
.page-inner::-webkit-scrollbar { display: none; }

/* ───────── prose ───────── */
.prose {
  font-family: var(--serif);
  font-size: var(--type-size);
  line-height: var(--line-h);
  color: var(--ink);
  text-align: justify;
  text-justify: inter-word;
  text-wrap: pretty;
  hyphens: auto;
}
.prose p {
  margin: 0;
  text-indent: 1.6em;
}
.prose p:first-child { text-indent: 0; }
.prose p.no-indent { text-indent: 0; }
.prose em { font-style: italic; color: var(--ink); }
.prose strong { font-weight: 500; color: var(--ink); }
.prose .dropcap::first-letter {
  font-family: var(--display);
  font-weight: 500;
  float: left;
  font-size: 4.6em;
  line-height: 0.86;
  margin: 0.06em 0.08em 0 -0.04em;
  color: var(--ink);
}
.prose .sep {
  text-align: center;
  margin: 1.2em 0;
  color: var(--ink-mute);
  letter-spacing: 1em;
  text-indent: 0;
}
.prose .signoff {
  text-align: center;
  margin-top: 1.4em;
  font-style: italic;
  color: var(--ink-soft);
  letter-spacing: 0.06em;
  text-indent: 0;
}

/* ───────── audio cues in text (hidden, kept for data-audio) ───────── */
.prose .audio-cue {
  display: none;
}

/* ───────── chapter title page ───────── */
.chapter-title {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  height: 100%;
  gap: 0;
}
.ch-marker {
  font-family: var(--ui);
  font-size: 11px;
  letter-spacing: 0.42em;
  color: var(--ink-mute);
  text-transform: uppercase;
  margin-bottom: 22px;
}
.ch-rule {
  width: 28px;
  height: 1px;
  background: var(--ink-soft);
  margin: 0 0 32px;
  opacity: 0.6;
}
.ch-number {
  font-family: var(--display);
  font-style: italic;
  font-weight: 300;
  font-size: 24px;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 18px;
}
.ch-name {
  font-family: var(--display);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(36px, 4.6vw, 60px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--ink);
  max-width: 520px;
  margin-bottom: 28px;
}
.ch-sub {
  font-family: var(--display);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-soft);
  max-width: 440px;
  line-height: 1.5;
  letter-spacing: 0.01em;
}
.ch-act-line {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 36px;
}
.ch-act-line .h {
  width: 32px; height: 1px;
  background: var(--ink-mute); opacity: 0.5;
}
.ch-act-line .lbl {
  font-family: var(--ui); font-size: 9.5px;
  letter-spacing: 0.42em; text-transform: uppercase;
  color: var(--ink-mute);
}

/* ───────── chapter synopsis (unwritten chapters) ───────── */
.synopsis {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 18px;
  padding-top: 8px;
}
.synopsis-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 12px;
}
.synopsis-head .ttl {
  font-family: var(--display);
  font-style: italic;
  font-size: 24px;
  color: var(--ink);
}
.synopsis-head .meta {
  font-family: var(--ui);
  font-size: 9.5px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.synopsis-body {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink-soft);
  text-align: justify;
  hyphens: auto;
}
.synopsis-body p { margin-bottom: 0.8em; text-indent: 0; }
.synopsis-body p:last-child { margin-bottom: 0; }
.synopsis-tags {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 24px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
}
.synopsis-tag {
  display: flex; flex-direction: column; gap: 4px;
}
.synopsis-tag .k {
  font-family: var(--ui);
  font-size: 8.5px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.synopsis-tag .v {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.4;
}
.synopsis-status {
  font-family: var(--ui);
  font-size: 9px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 4px 10px;
  border: 1px solid var(--accent);
  border-radius: 100px;
  align-self: flex-start;
  opacity: 0.75;
}

/* cover & halftitle need more room than body pages */
.page-inner:has(.cover),
.page-inner:has(.halftitle),
.page-inner:has(.warning-page),
.page-inner:has(.toc) {
  max-width: min(900px, 96vw);
}

/* ───────── cover ───────── */
.cover {
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  width: 100%;
  height: 100%;
  padding: 16px 0;
  text-align: center;
  position: relative;
}
.cover-top, .cover-bot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-top: 18px;
}
.cover-bot { justify-content: flex-end; padding-top: 0; padding-bottom: 18px; }
.cover-mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
}
.cover-eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.cover-pub {
  font-family: var(--ui);
  font-size: 10px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.cover-title {
  font-family: var(--display);
  font-size: clamp(56px, 11vw, 124px);
  font-weight: 300;
  letter-spacing: -0.025em;
  line-height: 0.9;
  color: var(--ink);
  text-transform: uppercase;
  position: relative;
  max-width: 100%;
  white-space: nowrap;
}
.cover-title::after {
  content: "";
  position: absolute;
  left: 50%; right: auto; bottom: -8px;
  transform: translateX(-50%);
  width: 1.6em; height: 1px;
  background: var(--accent);
  opacity: 0.7;
}
.cover-tag {
  font-family: var(--display);
  font-style: italic;
  font-size: 18px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  max-width: 380px;
  line-height: 1.4;
}
.cover-author {
  font-family: var(--ui);
  font-size: 12.5px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.cover-rule {
  width: 1px; height: 28px;
  background: var(--ink-mute);
  opacity: 0.55; margin: 6px 0;
}
.cover-bg {
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: 0.8;
  background:
    radial-gradient(ellipse 40% 30% at 30% 22%, rgba(102, 145, 255, 0.10), transparent 60%),
    radial-gradient(ellipse 50% 35% at 80% 78%, rgba(40, 84, 216, 0.08), transparent 65%),
    radial-gradient(ellipse 60% 50% at 50% 50%, rgba(2, 4, 16, 0.35), transparent 70%);
}
.theme-beton .cover-bg, .theme-lecture .cover-bg { opacity: 0; }

/* full-bleed cover background — fills entire viewport, not just the page-inner */
body.is-cover::before {
  background:
    radial-gradient(ellipse 80% 50% at 50% 18%, rgba(102, 145, 255, 0.18), transparent 55%),
    radial-gradient(ellipse 60% 50% at 80% 90%, rgba(40, 84, 216, 0.16), transparent 60%),
    radial-gradient(ellipse 90% 70% at 50% 50%, rgba(2, 4, 16, 0.0), rgba(2, 4, 16, 0.55) 100%);
  z-index: 1;
}
.cover-bg {
  display: none;
}

/* ───────── halftitle ───────── */
.halftitle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  height: 100%;
  gap: 22px;
}
.halftitle .ht-name {
  font-family: var(--display);
  font-size: 56px;
  font-weight: 300;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  color: var(--ink);
}
.halftitle .ht-tag {
  font-family: var(--display);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  max-width: 420px;
}
.halftitle .ht-meta {
  margin-top: 22px;
  font-family: var(--ui);
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.halftitle .ht-warning {
  margin-top: 14px;
  font-family: var(--ui);
  font-size: 9px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: var(--blood);
  opacity: 0.7;
}

/* ───────── end card ───────── */
.endcard {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  height: 100%;
  gap: 14px;
}
.endcard-mark {
  font-family: var(--display);
  font-style: italic;
  font-size: 56px;
  color: var(--ink);
  line-height: 1;
}
.endcard-line {
  width: 28px; height: 1px;
  background: var(--ink-soft); opacity: 0.5;
  margin: 6px 0;
}
.endcard-next {
  font-family: var(--ui);
  font-size: 10.5px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.endcard-ch {
  font-family: var(--display);
  font-style: italic;
  font-size: 22px;
  color: var(--ink-soft);
  margin-top: 2px;
}

/* ───────── warning / disclaimer page ───────── */
.warning-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
  gap: 20px;
}
.warning-head {
  text-align: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}
.warning-head .stamp {
  font-family: var(--ui);
  font-size: 10px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--blood);
  margin-bottom: 12px;
  display: inline-block;
  padding: 5px 14px;
  border: 1px solid var(--blood);
  border-radius: 100px;
}
.warning-head h3 {
  font-family: var(--display);
  font-style: italic;
  font-weight: 300;
  font-size: 36px;
  color: var(--ink);
  margin-top: 6px;
}
.warning-head .by {
  font-family: var(--display);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-soft);
  margin-top: 6px;
}
.warning-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 20px;
  padding: 6px 0;
}
.warning-grid .item {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink-soft);
}
.warning-grid .item::before {
  content: "·";
  color: var(--blood);
  font-size: 18px;
  line-height: 1;
}
.warning-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  font-family: var(--display);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-mute);
  text-align: center;
  line-height: 1.5;
}

/* ───────── scent label on chapter title ───────── */
.scent {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  max-width: 480px;
}
.scent-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.scent-disk {
  width: 22px; height: 22px;
  border-radius: 100px;
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 0 16px var(--scent-glow, var(--accent));
}
.scent-disk::after {
  content: "";
  position: absolute;
  inset: 4px;
  background: var(--scent-glow, var(--accent));
  border-radius: 100px;
  opacity: 0.7;
  filter: blur(1px);
  animation: flame-glow 2.4s ease-in-out infinite;
}
.scent-name {
  font-family: var(--ui);
  font-size: 10.5px;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: var(--ink);
}
.scent-notes {
  font-family: var(--display);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.4;
}
.scent-moment {
  font-family: var(--ui);
  font-size: 9px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

/* ───────── dialogue ───────── */
.prose .dialogue {
  border-left: 2px solid var(--ink-mute);
  padding-left: 14px;
  font-style: italic;
  color: var(--ink-soft);
}


/* ───────── candles ───────── */
.candle {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: opacity 220ms ease;
  opacity: 0.55;
}
.candle.lit { opacity: 1; }
.candle:hover { opacity: 1; }

.candle .flame {
  width: 10px; height: 14px;
  position: relative;
  display: flex; justify-content: center; align-items: flex-end;
}
.candle .flame::before {
  content: "";
  position: absolute;
  bottom: 0;
  width: 6px; height: 11px;
  background: radial-gradient(ellipse at 50% 70%, var(--ember-warm) 0%, var(--ember) 40%, transparent 75%);
  border-radius: 50% 50% 40% 40% / 60% 60% 40% 40%;
  filter: blur(0.3px);
  animation: flame-flicker 1.8s ease-in-out infinite;
  transform-origin: 50% 100%;
}
.candle .flame::after {
  content: "";
  position: absolute;
  bottom: -8px;
  width: 22px; height: 22px;
  background: radial-gradient(circle, rgba(255, 154, 60, 0.35), transparent 65%);
  filter: blur(2px);
  animation: flame-glow 2.2s ease-in-out infinite;
}
.candle:not(.lit) .flame::before,
.candle:not(.lit) .flame::after { display: none; }

.candle .body {
  width: 4px;
  height: 26px;
  background: linear-gradient(180deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0.04) 25%, var(--ink-faint) 100%);
  border-radius: 1px 1px 0 0;
}
.candle.lit .body {
  background: linear-gradient(180deg, rgba(255, 200, 140, 0.35) 0%, rgba(180, 130, 90, 0.18) 25%, var(--ink-faint) 100%);
}
.candle .wick {
  width: 1px; height: 4px;
  background: #0a0a0a;
  margin-bottom: -1px;
}
.candle .num {
  font-family: var(--ui);
  font-size: 8.5px;
  letter-spacing: 0.18em;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
}
.candle.lit .num { color: var(--ink-soft); }
.candle.current .num {
  color: var(--ember);
  font-weight: 500;
}

/* scent candle variant */
.scent-candle.lit .body {
  background: linear-gradient(180deg, var(--scent-glow) 0%, rgba(180,130,90,0.18) 25%, var(--ink-faint) 100%);
}
.scent-candle.lit .flame::after {
  background: radial-gradient(circle, var(--scent-glow), transparent 65%);
}
.scent-label {
  font-family: var(--ui);
  font-size: 8.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-top: 4px;
  white-space: nowrap;
}
.scent-candle.lit .scent-label { color: var(--ink-soft); }
.scent-candle.current .scent-label { color: var(--ember); }

@keyframes flame-flicker {
  0%, 100% { transform: scaleY(1) translateX(0); opacity: 0.95; }
  25%      { transform: scaleY(1.08) translateX(-0.4px); opacity: 1; }
  50%      { transform: scaleY(0.96) translateX(0.3px); opacity: 0.88; }
  75%      { transform: scaleY(1.04) translateX(-0.2px); opacity: 1; }
}
@keyframes flame-glow {
  0%, 100% { opacity: 0.65; transform: scale(1); }
  50%      { opacity: 0.9; transform: scale(1.15); }
}

/* candle row in chrome (mini) */
.candles-row {
  display: flex; align-items: flex-end; gap: 6px;
}
.candles-row .candle .body { height: 16px; }
.candles-row .candle .flame { width: 7px; height: 10px; }
.candles-row .candle .flame::before { width: 4px; height: 7px; }
.candles-row .candle .flame::after { width: 14px; height: 14px; bottom: -5px; }
.candles-row .scent-label { font-size: 6.5px; letter-spacing: 0.12em; }

/* ───────── TOC — Vingt-Deux Veilles ───────── */
.toc {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 24px;
}
.toc-head {
  text-align: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}
.toc-head .label {
  font-family: var(--ui);
  font-size: 10px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.toc-head .title {
  font-family: var(--display);
  font-style: italic;
  font-size: 36px;
  font-weight: 300;
  color: var(--ink);
  margin-top: 8px;
}
.toc-head .sub {
  font-family: var(--display);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-soft);
  margin-top: 4px;
}

.toc-grid {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 16px 0 8px;
}

.toc-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 24px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-faint) transparent;
  padding-right: 8px;
}
.toc-list::-webkit-scrollbar { width: 4px; }
.toc-list::-webkit-scrollbar-thumb { background: var(--ink-faint); border-radius: 2px; }

.toc-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: color 180ms ease, background 180ms ease;
}
.toc-item:hover { color: var(--ink); }
.toc-item.current .num { color: var(--ember); }
.toc-item .num {
  font-family: var(--ui);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}
.toc-item .name {
  font-family: var(--display);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.3;
}
.toc-item.current .name, .toc-item:hover .name { color: var(--ink); }
.toc-item .act {
  font-family: var(--ui);
  font-size: 8.5px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ───────── audio bar ───────── */
.audio-bar {
  position: fixed;
  bottom: 76px;
  right: 16px;
  left: auto;
  transform: none;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(9, 13, 30, 0.72);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--rule-strong);
  padding: 4px 10px 4px 4px;
  border-radius: 100px;
  z-index: 50;
  font-family: var(--ui);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
  max-width: 60vw;
}
.audio-bar.visible {
  opacity: 1; pointer-events: auto;
}
.theme-beton .audio-bar, .theme-lecture .audio-bar {
  background: rgba(245, 240, 228, 0.82);
}
.audio-btn {
  appearance: none;
  background: var(--accent);
  border: none;
  color: white;
  width: 24px; height: 24px;
  border-radius: 100px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 9px;
  transition: background 180ms ease;
  flex-shrink: 0;
}
.audio-btn:hover { background: var(--accent-deep); }
.audio-btn.muted { background: var(--ink-faint); }
.audio-title {
  font-family: var(--display);
  font-style: italic;
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--ink);
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.audio-meta {
  color: var(--ink-mute);
  letter-spacing: 0.18em;
  font-size: 8px;
  display: none;
}
.audio-vol {
  width: 50px;
  height: 2px;
  background: var(--rule-strong);
  border-radius: 100px;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}
.audio-vol-fill {
  position: absolute;
  inset: 0;
  width: 50%;
  background: var(--accent);
  border-radius: 100px;
}

/* nav arrows */
.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-mute);
  font-family: var(--ui);
  font-size: 22px;
  font-weight: 200;
  user-select: none;
  pointer-events: none;
  opacity: 0;
  transition: opacity 240ms ease;
  z-index: 4;
}
.stage:hover .nav-arrow { opacity: 0.7; }
.nav-arrow.l { left: 16px; }
.nav-arrow.r { right: 16px; }

@keyframes caret-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.9; }
}
.pulse { animation: caret-pulse 2.4s ease-in-out infinite; }

/* chrome auto-hide */
.chrome-hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 300ms ease !important;
}
.chrome-top, .chrome-bot, .progress {
  transition: opacity 300ms ease;
}

/* bottom safe-area for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .chrome-bot { padding-bottom: max(0px, env(safe-area-inset-bottom)); }
  .reader { padding-bottom: env(safe-area-inset-bottom); }
}

/* small screens */
@media (max-height: 720px) {
  :root { --type-size: 16px; --line-h: 1.6; --page-w: 540px; }
  .reader { grid-template-rows: 48px 1fr 48px; }
  .progress { bottom: 48px; }
  .audio-bar { bottom: 56px; right: 8px; }
}
@media (max-width: 640px) {
  :root { --type-size: 16px; --page-w: 92vw; --line-h: 1.6; }
  .reader { grid-template-rows: 48px 1fr 48px; }
  .page { padding: 14px 12px; }
  .chrome-top, .chrome-bot { padding: 0 10px; font-size: 8.5px; letter-spacing: 0.12em; }
  .chrome-top .crumb-r, .chrome-bot .crumb-r { display: none; }
  .cover-title { font-size: clamp(36px, 14vw, 60px); white-space: normal; }
  .ch-name { font-size: clamp(22px, 6vw, 32px); }
  .toc-head .title { font-size: 28px; }
  .toc-grid { gap: 8px; flex-wrap: wrap; }
  .toc-grid .scent-label { font-size: 7px; }
  .toc-list { grid-template-columns: 1fr; gap: 0; }
  .audio-bar { bottom: 54px; right: 6px; padding: 3px 8px 3px 3px; max-width: 75vw; }
  .audio-title { max-width: 80px; font-size: 10px; }
  .audio-vol { width: 36px; }
  .nav-arrow { display: none; }
  .crumb-c .dot { margin: 0 6px; }
  .warning-grid { grid-template-columns: 1fr; }
  .scent { max-width: 100%; padding: 10px 14px; }
  .scent-notes { font-size: 11px; }
  .twk-panel { width: 94vw !important; max-height: 70vh !important; right: 3vw !important; }
  .prose .dialogue { padding-left: 10px; border-left-width: 1.5px; }
  .ch-sub { font-size: 14px; max-width: 90%; }
  .ch-act-line { margin-top: 24px; }
  .ch-act-line .lbl { font-size: 8px; }
}
@media (max-width: 480px) {
  :root { --type-size: 15.5px; --page-w: 94vw; }
  .page { padding: 12px 10px; }
  .chrome-top .crumb-l, .chrome-bot .crumb-l { font-size: 7.5px; }
  .chrome-top, .chrome-bot { padding: 0 6px; }
  .toc-head .title { font-size: 22px; }
  .toc-list { gap: 0; }
  .toc-item { padding: 6px 0; gap: 6px; grid-template-columns: 22px 1fr auto; }
  .toc-item .name { font-size: 12px; }
  .audio-bar { bottom: 50px; right: 4px; padding: 2px 6px 2px 2px; gap: 4px; }
  .audio-title { max-width: 60px; font-size: 9px; }
  .audio-btn { width: 20px; height: 20px; font-size: 7px; }
  .audio-vol { width: 28px; }
  .cover-title { font-size: clamp(28px, 12vw, 48px); }
  .ch-name { font-size: clamp(20px, 5vw, 28px); }
  .ch-number { font-size: 18px; }
  .ch-marker { font-size: 9px; margin-bottom: 14px; }
  .ch-rule { margin-bottom: 20px; }
  .halftitle .ht-name { font-size: 36px; }
  .halftitle .ht-tag { font-size: 13px; }
  .endcard-mark { font-size: 40px; }
  .warning-head h3 { font-size: 26px; }
  .prose p { text-indent: 1.2em; }
  .candles-row .scent-label { display: none; }
}
@media (max-width: 420px) {
  :root { --type-size: 15px; --page-w: 96vw; }
  .page { padding: 8px 8px; }
  .chrome-top .crumb-l, .chrome-bot .crumb-l { font-size: 7px; }
  .audio-title { display: none; }
  .audio-bar { gap: 3px; }
  .toc-grid { gap: 4px; }
  .toc-grid .scent-label { display: none; }
  .toc-grid .candle .body { height: 18px; width: 3px; }
  .toc-head .sub { font-size: 11px; }
}
