/* Lumen design system — dark-first, warm amber accent, calm reading layout. */
:root {
  --bg: #0d0c0b;
  --bg-elev: #151312;
  --bg-elev2: #1c1a18;
  --bg-code: #111010;
  --line: #2a2725;
  --line-soft: #211f1d;
  --text: #ece7e0;
  --text-soft: #b6afa6;
  --text-mute: #7d766e;
  --accent: #f59e0b;
  --accent-soft: rgba(245, 158, 11, 0.14);
  --accent-2: #fb923c;
  --teal: #2dd4bf;
  --teal-soft: rgba(45, 212, 191, 0.14);
  --blue: #60a5fa;
  --blue-soft: rgba(96, 165, 250, 0.14);
  --pink: #f472b6;
  --pink-soft: rgba(244, 114, 182, 0.14);
  --green: #4ade80;
  --green-soft: rgba(74, 222, 128, 0.14);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.14);
  --purple: #a78bfa;
  --purple-soft: rgba(167, 139, 250, 0.14);
  --radius: 12px;
  --sidebar-w: 280px;
  --toc-w: 240px;
  --content-w: 780px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #faf7f2;
  --bg-elev: #ffffff;
  --bg-elev2: #f3efe8;
  --bg-code: #f6f3ee;
  --line: #e5dfd5;
  --line-soft: #ede8e0;
  --text: #1c1a17;
  --text-soft: #4b453e;
  --text-mute: #8a8178;
  --accent: #d97706;
  --accent-soft: rgba(217, 119, 6, 0.12);
  --teal: #0d9488;
  --blue: #2563eb;
  --pink: #db2777;
  --green: #16a34a;
  --red: #dc2626;
  --purple: #7c3aed;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 17px; line-height: 1.7; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd { font-family: var(--mono); }
img, svg, canvas { max-width: 100%; }
::selection { background: var(--accent-soft); }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid var(--line);
  background: var(--bg-elev); padding: 18px 14px 40px; font-size: 14px;
}
.sidebar::-webkit-scrollbar, .toc::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb, .toc::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; }
.brand .logo { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; color: #1a1207; font-weight: 800; font-size: 15px; }
.brand a { color: var(--text); font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand a:hover { text-decoration: none; }
.search-btn {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg-elev2); color: var(--text-mute); cursor: pointer; font: inherit; font-size: 13px;
}
.search-btn kbd { margin-left: auto; font-size: 11px; border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; color: var(--text-mute); }
.nav-group { margin-top: 18px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-mute); padding: 0 8px; }
.nav-part { margin-top: 8px; }
.nav-part-head {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; color: var(--text); font-weight: 600; user-select: none;
}
.nav-part-head:hover { background: var(--bg-elev2); }
.nav-part-head .chev { width: 14px; height: 14px; transition: transform .2s; color: var(--text-mute); }
.nav-part.open .nav-part-head .chev { transform: rotate(90deg); }
.nav-part-head .count { margin-left: auto; color: var(--text-mute); font-weight: 400; font-size: 12px; }
.nav-part-head .done { color: var(--green); font-size: 12px; }
.nav-list { display: none; margin: 2px 0 4px; padding: 0; list-style: none; }
.nav-part.open .nav-list { display: block; }
.nav-list li a {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px 5px 26px; border-radius: 8px; color: var(--text-soft); font-size: 13.5px;
}
.nav-list li a:hover { background: var(--bg-elev2); text-decoration: none; color: var(--text); }
.nav-list li a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-list li a .dot { width: 6px; height: 6px; border-radius: 50%; border: 1.5px solid var(--text-mute); flex-shrink: 0; }
.nav-list li a.done .dot { background: var(--green); border-color: var(--green); }
.nav-list li a.active .dot { border-color: var(--accent); }
.sidebar-foot { margin-top: 24px; padding: 12px 8px; border-top: 1px solid var(--line); color: var(--text-mute); font-size: 12px; }
.progress-bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 8px 0 4px; }
.progress-bar > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); width: 0; transition: width .4s; }

