/* Caretaker course. Folio theme (sachinsoman.com): white paper and black ink in light, warm near-black with gold and sage in dark. */
@font-face { font-family: 'Fraunces Variable'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('fonts/fraunces-latin-wght-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter Variable'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('fonts/inter-latin-wght-normal.woff2') format('woff2'); }
:root {
  --bg: #ffffff;
  --bg-soft: #f6f6f6;
  --bg-sunken: #f0f0f0;
  --surface: #ffffff;
  --text: #191919;
  --text-soft: #3a3a3a;
  --muted: #626262;
  --border: #d9d9d9;
  --border-strong: #777777;
  --accent: #191919;
  --accent-text: #191919;
  --accent-soft: #f0f0f0;
  --ok: #2f5a3c;
  --ok-soft: #eef1ee;
  --warn: #6b5428;
  --warn-soft: #f4f1ea;
  --danger: #8a2f26;
  --danger-soft: #f5eeed;
  --trust: #191919;
  --trust-soft: #f0f0f0;
  --code-bg: #f8f8f8;
  --code-border: #e2e2e2;
  --add-bg: #edf1ed;
  --add-mark: #2f5a3c;
  --del-bg: #f5eeed;
  --del-mark: #8a2f26;
  --hl-bg: #f1efe8;
  --term-bg: #1a1717;
  --term-text: #eeebe6;
  --term-muted: #a29c95;
  --term-prompt: #d7af6f;
  --shadow: none;
  --shadow-lg: 0 18px 40px rgba(20, 18, 18, .18);
  --radius: 2px;
  --radius-sm: 2px;
  --font: 'Inter Variable', -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --serif: 'Fraunces Variable', Georgia, serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --topbar-h: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1717; --bg-soft: #211d1c; --bg-sunken: #141212; --surface: #1f1b1a;
    --text: #eeebe6; --text-soft: #cfcac4; --muted: #b9b4ae; --border: #3d3835; --border-strong: #6c6560;
    --accent: #d7af6f; --accent-text: #d7af6f; --accent-soft: #2a2420;
    --ok: #93a38b; --ok-soft: #1f231d; --warn: #d7af6f; --warn-soft: #2a2420; --danger: #d99183; --danger-soft: #2c1d1a;
    --trust: #d7af6f; --trust-soft: #252120;
    --code-bg: #141212; --code-border: #2c2725; --add-bg: #1f251e; --add-mark: #93a38b; --del-bg: #2c1d1a; --del-mark: #d99183; --hl-bg: #2a2420;
    --term-bg: #110f0f; --shadow: none; --shadow-lg: 0 16px 40px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1717; --bg-soft: #211d1c; --bg-sunken: #141212; --surface: #1f1b1a;
  --text: #eeebe6; --text-soft: #cfcac4; --muted: #b9b4ae; --border: #3d3835; --border-strong: #6c6560;
  --accent: #d7af6f; --accent-text: #d7af6f; --accent-soft: #2a2420;
  --ok: #93a38b; --ok-soft: #1f231d; --warn: #d7af6f; --warn-soft: #2a2420; --danger: #d99183; --danger-soft: #2c1d1a;
  --trust: #d7af6f; --trust-soft: #252120;
  --code-bg: #141212; --code-border: #2c2725; --add-bg: #1f251e; --add-mark: #93a38b; --del-bg: #2c1d1a; --del-mark: #d99183; --hl-bg: #2a2420;
  --term-bg: #110f0f; --shadow: none; --shadow-lg: 0 16px 40px rgba(0,0,0,.55);
  color-scheme: dark;
}
/* Shiki dual-theme: tokens carry the light colour and a --shiki-dark variable. */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .code span[style] { color: var(--shiki-dark) !important; } }
:root[data-theme="dark"] .code span[style] { color: var(--shiki-dark) !important; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 16px); }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 var(--font); }
a { color: var(--accent-text); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
code, kbd, pre { font-family: var(--mono); }
:not(pre) > code { font-size: .875em; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 4px; padding: .08em .35em; word-break: break-word; }
kbd { font-size: .78em; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: .05em .4em; background: var(--surface); color: var(--text-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--accent); color: #fff; padding: 8px 12px; z-index: 100; border-radius: 6px; }
.skip-link:focus { left: 8px; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 650; letter-spacing: -.01em; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--text); color: var(--bg); font-size: 12px; letter-spacing: .02em; }
.brand-sub { display: block; font-weight: 450; font-size: 12px; color: var(--muted); line-height: 1.2; }
.brand-text { line-height: 1.15; }
.top-links { display: flex; gap: 4px; margin-left: 12px; }
.top-links a { color: var(--text-soft); text-decoration: none; font-size: 14px; padding: 6px 10px; border-radius: 6px; }
.top-links a:hover { background: var(--bg-soft); color: var(--text); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 1px solid transparent; background: none; color: var(--text-soft); border-radius: 8px; cursor: pointer; font: inherit; }
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.nav-toggle { display: none; }
.search-btn { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; min-width: 200px; border: 1px solid var(--border); background: var(--bg-soft); color: var(--muted); border-radius: 8px; cursor: pointer; font: 14px var(--font); }
.search-btn span { flex: 1; text-align: left; }
.search-btn:hover { border-color: var(--border-strong); color: var(--text-soft); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 288px minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
.layout.has-toc { grid-template-columns: 288px minmax(0, 1fr) 232px; }
main { min-width: 0; padding: 40px 48px 96px; outline: none; }
.sidebar { position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto; border-right: 1px solid var(--border); background: var(--bg-soft); padding: 16px 10px 40px; font-size: 14px; overscroll-behavior: contain; }
.sidebar-progress { padding: 4px 10px 14px; }
.sidebar-progress .bar { height: 6px; border-radius: 3px; background: var(--bg-sunken); overflow: hidden; border: 1px solid var(--border); }
.sidebar-progress .bar span { display: block; height: 100%; background: var(--ok); transition: width .3s; }
.sidebar-progress .label { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }
.nav-module { margin-bottom: 2px; }
.nav-module-toggle { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; color: var(--text); font: 600 13.5px/1.35 var(--font); text-align: left; cursor: pointer; border-radius: 6px; }
.nav-module-toggle:hover { background: var(--bg-sunken); }
.nav-mod-num { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; color: var(--text-soft); }
.nav-mod-title { flex: 1; }
.nav-mod-progress { font-size: 11px; color: var(--muted); font-weight: 500; }
.nav-lessons { list-style: none; margin: 0 0 6px; padding: 0 0 0 20px; display: none; }
.nav-module.open .nav-lessons { display: block; }
.nav-lessons a { display: flex; gap: 8px; align-items: baseline; padding: 5px 10px; border-radius: 6px; color: var(--text-soft); text-decoration: none; line-height: 1.4; }
.nav-lessons a:hover { background: var(--bg-sunken); color: var(--text); }
.nav-lessons a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-num { flex: none; min-width: 28px; font: 12px var(--mono); color: var(--muted); }
.nav-title { flex: 1; }
.nav-check { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--border-strong); align-self: center; }
.nav-lessons a.done .nav-check { background: var(--ok); border-color: var(--ok); box-shadow: inset 0 0 0 2px var(--bg-soft); }
.toc { position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto; padding: 40px 20px; font-size: 13px; }
.toc-title { font-weight: 650; color: var(--text); margin-bottom: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.toc ol { list-style: none; padding: 0; margin: 0; border-left: 1px solid var(--border); }
.toc a { display: block; padding: 4px 0 4px 12px; margin-left: -1px; color: var(--muted); text-decoration: none; border-left: 2px solid transparent; line-height: 1.4; }
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--accent-text); border-left-color: var(--accent); font-weight: 550; }

