/* The Great Inheritance: night-sky instrument, set for long reading */
:root {
  --serif: "Newsreader", "Iowan Old Style", Charter, Georgia, serif;
  --label: "IBM Plex Sans Condensed", "Avenir Next Condensed", "Arial Narrow", sans-serif;
  --amber: #F3B24A;
  --night: #06080C;
  --toc-w: 264px;
  --measure: 36rem;
  --topbar-h: 56px;
  --ease: cubic-bezier(.2, .7, .1, 1);
}
:root[data-theme="dark"] {
  --bg: #08090D; --bg-2: #0E1017; --ink: #ECE6D9; --ink-2: rgba(236, 230, 217, .78); --dim: rgba(236, 230, 217, .56);
  --faint: rgba(236, 230, 217, .28); --line: rgba(236, 230, 217, .12); --accent: #F3B24A; --accent-ink: #F3B24A;
  --sel: rgba(243, 178, 74, .3); --panel: rgba(16, 18, 26, .86); color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #F4EFE5; --bg-2: #EAE3D4; --ink: #1F1C17; --ink-2: rgba(31, 28, 23, .82); --dim: rgba(31, 28, 23, .7);
  --faint: rgba(31, 28, 23, .32); --line: rgba(31, 28, 23, .13); --accent: #C98A1E; --accent-ink: #94600F;
  --sel: rgba(201, 138, 30, .25); --panel: rgba(244, 239, 229, .9); color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden]:not(.player) { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 24px); -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--serif);
  font-size: clamp(18.5px, 1.05rem + .28vw, 21px); line-height: 1.62; font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: hidden;
  transition: background-color .4s var(--ease), color .4s var(--ease);
}
::selection { background: var(--sel); }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.skip { position: fixed; left: 12px; top: -60px; z-index: 100; background: var(--accent); color: #111; padding: 8px 14px; border-radius: 6px; font-family: var(--label); text-decoration: none; }
.skip:focus { top: 12px; }

/* ---------- labels ---------- */
.kicker, .ch-num, .toc-label, .toc-meta, .t-num, .btn-meta, .byline, .listen-chip, .pl-rate, .pl-time, .src-n, .foot-meta, .top-btn span, .scroll-cue span, .toast {
  font-family: var(--label); letter-spacing: .14em; text-transform: uppercase; font-weight: 500;
}

/* ---------- top bar ---------- */
.read-progress { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 60; pointer-events: none; }
.read-progress i { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 50; display: flex; align-items: center; justify-content: space-between;
  padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-left)); color: #ECE6D9;
  transition: background-color .35s var(--ease), color .35s var(--ease), border-color .35s var(--ease); border-bottom: 1px solid transparent;
}
.topbar.solid { background: var(--panel); color: var(--ink); border-bottom-color: var(--line); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 17px; letter-spacing: .01em; }
.brand-name { opacity: 0; transform: translateY(-4px); transition: opacity .35s, transform .35s var(--ease); white-space: nowrap; }
body.docked .brand-name, body:not(.mini-on) .topbar.solid .brand-name { opacity: 1; transform: none; }
.mark { position: relative; width: 36px; height: 36px; margin: -4px 0; flex: 0 0 auto; opacity: 0; transition: opacity .25s; }
.mark canvas, .mark svg { position: absolute; inset: 0; width: 100%; height: 100%; }
body.mini-on .mark-svg { display: none; }
body:not(.mini-on) .topbar.solid .mark, body.docked .mark { opacity: 1; }
#dock-sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 61; pointer-events: none; display: none; }
.top-actions { display: flex; gap: 4px; }
.top-btn { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: 18px; font-size: 12px; transition: background-color .2s; }
.top-btn:hover { background: rgba(127, 127, 127, .14); }
.top-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.listen-top svg, .top-btn .i-moon { fill: currentColor; stroke: none; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="light"] .theme-toggle .i-sun { display: block; }
:root[data-theme="light"] .theme-toggle .i-moon { display: none; }
.toc-open { display: none; }

