/* ============ Tokens ============ */
:root {
  --bg: #f5f4ef;
  --panel: #ffffff;
  --panel-2: #eeece5;
  --ink: #1b1d20;
  --ink-2: #474c54;
  --ink-3: #7a8089;
  --line: #dddad1;
  --line-2: #c9c5ba;
  --code-bg: #f0eee8;
  --sidebar: #ebe9e2;

  --java: #c2410c;
  --linux: #15803d;
  --sql: #1d4ed8;
  --hr: #7e22ce;
  --accent: var(--linux);

  --ok: #15803d;
  --bad: #b91c1c;
  --warn: #b45309;

  --tok-kw: #a626a4;
  --tok-str: #50a14f;
  --tok-com: #8a9099;
  --tok-num: #b76b01;
  --tok-fn: #4078f2;
  --tok-type: #c18401;
  --tok-var: #e45649;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 4px 16px rgba(20, 20, 20, .05);
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1013;
    --panel: #15181d;
    --panel-2: #1c2027;
    --ink: #e7e9ec;
    --ink-2: #aeb5bf;
    --ink-3: #747c88;
    --line: #252a32;
    --line-2: #333a44;
    --code-bg: #0a0c0f;
    --sidebar: #111317;
    --java: #fb923c;
    --linux: #4ade80;
    --sql: #60a5fa;
    --hr: #c084fc;
    --ok: #4ade80;
    --bad: #f87171;
    --warn: #fbbf24;
    --tok-kw: #c678dd;
    --tok-str: #98c379;
    --tok-com: #6b7380;
    --tok-num: #d19a66;
    --tok-fn: #61afef;
    --tok-type: #e5c07b;
    --tok-var: #e06c75;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1013;
  --panel: #15181d;
  --panel-2: #1c2027;
  --ink: #e7e9ec;
  --ink-2: #aeb5bf;
  --ink-3: #747c88;
  --line: #252a32;
  --line-2: #333a44;
  --code-bg: #0a0c0f;
  --sidebar: #111317;
  --java: #fb923c;
  --linux: #4ade80;
  --sql: #60a5fa;
  --hr: #c084fc;
  --ok: #4ade80;
  --bad: #f87171;
  --warn: #fbbf24;
  --tok-kw: #c678dd;
  --tok-str: #98c379;
  --tok-com: #6b7380;
  --tok-num: #d19a66;
  --tok-fn: #61afef;
  --tok-type: #e5c07b;
  --tok-var: #e06c75;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
code, kbd, pre { font-family: var(--mono); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0; text-wrap: balance; }
p { margin: 0 0 .9em; }
strong { font-weight: 600; color: var(--ink); }
mark { background: color-mix(in srgb, var(--accent) 28%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
[hidden] { display: none !important; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--panel); padding: 8px 12px; border-radius: 6px; z-index: 100; }
.skip:focus { left: 8px; }

/* ============ Layout ============ */
.app { display: grid; grid-template-columns: 284px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 22px 16px 16px;
  display: flex; flex-direction: column; gap: 18px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-weight: 700; font-size: 15px;
  text-decoration: none; padding: 0 6px;
}
.brand-mark {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px; border-radius: 7px;
  background: #15181d; color: #4ade80; font-size: 13px;
}

.search {
  position: relative; display: flex; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 0 10px; color: var(--ink-3);
}
.search:focus-within { border-color: var(--accent); }
.search input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  padding: 9px 8px; font-size: 14px; color: var(--ink);
}
.search input::-webkit-search-cancel-button { display: none; }
.search kbd {
  font-size: 11px; border: 1px solid var(--line); border-radius: 4px;
  padding: 1px 6px; color: var(--ink-3); background: var(--panel-2);
}

/* file-tree nav */
.tree { font-family: var(--mono); font-size: 13.5px; flex: 1; }
.tree-root { color: var(--ink-3); padding: 0 8px 8px; font-size: 12.5px; }
.tree-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 8px; border-radius: 6px; text-decoration: none; color: var(--ink-2);
  min-height: 34px;
}
.tree-item:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.tree-item.active { background: var(--panel); color: var(--ink); box-shadow: inset 2px 0 0 var(--accent); }
.tree-item.dir { color: var(--ink); font-weight: 700; margin-top: 8px; }
.tree-item.dir .tree-label::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px;
  background: var(--accent); margin-right: 9px; vertical-align: 1px;
}
.tree-meta { font-size: 11.5px; color: var(--ink-3); font-weight: 400; }
.tree-children { margin-left: 13px; padding-left: 8px; border-left: 1px solid var(--line-2); }
.tree-item.file { margin-top: 8px; }
.tree-item .live { color: var(--warn); }