.main { min-width: 0; }
.topbar { display: none; }
.content { max-width: var(--content-w); margin: 0 auto; padding: 36px 32px 96px; }
.toc { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 24px 18px; font-size: 13px; border-left: 1px solid var(--line-soft); }
.toc h4 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-mute); display: flex; align-items: center; gap: 6px; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li a { display: block; padding: 4px 8px; color: var(--text-mute); border-left: 2px solid transparent; border-radius: 0 6px 6px 0; line-height: 1.4; }
.toc li.l3 a { padding-left: 20px; font-size: 12.5px; }
.toc li a:hover { color: var(--text); text-decoration: none; }
.toc li a.active { color: var(--accent); border-left-color: var(--accent); background: var(--accent-soft); }
.toc .toc-actions { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-soft); display: grid; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-elev2); color: var(--text); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.btn:hover { border-color: var(--text-mute); text-decoration: none; }
.btn.primary { background: var(--accent); color: #1a1207; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.done { background: var(--green-soft); color: var(--green); border-color: transparent; }

/* ---------- chapter header ---------- */
.crumbs { font-size: 13px; color: var(--text-mute); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crumbs span.sep { opacity: .5; }
.chapter-head h1 { font-size: 40px; line-height: 1.15; letter-spacing: -0.02em; margin: 10px 0 12px; font-weight: 800; }
.chapter-head .lede { font-size: 20px; color: var(--text-soft); margin: 0 0 18px; line-height: 1.5; }
.meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-mute); padding-bottom: 22px; border-bottom: 1px solid var(--line); margin-bottom: 30px; }
.meta .pill { display: inline-flex; align-items: center; gap: 6px; }
.meta .pill svg { width: 14px; height: 14px; }

/* ---------- prose ---------- */
.content h2 { font-size: 28px; letter-spacing: -0.015em; margin: 56px 0 14px; line-height: 1.25; scroll-margin-top: 24px; font-weight: 750; }
.content h3 { font-size: 21px; margin: 38px 0 10px; line-height: 1.3; scroll-margin-top: 24px; font-weight: 700; }
.content h4 { font-size: 17px; margin: 26px 0 8px; color: var(--text); font-weight: 700; }
.content p { margin: 0 0 18px; }
.content ul, .content ol { padding-left: 24px; margin: 0 0 18px; }
.content li { margin-bottom: 6px; }
.content li::marker { color: var(--text-mute); }
.content strong { color: var(--text); font-weight: 700; }
.content em { color: var(--text-soft); }
.content hr { border: none; border-top: 1px solid var(--line); margin: 40px 0; }
.content blockquote { margin: 0 0 18px; padding: 4px 18px; border-left: 3px solid var(--accent); color: var(--text-soft); font-style: italic; }
.content code:not(pre code) { overflow-wrap: anywhere; background: var(--bg-elev2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font-size: 0.86em; color: var(--accent-2); }
.content table { width: 100%; border-collapse: collapse; margin: 0 0 22px; font-size: 15px; display: block; overflow-x: auto; }
.content th, .content td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.content th { color: var(--text-mute); font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.content td code { white-space: nowrap; }
.katex { font-size: 1.05em; }
.katex-display { margin: 18px 0 22px; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.content .lead { font-size: 19px; color: var(--text-soft); }
.small { font-size: 14px; color: var(--text-mute); }

/* ---------- callouts ---------- */
.callout { border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius); padding: 14px 18px; margin: 0 0 22px; background: var(--bg-elev); }
.callout > :last-child { margin-bottom: 0; }
.callout .callout-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; letter-spacing: .02em; margin-bottom: 8px; text-transform: uppercase; }
.callout .callout-title svg { width: 16px; height: 16px; }
.callout.intuition { border-left-color: var(--accent); }
.callout.intuition .callout-title { color: var(--accent); }
.callout.math { border-left-color: var(--blue); }
.callout.math .callout-title { color: var(--blue); }
.callout.note { border-left-color: var(--teal); }
.callout.note .callout-title { color: var(--teal); }
.callout.warning { border-left-color: var(--red); }
.callout.warning .callout-title { color: var(--red); }
.callout.example { border-left-color: var(--purple); }
.callout.example .callout-title { color: var(--purple); }
.callout.history { border-left-color: var(--pink); }
.callout.history .callout-title { color: var(--pink); }
.callout.exercise { border-left-color: var(--green); background: var(--green-soft); }
.callout.exercise .callout-title { color: var(--green); }

/* ---------- "symbols / what happens" strip (like a whiteboard card) ---------- */
.symbol-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr)); gap: 12px; margin: 0 0 22px; }
.symbol-strip > div { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; line-height: 1.5; }
.symbol-strip h5 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.symbol-strip .step { color: var(--text-mute); font-size: 11px; font-weight: 700; letter-spacing: .06em; }