/* ---------- hero (always night) ---------- */
.hero { position: relative; min-height: 100svh; display: flex; align-items: center; background: var(--night); color: #ECE6D9; overflow: hidden; isolation: isolate; }
#sky, #sky2d { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -2; }
#sky2d { mix-blend-mode: screen; }
.hero-scrim { position: absolute; inset: 0; z-index: -1; background:
  linear-gradient(90deg, rgba(6, 8, 12, .82) 0%, rgba(6, 8, 12, .45) 42%, rgba(6, 8, 12, 0) 70%),
  linear-gradient(180deg, rgba(6, 8, 12, 0) 70%, var(--bg) 100%); }
.hero-inner { width: min(640px, 100%); margin-left: clamp(20px, 8vw, 140px); padding: calc(var(--topbar-h) + 40px) 0 120px; }
.kicker { font-size: 12px; color: var(--amber); margin: 0 0 22px; display: flex; align-items: center; gap: 14px; }
.kicker::before { content: ""; width: 34px; height: 1px; background: currentColor; }
.hero h1 { font-weight: 300; font-size: clamp(3.1rem, 8.2vw, 7.2rem); line-height: .95; letter-spacing: -.025em; margin: 0 0 28px; font-variation-settings: "opsz" 72; }
.dek { font-style: italic; font-size: clamp(1.3rem, 2.3vw, 1.75rem); line-height: 1.35; color: rgba(236, 230, 217, .86); margin: 0 0 30px; max-width: 30ch; font-weight: 300; }
.byline { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; color: rgba(236, 230, 217, .58); margin: 0 0 40px; }
.byline span:first-child { color: rgba(236, 230, 217, .9); }
.ctas { display: flex; flex-wrap: wrap; gap: 12px; }
.btn { display: inline-flex; align-items: center; gap: 12px; height: 52px; padding: 0 22px; border-radius: 26px; text-decoration: none; font-size: 17px; transition: transform .25s var(--ease), background-color .25s, border-color .25s, color .25s; }
.btn svg { width: 14px; height: 14px; fill: currentColor; }
.btn .btn-meta { font-size: 11px; opacity: .65; }
.btn.primary { background: #ECE6D9; color: #0B0C10; }
.btn.primary:hover { background: #fff; transform: translateY(-1px); }
.btn.ghost { border: 1px solid rgba(236, 230, 217, .3); color: inherit; }
.btn.ghost:hover { border-color: var(--amber); color: var(--amber); transform: translateY(-1px); }
.btn.small { height: 42px; font-size: 15px; padding: 0 18px; }
.scroll-cue { position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 10px; text-decoration: none; color: rgba(236, 230, 217, .55); font-size: 10.5px; }
.scroll-cue i { width: 1px; height: 46px; background: linear-gradient(rgba(236, 230, 217, .6), transparent); animation: cue 2.4s var(--ease) infinite; transform-origin: top; }
@keyframes cue { 0% { transform: scaleY(0); opacity: 1; } 60% { transform: scaleY(1); opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }
.hero-inner > * { opacity: 0; transform: translateY(14px); animation: rise 1.1s var(--ease) forwards; }
.hero-inner > :nth-child(1) { animation-delay: .2s; } .hero-inner > :nth-child(2) { animation-delay: .32s; } .hero-inner > :nth-child(3) { animation-delay: .5s; }
.hero-inner > :nth-child(4) { animation-delay: .66s; } .hero-inner > :nth-child(5) { animation-delay: .8s; }
@keyframes rise { to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .hero-inner > * { animation: none; opacity: 1; transform: none; } .scroll-cue i { animation: none; } }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: var(--toc-w) minmax(0, 1fr); gap: 0 clamp(32px, 5vw, 88px); max-width: 1240px; margin: 0 auto; padding: 0 clamp(20px, 4vw, 48px); }
main { min-width: 0; padding-bottom: 80px; }

/* ---------- contents ---------- */
.toc { position: relative; }
.toc-inner { position: sticky; top: calc(var(--topbar-h) + 36px); padding: 72px 0 40px; max-height: calc(100vh - var(--topbar-h) - 36px); overflow-y: auto; scrollbar-width: none; }
.toc-label { font-size: 11px; color: var(--dim); margin: 0 0 18px; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { position: relative; display: flex; align-items: center; gap: 6px; }
.toc li::before { content: ""; position: absolute; left: -16px; top: 50%; width: 6px; height: 1px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .3s var(--ease); }
.toc li.active::before { transform: scaleX(1); }
.toc a { flex: 1; display: flex; gap: 12px; align-items: baseline; padding: 7px 0; text-decoration: none; color: var(--dim); font-size: 15.5px; line-height: 1.3; transition: color .2s; }
.toc a:hover, .toc li.active a { color: var(--ink); }
.t-num { font-size: 10.5px; color: var(--dim); min-width: 18px; }
.toc li.active .t-num { color: var(--accent-ink); }
.t-play { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 10px; font-family: var(--label); font-size: 10.5px; letter-spacing: .08em; color: var(--dim); opacity: .0; transition: opacity .2s, color .2s; }
.toc li:hover .t-play, .toc li.playing .t-play, .t-play:focus-visible { opacity: 1; }
.t-play:hover { color: var(--accent-ink); }
.eq { display: none; gap: 2px; align-items: flex-end; height: 10px; }
.eq i { width: 2px; background: var(--accent); height: 30%; animation: eq 1s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.3s; } .eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { 0%, 100% { height: 25%; } 50% { height: 100%; } }
.toc li.playing .eq { display: flex; }
.toc li.playing .t-play { color: var(--accent-ink); }
.player.paused ~ * .eq i, body.paused .eq i { animation-play-state: paused; }
.toc-meta { margin: 24px 0 0; font-size: 10.5px; color: var(--dim); line-height: 1.7; }

/* ---------- chapters ---------- */
.chapter { padding-top: 96px; }
.chapter + .chapter { border-top: 1px solid var(--line); margin-top: 72px; }
.ch-head { max-width: var(--measure); margin-bottom: 44px; }
.ch-num { display: flex; align-items: center; gap: 14px; font-size: 12px; color: var(--accent-ink); margin: 0 0 18px; }
.ch-num::after { content: ""; flex: 0 0 48px; height: 1px; background: currentColor; opacity: .6; }
.chapter h2 { margin: 0 0 22px; font-weight: 400; line-height: 1.04; letter-spacing: -.018em; font-variation-settings: "opsz" 60; }
.ch-title { display: block; font-size: clamp(2.3rem, 4.6vw, 3.5rem); }
.ch-sub { display: block; margin-top: 12px; font-style: italic; font-weight: 300; font-size: clamp(1.25rem, 2.1vw, 1.6rem); line-height: 1.25; color: var(--ink-2); letter-spacing: -.005em; }
.listen-chip { display: inline-flex; align-items: center; gap: 10px; height: 34px; padding: 0 14px 0 12px; border: 1px solid var(--line); border-radius: 17px; font-size: 11px; color: var(--ink-2); transition: border-color .2s, color .2s, background-color .2s; }
.listen-chip svg { width: 10px; height: 10px; fill: currentColor; }
.listen-chip .dur { color: var(--dim); letter-spacing: .06em; }
.listen-chip:hover { border-color: var(--accent); color: var(--accent-ink); }
.listen-chip.playing { border-color: var(--accent); color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 10%, transparent); }

/* ---------- prose ---------- */
.prose { max-width: var(--measure); hanging-punctuation: first; }
.prose p { margin: 0 0 1.08em; }
.prose strong { font-weight: 600; color: var(--ink); }
.prose em { font-style: italic; }
.prose a:not(.cite a) { text-decoration-color: var(--faint); text-underline-offset: .18em; text-decoration-thickness: 1px; }
.prose a:not(.cite a):hover { text-decoration-color: var(--accent); }
.opening .prose > p:first-of-type::first-letter { float: left; font-size: 5.1em; line-height: .82; margin: .06em .1em 0 -.02em; color: var(--accent-ink); font-weight: 300; font-variation-settings: "opsz" 72; }
.opening .prose > p:first-of-type { font-size: 1.12em; }
.prose h3 { font-weight: 400; font-style: italic; font-size: 1.5em; line-height: 1.2; margin: 2.2em 0 .7em; letter-spacing: -.01em; }
.prose h4 { font-family: var(--label); font-weight: 500; text-transform: uppercase; letter-spacing: .14em; font-size: 12.5px; color: var(--accent-ink); margin: 2.4em 0 .9em; }
.prose ol, .prose ul { padding-left: 0; margin: 0 0 1.4em; list-style: none; }
.prose li { position: relative; padding-left: 2.1em; margin-bottom: .6em; }
.prose ol { counter-reset: n; }
.prose ol > li { counter-increment: n; }
.prose ol > li::before { content: counter(n, decimal-leading-zero); position: absolute; left: 0; top: .32em; font-family: var(--label); font-size: 12px; letter-spacing: .1em; color: var(--accent-ink); }
.prose ul > li::before { content: ""; position: absolute; left: .55em; top: .78em; width: 5px; height: 5px; border-radius: 50%; border: 1px solid var(--accent); }
.prose hr { border: 0; height: 1px; background: var(--line); margin: 3em 0; }
.prose table { width: 100%; border-collapse: collapse; margin: 1.6em 0 2em; font-size: .86em; font-variant-numeric: tabular-nums; }
.prose th { font-family: var(--label); font-weight: 500; text-transform: uppercase; letter-spacing: .1em; font-size: 11px; color: var(--dim); text-align: left; padding: 0 12px 10px 0; border-bottom: 1px solid var(--faint); vertical-align: bottom; }
.prose td { padding: 12px 12px 12px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th[align="right"], .prose td[align="right"] { text-align: right; }
.math-block { margin: 1.4em 0 1.6em; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.katex { font-size: 1.04em; }
.table-wrap { overflow-x: auto; }

/* citations */
.cite { font-size: .62em; line-height: 0; vertical-align: super; font-family: var(--label); letter-spacing: .02em; }
.cite a { text-decoration: none; color: var(--accent-ink); padding: 0 .12em; border-radius: 3px; }
.cite a:hover, .cite a.on { background: var(--sel); }
.cite + .cite::before { content: ","; color: var(--dim); }
.cite-pop { position: fixed; z-index: 70; width: min(380px, calc(100vw - 32px)); padding: 16px 18px 14px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 50px rgba(0, 0, 0, .35); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); font-size: 15px; line-height: 1.5; opacity: 0; transform: translateY(4px); transition: opacity .18s, transform .18s var(--ease); }
.cite-pop.show { opacity: 1; transform: none; }
.cite-pop .cp-n { font-family: var(--label); font-size: 10.5px; letter-spacing: .14em; color: var(--accent-ink); margin-bottom: 6px; display: flex; justify-content: space-between; }
.cite-pop .cp-n a { color: var(--dim); text-decoration: none; }
.cite-pop .cp-n a:hover { color: var(--ink); }
.cite-pop a { color: var(--ink); text-decoration-color: var(--faint); text-underline-offset: .15em; }

/* appendix + sources */
.appendix .prose { font-size: .94em; }
.appendix .prose > p > strong:first-child { font-family: var(--label); text-transform: uppercase; letter-spacing: .12em; font-weight: 500; font-size: 12px; color: var(--accent-ink); margin-right: .5em; }
.sources .src-intro { color: var(--dim); }
.src-list { list-style: none; margin: 8px 0 0; padding: 0; max-width: 46rem; font-size: 15.5px; line-height: 1.55; }
.src-list li { display: grid; grid-template-columns: 44px 1fr; padding: 12px 0; border-bottom: 1px solid var(--line); scroll-margin-top: calc(var(--topbar-h) + 80px); transition: background-color .8s; }
.src-list li:target { background: var(--sel); }
.src-n { font-size: 11px; color: var(--dim); padding-top: 3px; }
.src-t { color: var(--ink-2); }
.src-t a { color: var(--ink); text-decoration-color: var(--faint); text-underline-offset: .15em; }

/* ---------- footer ---------- */
.site-foot { border-top: 1px solid var(--line); padding: 96px 20px calc(140px + env(safe-area-inset-bottom)); text-align: center; }
.foot-inner { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; }
.foot-mark { width: 64px; height: 64px; color: var(--dim); margin-bottom: 26px; }
.foot-title { font-size: clamp(2rem, 4vw, 2.8rem); font-weight: 300; margin: 0 0 10px; letter-spacing: -.015em; }
.foot-meta { font-size: 11.5px; color: var(--dim); margin: 0 0 34px; }
.foot-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 40px; }
.site-foot .btn.ghost { border-color: var(--line); }
.foot-small { font-size: 13px; color: var(--dim); margin: 0; }

/* ---------- player ---------- */
.player {
  position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 65; width: min(760px, calc(100vw - 24px));
  transform: translate(-50%, 0); background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .38); backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3);
  overflow: hidden; transition: transform .45s var(--ease), opacity .3s;
}
.player[hidden] { display: block; visibility: hidden; transform: translate(-50%, 140%); opacity: 0; pointer-events: none; transition: transform .45s var(--ease), opacity .3s, visibility 0s .45s; }
.pl-bar { position: relative; height: 4px; background: var(--line); }
.pl-buf, .pl-fill { position: absolute; inset: 0 auto 0 0; width: 0; }
.pl-buf { background: var(--faint); opacity: .35; }
.pl-fill { background: var(--accent); }
.pl-seek { position: absolute; inset: -8px 0; width: 100%; height: 20px; margin: 0; opacity: 0; cursor: pointer; }
.pl-row { display: flex; align-items: center; gap: 4px; padding: 8px 10px 8px 8px; }
.pl-ctrls, .pl-extras { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.pl-extras { gap: 4px; }
.pl-cmt svg { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; }
body:not(.comments-on) .pl-cmt { display: none; }
.pl-btn { width: 40px; height: 40px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 20px; transition: background-color .2s, color .2s; }
.pl-btn:hover { background: rgba(127, 127, 127, .14); }
.pl-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.pl-btn svg text { font-family: var(--label); font-size: 6.5px; fill: currentColor; stroke: none; font-weight: 600; }
.pl-btn.small svg { width: 18px; height: 18px; }
.pl-main { width: 46px; height: 46px; background: var(--ink); color: var(--bg); }
.pl-main:hover { background: var(--accent); color: #111; }
.pl-main svg { fill: currentColor; stroke: none; width: 20px; height: 20px; }
.pl-main .i-pause { display: none; }
.player.playing .pl-main .i-pause { display: block; }
.player.playing .pl-main .i-play { display: none; }
.pl-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; padding: 2px 10px; text-align: left; border-radius: 10px; }
.pl-meta:hover .pl-chap { color: var(--accent-ink); }
.pl-chap { width: 100%; font-size: 16px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color .2s; }
.pl-time { font-size: 10.5px; color: var(--dim); letter-spacing: .1em; margin-top: 2px; white-space: nowrap; }
.pl-rate { min-width: 46px; height: 32px; border: 1px solid var(--line); border-radius: 16px; font-size: 11.5px; letter-spacing: .06em; }
.pl-rate:hover { border-color: var(--accent); color: var(--accent-ink); }
.pl-list { list-style: none; margin: 0; padding: 4px 8px 10px; max-height: min(52vh, 420px); overflow-y: auto; border-top: 1px solid var(--line); }
.pl-list button { width: 100%; display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; align-items: baseline; padding: 9px 10px; border-radius: 10px; text-align: left; font-size: 15.5px; color: var(--ink-2); }
.pl-list button:hover { background: rgba(127, 127, 127, .12); color: var(--ink); }
.pl-list .n, .pl-list .d { font-family: var(--label); font-size: 10.5px; letter-spacing: .1em; color: var(--dim); }
.pl-list li.current button { color: var(--accent-ink); }
.pl-list li.current .n { color: var(--accent-ink); }
.toast { position: fixed; left: 50%; bottom: 110px; transform: translate(-50%, 10px); z-index: 80; padding: 10px 16px; border-radius: 20px; background: var(--ink); color: var(--bg); font-size: 11px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr); max-width: 760px; }
  .toc-open { display: flex; }
  .toc { position: fixed; inset: 0; z-index: 55; pointer-events: none; }
  .toc::before { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, .45); opacity: 0; transition: opacity .3s; }
  .toc-inner { position: absolute; top: 0; bottom: 0; left: 0; width: min(340px, 86vw); max-height: none; padding: calc(var(--topbar-h) + 24px) 24px 40px 36px; background: var(--bg); border-right: 1px solid var(--line); transform: translateX(-102%); transition: transform .4s var(--ease); }
  .toc.open { pointer-events: auto; }
  .toc.open::before { opacity: 1; }
  .toc.open .toc-inner { transform: none; }
  .t-play { opacity: 1; }
}
@media (max-width: 720px) {
  :root { --topbar-h: 52px; }
  .top-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .brand .brand-name { display: none; }
  .top-btn { padding: 0 10px; }
  .hero { align-items: flex-end; }
  .hero-scrim { background: linear-gradient(180deg, rgba(6, 8, 12, 0) 20%, rgba(6, 8, 12, .7) 52%, rgba(6, 8, 12, .92) 78%, var(--bg) 100%); }
  .hero-inner { margin: 0; padding: 0 20px 96px; }
  .hero h1 { margin-bottom: 20px; }
  .dek { margin-bottom: 22px; }
  .byline { margin-bottom: 28px; }
  .ctas .btn { flex: 1 1 auto; justify-content: center; }
  .scroll-cue { display: none; }
  .chapter { padding-top: 64px; }
  .chapter + .chapter { margin-top: 48px; }
  .ch-head { margin-bottom: 32px; }
  .pl-row { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "meta meta" "ctrls extras"; gap: 2px 0; padding: 8px 8px 8px 6px; }
  .pl-meta { grid-area: meta; padding: 4px 8px 6px; }
  .pl-ctrls { grid-area: ctrls; }
  .pl-extras { grid-area: extras; justify-content: flex-end; }
  .pl-btn { width: 44px; height: 44px; }
  .pl-main { width: 50px; height: 50px; }
  .pl-chap { font-size: 15px; }
  .pl-of { display: none; }
  .pl-rate { min-width: 40px; }
  .src-list li { grid-template-columns: 34px 1fr; }
}
/* ---------- section actions ---------- */
.ch-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cmt-chip { display: none; align-items: center; gap: 8px; height: 34px; padding: 0 14px 0 12px; border: 1px solid var(--line); border-radius: 17px; font-family: var(--label); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; font-weight: 500; color: var(--ink-2); transition: border-color .2s, color .2s; }
body.comments-on .cmt-chip { display: inline-flex; }
.cmt-chip svg, .cmt-top svg, .sel-btn svg, .cp-new svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; }
.cmt-chip:hover { border-color: var(--accent); color: var(--accent-ink); }
.cmt-chip .c-count { color: var(--accent-ink); letter-spacing: .04em; }
.cmt-chip.has .c-label::after { content: ""; }
.cmt-top { display: none; }
body.comments-on .cmt-top { display: flex; }
.cmt-top .c-total { font-family: var(--label); font-weight: 600; font-size: 11px; color: var(--accent); min-width: 0; }
.cmt-top .c-total:empty { display: none; }