.sidebar-foot { display: flex; gap: 8px; flex-wrap: wrap; }
.ghost-btn {
  background: transparent; border: 1px solid var(--line); border-radius: 7px;
  padding: 6px 10px; font-size: 13px; color: var(--ink-2);
}
.ghost-btn:hover { border-color: var(--line-2); color: var(--ink); }

.topbar { display: none; }
.scrim { display: none; }

.main { padding: 44px clamp(16px, 4vw, 56px) 96px; outline: none; min-width: 0; }
.page { max-width: 1080px; margin: 0 auto; }

/* ============ Common components ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--ink);
  border-radius: 8px; padding: 9px 16px; font-size: 14.5px; font-weight: 500;
  text-decoration: none; min-height: 40px; transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--ink) 85%, var(--accent)); }
.btn.small { padding: 5px 11px; min-height: 32px; font-size: 13.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.seg {
  display: inline-flex; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 3px; gap: 2px;
}
.seg button {
  border: 0; background: transparent; padding: 6px 13px; border-radius: 6px;
  font-size: 13.5px; color: var(--ink-2); min-height: 32px;
}
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); font-weight: 500; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }

.meter { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .4s ease; }

.eyebrow { font-family: var(--mono); font-size: 13px; color: var(--ink-3); margin-bottom: 10px; }
.eyebrow .ps1 { color: var(--accent); }

/* ============ Home ============ */
.hero { padding: 8px 0 36px; border-bottom: 1px solid var(--line); margin-bottom: 36px; }
.hero h1 { font-size: clamp(32px, 4.6vw, 48px); letter-spacing: -.02em; font-weight: 700; margin-bottom: 14px; }
.hero h1 em { font-style: normal; color: var(--accent); }
.lede { font-size: 18px; color: var(--ink-2); max-width: 68ch; }
.typed::after { content: "▍"; color: var(--accent); animation: blink 1.1s steps(1) infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: 0; } }

.hero-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 28px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat-num { font-family: var(--mono); font-size: 26px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--ink-3); }
.stat input[type="date"] {
  margin-top: 6px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 8px; font-size: 13px; width: 100%;
}

.section-title { font-size: 13px; font-family: var(--mono); color: var(--ink-3); text-transform: lowercase; margin: 0 0 14px; font-weight: 500; }

