/* Epoch - a paid interactive book on becoming a machine learning engineer */

:root {
  color-scheme: light;
  --bg: #FDF9F7;
  --surface: #FFFFFF;
  --surface-2: #F7EFEA;
  --surface-3: #F1E5DE;
  --ink: #2A2226;
  --ink-2: #6E5D65;
  --ink-3: #96848C;
  --rose: #B85570;
  --rose-hover: #9E4460;
  --rose-soft: #F6E2E8;
  --rose-line: #E9C7D2;
  --sage: #5F7E6B;
  --sage-soft: #E4EDE6;
  --sage-line: #C6D8CB;
  --amber: #A9722B;
  --amber-soft: #F8ECDA;
  --amber-line: #EBD3AE;
  --border: #E9DCD5;
  --border-strong: #D9C7BE;
  --code-bg: #2C2430;
  --code-ink: #EFE4E8;
  --shadow: 0 1px 2px rgba(42,34,38,.05), 0 8px 24px rgba(42,34,38,.06);
  --shadow-lg: 0 2px 4px rgba(42,34,38,.06), 0 24px 60px rgba(42,34,38,.12);
  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 720px;
  --sans: "Jost", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Fraunces", ui-serif, Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15111A;
  --surface: #1D1823;
  --surface-2: #262030;
  --surface-3: #302839;
  --ink: #F3EAEE;
  --ink-2: #BCA9B4;
  --ink-3: #8E7C88;
  --rose: #E9A0B4;
  --rose-hover: #F2B7C7;
  --rose-soft: #38232E;
  --rose-line: #4E3140;
  --sage: #9DC0A9;
  --sage-soft: #1F2E25;
  --sage-line: #33463A;
  --amber: #DFB273;
  --amber-soft: #322718;
  --amber-line: #4A3A22;
  --border: #322A3B;
  --border-strong: #453A50;
  --code-bg: #120E17;
  --code-ink: #EFE4E8;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  --shadow-lg: 0 2px 4px rgba(0,0,0,.35), 0 24px 60px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
  font-synthesis-weight: none;
}

a { color: var(--rose); text-decoration: none; }
a:hover { color: var(--rose-hover); text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -.012em;
  margin: 0 0 .5em;
  font-variation-settings: "SOFT" 40, "WONK" 1;
}

code, pre, kbd { font-family: var(--mono); }

button { font-family: inherit; font-size: inherit; cursor: pointer; }

::selection { background: var(--rose-soft); color: var(--ink); }

/* ---------- layout ---------- */

.topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--serif); font-weight: 600; font-size: 20px;
  color: var(--ink); text-decoration: none; letter-spacing: -.02em;
}
.brand:hover { text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 26px; height: 26px; flex: none;
  border-radius: 8px;
  background: linear-gradient(140deg, var(--rose) 0%, var(--sage) 100%);
  display: grid; place-items: center;
  color: #fff; font-family: var(--mono); font-size: 12px; font-weight: 700;
}
.brand-sub {
  font-family: var(--sans); font-size: 11px; letter-spacing: .13em;
  text-transform: uppercase; color: var(--ink-3); font-weight: 500;
  border-left: 1px solid var(--border-strong); padding-left: 10px; margin-left: 2px;
}

.topbar-spacer { flex: 1; }

