/* ══════════════════════════════════════════════════════════════
   AL MILLENNIUM — reader-lab.css
   One unified reader, three switchable layout directions:
     body[data-layout="rail"]       — persistent left Contents rail
     body[data-layout="dock"]       — minimal column + right icon dock
     body[data-layout="immersive"]  — hidden chrome + floating control sheet
   Shared reading column, typography, features. Tokens from style.css.
   ══════════════════════════════════════════════════════════════ */

/* ── Page base + mood ─────────────────────────────────────── */
html { scroll-behavior: smooth; }
body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(147,115,65,0.10), transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 30%,  rgba(60,30,20,0.16),  transparent 70%),
    radial-gradient(ellipse 70% 50% at 0%  70%,  rgba(40,30,50,0.11),  transparent 70%),
    var(--bg);
  min-height: 100vh;
  color: var(--text);
}
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 400;
  opacity: 0.055; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1   0 0 0 0 1   0 0 0 0 1   0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ── Top reading-progress hairline (all layouts except dock — left panel has it) ── */
.rdr-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 360;
  background: rgba(147,115,65,0.12);
}
.rdr-progress > span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(to right, var(--gold-dim), var(--gold-light));
  transition: width 0.12s linear;
}
body[data-layout="dock"] .rdr-progress { display: none; }

/* ════════════════════════════════════════════════════════════
   TOP BAR  (minimal; hidden in immersive)
   ════════════════════════════════════════════════════════════ */
.rdr-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 340;
  height: 56px; display: flex; align-items: center; gap: 18px;
  padding: 0 26px;
  background: linear-gradient(to bottom, rgba(6,6,8,0.92) 40%, transparent);
  backdrop-filter: blur(18px) saturate(120%);
}
.rdr-top-back {
  display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0;
  font-family: var(--font-display); font-size: 9px; letter-spacing: 0.26em;
  text-transform: uppercase; color: var(--text-muted); text-decoration: none;
  transition: color 0.2s;
}
.rdr-top-back:hover { color: var(--gold-light); }
.rdr-top-back svg { transition: transform 0.2s; }
.rdr-top-back:hover svg { transform: translateX(-3px); }
.rdr-top-mid {
  flex: 1; min-width: 0; text-align: center;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  opacity: 0; transition: opacity 0.4s;
}
.rdr-top-mid.show { opacity: 1; }
.rdr-top-act {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--gold); flex-shrink: 0;
}
.rdr-top-title {
  font-family: var(--font-display); font-size: 10px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--gold-bright);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rdr-top-tools { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* ── Generic icon button ──────────────────────────────────── */
.rdr-ic {
  position: relative;
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  background: none; border: 1px solid transparent; color: var(--text-muted);
  cursor: pointer; transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.rdr-ic:hover { color: var(--gold-light); }
.rdr-ic.active { color: var(--gold-bright); }
.rdr-ic svg { width: 17px; height: 17px; }
.rdr-ic-badge {
  position: absolute; top: 4px; right: 4px; min-width: 13px; height: 13px;
  padding: 0 3px; border-radius: 7px;
  background: var(--gold-light); color: var(--bg);
  font-family: var(--font-mono); font-size: 7px; line-height: 13px; text-align: center;
  transform: scale(0); transition: transform 0.2s var(--ease-out);
}
.rdr-ic-badge.show { transform: scale(1); }

/* ════════════════════════════════════════════════════════════
   CONTENTS PANEL  (rail when layout=rail, drawer otherwise)
   ════════════════════════════════════════════════════════════ */
.rdr-toc {
  display: flex; flex-direction: column;
  background: rgba(8,8,10,0.97);
  border-right: 1px solid var(--border-faint);
}
.toc-inner {
  display: flex; flex-direction: column; flex: 1; min-height: 0;
  padding: 30px 26px 24px; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--gold-dim) transparent;
}
.toc-inner::-webkit-scrollbar { width: 3px; }
.toc-inner::-webkit-scrollbar-thumb { background: var(--gold-dim); }
.toc-brand {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 18px; margin-bottom: 20px;
  border-bottom: 1px solid var(--border-faint);
}
.toc-brand img { opacity: 0.6; filter: drop-shadow(0 0 6px rgba(147,115,65,0.35)); }
.toc-brand span {
  font-family: var(--font-display); font-size: 9px; letter-spacing: 0.3em;
  text-transform: uppercase; color: var(--text-muted);
}
.toc-eyebrow {
  font-family: var(--font-display); font-size: 8px; letter-spacing: 0.45em;
  text-transform: uppercase; color: var(--gold); margin-bottom: 9px;
}
.toc-title {
  font-family: var(--font-display); font-size: 19px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold-bright);
  line-height: 1.15; margin-bottom: 7px;
}
.toc-title em { font-style: italic; font-weight: 400; color: var(--gold); }
.toc-format {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-muted);
}