.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 40px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px; display: flex; flex-direction: column; gap: 12px;
  border-top: 3px solid var(--accent); box-shadow: var(--shadow);
}
.card-dir { font-family: var(--mono); font-size: 13px; color: var(--accent); font-weight: 700; }
.card h3 { font-size: 22px; letter-spacing: -.01em; }
.card p { color: var(--ink-2); font-size: 14.5px; margin: 0; flex: 1; }
.card-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.card-stats div { background: var(--panel-2); border-radius: 8px; padding: 8px 10px; }
.card-stats dt { font-size: 12px; color: var(--ink-3); }
.card-stats dd { margin: 0; font-family: var(--mono); font-weight: 700; font-size: 15px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.steps { list-style: none; padding: 0; margin: 0 0 40px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; counter-reset: step; }
.steps li { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; font-size: 14.5px; color: var(--ink-2); counter-increment: step; }
.steps li::before { content: "0" counter(step); display: block; font-family: var(--mono); font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.steps strong { display: block; color: var(--ink); margin-bottom: 2px; }

.cta-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cta { text-decoration: none; display: flex; flex-direction: column; gap: 6px; padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.cta:hover { border-color: var(--accent); transform: translateY(-1px); }
.cta .file { font-family: var(--mono); font-weight: 700; color: var(--accent); }
.cta span:last-child { color: var(--ink-2); font-size: 14.5px; }

/* ============ Topic header & tabs ============ */
.topic-head { margin-bottom: 24px; }
.topic-head h1 { font-size: clamp(28px, 3.8vw, 40px); letter-spacing: -.02em; margin-bottom: 8px; }
.topic-head p { color: var(--ink-2); max-width: 72ch; margin: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 28px; overflow-x: auto; }
.tabs a {
  padding: 10px 14px; text-decoration: none; color: var(--ink-2); font-weight: 500; font-size: 15px;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  display: inline-flex; gap: 8px; align-items: center;
}
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .count { font-family: var(--mono); font-size: 12px; color: var(--ink-3); background: var(--panel-2); padding: 1px 7px; border-radius: 99px; }

/* ============ Notes ============ */
.notes-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 40px; align-items: start; }
.toc { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow-y: auto; font-size: 13.5px; }
.toc-title { font-family: var(--mono); font-size: 12px; color: var(--ink-3); margin-bottom: 8px; }
.toc a {
  display: flex; gap: 10px; padding: 6px 8px; text-decoration: none; color: var(--ink-2);
  border-radius: 6px; line-height: 1.35;
}
.toc a:hover { background: var(--panel-2); color: var(--ink); }
.toc-num { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); padding-top: 1px; min-width: 18px; }
.toc a.is-read .toc-num { color: var(--ok); }
.toc a.is-read .toc-num::before { content: "✓"; }
.toc a.is-read .toc-num span { display: none; }

.note { padding-bottom: 36px; margin-bottom: 36px; border-bottom: 1px solid var(--line); scroll-margin-top: 24px; }
.note:last-child { border-bottom: 0; }
.note-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.note-num { font-family: var(--mono); font-weight: 700; color: var(--accent); font-size: 14px; }
.note-head h2 { font-size: 24px; letter-spacing: -.01em; flex: 1; min-width: 200px; }
.read-toggle {
  border: 1px solid var(--line-2); background: transparent; border-radius: 99px;
  font-size: 12.5px; padding: 4px 12px; color: var(--ink-2); white-space: nowrap;
}
.read-toggle:hover { border-color: var(--ok); color: var(--ink); }
.read-toggle.on { border-color: var(--ok); color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }

.note p, .note li { color: var(--ink-2); max-width: 78ch; }
.note h4 { font-size: 16px; margin: 22px 0 10px; }
.note ul, .note ol { padding-left: 22px; margin: 0 0 1em; }
.note li { margin-bottom: 6px; }
.note li::marker { color: var(--ink-3); }

:not(pre) > code {
  font-size: .86em; background: var(--code-bg); border: 1px solid var(--line);
  padding: .08em .38em; border-radius: 5px; color: var(--ink); white-space: nowrap;
}
.table-wrap :not(pre) > code, .q-text code, .option code { white-space: normal; overflow-wrap: anywhere; }

.code { position: relative; margin: 0 0 1.1em; }
.code pre {
  margin: 0; background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; overflow-x: auto; font-size: 13.25px; line-height: 1.6; tab-size: 4;
}
.code pre code { background: none; border: 0; padding: 0; color: var(--ink); font-size: inherit; white-space: pre; }
.copy {
  position: absolute; top: 8px; right: 8px; font-family: var(--mono); font-size: 11.5px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-3);
  border-radius: 6px; padding: 3px 8px; opacity: 0; transition: opacity .15s;
}
.code:hover .copy, .copy:focus-visible { opacity: 1; }
@media (hover: none) { .copy { opacity: 1; } }