.tnav { display: flex; gap: 2px; align-items: center; }
.tnav a, .tnav button {
  font-size: 14px; color: var(--ink-2); padding: 7px 11px;
  border-radius: 8px; border: 0; background: transparent; font-weight: 500;
}
.tnav a:hover, .tnav button:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.tnav a.on { color: var(--rose); background: var(--rose-soft); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 500; font-size: 15px; letter-spacing: .005em;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--rose); color: #fff; }
.btn-primary:hover { background: var(--rose-hover); color: #fff; text-decoration: none; }
:root[data-theme="dark"] .btn-primary { color: #23151C; }
:root[data-theme="dark"] .btn-primary:hover { color: #23151C; }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.btn-sm { padding: 7px 13px; font-size: 14px; border-radius: 9px; }
.btn-lg { padding: 14px 26px; font-size: 17px; border-radius: 12px; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-2); display: grid; place-items: center;
  font-size: 15px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

.shell { display: flex; align-items: flex-start; }

.sidebar {
  width: 310px; flex: none;
  position: sticky; top: 53px;
  height: calc(100vh - 53px);
  overflow-y: auto; overscroll-behavior: contain;
  border-right: 1px solid var(--border);
  padding: 18px 10px 60px 18px;
  background: var(--bg);
}
.sidebar::-webkit-scrollbar { width: 9px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 9px; border: 3px solid var(--bg); }

.side-search {
  width: 100%; padding: 9px 12px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--ink); font-size: 14px; font-family: inherit; margin-bottom: 14px;
}
.side-search:focus { outline: 2px solid var(--rose-line); outline-offset: 1px; }

.side-progress { margin-bottom: 16px; padding: 0 4px; }
.side-progress-label {
  display: flex; justify-content: space-between; font-size: 12px;
  color: var(--ink-3); letter-spacing: .06em; text-transform: uppercase; margin-bottom: 6px;
}
.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--rose), var(--sage)); border-radius: 99px; transition: width .4s ease; }

.part { margin-bottom: 4px; }
.part-head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 8px; border: 0; background: transparent; border-radius: 8px;
  text-align: left; color: var(--ink); font-weight: 600; font-size: 14px;
  font-family: var(--serif); letter-spacing: -.005em;
}
.part-head:hover { background: var(--surface-2); }
.part-num {
  font-family: var(--mono); font-size: 10px; font-weight: 700; color: var(--rose);
  background: var(--rose-soft); padding: 3px 6px; border-radius: 5px; flex: none;
}
.part-caret { margin-left: auto; color: var(--ink-3); font-size: 11px; transition: transform .18s ease; }
.part.open .part-caret { transform: rotate(90deg); }
.part-list { display: none; padding: 2px 0 8px 12px; margin-left: 12px; border-left: 1px solid var(--border); }
.part.open .part-list { display: block; }

.ch-link {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 6px 9px; border-radius: 7px; font-size: 13.5px; line-height: 1.45;
  color: var(--ink-2); font-weight: 400;
}
.ch-link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.ch-link.on { background: var(--rose-soft); color: var(--rose); font-weight: 500; }
.ch-tick { flex: none; width: 15px; font-size: 11px; color: var(--sage); padding-top: 2px; }
.ch-lock { flex: none; font-size: 10px; color: var(--ink-3); padding-top: 3px; }

.main { flex: 1; min-width: 0; }

.reader { max-width: var(--maxw); margin: 0 auto; padding: 40px 24px 120px; }

/* ---------- reading progress ---------- */
.readbar { position: fixed; top: 52px; left: 0; height: 2px; background: var(--rose); z-index: 70; width: 0; transition: width .1s linear; }

/* ---------- chapter ---------- */

.ch-kicker {
  font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--rose); font-weight: 600; margin-bottom: 10px;
}
.reader h1 { font-size: clamp(30px, 4.6vw, 40px); margin-bottom: 14px; }
.ch-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 26px; font-size: 13px; color: var(--ink-3); }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 99px; font-size: 12px;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border);
}
.pill.free { background: var(--sage-soft); color: var(--sage); border-color: var(--sage-line); font-weight: 600; }
.pill.done { background: var(--sage-soft); color: var(--sage); border-color: var(--sage-line); }

.objectives {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px; margin: 0 0 32px;
  box-shadow: var(--shadow);
}
.objectives h4 {
  font-family: var(--sans); font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-3); margin: 0 0 10px; font-weight: 600;
}
.objectives ul { margin: 0; padding-left: 20px; }
.objectives li { margin-bottom: 5px; color: var(--ink-2); font-size: 15.5px; }
.objectives li::marker { color: var(--rose); }