/* ---------- lesson typography ---------- */
.lesson { max-width: 780px; margin: 0 auto; }
.eyebrow { margin: 0 0 6px; font-size: 13px; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
.eyebrow a { color: inherit; }
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -.015em; position: relative; }
h1 { font-size: 34px; margin: 0 0 12px; font-weight: 700; }
h2 { font-size: 24px; margin: 52px 0 14px; padding-top: 8px; font-weight: 680; }
h3 { font-size: 18.5px; margin: 34px 0 10px; font-weight: 650; }
h4 { font-size: 16px; margin: 24px 0 8px; }
.anchor { position: absolute; left: -22px; color: var(--muted); text-decoration: none; opacity: 0; font-weight: 400; }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }
.lesson-num { display: inline-block; font: 600 .62em var(--mono); color: var(--accent-text); background: var(--accent-soft); border-radius: 6px; padding: .2em .45em; vertical-align: .28em; margin-right: 4px; }
.lede { font-size: 18px; color: var(--text-soft); margin: 0 0 18px; }
p, ul, ol { margin: 0 0 16px; }
li { margin: 4px 0; }
li > ul, li > ol { margin: 4px 0 0; }
blockquote { margin: 0 0 16px; padding: 4px 18px; border-left: 3px solid var(--border-strong); color: var(--text-soft); font-size: 17px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }
.lesson-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.meta-item { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-soft); padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-soft); }
.meta-item.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); background: var(--ok-soft); }
button.meta-item { cursor: pointer; font: inherit; font-size: 13px; }
button.meta-item[aria-pressed="true"] { color: var(--ok); background: var(--ok-soft); }
.table-wrap { overflow-x: auto; margin: 0 0 20px; border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--bg-soft); font-weight: 620; font-size: 13.5px; }
tr:last-child td { border-bottom: 0; }