.hljs-keyword, .hljs-built_in, .hljs-selector-tag, .hljs-section { color: var(--tok-kw); }
.hljs-string, .hljs-regexp, .hljs-addition { color: var(--tok-str); }
.hljs-comment, .hljs-quote { color: var(--tok-com); font-style: italic; }
.hljs-number, .hljs-literal, .hljs-symbol { color: var(--tok-num); }
.hljs-title, .hljs-title.function_, .hljs-function .hljs-title { color: var(--tok-fn); }
.hljs-type, .hljs-title.class_, .hljs-class .hljs-title { color: var(--tok-type); }
.hljs-variable, .hljs-template-variable, .hljs-attr, .hljs-meta, .hljs-params .hljs-variable { color: var(--tok-var); }
.hljs-meta { color: var(--tok-type); }

.table-wrap { overflow-x: auto; margin: 0 0 1.2em; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 9px 13px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--panel-2); font-weight: 600; font-size: 13px; color: var(--ink); white-space: nowrap; }
td { color: var(--ink-2); }
tr:last-child td { border-bottom: 0; }

.callout {
  display: flex; gap: 12px; padding: 13px 16px; border-radius: var(--radius); margin: 0 0 1.1em;
  background: color-mix(in srgb, var(--accent) 9%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  font-size: 15px; color: var(--ink-2);
}
.callout.warn { background: color-mix(in srgb, var(--warn) 9%, var(--panel)); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.callout-label { font-family: var(--mono); font-size: 11.5px; font-weight: 700; text-transform: uppercase; color: var(--accent); padding-top: 3px; white-space: nowrap; }
.callout.warn .callout-label { color: var(--warn); }

/* ============ Q&A ============ */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.toolbar .spacer { flex: 1; }
.toolbar-note { font-size: 13.5px; color: var(--ink-3); }

.qa {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 10px; scroll-margin-top: 24px; transition: border-color .15s;
}
.qa[open] { border-color: var(--line-2); box-shadow: var(--shadow); }
.qa summary {
  list-style: none; cursor: pointer; display: flex; gap: 14px; align-items: flex-start;
  padding: 15px 18px; font-weight: 500;
}
.qa summary::-webkit-details-marker { display: none; }
.qa summary::after {
  content: "+"; font-family: var(--mono); color: var(--ink-3); margin-left: auto; font-size: 18px; line-height: 1.3;
}
.qa[open] summary::after { content: "−"; }
.qa-num { font-family: var(--mono); font-size: 12px; color: var(--accent); font-weight: 700; padding-top: 3px; min-width: 30px; }
.qa-q { flex: 1; }
.qa-known { font-size: 12px; color: var(--ok); font-family: var(--mono); padding-top: 3px; white-space: nowrap; }
.qa-body { padding: 0 18px 16px 62px; color: var(--ink-2); }
.qa-body ul { padding-left: 20px; margin: 0 0 .9em; }
.qa-body li { margin-bottom: 4px; }
.qa-foot { display: flex; justify-content: flex-end; margin-top: 4px; }

.flash { max-width: 760px; margin: 0 auto; }
.flash-meta { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 13px; color: var(--ink-3); margin-bottom: 10px; }
.flash-card {
  display: block; width: 100%; min-height: 320px; text-align: left; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 32px 34px; box-shadow: var(--shadow); position: relative;
  border-top: 3px solid var(--accent);
}
.flash-card:hover { border-color: var(--line-2); border-top-color: var(--accent); }
.flash-side { font-family: var(--mono); font-size: 12px; color: var(--accent); font-weight: 700; margin-bottom: 14px; display: block; }
.flash-q { font-size: 22px; font-weight: 600; line-height: 1.4; color: var(--ink); }
.flash-a { color: var(--ink-2); font-size: 16px; }
.flash-a ul { padding-left: 20px; }
.flash-hint { position: absolute; bottom: 14px; right: 18px; font-size: 12.5px; color: var(--ink-3); }
.flash-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.flash-actions .btn.know { border-color: var(--ok); color: var(--ok); }
.flash-actions .btn.know:hover { background: color-mix(in srgb, var(--ok) 10%, var(--panel)); }
.kbd-hint { text-align: center; font-size: 12.5px; color: var(--ink-3); margin-top: 14px; }
.kbd-hint kbd { font-size: 11px; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; background: var(--panel); }

.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* ============ Quiz ============ */
.quiz-start { max-width: 640px; }
.quiz-start h2 { font-size: 26px; margin-bottom: 6px; }
.quiz-start .sub { color: var(--ink-2); margin-bottom: 22px; }
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.check { display: flex; align-items: center; gap: 10px; font-size: 14.5px; color: var(--ink-2); margin-bottom: 22px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.history { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-2); }
.history strong { font-family: var(--mono); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check { display: inline-flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px 6px 10px; font-size: 14px; cursor: pointer; background: var(--panel); }
.chip-check:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.chip-check input { accent-color: var(--accent); }
.chip-check .dot { width: 8px; height: 8px; border-radius: 2px; }

.quiz { max-width: 820px; }
.quiz-top { display: flex; justify-content: space-between; gap: 12px; font-family: var(--mono); font-size: 13px; color: var(--ink-3); margin-bottom: 8px; flex-wrap: wrap; }
.quiz .meter { margin-bottom: 26px; }
.q-tag { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 8px; display: inline-block; }
.q-text { font-size: 19px; font-weight: 600; color: var(--ink); line-height: 1.45; margin-bottom: 16px; }
.options { display: grid; gap: 10px; margin: 18px 0; }
.option {
  display: flex; align-items: flex-start; gap: 14px; text-align: left; width: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: 11px;
  padding: 13px 16px; font-size: 15.5px; color: var(--ink); min-height: 50px;
  transition: border-color .12s, background .12s;
}
.option:hover:not(:disabled) { border-color: var(--accent); }
.option:disabled { cursor: default; }
.opt-key {
  flex: none; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px;
  background: var(--panel-2); font-family: var(--mono); font-size: 12.5px; font-weight: 700; color: var(--ink-2);
}
.option.chosen { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.option.chosen .opt-key { background: var(--accent); color: var(--panel); }
.option.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--panel)); }
.option.correct .opt-key { background: var(--ok); color: var(--panel); }
.option.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 9%, var(--panel)); }
.option.wrong .opt-key { background: var(--bad); color: var(--panel); }
.option.dim { opacity: .55; }