.reader h2 {
  font-size: 25px; margin-top: 48px; margin-bottom: 14px;
  padding-top: 10px;
}
.reader h2::before {
  content: ""; display: block; width: 38px; height: 3px; border-radius: 3px;
  background: var(--rose); margin-bottom: 14px; opacity: .85;
}
.reader p { margin: 0 0 18px; }
.reader ul, .reader ol { margin: 0 0 20px; padding-left: 24px; }
.reader li { margin-bottom: 7px; }
.reader li::marker { color: var(--rose); }

.reader p code, .reader li code, td code, .callout code {
  background: var(--surface-3); padding: 1.5px 6px; border-radius: 5px;
  font-size: .855em; color: var(--ink); border: 1px solid var(--border);
}

/* code blocks */
.codewrap { margin: 0 0 24px; }
.code-caption { font-size: 13px; color: var(--ink-3); margin-bottom: 7px; font-style: italic; }
.code {
  position: relative; background: var(--code-bg); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}
.code-head {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-bottom: 1px solid rgba(255,255,255,.08);
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: #A395AC;
}
.code-copy {
  margin-left: auto; background: rgba(255,255,255,.07); border: 0; color: #D9CBD3;
  padding: 3px 10px; border-radius: 6px; font-size: 11px; letter-spacing: .06em;
}
.code-copy:hover { background: rgba(255,255,255,.15); color: #fff; }
.code pre {
  margin: 0; padding: 15px 16px; overflow-x: auto; color: var(--code-ink);
  font-size: 13.5px; line-height: 1.62; tab-size: 4;
}
.code pre::-webkit-scrollbar { height: 8px; }
.code pre::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 8px; }