/* ---------- passages with comments ---------- */
mark.c-hl, mark.c-pending { color: inherit; background: linear-gradient(transparent 62%, color-mix(in srgb, var(--accent) 30%, transparent) 62%); border-radius: 2px; cursor: pointer; transition: background-color .3s; }
mark.c-hl:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
mark.c-pending { background: color-mix(in srgb, var(--accent) 26%, transparent); cursor: default; }
mark.flash, .c-card.flash { animation: flash 1.6s var(--ease); }
@keyframes flash { 0%, 30% { background: color-mix(in srgb, var(--accent) 45%, transparent); } }

/* floating "Comment" on a selection */
.sel-btn { position: fixed; z-index: 75; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px 0 13px; border-radius: 19px; background: var(--ink); color: var(--bg); font-family: var(--label); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; font-weight: 500; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); opacity: 0; transform: translateY(4px) scale(.96); transition: opacity .15s, transform .2s var(--ease); }
.sel-btn.show { opacity: 1; transform: none; }
.sel-btn:hover { background: var(--accent); color: #111; }
body:not(.comments-on) .sel-btn { display: none; }

/* ---------- comments panel (side panel; bottom sheet on phones) ---------- */
.cp-scrim { position: fixed; inset: 0; z-index: 66; background: rgba(0, 0, 0, .4); opacity: 0; transition: opacity .3s; }
.cp-scrim.show { opacity: 1; }
.cpanel { position: fixed; z-index: 67; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); display: flex; flex-direction: column; background: var(--bg); color: var(--ink); border-left: 1px solid var(--line); box-shadow: -24px 0 60px rgba(0, 0, 0, .3); transform: translateX(104%); visibility: hidden; transition: transform .45s var(--ease), visibility 0s .45s; }
.cpanel.open { transform: none; visibility: visible; transition: transform .45s var(--ease); }
.cp-grab { display: none; }
.cp-head { display: flex; align-items: flex-start; gap: 10px; padding: 22px 20px 16px 26px; border-bottom: 1px solid var(--line); }
.cp-heading { flex: 1; min-width: 0; }
.cp-kicker { margin: 0 0 6px; font-family: var(--label); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-ink); }
.cp-title { margin: 0; font-weight: 400; font-size: 1.45rem; line-height: 1.2; }
.cp-all { font-family: var(--label); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); padding: 8px 10px; border-radius: 14px; margin-top: 4px; }
.cp-all:hover { color: var(--ink); background: rgba(127, 127, 127, .12); }
.cp-x { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 20px; flex: 0 0 auto; }
.cp-x:hover { background: rgba(127, 127, 127, .14); }
.cp-x svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.cp-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 18px 26px calc(120px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.cp-start { margin-bottom: 18px; }
.cp-start .btn { color: var(--ink); border-color: var(--line); width: 100%; justify-content: center; }
.cp-hint, .cp-empty { color: var(--dim); font-size: 16px; line-height: 1.55; margin: 6px 0 20px; }
.cp-group { display: block; width: 100%; text-align: left; margin: 26px 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); font-family: var(--label); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.cp-group:first-child { margin-top: 4px; }
.cp-group:hover { color: var(--accent-ink); }

.c-card { padding: 16px 0 18px; border-bottom: 1px solid var(--line); border-radius: 6px; }
.c-quote { display: block; width: 100%; text-align: left; margin: 0 0 10px; padding: 2px 0 2px 14px; border-left: 2px solid var(--accent); font-style: italic; font-size: 15.5px; line-height: 1.5; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.c-quote:hover { color: var(--ink); }
.c-quote.orphan { border-left-color: var(--faint); color: var(--dim); }
.c-audio { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px 0 10px; margin: 0 0 10px; border-radius: 15px; border: 1px solid var(--line); font-family: var(--label); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-ink); }
.c-audio svg { width: 9px; height: 9px; fill: currentColor; }
.c-audio:hover { border-color: var(--accent); }
.c-body { margin: 0 0 10px; font-size: 17px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.c-card footer { display: flex; align-items: baseline; gap: 12px; font-family: var(--label); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.c-name { color: var(--ink); font-weight: 600; }
.c-time { color: var(--dim); }
.c-del { margin-left: auto; color: var(--dim); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; padding: 4px 6px; border-radius: 8px; }
.c-del:hover { color: #E06C5A; }

.composer { margin: 0 0 22px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-2); }
.cmp-where { margin: 0 0 10px; font-family: var(--label); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-ink); }
.cmp-quote { margin: 0 0 14px; padding: 2px 0 2px 14px; border-left: 2px solid var(--accent); font-style: italic; font-size: 15.5px; line-height: 1.5; color: var(--ink-2); max-height: 7.5em; overflow: auto; }
.cmp-name { display: block; margin-bottom: 12px; }
.cmp-name span { display: block; font-family: var(--label); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); margin-bottom: 6px; }
.composer input[name="name"], .composer textarea { width: 100%; font: inherit; font-size: 17px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; transition: border-color .2s; }
.composer textarea { resize: vertical; min-height: 110px; line-height: 1.5; display: block; }
.composer input:focus, .composer textarea:focus { outline: none; border-color: var(--accent); }
.cmp-as { margin: 0 0 10px; font-size: 15px; color: var(--dim); }
.cmp-as b { color: var(--ink); font-weight: 600; }
.cmp-change { color: var(--accent-ink); text-decoration: underline; text-underline-offset: .15em; font-size: 15px; }
.cmp-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.cmp-err { flex: 1; font-size: 14px; color: #E06C5A; line-height: 1.35; }
.cmp-cancel, .cmp-post { height: 40px; padding: 0 16px; border-radius: 20px; font-family: var(--label); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; font-weight: 500; }
.cmp-cancel { color: var(--dim); }
.cmp-cancel:hover { color: var(--ink); }
.cmp-post { background: var(--ink); color: var(--bg); padding: 0 20px; }
.cmp-post:hover { background: var(--accent); color: #111; }
.cmp-post:disabled { opacity: .5; }
.hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
body.cp-open .player { z-index: 64; }

@media (max-width: 720px) {
  .cpanel { top: auto; left: 0; right: 0; width: 100%; height: min(88svh, 88vh); border-left: 0; border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; box-shadow: 0 -24px 60px rgba(0, 0, 0, .35); transform: translateY(104%); }
  .cp-grab { display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--faint); margin: 10px auto 0; }
  .cp-head { padding: 12px 12px 14px 20px; }
  .cp-scroll { padding: 16px 20px calc(40px + env(safe-area-inset-bottom)); }
  .c-body { font-size: 16.5px; }
  .composer { padding: 14px; }
  .composer input[name="name"], .composer textarea { font-size: 16px; }
  .ch-actions { gap: 8px; }
}

@media print {
  .topbar, .hero canvas, .scroll-cue, .toc, .player, .listen-chip, .cmt-chip, .sel-btn, .cpanel, .read-progress, .foot-actions { display: none !important; }
  .hero { min-height: auto; background: none; color: #000; }
  body { background: #fff; color: #000; }
}