.feedback { border-radius: 11px; padding: 14px 16px; margin-bottom: 18px; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); }
.feedback .verdict { font-weight: 700; display: block; margin-bottom: 4px; }
.feedback.good { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.feedback.good .verdict { color: var(--ok); }
.feedback.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.feedback.bad .verdict { color: var(--bad); }
.quiz-nav { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.results-head { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; margin-bottom: 28px; }
.ring { --p: 0; width: 132px; height: 132px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--panel-2) 0); }
.ring::before { content: ""; grid-area: 1 / 1; width: 106px; height: 106px; border-radius: 50%; background: var(--bg); }
.ring span { grid-area: 1 / 1; font-family: var(--mono); font-weight: 700; font-size: 28px; z-index: 1; }
.results-head h2 { font-size: 28px; margin-bottom: 6px; }
.results-head p { color: var(--ink-2); margin-bottom: 14px; }
.results-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.breakdown { display: grid; gap: 12px; margin: 0 0 32px; }
.breakdown-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 70px; gap: 14px; align-items: center; font-size: 14.5px; }
.breakdown-row .num { font-family: var(--mono); text-align: right; color: var(--ink-2); }

.review h3 { font-size: 18px; margin: 0 0 14px; }
.review-item { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--ok); border-radius: 10px; padding: 16px 18px; margin-bottom: 10px; }
.review-item.is-wrong { border-left-color: var(--bad); }
.review-item .q-text { font-size: 16px; margin-bottom: 10px; }
.review-ans { font-size: 14.5px; color: var(--ink-2); margin: 0 0 4px; }
.review-ans b { font-weight: 600; }
.review-ans .ok { color: var(--ok); }
.review-ans .no { color: var(--bad); }
.review-explain { font-size: 14.5px; color: var(--ink-2); margin: 8px 0 0; padding-top: 8px; border-top: 1px dashed var(--line); }