/* progress block */
.toc-prog { margin: 22px 0 6px; }
.toc-prog-row {
  display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px;
}
.toc-prog-lbl {
  font-family: var(--font-display); font-size: 8px; letter-spacing: 0.32em;
  text-transform: uppercase; color: var(--text-muted);
}
.toc-prog-pct {
  font-family: var(--font-mono); font-size: 12px; color: var(--gold-light);
}
.toc-prog-track { height: 2px; background: rgba(147,115,65,0.16); }
.toc-prog-track > i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(to right, var(--gold-dim), var(--gold-light));
  transition: width 0.3s ease;
}
.toc-prog-left {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-muted); margin-top: 9px;
}
.toc-actions { margin: 14px 0 2px; }
.toc-act-btn {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: var(--bg2); border: 1px solid var(--border); color: var(--text-sub);
  font-family: var(--font-display); font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase;
  padding: 10px 12px; cursor: pointer; transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.toc-act-btn:hover { color: var(--gold-light); border-color: var(--border-hover); background: var(--bg3); }
.toc-act-btn svg { flex-shrink: 0; }

/* ── Ghost strip (dock collapsed state) ─────────────────── */
.toc-ghost {
  display: none;   /* enabled per-layout above */
  position: absolute; inset: 0; width: 44px;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; z-index: 2; pointer-events: none;
}
.toc-ghost-icon {
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; color: rgba(196,185,152,0.28);
  margin-bottom: 6px;
}
.toc-ghost-icon svg { width: 16px; height: 16px; }

.toc-ghost-pip {
  width: 4px; height: 4px;
  background: rgba(147,115,65,0.38); transform: rotate(45deg);
  flex-shrink: 0;
}
.toc-ghost-ch {
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-family: var(--font-display); font-size: 8px; letter-spacing: 0.3em;
  text-transform: uppercase; color: rgba(196,185,152,0.28);
  max-height: 160px; overflow: hidden; white-space: nowrap;
}

/* section labels inside drawer */
.toc-sec {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-size: 8px; letter-spacing: 0.36em;
  text-transform: uppercase; color: rgba(196,185,152,0.45);
  margin: 26px 0 14px;
}
.toc-sec svg { flex-shrink: 0; opacity: 0.55; }

/* chapter list */
.toc-list { list-style: none; margin: 0; padding: 0; flex: none; }
.toc-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 0; cursor: pointer;
  border-bottom: 1px dashed rgba(147,115,65,0.08);
  transition: background 0.22s;
}
.toc-item:last-child { border-bottom: none; }
.toc-item:hover { background: rgba(147,115,65,0.04); }

/* chapter icon (diamond) */
.toc-item-icon {
  flex-shrink: 0; width: 16px; padding-top: 3px;
  display: flex; justify-content: center;
}
.toc-item-icon svg {
  fill: rgba(147,115,65,0.22); transition: fill 0.25s, filter 0.25s;
}
.toc-item.active .toc-item-icon svg {
  fill: var(--gold-light);
  filter: drop-shadow(0 0 4px rgba(196,185,152,0.6));
}
.toc-item.passed .toc-item-icon svg { fill: rgba(147,115,65,0.14); }
.toc-item:hover .toc-item-icon svg { fill: rgba(147,115,65,0.5); }

.toc-item-body { flex: 1; min-width: 0; }
.toc-item-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.toc-item-act {
  font-family: var(--font-mono); font-size: 8px; letter-spacing: 0.2em;
  text-transform: uppercase; color: rgba(147,115,65,0.5); margin-bottom: 5px; transition: color 0.22s;
}
.toc-item.active .toc-item-act { color: var(--gold); }
.toc-item-min {
  font-family: var(--font-mono); font-size: 8px; letter-spacing: 0.08em;
  color: rgba(147,115,65,0.45); flex-shrink: 0;
}
.toc-item-title {
  font-family: var(--font-display); font-size: 12px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; line-height: 1.3;
  color: rgba(200,190,170,0.72); transition: color 0.22s;  /* upcoming = readable */
}
.toc-item.active  .toc-item-title { color: var(--gold-bright); }
.toc-item.passed  .toc-item-title { color: rgba(200,190,170,0.28); }  /* passed = dim */
.toc-item:hover   .toc-item-title { color: rgba(200,190,170,0.9); }
.toc-item-desc {
  font-family: var(--font-body); font-size: 10.5px; font-style: italic;
  color: rgba(147,115,65,0.55); line-height: 1.5; margin-top: 4px; transition: color 0.22s;
}
.toc-item.active .toc-item-desc { color: rgba(147,115,65,0.82); }
.toc-item.passed .toc-item-desc { color: rgba(147,115,65,0.28); }