/* ---------- figures ---------- */
figure { margin: 0 0 26px; }
figure .fig { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; overflow-x: auto; }
figure svg text { font-family: var(--font); }
figcaption { font-size: 13.5px; color: var(--text-mute); margin-top: 10px; line-height: 1.5; }
figcaption b { color: var(--text-soft); }
.diagram { font-family: var(--font); }
.diagram .box { fill: var(--bg-elev2); stroke: var(--line); }
.diagram .label { fill: var(--text); font-size: 13px; }
.diagram .sub { fill: var(--text-mute); font-size: 11px; }
.diagram .arrow { stroke: var(--text-mute); stroke-width: 1.5; fill: none; marker-end: url(#arrow); }
.diagram .accent { stroke: var(--accent); }

/* ---------- interactive panels ---------- */
.interactive {
  max-width: 100%;
  border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 28px; background: var(--bg-elev); overflow: hidden;
}
.interactive-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--bg-elev2); }
.interactive-head .tag { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); padding: 3px 8px; border-radius: 6px; }
.interactive-head .title { font-weight: 700; font-size: 15px; }
.interactive-head .spacer { flex: 1; }
.interactive-head .hint { font-size: 12.5px; color: var(--text-mute); }
.interactive-body { padding: 16px; }
.interactive-body > p:first-child { margin-top: 0; }
.controls { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; margin-bottom: 14px; font-size: 13.5px; }
.controls label { display: flex; align-items: center; gap: 8px; color: var(--text-soft); }
.controls input[type="range"] { accent-color: var(--accent); width: 150px; max-width: 100%; }
.controls input[type="text"], .controls textarea, .controls select {
  font: inherit; font-size: 13.5px; background: var(--bg-code); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
}
.controls textarea { width: 100%; min-height: 60px; font-family: var(--mono); font-size: 13px; }
.controls .val { font-family: var(--mono); color: var(--accent); min-width: 44px; text-align: right; font-size: 13px; }
.controls .seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.controls .seg button { font: inherit; font-size: 12.5px; padding: 5px 10px; border: none; background: transparent; color: var(--text-soft); cursor: pointer; }
.controls .seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.viz { background: var(--bg-code); border: 1px solid var(--line-soft); border-radius: 10px; padding: 12px; overflow-x: auto; }
.viz svg { display: block; margin: 0 auto; }
.viz-note { font-size: 13px; color: var(--text-mute); margin-top: 10px; line-height: 1.5; }
.step-ctl { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.step-ctl .step-label { font-weight: 700; font-size: 14px; flex: 1; }
.step-ctl .step-n { font-size: 12px; color: var(--text-mute); font-family: var(--mono); }
.readout { font-family: var(--mono); font-size: 13px; color: var(--text-soft); background: var(--bg-code); border-radius: 8px; padding: 10px 12px; margin-top: 10px; white-space: pre-wrap; word-break: break-word; line-height: 1.55; }
.token-chip { display: inline-block; padding: 2px 6px; margin: 2px; border-radius: 6px; font-family: var(--mono); font-size: 13px; border: 1px solid transparent; }

/* ---------- code ---------- */
pre { margin: 0 0 22px; background: var(--bg-code); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; position: relative; }
pre code.hljs { background: transparent; padding: 16px 18px; font-size: 13.5px; line-height: 1.6; display: block; }
.code-block { position: relative; margin: 0 0 22px; }
.code-block pre { margin: 0; }
.code-block .code-head { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-mute); background: var(--bg-elev2); border: 1px solid var(--line); border-bottom: none; border-radius: var(--radius) var(--radius) 0 0; padding: 6px 12px; }
.code-block .code-head + pre { border-radius: 0 0 var(--radius) var(--radius); }
.code-block .copy { margin-left: auto; font: inherit; font-size: 11.5px; background: transparent; border: 1px solid var(--line); color: var(--text-mute); border-radius: 6px; padding: 2px 8px; cursor: pointer; }
.code-block .copy:hover { color: var(--text); }
.code-output { background: var(--bg-elev2); border: 1px dashed var(--line); border-radius: var(--radius); padding: 10px 14px; font-family: var(--mono); font-size: 13px; color: var(--text-soft); margin: -12px 0 22px; white-space: pre-wrap; }
.code-output::before { content: "output"; display: block; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-mute); margin-bottom: 4px; font-family: var(--font); }