/* ---------- callouts & disclosures ---------- */
.callout { margin: 0 0 20px; padding: 14px 16px 2px; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius-sm); background: var(--accent-soft); }
.callout-title { font-weight: 650; font-size: 14px; margin-bottom: 6px; }
.callout-warning { border-left-color: var(--warn); background: var(--warn-soft); }
.callout-tip { border-left-color: var(--ok); background: var(--ok-soft); }
.callout-trust { border-left-color: var(--trust); background: var(--trust-soft); }
.callout-trust .callout-title::before { content: "⛨ "; }
.callout-windows, .callout-linux { border-left-color: var(--muted); background: var(--bg-soft); }
.disclose { margin: 0 0 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.disclose > summary { cursor: pointer; padding: 10px 14px; font-weight: 550; list-style: none; display: flex; gap: 8px; align-items: baseline; }
.disclose > summary::-webkit-details-marker { display: none; }
.disclose > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; display: inline-block; }
.disclose[open] > summary::before { transform: rotate(90deg); }
.disclose-kind { font: 600 11px var(--font); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; flex: none; }
.disclose-debug .disclose-kind { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
.disclose-solution .disclose-kind { color: var(--ok); }
.disclose-body { padding: 2px 16px 4px; border-top: 1px solid var(--border); }
.disclose-body > :first-child { margin-top: 12px; }
.predict { margin: 0 0 10px; padding: 14px 16px; border-radius: var(--radius-sm); border: 1px dashed var(--border-strong); background: var(--bg-soft); }
.predict-label { font: 700 11px var(--font); letter-spacing: .07em; text-transform: uppercase; color: var(--accent-text); margin-right: 6px; }
.predict-q { font-weight: 560; margin-bottom: 8px; }
.predict textarea { width: 100%; font: 14px var(--font); padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); resize: vertical; }
.predict + .disclose { margin-top: -4px; }