.tok-kw { color: #E39BC0; }
.tok-str { color: #A8D5B5; }
.tok-num { color: #E9B98A; }
.tok-com { color: #8A7A92; font-style: italic; }
.tok-fn { color: #9FC5E8; }
.tok-bi { color: #C8AAE8; }
.tok-op { color: #C9BCD1; }

/* callouts */
.callout {
  border-radius: var(--radius-sm); padding: 16px 18px; margin: 0 0 24px;
  border: 1px solid var(--border); background: var(--surface-2);
  border-left: 3px solid var(--ink-3);
}
.callout-title {
  font-weight: 600; font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  margin-bottom: 7px; display: flex; align-items: center; gap: 7px;
}
.callout p:last-child { margin-bottom: 0; }
.callout.note { border-left-color: var(--ink-3); }
.callout.note .callout-title { color: var(--ink-2); }
.callout.tip { background: var(--sage-soft); border-color: var(--sage-line); border-left-color: var(--sage); }
.callout.tip .callout-title { color: var(--sage); }
.callout.warn { background: var(--amber-soft); border-color: var(--amber-line); border-left-color: var(--amber); }
.callout.warn .callout-title { color: var(--amber); }
.callout.interview { background: var(--rose-soft); border-color: var(--rose-line); border-left-color: var(--rose); }
.callout.interview .callout-title { color: var(--rose); }
.callout.jargon { background: var(--surface); border-left-color: var(--border-strong); }
.callout.jargon .callout-title { color: var(--ink-3); }

/* tables */
.tablewrap { overflow-x: auto; margin: 0 0 26px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; font-size: 12.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }

/* math */
.math {
  text-align: center; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 18px 16px; margin: 0 0 24px;
}
.math-eq { font-family: var(--mono); font-size: 15px; color: var(--ink); word-break: break-word; }
.math-note { font-size: 13.5px; color: var(--ink-3); margin-top: 10px; font-style: italic; }

/* exercise */
.exercise {
  border: 1px solid var(--sage-line); background: var(--sage-soft);
  border-radius: var(--radius); padding: 20px 22px; margin: 0 0 26px;
}
.exercise h4 { font-family: var(--sans); font-size: 15px; margin: 0 0 10px; color: var(--sage); font-weight: 600; }
.exercise p { margin-bottom: 12px; }
.disclose { border-top: 1px solid var(--sage-line); margin-top: 12px; padding-top: 12px; }
.disclose summary { cursor: pointer; font-size: 14px; font-weight: 500; color: var(--sage); list-style: none; }
.disclose summary::-webkit-details-marker { display: none; }
.disclose summary::before { content: "▸ "; }
.disclose[open] summary::before { content: "▾ "; }
.disclose .codewrap { margin-top: 12px; margin-bottom: 0; }

/* takeaways */
.takeaways {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 24px; margin: 44px 0 0; box-shadow: var(--shadow);
}
.takeaways h3 { font-size: 19px; margin-bottom: 12px; }
.takeaways ul { margin: 0; padding-left: 20px; }
.takeaways li { margin-bottom: 8px; color: var(--ink-2); }

/* ---------- quiz ---------- */
.quiz { margin: 44px 0 0; }
.quiz-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.quiz-head h3 { font-size: 24px; margin: 0; }
.quiz-sub { color: var(--ink-3); font-size: 14px; margin-bottom: 22px; }

.q {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.q-num { font-family: var(--mono); font-size: 11px; color: var(--rose); letter-spacing: .1em; margin-bottom: 8px; }
.q-text { font-weight: 500; margin-bottom: 14px; font-size: 16.5px; }
.q-multi { font-size: 12.5px; color: var(--ink-3); margin-bottom: 12px; margin-top: -8px; }

.opt {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 11px 14px; border-radius: 10px; border: 1px solid var(--border);
  margin-bottom: 8px; cursor: pointer; background: var(--bg);
  transition: border-color .12s ease, background .12s ease;
  font-size: 15.5px; line-height: 1.5;
}
.opt:hover { border-color: var(--rose-line); background: var(--surface-2); }
.opt input { margin: 5px 0 0; accent-color: var(--rose); flex: none; }
.opt.sel { border-color: var(--rose); background: var(--rose-soft); }
.opt.right { border-color: var(--sage); background: var(--sage-soft); }
.opt.wrong { border-color: #C4756F; background: color-mix(in srgb, #C4756F 12%, var(--bg)); }
.opt.locked { cursor: default; }
.opt-mark { margin-left: auto; font-size: 13px; font-weight: 700; flex: none; padding-left: 8px; }
.opt.right .opt-mark { color: var(--sage); }
.opt.wrong .opt-mark { color: #B9605A; }

.q-actions { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.explain {
  margin-top: 12px; padding: 13px 15px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 15px; color: var(--ink-2);
}
.explain b { color: var(--ink); }

.quiz-score {
  margin-top: 24px; padding: 24px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); text-align: center;
  box-shadow: var(--shadow);
}
.score-big { font-family: var(--serif); font-size: 44px; line-height: 1; margin-bottom: 6px; }
.score-msg { color: var(--ink-2); margin-bottom: 16px; }

/* ---------- chapter footer nav ---------- */
.chfoot { display: flex; gap: 12px; margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--border); }
.chfoot a {
  flex: 1; padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); text-decoration: none; min-width: 0;
}
.chfoot a:hover { border-color: var(--rose-line); background: var(--surface-2); text-decoration: none; }
.chfoot .dir { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }
.chfoot .ttl { font-weight: 500; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chfoot .next { text-align: right; }

.markread {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: 36px; padding: 16px; border-radius: var(--radius);
  border: 1px dashed var(--border-strong); background: var(--surface);
  width: 100%; color: var(--ink-2); font-size: 15px;
}
.markread:hover { border-color: var(--sage); color: var(--sage); background: var(--sage-soft); }
.markread.done { border-style: solid; border-color: var(--sage); background: var(--sage-soft); color: var(--sage); }

/* ---------- paywall ---------- */
.fade-out {
  position: relative; max-height: 340px; overflow: hidden;
}
.fade-out::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 200px;
  background: linear-gradient(to bottom, transparent, var(--bg) 82%);
  pointer-events: none;
}
.paywall {
  border: 1px solid var(--rose-line); background: var(--surface);
  border-radius: var(--radius); padding: 32px; text-align: center;
  box-shadow: var(--shadow-lg); margin-top: -20px; position: relative; z-index: 2;
}
.paywall h3 { font-size: 26px; margin-bottom: 8px; }
.paywall p { color: var(--ink-2); max-width: 46ch; margin: 0 auto 18px; }
.paywall-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.paywall-list { text-align: left; max-width: 420px; margin: 22px auto 0; }
.paywall-list li { color: var(--ink-2); font-size: 15px; margin-bottom: 6px; }

/* ---------- generic page ---------- */
.page { max-width: 980px; margin: 0 auto; padding: 44px 24px 110px; }
.page.narrow { max-width: 720px; }
.page h1 { font-size: clamp(30px, 4.4vw, 40px); }
.lede { font-size: 19px; color: var(--ink-2); max-width: 62ch; margin-bottom: 34px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.card {
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.card h3 { font-size: 18px; margin-bottom: 8px; }
.card p { color: var(--ink-2); font-size: 15px; margin: 0; }

.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 0 0 40px; }
.stat { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 18px 20px; }
.stat .n { font-family: var(--serif); font-size: 32px; line-height: 1; color: var(--rose); }
.stat .l { font-size: 13px; color: var(--ink-3); margin-top: 6px; letter-spacing: .04em; }

/* ---------- landing ---------- */
.hero { padding: 76px 24px 60px; max-width: 900px; margin: 0 auto; text-align: center; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: .13em;
  text-transform: uppercase; color: var(--sage); background: var(--sage-soft);
  border: 1px solid var(--sage-line); padding: 6px 14px; border-radius: 99px; margin-bottom: 24px; font-weight: 600;
}
.hero h1 { font-size: clamp(38px, 7vw, 64px); letter-spacing: -.03em; margin-bottom: 20px; }
.hero h1 em { font-style: normal; color: var(--rose); }
.hero-lede { font-size: clamp(17px, 2.2vw, 21px); color: var(--ink-2); max-width: 60ch; margin: 0 auto 32px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.hero-note { font-size: 13.5px; color: var(--ink-3); }

.band { border-top: 1px solid var(--border); background: var(--surface); }
.band.alt { background: var(--bg); }
.band-inner { max-width: 980px; margin: 0 auto; padding: 64px 24px; }
.band h2 { font-size: clamp(26px, 3.6vw, 34px); margin-bottom: 12px; }
.band .lede { margin-bottom: 34px; }

.toc-part {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
  margin-bottom: 10px; overflow: hidden;
}
.toc-part-head {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 16px 20px; border: 0; background: transparent; text-align: left; color: var(--ink);
}
.toc-part-head:hover { background: var(--surface-2); }
.toc-part-head .t { font-family: var(--serif); font-weight: 600; font-size: 17px; }
.toc-part-head .c { margin-left: auto; font-size: 13px; color: var(--ink-3); }
.toc-part-body { display: none; padding: 0 20px 16px 20px; }
.toc-part.open .toc-part-body { display: block; }
.toc-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-top: 1px solid var(--border); font-size: 15px; color: var(--ink-2);
}
.toc-row .n { font-family: var(--mono); font-size: 12px; color: var(--ink-3); width: 34px; flex: none; }
.toc-row .free-tag {
  margin-left: auto; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--sage); background: var(--sage-soft); border: 1px solid var(--sage-line);
  padding: 2px 8px; border-radius: 99px; font-weight: 600; flex: none;
}
.toc-row .lock-tag { margin-left: auto; font-size: 12px; color: var(--ink-3); flex: none; }

.pricecard {
  max-width: 460px; margin: 0 auto; border: 2px solid var(--rose);
  border-radius: 18px; background: var(--surface); padding: 34px; text-align: center;
  box-shadow: var(--shadow-lg);
}
.price { font-family: var(--serif); font-size: 56px; line-height: 1; margin-bottom: 4px; }
.price small { font-size: 18px; color: var(--ink-3); font-family: var(--sans); }
.price-sub { color: var(--ink-3); font-size: 14px; margin-bottom: 24px; }
.price-list { text-align: left; margin: 0 0 26px; padding: 0; list-style: none; }
.price-list li { padding: 7px 0 7px 28px; position: relative; color: var(--ink-2); font-size: 15px; border-bottom: 1px solid var(--border); }
.price-list li:last-child { border-bottom: 0; }
.price-list li::before { content: "✓"; position: absolute; left: 4px; color: var(--sage); font-weight: 700; }

.faq { border-bottom: 1px solid var(--border); }
.faq summary { padding: 16px 0; cursor: pointer; font-weight: 500; font-size: 16.5px; list-style: none; display: flex; align-items: center; gap: 10px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; margin-left: auto; color: var(--rose); font-size: 20px; }
.faq[open] summary::after { content: "−"; }
.faq p { color: var(--ink-2); padding-bottom: 16px; margin: 0; max-width: 68ch; }

/* ---------- unlock ---------- */
.keyform { display: flex; gap: 10px; max-width: 460px; margin: 0 auto; flex-wrap: wrap; }
.keyinput {
  flex: 1; min-width: 220px; padding: 13px 16px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--ink); font-family: var(--mono); font-size: 15px; letter-spacing: .06em;
  text-align: center; text-transform: uppercase;
}
.keyinput:focus { outline: 2px solid var(--rose-line); outline-offset: 1px; }
.keymsg { margin-top: 16px; font-size: 15px; min-height: 24px; }
.keymsg.err { color: #B9605A; }
.keymsg.ok { color: var(--sage); }

/* ---------- progress page ---------- */
.prow {
  display: flex; align-items: center; gap: 14px; padding: 13px 16px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); margin-bottom: 8px;
}
.prow .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .s { font-family: var(--mono); font-size: 13px; color: var(--ink-3); flex: none; }
.prow .bar { width: 120px; flex: none; }

/* ---------- search ---------- */
.sresult {
  display: block; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); margin-bottom: 8px; color: var(--ink);
}
.sresult:hover { border-color: var(--rose-line); text-decoration: none; background: var(--surface-2); }
.sresult .h { font-weight: 500; margin-bottom: 3px; }
.sresult .m { font-size: 13.5px; color: var(--ink-3); }

.empty { text-align: center; padding: 60px 20px; color: var(--ink-3); }

.footer { border-top: 1px solid var(--border); padding: 34px 24px; text-align: center; color: var(--ink-3); font-size: 14px; }
.footer a { color: var(--ink-2); }

.sidebar-toggle { display: none; }
.scrim { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .sidebar {
    position: fixed; top: 53px; left: 0; z-index: 55;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: var(--shadow-lg); width: 300px;
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 53px 0 0 0; background: rgba(0,0,0,.35); z-index: 54; }
  .sidebar-toggle { display: grid; }
  .brand-sub { display: none; }
}
@media (max-width: 620px) {
  body { font-size: 16px; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .brand { font-size: 18px; }
  .tnav a { padding: 6px 6px; font-size: 13px; }
  .reader { padding: 28px 18px 90px; }
  .page, .band-inner { padding-left: 18px; padding-right: 18px; }
  .hero { padding: 48px 18px 40px; }
  .tnav a, .tnav button { padding: 7px 8px; font-size: 13.5px; }
  .chfoot { flex-direction: column; }
  .paywall { padding: 24px 18px; }
}

@media print {
  .topbar, .sidebar, .quiz, .chfoot, .markread, .readbar, .footer { display: none !important; }
  .reader { max-width: 100%; padding: 0; }
  body { background: #fff; color: #000; }
}