/* bookmarks list */
.toc-bm-empty {
  font-family: var(--font-body); font-size: 11px; font-style: italic;
  color: var(--text-muted); line-height: 1.55;
}
.toc-bm {
  display: flex; gap: 11px; align-items: flex-start; padding: 11px 0; cursor: pointer;
  border-bottom: 1px solid rgba(147,115,65,0.08); text-decoration: none;
}
.toc-bm:last-child { border-bottom: none; }
.toc-bm-mark { flex-shrink: 0; color: var(--gold-light); margin-top: 2px; }
.toc-bm-body { flex: 1; min-width: 0; }
.toc-bm-ch {
  font-family: var(--font-mono); font-size: 8px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--gold); margin-bottom: 4px;
}
.toc-bm-text {
  font-family: var(--font-body); font-size: 11.5px; color: var(--text-sub);
  line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.toc-bm-del {
  flex-shrink: 0; background: none; border: none; cursor: pointer; padding: 2px;
  color: var(--gold-dim); transition: color 0.2s;
}
.toc-bm-del:hover { color: var(--nation-frysia); }

/* settings block — sits below Settings section header, no extra border needed */
.toc-foot { padding-top: 4px; margin-top: 0; }
.set-block { margin-bottom: 14px; }
.set-block:last-child { margin-bottom: 0; }
.set-label {
  font-family: var(--font-display); font-size: 8px; letter-spacing: 0.32em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 9px;
}
.set-row { display: flex; gap: 5px; }
.set-btn {
  flex: 1; background: var(--bg2); border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer; padding: 8px 0;
  font-family: var(--font-display); letter-spacing: 0.1em;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.set-btn.size-sm { font-size: 11px; }
.set-btn.size-md { font-size: 13px; }
.set-btn.size-lg { font-size: 16px; }
.set-btn.theme { font-size: 8px; letter-spacing: 0.14em; text-transform: uppercase; }
.set-btn:hover { color: var(--gold-light); }
.set-btn.active { border-color: rgba(196,185,152,0.5); color: var(--gold-bright); background: var(--bg3); }

/* ════════════════════════════════════════════════════════════
   RIGHT ICON DOCK  (layout=dock only)
   ════════════════════════════════════════════════════════════ */
.rdr-dock {
  position: fixed; top: 50%; right: 18px; transform: translateY(-50%); z-index: 350;
  display: none; flex-direction: column; gap: 4px; padding: 8px 6px;
  background: rgba(12,12,15,0.9); border: 1px solid var(--border);
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
  backdrop-filter: blur(16px) saturate(120%);
}
.rdr-dock .rdr-ic { width: 40px; height: 40px; color: var(--text-sub); }
.rdr-dock-sep { height: 1px; background: var(--border-faint); margin: 3px 8px; }

/* ════════════════════════════════════════════════════════════
   FLOATING PILL  (layout=immersive only)
   ════════════════════════════════════════════════════════════ */
.rdr-float {
  position: fixed; bottom: 26px; left: 50%; transform: translate(-50%, 14px); z-index: 350;
  display: none; align-items: center; gap: 2px; padding: 5px 8px;
  background: rgba(8,8,10,0.9); border: 1px solid var(--border-faint);
  backdrop-filter: blur(18px) saturate(120%);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s var(--ease-out), transform 0.3s var(--ease-out);
}
.rdr-float.show { opacity: 1; pointer-events: all; transform: translate(-50%, 0); }
.rdr-float-sep { width: 1px; height: 20px; background: var(--border-faint); margin: 0 5px; }

/* ════════════════════════════════════════════════════════════
   POPOVERS  (type / theme — used by dock & float)
   ════════════════════════════════════════════════════════════ */
.rdr-pop {
  position: fixed; z-index: 355; min-width: 168px;
  background: rgba(8,8,10,0.98); border: 1px solid rgba(196,185,152,0.18);
  backdrop-filter: blur(22px) saturate(140%); padding: 16px;
  opacity: 0; pointer-events: none; transform: translateY(6px) scale(0.97);
  transition: opacity 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}
.rdr-pop.open { opacity: 1; pointer-events: all; transform: none; }

/* ════════════════════════════════════════════════════════════
   SCRIM  (backdrop for drawer / overlay)
   ════════════════════════════════════════════════════════════ */
.rdr-scrim {
  position: fixed; inset: 0; z-index: 345; background: rgba(4,4,6,0.6);
  backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.rdr-scrim.show { opacity: 1; pointer-events: all; }

/* ════════════════════════════════════════════════════════════
   READING COLUMN  (shared)
   ════════════════════════════════════════════════════════════ */
.rdr-stage { display: flex; justify-content: center; }
.rdr-col {
  width: 100%; max-width: 680px; padding: 0 32px 40px;
}

/* opening */
.rdr-open {
  min-height: 64vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  padding: 120px 0 60px; position: relative;
}
.rdr-open::after {
  content: ''; position: absolute; bottom: 0; left: 12%; right: 12%; height: 1px;
  background: linear-gradient(to right, transparent, rgba(147,115,65,0.4), transparent);
}
.rdr-open-mark {
  width: clamp(150px, 22vw, 260px); margin-bottom: 26px;
  filter: invert(1) sepia(0.3) saturate(0.6) brightness(0.7);
}
.rdr-open-eyebrow {
  font-family: var(--font-display); font-size: 9px; letter-spacing: 0.5em;
  text-transform: uppercase; color: var(--gold); margin-bottom: 20px;
}
.rdr-open-eyebrow::before, .rdr-open-eyebrow::after {
  content: ''; display: inline-block; width: 22px; height: 1px;
  background: var(--gold-dim); vertical-align: middle; margin: 0 15px;
}
.rdr-open-title {
  font-family: var(--font-display); font-size: clamp(42px, 6.5vw, 80px); font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold-bright);
  line-height: 0.95; text-shadow: 0 0 80px rgba(196,185,152,0.15); margin-bottom: 22px;
}
.rdr-open-title em { font-style: italic; font-weight: 400; color: var(--gold); }
.rdr-open-logline {
  font-family: var(--font-body); font-style: italic; font-weight: 300;
  font-size: 16px; line-height: 1.65; color: rgba(196,185,152,0.65);
  max-width: 460px; margin: 0 auto 30px;
}
.rdr-open-rule { display: flex; align-items: center; justify-content: center; gap: 12px; }
.rdr-open-rule i { width: 56px; height: 1px; background: rgba(147,115,65,0.3); }
.rdr-open-rule b { width: 6px; height: 6px; background: var(--gold-dim); transform: rotate(45deg); }
@keyframes rdrFadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* chapter section */
.rdr-chapter { padding-top: 92px; }
.rdr-break { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 74px; }
.rdr-break i { flex: 1; max-width: 110px; height: 1px; }
.rdr-break i.l { background: linear-gradient(to left, transparent, rgba(147,115,65,0.3)); }
.rdr-break i.r { background: linear-gradient(to right, transparent, rgba(147,115,65,0.3)); }
.rdr-break b { font-family: var(--font-display); font-size: 11px; color: rgba(147,115,65,0.4); letter-spacing: 0.3em; }

.rdr-ch-head { text-align: center; margin-bottom: 48px; }
.rdr-ch-num {
  font-family: var(--font-display); font-style: italic; font-weight: 400;
  font-size: clamp(50px, 6.5vw, 72px); color: rgba(147,115,65,0.22);
  line-height: 1; margin-bottom: 18px; letter-spacing: 0.06em;
}
.rdr-ch-rule { display: flex; align-items: center; justify-content: center; gap: 11px; margin-bottom: 18px; }
.rdr-ch-rule i { width: 42px; height: 1px; background: rgba(147,115,65,0.3); }
.rdr-ch-rule b { width: 5px; height: 5px; background: var(--gold); transform: rotate(45deg); }
.rdr-ch-title {
  font-family: var(--font-display); font-size: clamp(20px, 2.6vw, 27px); font-weight: 700;
  letter-spacing: 0.13em; text-transform: uppercase; color: var(--gold-bright); margin-bottom: 12px;
}
.rdr-ch-meta {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-muted);
}

/* prose */
.rdr-prose {
  font-family: var(--font-body); font-weight: 400; font-size: 17px;
  line-height: 1.95; color: rgba(220,210,188,0.85); letter-spacing: 0.012em; text-wrap: pretty;
}
.rdr-prose p { margin-bottom: 26px; }
.rdr-prose p:last-child { margin-bottom: 0; }
.rdr-prose .drop::first-letter {
  font-family: var(--font-display); font-size: 4.6em; font-weight: 700;
  color: var(--gold-bright); float: left; line-height: 0.78; margin: 6px 12px 0 0;
}
.rdr-pull {
  margin: 46px 0; padding: 2px 0 2px 26px; border-left: 2px solid var(--gold-dim);
}
.rdr-pull p {
  font-family: var(--font-display); font-style: italic; font-weight: 400;
  font-size: clamp(16px, 2vw, 20px); line-height: 1.6; color: var(--gold-light);
  letter-spacing: 0.02em; margin: 0;
}

/* font-size variants */
body.fs-sm .rdr-prose { font-size: 14.5px; line-height: 1.9; }
body.fs-md .rdr-prose { font-size: 17px;   line-height: 1.95; }
body.fs-lg .rdr-prose { font-size: 20px;   line-height: 2.0; }

/* next-chapter prompt */
.rdr-next {
  margin-top: 70px; padding-top: 30px; border-top: 1px solid var(--border-faint);
  display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center;
}
.rdr-next-lbl {
  font-family: var(--font-display); font-size: 8px; letter-spacing: 0.4em;
  text-transform: uppercase; color: var(--text-muted);
}
.rdr-next-btn {
  display: inline-flex; align-items: center; gap: 14px; cursor: pointer;
  background: none; border: none;
  font-family: var(--font-display); font-size: clamp(15px, 2vw, 19px); font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold-bright);
  transition: color 0.2s;
}
.rdr-next-btn:hover { color: var(--gold-light); }
.rdr-next-btn .arr { transition: transform 0.25s var(--ease-out); }
.rdr-next-btn:hover .arr { transform: translateX(5px); }
.rdr-next-min { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.14em; color: var(--gold-dim); text-transform: uppercase; }