/* ---------- code blocks ---------- */
.code-block { margin: 0 0 20px; border: 1px solid var(--code-border); border-radius: var(--radius); background: var(--code-bg); overflow: hidden; }
.code-head { display: flex; align-items: center; gap: 10px; padding: 7px 8px 7px 12px; border-bottom: 1px solid var(--code-border); background: var(--bg-soft); font-size: 13px; min-height: 40px; flex-wrap: wrap; }
.code-head .path { font: 600 13px var(--mono); color: var(--text); word-break: break-all; }
.code-head .lang { font-size: 12px; color: var(--muted); }
.badge { font: 650 11px var(--font); letter-spacing: .04em; text-transform: uppercase; padding: 3px 7px; border-radius: 4px; background: var(--bg-sunken); color: var(--text-soft); border: 1px solid var(--border); white-space: nowrap; }
.badge-new { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, var(--border)); }
.badge-edit { background: var(--accent-soft); color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.badge-replace { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, var(--border)); }
.badge-sql { background: var(--trust-soft); color: var(--trust); }
.code-note { padding: 7px 12px; font-size: 13px; color: var(--text-soft); border-bottom: 1px solid var(--code-border); background: var(--surface); }
.del-sample { color: var(--del-mark); font-weight: 700; background: var(--del-bg); padding: 0 5px; border-radius: 3px; }
.add-sample { color: var(--add-mark); font-weight: 700; background: var(--add-bg); padding: 0 5px; border-radius: 3px; }
pre.code { margin: 0; padding: 12px 0; overflow-x: auto; font-size: 13.5px; line-height: 1.6; counter-reset: ln; tab-size: 2; }
pre.code code { display: block; min-width: max-content; }
.ln { display: block; padding-right: 16px; white-space: pre; }
.ln .num { display: inline-block; width: 3.2em; padding-right: 1em; text-align: right; color: var(--muted); opacity: .7; user-select: none; }
.ln:not(.del) .num::before { counter-increment: ln; content: counter(ln); }
.ln .sign { display: inline-block; width: 1.4em; text-align: center; user-select: none; font-weight: 700; }
pre.diff .ln { padding-left: 6px; }
.ln.add { background: var(--add-bg); }
.ln.add .sign { color: var(--add-mark); }
.ln.del { background: var(--del-bg); }
.ln.del .sign { color: var(--del-mark); }
.ln.del .src { opacity: .75; text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--del-mark) 50%, transparent); }
.ln.hl { background: var(--hl-bg); box-shadow: inset 3px 0 0 var(--warn); }
.hunk + .hunk { border-top: 1px dashed var(--code-border); }
.hunk-label { font-size: 12px; color: var(--muted); padding: 8px 12px 0; }
.hunk-actions { display: flex; justify-content: flex-end; padding: 0 8px 8px; }
.full-file { border-top: 1px solid var(--code-border); }
.full-file > summary { cursor: pointer; padding: 9px 12px; font-size: 13px; color: var(--text-soft); background: var(--bg-soft); }
.full-file > .copy-btn { margin: 0 8px 8px auto; display: flex; }
.copy-btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); border-radius: 6px; cursor: pointer; font: 12.5px var(--font); }
.copy-btn:hover { color: var(--text); border-color: var(--border-strong); }
.copy-btn.copied { color: var(--ok); border-color: var(--ok); }