/* mock exam */
.exam-bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  padding: 12px 0; margin-bottom: 18px; border-bottom: 1px solid var(--line);
}
.timer { font-family: var(--mono); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer.low { color: var(--bad); }
.exam-bar .spacer { flex: 1; }
.exam-bar .answered { font-family: var(--mono); font-size: 13px; color: var(--ink-3); }
.qgrid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
.qgrid button {
  width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel);
  font-family: var(--mono); font-size: 13px; color: var(--ink-2); position: relative;
}
.qgrid button.done { background: color-mix(in srgb, var(--accent) 14%, var(--panel)); border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); color: var(--ink); }
.qgrid button.current { outline: 2px solid var(--ink); outline-offset: 1px; }
.qgrid button.flagged::after { content: ""; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.flag-btn[aria-pressed="true"] { border-color: var(--warn); color: var(--warn); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-3); margin-top: 10px; flex-wrap: wrap; }

/* ============ Cram ============ */
.cram-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cram-col { background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 12px; padding: 20px 22px; }
.cram-col h2 { font-size: 18px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: baseline; }
.cram-col h2 span { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.cram-col ol { margin: 0; padding-left: 22px; font-size: 14.5px; color: var(--ink-2); }
.cram-col li { margin-bottom: 7px; }
.cram-col li::marker { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }

/* ============ Search ============ */
.result-group { margin-bottom: 28px; }
.result-group h2 { font-size: 15px; font-family: var(--mono); color: var(--accent); margin-bottom: 10px; }
.result {
  display: block; text-decoration: none; padding: 12px 16px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px;
}
.result:hover { border-color: var(--accent); }
.result-kind { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; }
.result-title { font-weight: 600; display: block; margin: 2px 0; }
.result-snip { font-size: 14px; color: var(--ink-2); display: block; }

/* ============ Responsive ============ */
@media (max-width: 1100px) {
  .notes-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toc { position: static; max-height: none; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 28px; columns: 2; column-gap: 12px; }
  .toc-title { column-span: all; }
  .toc a { break-inside: avoid; }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20;
    padding: 10px 16px; background: color-mix(in srgb, var(--bg) 90%, transparent);
    backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  }
  .icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); }
  .sidebar {
    position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: min(300px, 86vw);
    transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 30; }
  .main { padding: 24px 16px 80px; }
  .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards, .cta-row, .cram-grid { grid-template-columns: minmax(0, 1fr); }
  .exam-bar { top: 61px; }
}

@media (max-width: 560px) {
  .steps { grid-template-columns: minmax(0, 1fr); }
  .toc { columns: 1; }
  .qa summary { padding: 14px; gap: 10px; }
  .qa-body { padding: 0 14px 14px; }
  .flash-card { padding: 24px 20px 40px; min-height: 280px; }
  .flash-q { font-size: 19px; }
  .panel { padding: 20px; }
  .breakdown-row { grid-template-columns: 90px minmax(0, 1fr) 56px; gap: 10px; }
  .q-text { font-size: 17px; }
  .lede { font-size: 16.5px; }
}

/* ============ Print (cram sheet) ============ */
@media print {
  .sidebar, .topbar, .no-print, .scrim { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .cram-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .cram-col { box-shadow: none; break-inside: avoid; padding: 10px 12px; }
  :not(pre) > code { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