/* in-prose bookmark anchor flash */
.rdr-prose p.bm-hit { animation: bmFlash 1.6s ease; }
@keyframes bmFlash {
  0%, 100% { background: transparent; }
  25%      { background: rgba(196,185,152,0.09); }
}
/* bookmark ribbon marker on a paragraph */
.bm-flag {
  position: absolute; left: -30px; top: 2px; color: var(--gold-light);
  opacity: 0.85; pointer-events: none;
}
.rdr-prose p { position: relative; }

/* end block */
.rdr-end { text-align: center; padding: 110px 0 130px; }
.rdr-end-mark {
  width: clamp(96px, 15vw, 160px); margin: 0 auto 30px; display: block;
  filter: invert(1) sepia(0.3) saturate(0.5) brightness(0.45); opacity: 0.55;
}
.rdr-end-diamond { width: 9px; height: 9px; background: var(--gold-dim); transform: rotate(45deg); margin: 0 auto 30px; }
.rdr-end-label {
  font-family: var(--font-display); font-size: 11px; letter-spacing: 0.45em;
  text-transform: uppercase; color: rgba(201,165,53,0.45); margin-bottom: 30px;
}
.rdr-end-back {
  display: inline-flex; align-items: center; gap: 14px;
  font-family: var(--font-display); font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--gold-bright); text-decoration: none; padding: 14px 28px;
  border: 1px solid var(--gold-light); position: relative; overflow: hidden;
}
.rdr-end-back::before {
  content: ''; position: absolute; inset: 0; background: var(--gold-light);
  transform: translateX(-101%); transition: transform 0.4s var(--ease-fill); z-index: -1;
}
.rdr-end-back:hover { color: var(--bg); }
.rdr-end-back:hover::before { transform: translateX(0); }