/* ---------- quiz ---------- */
.quiz { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 24px; background: var(--bg-elev); }
.quiz-head { padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 700; display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--purple); }
.quiz-q { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.quiz-q:last-child { border-bottom: none; }
.quiz-q .q { font-weight: 600; margin-bottom: 10px; }
.quiz-q .opts { display: grid; gap: 6px; }
.quiz-q .opts button { text-align: left; font: inherit; font-size: 14.5px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-elev2); color: var(--text); cursor: pointer; }
.quiz-q .opts button:hover { border-color: var(--text-mute); }
.quiz-q .opts button.correct { border-color: var(--green); background: var(--green-soft); }
.quiz-q .opts button.wrong { border-color: var(--red); background: var(--red-soft); }
.quiz-q .explain { display: none; margin-top: 10px; font-size: 14px; color: var(--text-soft); padding: 10px 12px; background: var(--bg-code); border-radius: 8px; }
.quiz-q.answered .explain { display: block; }

/* ---------- reveal / details ---------- */
details.reveal { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 18px; background: var(--bg-elev); }
details.reveal summary { cursor: pointer; padding: 10px 14px; font-weight: 600; font-size: 14.5px; color: var(--text-soft); list-style: none; display: flex; align-items: center; gap: 8px; }
details.reveal summary::before { content: "▸"; color: var(--accent); transition: transform .15s; }
details.reveal[open] summary::before { transform: rotate(90deg); }
details.reveal .reveal-body { padding: 4px 14px 14px; border-top: 1px solid var(--line-soft); }

/* ---------- takeaways, next ---------- */
.takeaways { background: linear-gradient(180deg, var(--accent-soft), transparent); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; margin: 40px 0 26px; }
.takeaways h3 { margin: 0 0 10px !important; font-size: 16px !important; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.takeaways ul { margin: 0; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 48px; }
.pager a { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--text); background: var(--bg-elev); display: block; }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager a .k { font-size: 12px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .08em; }
.pager a .t { font-weight: 700; margin-top: 2px; }
.pager a.next { text-align: right; }
.pager a.empty { visibility: hidden; }
.complete-row { display: flex; gap: 10px; align-items: center; margin-top: 28px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-elev); flex-wrap: wrap; }
.complete-row .txt { flex: 1; font-size: 14px; color: var(--text-soft); }