/* ---------- terminals ---------- */
.terminal { margin: 0 0 20px; border-radius: var(--radius); overflow: hidden; background: var(--term-bg); border: 1px solid #000; box-shadow: var(--shadow); }
.term-head { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 12px; background: #1b2029; color: var(--term-muted); font-size: 12.5px; flex-wrap: wrap; }
.term-head .badge { background: #262d38; color: #c8d0db; border-color: #333c49; }
.kind-check .term-head .badge { background: #173326; color: #8fe0b5; border-color: #24513a; }
.kind-server .term-head .badge { background: #2f2610; color: #f3c674; border-color: #4f3f19; }
.kind-log .term-head .badge { background: #232a3d; color: #a9bcff; border-color: #36405c; }
.term-head .cwd { font: 12px var(--mono); color: var(--term-muted); }
.term-head .exit { font-size: 12px; color: #f3c674; }
.term-head .copy-btn { background: #262d38; color: #c8d0db; border-color: #333c49; }
.term-head .copy-btn:hover { color: #fff; }
.term-note { padding: 6px 12px; font-size: 13px; color: var(--term-muted); border-bottom: 1px solid #1f252e; }
pre.term { margin: 0; padding: 12px 14px; overflow-x: auto; color: var(--term-text); font-size: 13.2px; line-height: 1.55; white-space: pre; }
pre.term .cmd { color: #fff; font-weight: 550; }
pre.term .prompt { color: var(--term-prompt); user-select: none; }
pre.term .out { color: #c3cad4; }
pre.term .muted { color: var(--term-muted); font-style: italic; }
.more-output summary { color: var(--term-muted); cursor: pointer; font-family: var(--font); font-size: 12.5px; }
.psql-out { background: var(--term-bg); border-top: 1px solid var(--code-border); max-height: 520px; }
.stop-server { margin: 0 0 20px; font-size: 14px; color: var(--text-soft); padding: 8px 12px; border-radius: var(--radius-sm); background: var(--bg-soft); border: 1px solid var(--border); }

/* ---------- figures ---------- */
.shot { margin: 0 0 24px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.browser-bar { display: flex; align-items: center; gap: 10px; padding: 7px 12px; background: var(--bg-soft); border-bottom: 1px solid var(--border); font-size: 12.5px; }
.browser-bar .dots { display: flex; gap: 5px; }
.browser-bar .dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); display: block; }
.browser-bar .url { flex: 1; font-family: var(--mono); color: var(--text-soft); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 2px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shot-user { color: var(--muted); white-space: nowrap; }
.shot img { display: block; width: 100%; height: auto; }
.shot figcaption, .diagram figcaption { padding: 10px 14px; font-size: 13.5px; color: var(--text-soft); border-top: 1px solid var(--border); }
.shot.missing .shot-missing { padding: 24px; color: var(--danger); }
.diagram { margin: 0 0 24px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow-x: auto; }
.diagram svg { display: block; width: 100%; height: auto; min-width: 560px; }

/* ---------- lesson end ---------- */
.lesson-end { margin: 48px 0 0; padding: 20px; border-radius: var(--radius); background: var(--bg-soft); border: 1px solid var(--border); display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between; }
.lesson-end .checkpoint-link { margin: 0; }
.btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 550 14.5px var(--font); text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--text-soft); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-primary[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); }
.btn-ghost { background: transparent; }
.prev-next { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.pn { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.pn:hover { border-color: var(--accent); }
.pn.next { text-align: right; }
.pn-dir { font-size: 12.5px; color: var(--muted); }
.pn-title { font-weight: 600; }

/* ---------- search & dialogs ---------- */
.search-dialog, .kbd-help { position: fixed; inset: 0; z-index: 50; background: rgba(10, 14, 20, .45); display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; }
.search-dialog[hidden], .kbd-help[hidden] { display: none; }
.search-panel, .kbd-panel { width: min(680px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; }
.search-input-row { display: flex; align-items: center; gap: 8px; padding: 10px; border-bottom: 1px solid var(--border); }
.search-input-row input { flex: 1; height: 42px; border: 0; background: none; color: var(--text); font: 17px var(--font); padding: 0 8px; outline: none; }
.search-results { list-style: none; margin: 0; padding: 6px; max-height: 60vh; overflow-y: auto; }
.search-results li a { display: block; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--text); }
.search-results li a .sr-where { font-size: 12px; color: var(--muted); }
.search-results li a .sr-head { font-weight: 600; display: block; }
.search-results li a .sr-snip { font-size: 13.5px; color: var(--text-soft); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results li a mark { background: var(--hl-bg); color: inherit; border-radius: 2px; }
.search-results li[aria-selected="true"] a, .search-results li a:hover { background: var(--accent-soft); }
.search-results .empty { padding: 16px; color: var(--muted); }
.search-foot { padding: 8px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.kbd-panel { padding: 20px 24px; width: min(420px, 100%); }
.kbd-panel h2 { margin: 0 0 12px; font-size: 18px; }
.kbd-panel dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0 0 16px; }
.kbd-panel dd { margin: 0; color: var(--text-soft); }

/* ---------- landing & index pages ---------- */
.landing { max-width: 1040px; margin: 0 auto; }
.hero { padding: 24px 0 8px; }
.hero h1 { font-size: clamp(30px, 4.2vw, 46px); line-height: 1.12; letter-spacing: -.03em; max-width: 860px; }
.hero .lede { font-size: 19px; max-width: 780px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 14px; }
.hero-note { font-size: 14px; color: var(--muted); }
.landing-section { margin: 56px 0 0; }
.landing-section h2 { margin-top: 0; }
.shot-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.checks { list-style: none; padding: 0; }
.checks li { padding-left: 26px; position: relative; margin: 8px 0; }
.checks li::before { content: ""; position: absolute; left: 2px; top: .55em; width: 12px; height: 7px; border-left: 2px solid var(--ok); border-bottom: 2px solid var(--ok); transform: rotate(-45deg); }
.journey { list-style: none; padding: 0; display: grid; gap: 10px; }
.journey-mod a { display: flex; gap: 16px; align-items: flex-start; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); background: var(--surface); }
.journey-mod a:hover { border-color: var(--accent); }
.jm-num { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-text); font: 650 15px var(--mono); }
.jm-body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.jm-title { font-weight: 650; }
.jm-sum { color: var(--text-soft); font-size: 14.5px; }
.jm-meta { color: var(--muted); font-size: 13px; }
.jm-progress { font-size: 12.5px; color: var(--ok); white-space: nowrap; }
.map-module { margin-top: 36px; }
.map-lessons { list-style: none; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.map-lessons li { margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--border); display: grid; gap: 2px; }
.map-lessons li:last-child { border-bottom: 0; }
.map-lessons li.done > a::after { content: " ✓"; color: var(--ok); }
.map-sum { color: var(--text-soft); font-size: 14px; }
.map-meta { color: var(--muted); font-size: 12.5px; }
.ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.ex-card { display: flex; flex-direction: column; gap: 6px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); background: var(--surface); }
.ex-card:hover { border-color: var(--accent); }
.ex-kind { align-self: flex-start; font: 650 11px var(--font); text-transform: uppercase; letter-spacing: .05em; padding: 2px 7px; border-radius: 4px; }
.ex-kind.real { background: var(--ok-soft); color: var(--ok); }
.ex-kind.sim { background: var(--warn-soft); color: var(--warn); }
.ex-title { font-weight: 650; font-size: 17px; }
.ex-desc { color: var(--text-soft); font-size: 14px; }
.ex-used { color: var(--muted); font-size: 12.5px; }
.explorer-page { max-width: 1100px; }
.cp-meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14.5px; }
.cp-meta dt { color: var(--muted); }
.cp-meta dd { margin: 0; }
.cp-file h3 { font-size: 15px; }
.pill { font: 600 11px var(--font); text-transform: uppercase; letter-spacing: .05em; padding: 2px 6px; border-radius: 4px; background: var(--bg-sunken); color: var(--text-soft); }
pre.tree { background: var(--code-bg); border: 1px solid var(--code-border); border-radius: var(--radius); padding: 12px 16px; font-size: 13px; overflow-x: auto; }

/* ---------- explorers (shared) ---------- */
.explorer { margin: 0 0 28px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.explorer-loading { padding: 28px; color: var(--muted); }

/* ---------- responsive ---------- */
@media (max-width: 1240px) {
  .layout.has-toc { grid-template-columns: 272px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 960px) {
  .layout, .layout.has-toc { grid-template-columns: minmax(0, 1fr); }
  .nav-toggle { display: inline-grid; }
  .top-links { display: none; }
  .sidebar { position: fixed; top: var(--topbar-h); left: 0; bottom: 0; height: auto; width: min(320px, 88vw); z-index: 40; transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(10,14,20,.35); z-index: 35; }
  main { padding: 28px 20px 80px; }
  .shot-grid, .two-col { grid-template-columns: 1fr; }
  .search-btn { min-width: 0; }
  .search-btn span, .search-btn kbd { display: none; }
}
@media (max-width: 560px) {
  main { padding: 22px 16px 72px; }
  h1 { font-size: 27px; }
  h2 { font-size: 21px; }
  .brand-sub { display: none; }
  .prev-next { grid-template-columns: 1fr; }
  .pn.next { text-align: left; }
  pre.code, pre.term { font-size: 12.5px; }
  .anchor { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print {
  .topbar, .sidebar, .toc, .prev-next, .lesson-end, .copy-btn { display: none !important; }
  .layout { display: block; }
}

/* ---------- capstone solution gate ---------- */
.solution-gate { margin: 24px 0; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.solution-gate > summary { cursor: pointer; padding: 18px 20px; background: var(--warn-soft); border-radius: var(--radius); list-style: none; }
.solution-gate > summary::-webkit-details-marker { display: none; }
.solution-gate[open] > summary { border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
.gate-title { font-weight: 700; display: block; margin-bottom: 4px; }
.solution-body { padding: 0 20px 8px; }

/* ---------- Folio typography and rules ---------- */
h1, h2, h3, .brand, .hero h1 { font-family: var(--serif); font-weight: 580; letter-spacing: -.035em; }
h1 { font-size: 40px; line-height: 1.08; }
h2 { font-size: 30px; line-height: 1.12; border-top: 1px solid var(--border-strong); padding-top: 26px; }
.landing-section h2, .kbd-panel h2 { border-top: 0; padding-top: 0; }
h3 { font-size: 22px; letter-spacing: -.02em; }
h4 { font-family: var(--font); }
.hero h1 { font-size: clamp(38px, 5.4vw, 64px); line-height: 1.03; letter-spacing: -.05em; }
.brand { font-size: 23px; letter-spacing: -.05em; }
.brand-mark { display: none; }
.brand-sub { font-family: var(--font); letter-spacing: 0; }
a { text-decoration-thickness: 1px; text-underline-offset: 4px; }
:not(pre) > code { border-radius: 2px; }
@media (max-width: 760px) { h1 { font-size: 31px; } h2 { font-size: 25px; } }