/* reveal — base visible; gentle lift only when motion is allowed & JS-armed */
.rdr-chapter { opacity: 1; transform: none; }
@media (prefers-reduced-motion: no-preference) {
  body.reveal-on .rdr-chapter { transform: translateY(20px); transition: transform 0.75s var(--ease-out); }
  body.reveal-on .rdr-chapter.vis { transform: none; }
}

/* ════════════════════════════════════════════════════════════
   LAYOUT A — RAIL  (persistent left Contents)
   ════════════════════════════════════════════════════════════ */
body[data-layout="rail"] .rdr-toc {
  position: fixed; top: 0; left: 0; width: 300px; height: 100vh; z-index: 330;
}
body[data-layout="rail"] .rdr-top { left: 300px; }
body[data-layout="rail"] .rdr-progress { left: 300px; }
body[data-layout="rail"] .rdr-stage { padding-left: 300px; }
body[data-layout="rail"] .rdr-col { padding-top: 56px; }
body[data-layout="rail"] .rdr-top-back { display: none; }   /* back lives in rail */
body[data-layout="rail"] .rdr-top-tools { display: none; }
body[data-layout="rail"] .rdr-dock,
body[data-layout="rail"] .rdr-float { display: none !important; }
/* rail back link */
.toc-back {
  display: inline-flex; align-items: center; gap: 9px; margin-top: 16px;
  font-family: var(--font-display); font-size: 9px; letter-spacing: 0.28em;
  text-transform: uppercase; color: var(--text-muted); text-decoration: none; transition: color 0.2s;
}
.toc-back:hover { color: var(--gold-light); }
.toc-back svg { transition: transform 0.2s; }
.toc-back:hover svg { transform: translateX(-3px); }
body:not([data-layout="rail"]) .toc-back { display: none; }