/* ---------- grid cards (landing) ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 0 0 24px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--bg-elev); }
.card h4 { margin: 0 0 6px; font-size: 15px; }
.card p { margin: 0; font-size: 14px; color: var(--text-soft); }
.card .n { font-family: var(--mono); font-size: 11px; color: var(--accent); letter-spacing: .1em; }

/* ---------- search modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; z-index: 50; backdrop-filter: blur(4px); }
.modal-bg.open { display: block; }
.modal { position: absolute; top: 12vh; left: 50%; transform: translateX(-50%); width: min(680px, 92vw); background: var(--bg-elev); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.modal input { width: 100%; font: inherit; font-size: 17px; padding: 16px 18px; border: none; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); outline: none; }
.modal .results { max-height: 55vh; overflow-y: auto; }
.modal .r { padding: 10px 18px; border-bottom: 1px solid var(--line-soft); display: block; color: var(--text); }
.modal .r:hover, .modal .r.sel { background: var(--accent-soft); text-decoration: none; }
.modal .r .rt { font-weight: 600; font-size: 14.5px; }
.modal .r .rp { font-size: 12px; color: var(--text-mute); }
.modal .r .rs { font-size: 13px; color: var(--text-soft); margin-top: 2px; }
.modal .empty { padding: 20px; color: var(--text-mute); font-size: 14px; }
mark { background: var(--accent-soft); color: var(--accent); padding: 0 2px; border-radius: 3px; }

/* ---------- misc ---------- */
.kbd { font-family: var(--mono); font-size: 12px; border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; background: var(--bg-elev2); }
.badge { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); vertical-align: middle; }
.badge.teal { background: var(--teal-soft); color: var(--teal); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.purple { background: var(--purple-soft); color: var(--purple); }
.badge.green { background: var(--green-soft); color: var(--green); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 22px; }
.two-col > div > :last-child { margin-bottom: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12.5px; color: var(--text-soft); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.theme-toggle { font: inherit; font-size: 12px; background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; color: var(--text-mute); cursor: pointer; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .app { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: min(320px, 86vw); transform: translateX(-105%); transition: transform .2s; box-shadow: 0 0 60px rgba(0,0,0,.5); }
  .sidebar.open { transform: translateX(0); }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--bg-elev); position: sticky; top: 0; z-index: 30; }
  .topbar .brand { padding: 0; }
  .topbar .menu { font: inherit; background: transparent; border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 6px 10px; cursor: pointer; }
  .content { padding: 22px 18px 80px; }
  .chapter-head h1 { font-size: 30px; }
  .two-col { grid-template-columns: 1fr; }
  .pager { grid-template-columns: 1fr; }
  body { font-size: 16px; }
}
@media print {
  .sidebar, .toc, .topbar, .pager, .complete-row, .search-btn { display: none !important; }
  .app { display: block; }
}

/* ---------- whiteboard figure cards (hand-drawn feel) ---------- */
.whiteboard { background: #121212; border: 3px solid #e8e4dd; border-radius: 14px; padding: 18px 20px; overflow-x: auto; box-shadow: 0 8px 30px rgba(0,0,0,.35); }
[data-theme="light"] .whiteboard { background: #1b1b1b; border-color: #2a2a2a; }
.whiteboard svg { display: block; margin: 0 auto; font-family: "Comic Sans MS", "Chalkboard SE", "Segoe Print", "Bradley Hand", cursive; }
.whiteboard .wb-blue { fill: #a9d6f5; stroke: #7fb8e6; stroke-width: 1.5; }
.whiteboard .wb-yellow { fill: #f7e39a; stroke: #e3c65c; stroke-width: 1.5; }
.whiteboard .wb-pink { fill: #f5b8c8; stroke: #e58aa4; stroke-width: 1.5; }
.whiteboard .wb-green { fill: #b9e6b3; stroke: #86c97d; stroke-width: 1.5; }
.whiteboard .wb-purple { fill: #d5c4f7; stroke: #a98ee8; stroke-width: 1.5; }
.whiteboard .wb-grey { fill: #3a3a3a; stroke: #6a6a6a; stroke-width: 1.5; }
.whiteboard .wb-text { fill: #f2efe9; font-size: 15px; }
.whiteboard .wb-text.dark { fill: #1b1b1b; }
.whiteboard .wb-small { fill: #cfc9c0; font-size: 12px; }
.whiteboard .wb-line { stroke: #f2efe9; stroke-width: 2; fill: none; stroke-linecap: round; }
.whiteboard .wb-op { fill: #f2efe9; font-size: 28px; font-weight: 700; }