/* ════════════════════════════════════════════════════════════
   LAYOUT B — DOCK  (centered column + left hover-reveal panel)
   ════════════════════════════════════════════════════════════ */
body[data-layout="dock"] .rdr-dock      { display: none; }   /* absorbed into left panel */
body[data-layout="dock"] .rdr-top-tools { display: none; }   /* replaced by left panel */
body[data-layout="dock"] .rdr-top-toc   { display: none; }   /* icon lives in the strip */
body[data-layout="dock"] .rdr-col { padding-top: 56px; }
body[data-layout="dock"] .rdr-float { display: none !important; }

/* Progress line on panel right edge — fills as you read */
body[data-layout="dock"] .rdr-toc::before {
  content: ''; position: absolute; right: 0; top: 0; z-index: 4; pointer-events: none;
  width: 1px; height: var(--toc-prog, 0%);
  background: linear-gradient(to bottom,
    transparent 0%,
    rgba(147,115,65,0.5) 20%,
    var(--gold-light) 60%,
    rgba(147,115,65,0.3) 100%);
  transition: height 0.18s linear;
}

/* Left hover-reveal panel */
body[data-layout="dock"] .rdr-toc {
  position: fixed; top: 0; left: 0; width: 44px; height: 100vh; z-index: 348;
  border-right: 1px solid rgba(196,185,152,0.05); border-left: none;
  transform: none;   /* always on-screen */
  overflow: hidden;
  background: rgba(5,5,7,0.35);
  backdrop-filter: blur(10px);
  transition: width 0.44s cubic-bezier(0.4,0,0.2,1),
              background 0.38s,
              border-color 0.38s;
}
body[data-layout="dock"] .rdr-toc:hover,
body[data-layout="dock"] .rdr-toc.open {
  width: 300px;
  background: rgba(7,7,9,0.97);
  border-right-color: rgba(196,185,152,0.11);
}

/* In dock layout: truly center the title against the full viewport */
body[data-layout="dock"] .rdr-top-mid {
  position: absolute; left: 50%; transform: translateX(-50%);
  flex: none; pointer-events: none;
}
/* Back arrow only — hide label text */
body[data-layout="dock"] #topBackLabel { display: none; }

/* Ghost strip — chapter name; fades as panel expands */
body[data-layout="dock"] .toc-ghost {
  display: flex;
  opacity: 1;
  transition: opacity 0.18s 0.12s;
}
body[data-layout="dock"] .rdr-toc:hover .toc-ghost,
body[data-layout="dock"] .rdr-toc.open  .toc-ghost {
  opacity: 0;
  transition: opacity 0.14s;
}

/* Inner panel content — fades in as panel expands */
body[data-layout="dock"] .rdr-toc .toc-inner {
  width: 300px; flex-shrink: 0;
  opacity: 0; pointer-events: none;
  transition: opacity 0.22s 0.18s;
}
body[data-layout="dock"] .rdr-toc:hover .toc-inner,
body[data-layout="dock"] .rdr-toc.open  .toc-inner {
  opacity: 1; pointer-events: all;
}

/* Close button fades in with inner */
body[data-layout="dock"] .toc-close {
  display: flex; opacity: 0;
  transition: opacity 0.22s 0.18s;
}
body[data-layout="dock"] .rdr-toc:hover .toc-close,
body[data-layout="dock"] .rdr-toc.open  .toc-close {
  opacity: 1;
}

/* Immersive: right-side drawer (unchanged) */
body[data-layout="immersive"] .rdr-toc {
  position: fixed; top: 0; right: 0; width: 340px; max-width: 88vw; height: 100vh; z-index: 348;
  border-right: none; border-left: 1px solid var(--border-faint);
  transform: translateX(100%); transition: transform 0.36s var(--ease-out);
}
body[data-layout="immersive"] .rdr-toc.open { transform: translateX(0); }

/* ════════════════════════════════════════════════════════════
   LAYOUT C — IMMERSIVE  (hidden chrome + floating sheet)
   ════════════════════════════════════════════════════════════ */
body[data-layout="immersive"] .rdr-top { transform: translateY(-100%); transition: transform 0.3s; }
body[data-layout="immersive"] .rdr-top.show { transform: none; }
body[data-layout="immersive"] .rdr-float { display: flex; }
body[data-layout="immersive"] .rdr-dock { display: none !important; }
body[data-layout="immersive"] .rdr-col { padding-top: 90px; }

/* drawer close button */
.toc-close {
  position: absolute; top: 16px; right: 16px; z-index: 3;
  width: 32px; height: 32px; display: none; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--border-faint); color: var(--text-muted); cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.toc-close:hover { color: var(--gold-light); border-color: var(--gold-light); }
/* dock: shown via opacity fade-in rule above; immersive: always show */
body[data-layout="immersive"] .toc-close { display: flex; }

/* ════════════════════════════════════════════════════════════
   THEMES
   ════════════════════════════════════════════════════════════ */
body.theme-dim .rdr-prose { color: rgba(196,186,165,0.6); }
body.theme-dim .rdr-col { filter: brightness(0.82); }

body.theme-sepia {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(120,80,30,0.16), transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 30%,  rgba(80,50,15,0.2),   transparent 70%),
    #0e0a05;
}
body.theme-sepia .rdr-prose { color: #cbb27e; }
body.theme-sepia .rdr-prose .drop::first-letter { color: #ddc488; }
body.theme-sepia .rdr-open-logline { color: rgba(203,178,126,0.7); }

/* ════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 960px) {
  body[data-layout="rail"] .rdr-toc {
    transform: translateX(-100%); transition: transform 0.36s var(--ease-out);
    border-right: 1px solid var(--border-faint); z-index: 348;
  }
  body[data-layout="rail"] .rdr-toc.open { transform: translateX(0); }
  body[data-layout="rail"] .rdr-top { left: 0; }
  body[data-layout="rail"] .rdr-progress { left: 0; }
  body[data-layout="rail"] .rdr-stage { padding-left: 0; }
  body[data-layout="rail"] .rdr-top-back,
  body[data-layout="rail"] .rdr-top-tools { display: flex; }
  body[data-layout="rail"] .toc-close { display: flex; }
}
@media (max-width: 600px) {
  .rdr-col { padding-left: 22px; padding-right: 22px; }
  .bm-flag { left: -18px; }
}

/* ════════════════════════════════════════════════════════════
   EXTRA BLOCK TYPES  (the live editor supports more than the
   legacy text/pullquote — render them in the same gold-on-dark
   spirit so DB stories that use them stay beautiful)
   ════════════════════════════════════════════════════════════ */
.rdr-pull cite {
  display: block; margin-top: 14px; font-style: normal;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--text-muted);
}
.rdr-prose .rdr-h {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(17px, 2vw, 21px);
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold-bright);
  margin: 44px 0 22px; line-height: 1.3;
}
.rdr-epi {
  margin: 44px auto; max-width: 80%; text-align: center;
}
.rdr-epi p {
  font-family: var(--font-body); font-style: italic; font-weight: 300;
  font-size: clamp(15px, 1.9vw, 18px); line-height: 1.7; color: rgba(196,185,152,0.7); margin: 0;
}
.rdr-epi cite {
  display: block; margin-top: 14px; font-style: normal;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--text-muted);
}
.rdr-fig { margin: 46px 0; text-align: center; }
.rdr-fig img {
  max-width: 100%; height: auto; display: block; margin: 0 auto;
  border: 1px solid var(--border-faint);
}
.rdr-fig.align-left  { text-align: left; }
.rdr-fig.align-right { text-align: right; }
.rdr-fig figcaption {
  margin-top: 12px; font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-muted);
}
.rdr-hr { display: flex; align-items: center; justify-content: center; gap: 11px; margin: 46px 0; }
.rdr-hr i { width: 42px; height: 1px; background: rgba(147,115,65,0.3); }
.rdr-hr b { width: 5px; height: 5px; background: var(--gold-dim); transform: rotate(45deg); }

/* Per-chapter interstitial image (a cinematic beat at the chapter's start). */
.rdr-interstitial { margin: 0 0 70px; text-align: center; }
.rdr-interstitial-img {
  display: block; width: 100%; aspect-ratio: 16 / 9;
  background-size: cover; background-position: 50% 50%;
  border: 1px solid var(--border-faint);
}
.rdr-interstitial figcaption {
  margin-top: 12px; font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-muted);
}
.rdr-chapter:first-child .rdr-interstitial { margin-top: 30px; }

/* ════════════════════════════════════════════════════════════
   AMBIENT SCORE PLAYER  (kept so the per-story soundtrack works
   on the reader; ported from enhancements.js so this immersive
   layout doesn't need the full site enhancements bundle)
   ════════════════════════════════════════════════════════════ */
.alm-music {
  position: fixed; left: 22px; bottom: 22px; z-index: 9996;
  display: flex; align-items: center; font-family: var(--font-body), sans-serif;
}
.alm-music-orb {
  position: relative; flex-shrink: 0; width: 50px; height: 50px; border-radius: 50%;
  background: rgba(10,10,12,0.74); border: 1px solid rgba(196,185,152,0.30);
  backdrop-filter: blur(14px) saturate(130%); -webkit-backdrop-filter: blur(14px) saturate(130%);
  display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
  transition: border-color 0.3s, box-shadow 0.4s, transform 0.2s;
}
.alm-music-orb:hover { border-color: rgba(196,185,152,0.65); transform: translateY(-1px); }
.alm-music.playing .alm-music-orb { border-color: rgba(196,185,152,0.5); animation: almOrbPulse 2.8s ease-in-out infinite; }
@keyframes almOrbPulse {
  0%   { box-shadow: 0 0 0 0 rgba(196,185,152,0.22); }
  70%  { box-shadow: 0 0 0 13px rgba(196,185,152,0); }
  100% { box-shadow: 0 0 0 0 rgba(196,185,152,0); }
}
.alm-music-orb svg { color: var(--gold-light, #C4B998); transition: opacity 0.2s; }
.alm-ic-pause { display: none; }
.alm-music.playing .alm-ic-play  { display: none; }
.alm-music.playing .alm-ic-pause { display: block; }
.alm-panel {
  display: flex; align-items: center; max-width: 0; opacity: 0; margin-left: 0; overflow: hidden;
  transition: max-width 0.5s cubic-bezier(0.2,0,0.2,1), opacity 0.35s ease, margin-left 0.5s cubic-bezier(0.2,0,0.2,1);
}
.alm-music:hover .alm-panel, .alm-music:focus-within .alm-panel, .alm-music.peek .alm-panel { max-width: 360px; opacity: 1; margin-left: 10px; }
.alm-panel-inner {
  display: flex; align-items: center; gap: 15px; padding: 9px 17px 9px 15px; white-space: nowrap;
  background: rgba(10,10,12,0.74); border: 1px solid rgba(196,185,152,0.20);
  backdrop-filter: blur(14px) saturate(130%); -webkit-backdrop-filter: blur(14px) saturate(130%);
}
.alm-eq { display: flex; align-items: center; gap: 2.5px; height: 20px; flex-shrink: 0; }
.alm-eq span { width: 2.5px; height: 26%; border-radius: 2px; background: var(--gold-light, #C4B998); transition: height 0.3s, opacity 0.3s; opacity: 0.5; }
.alm-music.playing .alm-eq span { opacity: 1; animation: almEq 0.95s ease-in-out infinite; }
.alm-eq span:nth-child(1) { animation-delay: -0.20s; }
.alm-eq span:nth-child(2) { animation-delay: -0.55s; }
.alm-eq span:nth-child(3) { animation-delay: -0.10s; }
.alm-eq span:nth-child(4) { animation-delay: -0.75s; }
@keyframes almEq { 0%,100% { height: 22%; } 50% { height: 94%; } }
.alm-panel-meta { display: flex; flex-direction: column; }
.alm-track { font-family: var(--font-display), serif; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold-bright, #F0E6D2); line-height: 1; }
.alm-sub { font-family: var(--font-mono), monospace; font-size: 8px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-muted, #7a7060); margin-top: 5px; }
.alm-progress-track { width: 150px; height: 2px; margin-top: 9px; background: rgba(196,185,152,0.18); cursor: pointer; position: relative; }
.alm-progress-fill { height: 100%; width: 0%; background: var(--gold-light, #C4B998); }
.alm-vol { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.alm-vol svg { color: var(--gold-dim, #7a7060); flex-shrink: 0; }
.alm-vol-slider { -webkit-appearance: none; appearance: none; width: 62px; height: 2px; border-radius: 2px; background: rgba(196,185,152,0.25); outline: none; cursor: pointer; }
.alm-vol-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 9px; height: 9px; border-radius: 50%; background: var(--gold-light, #C4B998); box-shadow: 0 0 6px rgba(196,185,152,0.55); }
.alm-vol-slider::-moz-range-thumb { width: 9px; height: 9px; border: none; border-radius: 50%; background: var(--gold-light, #C4B998); }
@media (max-width: 640px) {
  .alm-music { left: 16px; bottom: 16px; }
  .alm-music:hover .alm-panel, .alm-music.peek .alm-panel { max-width: 280px; }
  .alm-progress-track { width: 96px; }
  .alm-vol-slider { width: 48px; }
}
