/* Python Mastery — single stylesheet. Dark by default, light via [data-theme="light"]. */
:root {
  --bg: #0f1216;
  --bg-elev: #161a20;
  --bg-sunk: #0b0d10;
  --border: #262c35;
  --border-strong: #353d49;
  --text: #e3e7ec;
  --text-muted: #8b95a3;
  --accent: #5b9dff;
  --accent-soft: rgba(91, 157, 255, 0.14);
  --good: #3fb27f;
  --good-soft: rgba(63, 178, 127, 0.14);
  --mid: #d9a441;
  --mid-soft: rgba(217, 164, 65, 0.14);
  --bad: #e5606a;
  --bad-soft: rgba(229, 96, 106, 0.14);
  --code-bg: #0c0f13;
  --t-kw: #c792ea; --t-str: #a5d6a7; --t-num: #f7a76c; --t-com: #6b7685; --t-def: #82aaff; --t-bi: #64d2d8; --t-dec: #ffcb6b; --t-self: #f07178;
  --radius: 8px;
  --sidebar: 288px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f6f7f9; --bg-elev: #ffffff; --bg-sunk: #eef0f3; --border: #dde1e6; --border-strong: #c7cdd5;
  --text: #1b2028; --text-muted: #5d6775; --accent: #2563eb; --accent-soft: rgba(37, 99, 235, 0.1);
  --good: #16865a; --good-soft: rgba(22, 134, 90, 0.1); --mid: #a86d00; --mid-soft: rgba(168, 109, 0, 0.1);
  --bad: #c9303c; --bad-soft: rgba(201, 48, 60, 0.09); --code-bg: #f3f5f8;
  --t-kw: #7c3aed; --t-str: #15803d; --t-num: #c2410c; --t-com: #8a94a3; --t-def: #1d4ed8; --t-bi: #0e7490; --t-dec: #a16207; --t-self: #be123c;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, textarea.mono { font-family: var(--mono); font-size: 13px; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 26px; } h2 { font-size: 21px; } h3 { font-size: 17px; } h4 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- layout */
#app { display: flex; min-height: 100vh; }
#sidebar { width: var(--sidebar); flex-shrink: 0; background: var(--bg-elev); border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 14px 10px 40px; }
#content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
#search-form { flex: 1; max-width: 520px; }
#search-input { width: 100%; padding: 7px 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-elev); color: var(--text); font: inherit; }
#search-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
#main { padding: 28px 32px 80px; max-width: 1180px; width: 100%; }
#main:focus { outline: none; }
#menu-button { display: none; }

.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(135deg, #3b7ddd, #ffd43b); color: #0b0d10; font-weight: 800; display: grid; place-items: center; }
.brand-text { font-weight: 700; display: flex; flex-direction: column; line-height: 1.2; }
.brand-text small { font-weight: 400; color: var(--text-muted); font-size: 12px; }

.nav-item, .nav-module, .nav-topic { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 6px; color: var(--text); font-size: 14px; }
.nav-item:hover, .nav-module:hover, .nav-topic:hover { background: var(--bg-sunk); text-decoration: none; }
.nav-item.active, .nav-module.active, .nav-topic.active { background: var(--accent-soft); color: var(--accent); }
.nav-count { margin-left: auto; background: var(--bad); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; font-weight: 600; }
.nav-label { margin: 18px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.nav-track { margin: 12px 10px 2px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.nav-module-id { font-family: var(--mono); font-size: 11px; color: var(--text-muted); width: 18px; }
.nav-module-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-topic { padding-left: 34px; font-size: 13px; }
.nav-module.pending, .nav-topic.pending { opacity: 0.5; }

/* ---------------------------------------------------------------- generic pieces */
.page-head { margin-bottom: 20px; }
.page-sub { color: var(--text-muted); margin: 0; }
.muted { color: var(--text-muted); }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.card h3 { margin-bottom: 10px; }
.columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.columns.two { grid-template-columns: repeat(2, 1fr); }
.columns > .card { margin-bottom: 0; }
section { margin-bottom: 22px; }
.crumbs { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.crumb-sep { opacity: 0.6; }
.callout { background: var(--accent-soft); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 6px; margin: 10px 0; }
.callout.warn { background: var(--mid-soft); border-color: var(--mid); }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:disabled, .btn.disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-small { padding: 3px 10px; font-size: 13px; }
.btn-danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn-armed { border-color: var(--bad); color: var(--bad); }
.icon-button { background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--text); cursor: pointer; padding: 5px 10px; font-size: 15px; }
.file-input { display: none; }

.pill { font-size: 12px; padding: 3px 10px; border-radius: 12px; background: var(--bg-elev); border: 1px solid var(--border); color: var(--text-muted); white-space: nowrap; }
.pill-link:hover { text-decoration: none; border-color: var(--accent); }
.pill-hot { color: var(--bad); border-color: var(--bad); }
.pill-bad { color: var(--bad); border-color: var(--bad); }

.badge { font-size: 12px; padding: 2px 9px; border-radius: 10px; font-weight: 600; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; display: inline-block; background: var(--border-strong); }
.st-not_started { --st: var(--border-strong); }
.st-learning { --st: #6c8ebf; }
.st-practicing { --st: var(--accent); }
.st-weak { --st: var(--bad); }
.st-intermediate { --st: var(--mid); }
.st-strong { --st: #4fc3a1; }
.st-mastered { --st: var(--good); }
.dot[class*="st-"] { background: var(--st); }
.badge[class*="st-"] { color: var(--st); background: color-mix(in srgb, var(--st) 15%, transparent); }
.badge.st-not_started { color: var(--text-muted); }

.bar { height: 6px; background: var(--bg-sunk); border-radius: 3px; overflow: hidden; margin: 6px 0; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; }

.tag { font-size: 12px; padding: 2px 8px; border-radius: 5px; background: var(--bg-sunk); color: var(--text-muted); white-space: nowrap; }
.tag-concept { color: #6cb6ff; } .tag-predict { color: #c792ea; } .tag-implement { color: var(--good); }
.tag-debug { color: var(--mid); } .tag-advanced { color: var(--bad); } .tag-interview { color: #4fc3a1; }
.tag-level { letter-spacing: 1px; color: var(--mid); }
.tag-link:hover { color: var(--accent); text-decoration: none; }
.status-ok { color: var(--good); background: var(--good-soft); }
.status-help { color: var(--mid); background: var(--mid-soft); }
.status-ko { color: var(--bad); background: var(--bad-soft); }
.status-new { color: var(--text-muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 2px 10px; border: 1px solid var(--border); border-radius: 12px; color: var(--text); }

.list-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 6px; color: var(--text); font-size: 14px; }
.list-row:hover { background: var(--bg-sunk); text-decoration: none; }
.mark { width: 18px; text-align: center; font-weight: 700; color: var(--text-muted); }
.mark.ok { color: var(--good); } .mark.help { color: var(--mid); } .mark.ko { color: var(--bad); }

/* ---------------------------------------------------------------- dashboard */
.hero { background: linear-gradient(135deg, var(--accent-soft), transparent 70%), var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: 24px 26px; }
.hero h2 { font-size: 24px; margin: 4px 0; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.tile { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tile-label { font-size: 12px; color: var(--text-muted); }
.tile-value { font-size: 22px; font-weight: 700; margin: 2px 0; }
.tile-detail { font-size: 12px; color: var(--text-muted); }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.module-tile { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--border); border-top: 3px solid var(--st, var(--border)); background: var(--bg-elev); color: var(--text); }
.module-tile:hover { text-decoration: none; border-color: var(--accent); }
.module-tile.pending { opacity: 0.55; }
.module-tile-id { font-family: var(--mono); font-size: 11px; color: var(--text-muted); }
.module-tile-title { font-size: 13px; font-weight: 600; line-height: 1.3; min-height: 34px; }
.module-tile-foot { font-size: 11px; color: var(--text-muted); }

/* ---------------------------------------------------------------- path, module */
.path-modules { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.path-module { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); }
.path-module:hover { border-color: var(--accent); text-decoration: none; }
.path-module.pending { opacity: 0.6; }
.path-progress { width: 140px; text-align: right; font-size: 12px; }
.requires { font-size: 12px; color: var(--text-muted); }
.module-meta { margin-bottom: 18px; }
.topic-card .scope { font-size: 13px; }
.topic-card.pending { opacity: 0.7; }

/* ---------------------------------------------------------------- topic and lesson */
.topic-head { margin-bottom: 16px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.tab { padding: 8px 14px; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 14px; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.lesson-layout { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 28px; }
.toc { position: sticky; top: 70px; align-self: start; font-size: 13px; display: flex; flex-direction: column; gap: 4px; border-left: 1px solid var(--border); padding-left: 14px; max-height: calc(100vh - 90px); overflow-y: auto; }
.toc a { color: var(--text-muted); }
.toc a:hover { color: var(--accent); text-decoration: none; }
.toc-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 4px; }
details.french { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 16px; margin-bottom: 20px; }
details.french summary { cursor: pointer; font-weight: 600; }
.lesson-end { justify-content: flex-end; margin-top: 20px; }
.key-points li { margin-bottom: 4px; }

.md { overflow-wrap: break-word; }
.md p { margin: 0 0 0.9em; }
.md h2 { margin-top: 1.8em; padding-top: 0.4em; border-top: 1px solid var(--border); scroll-margin-top: 70px; }
.md h3 { margin-top: 1.4em; }
.md ul, .md ol { padding-left: 1.4em; margin: 0 0 0.9em; }
.md li { margin-bottom: 0.25em; }
.md li > ul, .md li > ol { margin: 0.3em 0; }
.md code { background: var(--bg-sunk); border: 1px solid var(--border); padding: 0 4px; border-radius: 4px; font-size: 0.88em; }
.md pre code { background: none; border: 0; padding: 0; font-size: 13px; }
.md blockquote { margin: 1em 0; padding: 10px 16px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 6px 6px 0; }
.md blockquote p:last-child { margin: 0; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1.5em 0; }
.lesson { font-size: 15.5px; }
.table-wrap { overflow-x: auto; margin: 0 0 1em; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
th { background: var(--bg-sunk); font-weight: 600; }

pre.code, pre.output { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; overflow-x: auto; margin: 0 0 1em; line-height: 1.5; tab-size: 4; }
pre.output { font-family: var(--mono); font-size: 13px; white-space: pre-wrap; border-style: dashed; }
.output-error { color: var(--bad); }
.output-muted { color: var(--text-muted); }
.t-kw { color: var(--t-kw); } .t-str { color: var(--t-str); } .t-num { color: var(--t-num); } .t-com { color: var(--t-com); font-style: italic; }
.t-def { color: var(--t-def); } .t-bi { color: var(--t-bi); } .t-dec { color: var(--t-dec); } .t-self { color: var(--t-self); }
.snippet { margin: 0 0 1.2em; }
.snippet pre.code, .snippet .editor-holder { margin-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.snippet-bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-top: 0; background: var(--bg-sunk); border-radius: 0 0 var(--radius) var(--radius); }
.snippet-note { font-size: 12px; color: var(--text-muted); }
.snippet pre.output { margin-top: 6px; }

/* ---------------------------------------------------------------- editor */
.editor-holder { margin-bottom: 10px; }
.ed { display: flex; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--code-bg); overflow: hidden; font-family: var(--mono); font-size: 13px; line-height: 1.5; }
.ed:focus-within { border-color: var(--accent); }
.ed-gutter { padding: 12px 8px 12px 12px; text-align: right; color: var(--t-com); user-select: none; background: var(--bg-sunk); border-right: 1px solid var(--border); min-width: 42px; }
.ed-gutter span { display: block; }
.ed-scroll { position: relative; flex: 1; overflow-x: auto; min-height: 120px; }
.ed-pre, .ed-input { margin: 0; padding: 12px 14px; font: inherit; line-height: inherit; white-space: pre; tab-size: 4; border: 0; }
.ed-pre { pointer-events: none; min-width: 100%; display: inline-block; }
.ed-input { position: absolute; inset: 0; height: 100%; color: transparent; caret-color: var(--text); background: transparent; resize: none; outline: none; overflow: hidden; }
.ed-input::selection { background: var(--accent-soft); color: transparent; }
.ed-readonly .ed-input { caret-color: transparent; }

/* ---------------------------------------------------------------- exercises */
.ex-nav { margin-bottom: 14px; }
.ex { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 20px 22px; }
.ex-header { margin-bottom: 10px; }
.ex-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.ex-title { font-size: 20px; margin: 0; }
.ex-prompt { margin: 10px 0 14px; }
.ex-input { margin-bottom: 12px; }
.ex-actions, .ex-help-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.keys { margin-left: auto; }
.input-label { display: block; font-size: 13px; color: var(--text-muted); margin: 6px 0 4px; }
.input-note { font-size: 12px; color: var(--text-muted); }
.answer-box { width: 100%; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--code-bg); color: var(--text); font: inherit; resize: vertical; }
.answer-box.mono { font-family: var(--mono); font-size: 13px; }
.answer-box:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.options { display: flex; flex-direction: column; gap: 8px; }
.option { display: flex; align-items: flex-start; gap: 10px; text-align: left; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg); color: var(--text); font: inherit; cursor: pointer; }
.option:hover { border-color: var(--accent); }
.option.selected { border-color: var(--accent); background: var(--accent-soft); }
.options.locked .option { cursor: default; }
.option.right { border-color: var(--good); background: var(--good-soft); }
.option.missed { border-color: var(--good); border-style: dashed; }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option-key { font-family: var(--mono); font-weight: 700; color: var(--text-muted); width: 18px; flex-shrink: 0; }
.option-text { flex: 1; }
.option-tag { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.tests-spec { margin-top: 8px; font-size: 14px; }
.tests-spec summary, .solution-details summary, details summary { cursor: pointer; color: var(--text-muted); }
.hints { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.hint { border-left: 3px solid var(--mid); background: var(--mid-soft); padding: 8px 12px; border-radius: 0 6px 6px 0; }
.hint-label { font-size: 12px; font-weight: 600; color: var(--mid); }
.hint .md p:last-child { margin: 0; }
.feedback, .ex-feedback { margin-top: 10px; }
.verdict { font-weight: 600; padding: 8px 12px; border-radius: 6px; margin-bottom: 10px; background: var(--bg-sunk); }
.verdict.good { color: var(--good); background: var(--good-soft); }
.verdict.mid { color: var(--mid); background: var(--mid-soft); }
.verdict.bad { color: var(--bad); background: var(--bad-soft); }
.critique { margin: 0 0 12px; }
.fb-block { margin: 14px 0; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.line-ok { color: var(--good); } .line-ko { color: var(--bad); }
.run-meta { font-size: 12px; color: var(--text-muted); margin: 4px 0 10px; }
.run-meta.bad { color: var(--bad); }
.test-list { list-style: none; padding: 0; margin: 0 0 10px; }
.test-list li { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; padding: 4px 0; border-bottom: 1px solid var(--border); }
.test-list li.ok .test-mark { color: var(--good); } .test-list li.ko .test-mark { color: var(--bad); }
.test-mark { font-weight: 700; width: 16px; }
.test-name { font-family: var(--mono); font-size: 13px; }
.test-doc { font-size: 12px; color: var(--text-muted); }
.test-error { width: 100%; margin: 4px 0 4px 24px; color: var(--bad); font-size: 12px; white-space: pre-wrap; background: none; border: 0; padding: 0; }
.solution-details details { border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; margin-bottom: 8px; }
.solution-details details[open] summary { margin-bottom: 8px; }
.rubric { list-style: none; padding: 0; margin: 0; }
.rubric li { padding: 6px 8px; border-radius: 6px; margin-bottom: 4px; }
.rubric li.ok { background: var(--good-soft); }
.rubric li.ko { background: var(--bad-soft); }
.rubric label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.followups li { margin-bottom: 8px; }
.next-bar { margin-top: 14px; display: flex; justify-content: flex-end; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 8px; padding: 3px 0; color: var(--text-muted); }
.checklist li.ok { color: var(--text); }

/* ---------------------------------------------------------------- review, interview, exams */
.mode-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.timer { font-family: var(--mono); font-size: 18px; font-weight: 600; padding: 4px 12px; border: 1px solid var(--border); border-radius: 6px; }
.timer.late { color: var(--bad); border-color: var(--bad); }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.choice { text-align: left; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); color: var(--text); font: inherit; cursor: pointer; }
.choice:hover, .choice.selected { border-color: var(--accent); }
.choice.selected { background: var(--accent-soft); }
.choice strong { display: block; margin-bottom: 4px; }
.choice span { font-size: 13px; color: var(--text-muted); }
.exam-question { margin-bottom: 18px; }
.exam-nav { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 14px; }
.exam-nav button { width: 32px; height: 28px; border-radius: 5px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text); cursor: pointer; font-size: 12px; }
.exam-nav button.answered { background: var(--accent-soft); border-color: var(--accent); }
.exam-nav button.current { outline: 2px solid var(--accent); }
.exam-nav button.ok { background: var(--good-soft); border-color: var(--good); }
.exam-nav button.ko { background: var(--bad-soft); border-color: var(--bad); }
.score-big { font-size: 44px; font-weight: 800; }
.score-table td:last-child, .score-table th:last-child { text-align: right; }

/* ---------------------------------------------------------------- progress, search */
.progress-table td, .progress-table th { white-space: nowrap; }
.progress-table td:first-child { white-space: normal; }
.search-row { align-items: flex-start; }
.excerpt { font-size: 13px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .lesson-layout { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  #sidebar { position: fixed; left: 0; top: 0; z-index: 20; transform: translateX(-100%); transition: transform 0.2s; box-shadow: 0 0 40px rgba(0,0,0,0.4); }
  #app.menu-open #sidebar { transform: none; }
  #menu-button { display: block; }
  #main { padding: 18px 16px 60px; }
  #topbar { padding: 8px 12px; }
  #runner-status { display: none; }
  .columns, .columns.two, .compare { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .ex { padding: 16px 14px; }
  .keys { display: none; }
  .path-progress { width: 80px; }
}

/* ================================================================ v2: tabs, cards, stepper, memo, plans, editor */
.ptabs { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); margin: 8px 0 14px; }
.ptabs-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 6px 0; border-bottom: 1px solid var(--border); background: var(--bg-sunk); border-radius: var(--radius) var(--radius) 0 0; }
.ptab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--text-muted); font: inherit; font-size: 13px; padding: 6px 10px; cursor: pointer; margin-bottom: -1px; }
.ptab:hover { color: var(--text); }
.ptab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.ptabs-body { padding: 14px 16px; }
.ptabs-panel > :last-child { margin-bottom: 0; }

.concept-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px 2px; margin-bottom: 18px; scroll-margin-top: 70px; }
.cc-head { display: flex; align-items: center; gap: 10px; }
.cc-head h3 { margin: 0; flex: 1; }
.cc-index { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.cc-cx { font-family: var(--mono); font-size: 12px; color: var(--mid); background: var(--mid-soft); padding: 2px 8px; border-radius: 5px; white-space: nowrap; }
.concept-card .ptabs { border: 0; background: none; margin: 8px -16px 0; border-radius: 0; }
.concept-card .ptabs-bar { border-radius: 0; }
.tldr { border-left: 3px solid var(--accent); }
.toc-extra { margin-top: 8px; color: var(--accent) !important; }

.think-first { background: var(--mid-soft); border-left: 3px solid var(--mid); border-radius: 0 6px 6px 0; padding: 8px 12px; margin: 10px 0; }
.think-first summary { cursor: pointer; }
.tf-label { font-size: 13px; font-weight: 600; color: var(--mid); }
.think-first .md p:last-child, .think-first ul { margin-bottom: 0; }
.traps li { margin-bottom: 6px; }
.traps li::marker { content: '⚠ '; color: var(--bad); }

.faq { display: flex; flex-direction: column; gap: 6px; }
.faq-item { border: 1px solid var(--border); border-radius: 6px; padding: 7px 12px; background: var(--bg); }
.faq-item summary { cursor: pointer; color: var(--text); font-weight: 600; font-size: 14px; }
.faq-item[open] summary { margin-bottom: 6px; color: var(--accent); }
.faq-item .md p:last-child { margin-bottom: 0; }

.cx { display: flex; flex-direction: column; gap: 6px; }
.cx-row { display: flex; gap: 12px; align-items: baseline; }
.cx-label { width: 70px; flex-shrink: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.cx-value { font-size: 14px; }
.cx-value code { color: var(--mid); }
.cx-sub { font-size: 12px; font-weight: 600; color: var(--text-muted); margin: 6px 0 2px; }

.codebox { margin-bottom: 10px; }
.codebox pre.code, .codebox .editor-holder { margin-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.cb-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-top: 0; background: var(--bg-sunk); border-radius: 0 0 var(--radius) var(--radius); }
.cb-result { margin-top: 6px; }
.btn-step { border-color: var(--mid); color: var(--mid); }
.example { margin-bottom: 14px; }
.example-title { font-weight: 600; margin-bottom: 2px; }

/* stepper */
.stepper { border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg); padding: 10px; outline: none; }
.stepper:focus { border-color: var(--mid); }
.st-note { font-size: 13px; color: var(--mid); margin-bottom: 8px; }
.st-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.st-slider { flex: 1; min-width: 120px; accent-color: var(--mid); }
.st-counter { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }
.st-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 10px; }
.st-code { background: var(--code-bg); border: 1px solid var(--border); border-radius: 6px; font-family: var(--mono); font-size: 13px; line-height: 1.55; max-height: 420px; overflow: auto; padding: 6px 0; position: relative; }
.st-line { display: flex; gap: 10px; padding: 0 10px; white-space: pre; cursor: pointer; border-left: 3px solid transparent; }
.st-line:hover { background: var(--bg-sunk); }
.st-num { color: var(--t-com); width: 24px; text-align: right; flex-shrink: 0; user-select: none; }
.st-line.st-current { background: var(--mid-soft); border-left-color: var(--mid); }
.st-line.st-prev { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.st-right { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.st-event { font-size: 13px; font-weight: 600; padding: 4px 8px; border-radius: 5px; background: var(--bg-sunk); }
.st-event.ev-call { color: var(--accent); } .st-event.ev-return { color: var(--good); } .st-event.ev-exception { color: var(--bad); }
.st-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-top: 6px; }
.st-stack { display: flex; flex-wrap: wrap; gap: 4px; }
.st-frame { font-family: var(--mono); font-size: 12px; padding: 1px 7px; border: 1px solid var(--border); border-radius: 4px; color: var(--text-muted); }
.st-frame.top { border-color: var(--accent); color: var(--accent); }
.st-vars { width: 100%; font-family: var(--mono); font-size: 12.5px; }
.st-vars td { border: 0; border-bottom: 1px solid var(--border); padding: 3px 6px; }
.st-name { color: var(--t-def); width: 1%; white-space: nowrap; }
.st-value { word-break: break-all; }
.st-vars tr.st-changed td { background: var(--mid-soft); }
.st-vars tr.st-changed .st-value { color: var(--mid); font-weight: 600; }
.st-out { max-height: 140px; overflow: auto; margin: 0; }

/* editor v2 */
.ed-wrap { position: relative; }
.ed-marks { position: absolute; inset: 0; pointer-events: none; }
.ed-squiggle { position: absolute; height: 3px; background: repeating-linear-gradient(135deg, var(--bad) 0 2px, transparent 2px 4px); pointer-events: auto; }
.ed-gutter .ed-bad { color: var(--bad); font-weight: 700; cursor: help; }
.ed-gutter .ed-bad::before { content: '● '; font-size: 9px; }
.ed-complete { position: absolute; z-index: 30; min-width: 220px; max-width: 460px; max-height: 260px; overflow-y: auto; background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,0.35); font-family: var(--mono); font-size: 12.5px; }
.ed-item { display: flex; gap: 8px; align-items: center; padding: 3px 8px; cursor: pointer; white-space: nowrap; }
.ed-item.selected, .ed-item:hover { background: var(--accent-soft); }
.ed-kind { width: 16px; height: 16px; border-radius: 3px; display: grid; place-items: center; font-size: 10px; background: var(--bg-sunk); color: var(--text-muted); flex-shrink: 0; }
.ed-kind-function { color: var(--t-def); } .ed-kind-class { color: var(--t-dec); } .ed-kind-keyword { color: var(--t-kw); } .ed-kind-module { color: var(--t-bi); }
.ed-name { color: var(--text); }
.ed-desc { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
.ed-problems { font-size: 12.5px; margin-top: 4px; color: var(--bad); }
.ed-problems ul { margin: 4px 0 0; padding-left: 18px; color: var(--text); }

/* memo */
.memo-top { position: sticky; top: 52px; z-index: 3; background: var(--bg); padding: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.memo-nav { display: flex; flex-wrap: wrap; gap: 6px; }
.memo-section { margin-bottom: 26px; scroll-margin-top: 140px; }
.memo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(480px, 1fr)); gap: 12px; }
.memo-grid-wide { grid-template-columns: 1fr; }
.memo-item { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.memo-title { text-transform: none; letter-spacing: 0; color: var(--text); font-size: 15px; margin-bottom: 6px; }
.memo-item table { font-size: 13px; }
.tpl-head { display: flex; align-items: center; gap: 10px; }
.tpl-head .memo-title { flex: 1; margin: 0; }
.memo-template .ptabs { margin-bottom: 0; }
.memo-drawer { position: fixed; top: 0; right: 0; width: min(760px, 92vw); height: 100vh; background: var(--bg); border-left: 1px solid var(--border-strong); box-shadow: -10px 0 40px rgba(0,0,0,0.35); z-index: 40; overflow-y: auto; padding: 0 18px 40px; transform: translateX(105%); transition: transform 0.2s; }
.memo-drawer.open { transform: none; }
.memo-drawer .memo-top { top: 44px; }
.drawer-head { position: sticky; top: 0; z-index: 4; background: var(--bg); padding: 10px 0; border-bottom: 1px solid var(--border); }
.memo-drawer .memo-grid { grid-template-columns: 1fr; }

/* plans and session */
.plan-card { display: block; color: var(--text); }
.plan-card:hover { border-color: var(--accent); text-decoration: none; }
.plan-chips { margin-top: 8px; }
.session-row.done .grow { text-decoration: line-through; color: var(--text-muted); }
.session-row .tag { min-width: 90px; text-align: center; }
.num-input, .text-input { padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--bg); color: var(--text); font: inherit; }
.num-input { width: 80px; }
.text-input { width: 100%; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-muted); margin-bottom: 10px; flex: 1; }
.topic-picker { max-height: 460px; overflow-y: auto; margin-top: 10px; border: 1px solid var(--border); border-radius: 6px; padding: 6px; }
.picker-module { font-size: 12px; font-weight: 700; color: var(--text-muted); margin: 10px 4px 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.picker-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 5px; cursor: pointer; font-size: 14px; }
.picker-row:hover { background: var(--bg-sunk); }
.prio { padding: 3px 6px; border-radius: 5px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: 12px; }
.variant-row .grow { color: var(--text-muted); }
.oral-bar { margin-bottom: 6px; }

/* sidebar tracks (collapsible) */
.nav-track { display: flex; align-items: center; gap: 6px; width: 100%; background: none; border: 0; text-align: left; cursor: pointer; padding: 6px 10px; margin: 6px 0 2px; font: inherit; font-size: 12px; font-weight: 600; color: var(--text-muted); border-radius: 6px; }
.nav-track:hover { background: var(--bg-sunk); color: var(--text); }
.nav-caret { width: 10px; }
.nav-track-count { font-family: var(--mono); font-size: 11px; }

@media (max-width: 1100px) { .st-grid { grid-template-columns: 1fr; } }

/* stepper: drawn structures */
.st-structs-block { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 6px; }
.st-structs { display: flex; flex-direction: column; gap: 10px; }
.sv-var { display: flex; gap: 10px; align-items: flex-start; }
.sv-name { font-family: var(--mono); font-size: 12.5px; color: var(--t-def); min-width: 110px; padding-top: 6px; }
.sv-kind { display: block; font-family: var(--sans); font-size: 10.5px; color: var(--text-muted); }
.sv-seq { display: flex; flex-wrap: wrap; gap: 0; }
.sv-slot { display: flex; flex-direction: column; align-items: center; border: 1px solid var(--border-strong); margin-left: -1px; min-width: 38px; background: var(--code-bg); }
.sv-set .sv-slot, .sv-frozenset .sv-slot { border-radius: 14px; margin: 0 4px 4px 0; }
.sv-index { font-size: 10px; color: var(--text-muted); border-bottom: 1px solid var(--border); width: 100%; text-align: center; padding: 0 4px; }
.sv-text { font-family: var(--mono); font-size: 12.5px; padding: 3px 7px; white-space: nowrap; }
.sv-changed { background: var(--mid-soft); color: var(--mid); font-weight: 700; }
.sv-dict { display: grid; grid-template-columns: auto auto; gap: 0; border: 1px solid var(--border-strong); background: var(--code-bg); }
.sv-pair { display: contents; }
.sv-key { font-family: var(--mono); font-size: 12.5px; padding: 3px 8px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); color: var(--t-str); }
.sv-dict .sv-text, .sv-dict .sv-ref { border-bottom: 1px solid var(--border); }
.sv-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sv-obj { border: 1px solid var(--accent); border-radius: 6px; background: var(--code-bg); min-width: 90px; transition: box-shadow 0.15s; }
.sv-obj.sv-hot { box-shadow: 0 0 0 3px var(--accent-soft); }
.sv-obj.sv-changed-box { border-color: var(--mid); }
.sv-obj-title { font-size: 11px; font-weight: 700; color: var(--accent); padding: 2px 7px; border-bottom: 1px solid var(--border); }
.sv-field { display: flex; justify-content: space-between; gap: 8px; }
.sv-fname { font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); padding: 3px 0 3px 7px; }
.sv-ref { font-family: var(--mono); font-size: 12px; color: var(--accent); padding: 3px 7px; cursor: help; white-space: nowrap; }
.sv-arrow { color: var(--text-muted); font-size: 16px; }
.sv-none { font-family: var(--mono); font-size: 12px; color: var(--text-muted); border: 1px dashed var(--border-strong); border-radius: 5px; padding: 2px 6px; }
.st-help { font-size: 11.5px; color: var(--text-muted); margin-top: 8px; }

/* ================================================================ v3: hierarchy and UX */
/* summary as bullets */
.tldr { border-left: 3px solid var(--accent); padding: 12px 18px; }
.tldr-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); font-weight: 700; margin-bottom: 4px; }
.tldr-list { margin: 0; padding-left: 1.2em; }
.tldr-list li { margin-bottom: 3px; }

/* clearer blocks: idea / think first / traps / code */
.ptabs-panel .md p { max-width: 74ch; }
.traps-panel { background: var(--bad-soft); border-left: 3px solid var(--bad); border-radius: 0 6px 6px 0; padding: 8px 12px 2px; }
.traps-panel li::marker { content: '⚠ '; color: var(--bad); }
.codebox pre.code, .st-code { background: var(--bg-sunk); }
.concept-card { box-shadow: 0 1px 0 rgba(0,0,0,0.25); }
.concept-card .cc-head h3 { font-size: 17px; }
.read-toggle { font-size: 12px; padding: 2px 9px; color: var(--text-muted); }
.read-toggle.done { color: var(--good); border-color: var(--good); background: var(--good-soft); }
.toc a.read::after { content: ' ✓'; color: var(--good); }
.ex-minutes { font-size: 12px; min-width: 52px; text-align: right; }

/* home */
.start-step { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--border); }
.start-step:first-of-type { border-top: 0; }
.start-step p { margin: 2px 0 0; }
.tiles-4 { grid-template-columns: repeat(4, 1fr); }
.home-session { border-top: 3px solid var(--accent); }
.session-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 10px; }
.session-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.budget { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.session-row.next { background: var(--accent-soft); }
.session-row.next .mark { color: var(--accent); }

/* nav */
.nav-key { margin-left: auto; font-family: var(--mono); font-size: 10.5px; color: var(--text-muted); border: 1px solid var(--border-strong); border-radius: 4px; padding: 0 5px; }
.nav-count.big { font-size: 12px; padding: 2px 9px; }
.topbar-right a.icon-button { text-decoration: none; display: inline-block; line-height: 1.2; }

/* training hub */
.train-grid { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.train-card { display: flex; gap: 16px; align-items: center; padding: 18px 20px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-elev); color: var(--text); }
.train-card:hover { border-color: var(--accent); text-decoration: none; }
.train-card h3 { margin: 0 0 4px; }
.train-card p { margin: 0; }
.train-icon { font-size: 28px; width: 44px; text-align: center; }

/* exercise actions: one primary, a secondary group, an overflow menu */
.action-group { display: inline-flex; gap: 6px; padding-left: 8px; margin-left: 2px; border-left: 1px solid var(--border); }
.more-menu { position: relative; }
.more-menu > summary { list-style: none; cursor: pointer; }
.more-menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; z-index: 20; top: 110%; left: 0; min-width: 230px; background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.35); padding: 4px; display: flex; flex-direction: column; }
.menu-item { background: none; border: 0; text-align: left; justify-content: flex-start; width: 100%; }
.menu-item:hover { background: var(--bg-sunk); }
.ex-actions { padding: 10px 0; border-top: 1px solid var(--border); }

/* help overlay */
.help-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,0.55); display: grid; place-items: center; padding: 20px; }
.help-box { background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 12px; padding: 20px 24px; max-width: 640px; width: 100%; max-height: 86vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.help-box h2 { margin: 0; }

@media (max-width: 1100px) { .tiles-4 { grid-template-columns: repeat(2, 1fr); } }

.cc-cx { max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 1; }
.cc-cx code { background: none; border: 0; padding: 0; color: inherit; }
.cc-head h3 { min-width: 0; }

/* ================================================================ drawings (trees, heaps, graphs, grids) */
.viz-wrap { display: flex; flex-direction: column; gap: 4px; overflow-x: auto; }
.viz { display: block; max-width: 100%; }
.viz-edge { stroke: var(--border-strong); stroke-width: 1.6; }
.viz-arrowhead { fill: var(--border-strong); }
.viz-node circle { fill: var(--code-bg); stroke: var(--accent); stroke-width: 1.6; transition: fill 0.25s, stroke 0.25s; }
.viz-node text { fill: var(--text); font-family: var(--mono); font-size: 11.5px; }
.viz-node .viz-note { fill: var(--text-muted); font-size: 9.5px; }
.viz-node.viz-changed circle { fill: var(--mid-soft); stroke: var(--mid); stroke-width: 2.4; }
.viz-node.viz-visited circle { fill: var(--good-soft); stroke: var(--good); }
.viz-node.viz-queued circle { fill: var(--mid-soft); stroke: var(--mid); stroke-dasharray: 3 2; }
.viz-node.viz-current circle { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 3.2; }
.viz-legend { display: flex; gap: 12px; font-size: 11px; color: var(--text-muted); }
.viz-legend span::before { content: '●'; margin-right: 4px; }
.lg-current::before { color: var(--accent); } .lg-queued::before { color: var(--mid); } .lg-visited::before { color: var(--good); }
.viz-caption { font-size: 11.5px; }
.viz-grid { border-collapse: collapse; width: auto; font-family: var(--mono); font-size: 12.5px; }
.viz-grid th { background: none; border: 0; color: var(--text-muted); font-size: 10px; padding: 1px 5px; font-weight: 400; }
.viz-grid td { border: 1px solid var(--border-strong); min-width: 30px; height: 28px; text-align: center; padding: 2px 6px; background: var(--code-bg); transition: background 0.25s; }
.viz-grid td.viz-changed { background: var(--mid-soft); color: var(--mid); font-weight: 700; }
.btn-play { border-color: var(--accent); color: var(--accent); }

/* ================================================================ examiner and resources */
.x-card { border-top: 3px solid #4fc3a1; }
.x-meta { margin-bottom: 8px; }
.x-question { font-size: 19px; line-height: 1.4; margin: 6px 0 12px; }
.x-fr { margin: 10px 0; }
.x-precision { margin: 10px 0; }
.x-warn { color: var(--bad); }
.x-verify { font-size: 12px; margin-top: 10px; }
.x-followups { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.x-followup { border-left: 3px solid var(--accent); padding: 6px 12px; background: var(--accent-soft); border-radius: 0 6px 6px 0; }
.x-followup-q { font-weight: 600; }
.x-followup-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
.x-hint { font-size: 12px; margin: 2px 0 6px; }
.x-followup-answer { margin-top: 6px; }
.x-grade { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.x-ok { border-color: var(--good); color: var(--good); } .x-help { border-color: var(--mid); color: var(--mid); } .x-ko { border-color: var(--bad); color: var(--bad); }
.x-list { margin-top: 12px; }
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 10px; }
.res-card { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-elev); color: var(--text); }
.res-card:hover { border-color: var(--accent); text-decoration: none; }
.res-thumb { width: 128px; height: 72px; object-fit: cover; border-radius: 6px; flex-shrink: 0; background: var(--bg-sunk); }
.res-icon { width: 44px; height: 44px; border-radius: 8px; display: grid; place-items: center; font-size: 22px; background: var(--bg-sunk); flex-shrink: 0; }
.res-kind { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); }
.res-title { font-weight: 600; line-height: 1.3; margin: 2px 0; }
.res-source { font-size: 12.5px; }
.res-why { font-size: 13px; margin-top: 4px; }
.res-open { color: var(--text-muted); }
.res-visualizer .res-kind { color: var(--good); }

/* ================================================================ stepper v4: process view */
.st-event { font-weight: 400; }
.st-event > div:first-child { font-weight: 600; }
.st-changed-line { font-family: var(--mono); font-size: 12px; color: var(--mid); margin-top: 3px; }
.st-narration { margin-top: 6px; padding: 6px 8px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 5px 5px 0; font-size: 13px; }
.st-process { display: flex; flex-direction: column; gap: 8px; }
.st-heap { border: 1px dashed var(--border-strong); border-radius: 8px; padding: 6px 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.st-heap .st-label { width: 100%; margin-top: 0; }
.st-empty { font-size: 12px; }
.st-obj { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--border-strong); border-radius: 6px; padding: 3px 8px; background: var(--code-bg); font-family: var(--mono); font-size: 11.5px; max-width: 100%; transition: box-shadow 0.15s; }
.st-obj.shared { border-color: var(--mid); }
.st-obj.hot { box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }
.st-obj-name { color: var(--accent); font-weight: 700; }
.st-obj-repr { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.st-obj-shared { font-family: var(--sans); font-size: 10px; color: var(--mid); text-transform: uppercase; }
.st-threads { display: grid; grid-template-columns: 1fr; gap: 8px; }
.st-threads.multi { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.st-thread { border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; opacity: 0.7; transition: opacity 0.2s, border-color 0.2s; }
.st-thread.active { opacity: 1; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.st-thread.finished { opacity: 0.45; }
.st-thread-head { display: flex; justify-content: space-between; gap: 6px; font-size: 12.5px; font-weight: 700; }
.st-thread-state { font-weight: 400; font-size: 11.5px; color: var(--text-muted); }
.st-thread.active .st-thread-state { color: var(--accent); }
.st-sublabel { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin: 6px 0 2px; }
.st-frames { display: flex; flex-direction: column-reverse; gap: 2px; }
.st-frame-box { font-family: var(--mono); font-size: 11.5px; border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; color: var(--text-muted); }
.st-frame-box.top { border-color: var(--accent); color: var(--text); }
.st-ref { color: var(--accent); cursor: help; }
.st-line.st-other { background: color-mix(in srgb, var(--mid) 9%, transparent); }
.st-tags { margin-left: auto; padding-left: 10px; font-family: var(--sans); font-size: 10.5px; color: var(--mid); }

/* ================================================================ v4: bilingual course, callouts, anecdotes, parsons, badges */
.lesson-top { justify-content: flex-end; margin-bottom: 8px; }
.lang-switch { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.lang-btn { background: var(--bg-elev); color: var(--text-muted); border: 0; padding: 5px 14px; font: inherit; font-size: 13px; cursor: pointer; }
.lang-btn.active { background: var(--accent); color: #fff; font-weight: 600; }
.lang-note { font-size: 12.5px; }
.keypoint { border: 1px solid var(--good); background: var(--good-soft); border-radius: 8px; padding: 10px 14px; margin: 14px 0; }
.keypoint p:last-child { margin-bottom: 0; }
.keypoint strong:first-child { color: var(--good); }
.anecdote { margin: 10px 0; border-left: 3px solid #b48ead; background: color-mix(in srgb, #b48ead 10%, transparent); border-radius: 0 8px 8px 0; padding: 6px 12px; }
.anecdote summary { cursor: pointer; font-size: 14px; color: var(--text); }
.anecdote summary:hover { color: #b48ead; }
.anecdote-kind { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: #b48ead; font-weight: 700; margin-right: 4px; }
.anecdote[open] summary { margin-bottom: 6px; }
.anecdote .md p:last-child { margin-bottom: 0; }
.toc-note { margin-top: 8px; font-size: 12px; }
.diff-easy { color: var(--good); background: var(--good-soft); }
.diff-medium { color: var(--mid); background: var(--mid-soft); }
.diff-hard { color: var(--bad); background: var(--bad-soft); font-weight: 700; }
.btn-understood { border-color: var(--good); color: var(--good); }
.verdict.inline { display: inline-block; margin: 0; font-size: 13px; }
.understood-row { margin-top: 10px; }
.quiz-card .row h3 { margin: 0; }
.parsons { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.parsons.locked { pointer-events: none; opacity: 0.8; }
.parsons-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--code-bg); cursor: grab; }
.parsons-row.dragging { opacity: 0.4; }
.parsons-row.off { opacity: 0.45; text-decoration: line-through; }
.parsons-grip { color: var(--text-muted); }
.parsons-code { flex: 1; font-family: var(--mono); font-size: 13px; white-space: pre; background: none; border: 0; padding: 0; }
.parsons-tools { display: inline-flex; gap: 4px; }
.parsons-tools .icon-button { padding: 1px 7px; font-size: 13px; }
.combined { border-top: 3px solid var(--accent); }
.combined-main { font-size: 20px; margin: 2px 0; }
.constraints { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.constraint { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 6px; background: var(--bg-sunk); font-size: 14px; }
.constraint.tight { outline: 1px solid var(--bad); }
.how { margin-top: 10px; font-size: 13.5px; }
.plan-title { color: var(--text); }
.plan-title h3 { margin: 0; }
.plan-card .row { flex-wrap: wrap; }
.shared-note { margin-top: 4px; }
.option-text pre.code { margin: 0; padding: 6px 10px; }
.option-text .md p { margin: 0; }

/* ================================================================ v4: sidebar hierarchy and course TOC */
#nav-curriculum { margin-top: 2px; }
.nav-track { margin: 14px 0 4px; padding: 6px 10px; border-top: 1px solid var(--border); border-radius: 0; text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px; color: var(--text-muted); }
.nav-track.open { color: var(--text); }
.nav-module { margin: 1px 0; font-size: 13.5px; font-weight: 500; }
.nav-module.active { background: var(--accent-soft); color: var(--text); font-weight: 600; border-radius: 6px 6px 0 0; }
.nav-module-id { font-family: var(--mono); font-size: 10.5px; width: 22px; height: 18px; display: inline-grid; place-items: center; border: 1px solid var(--border-strong); border-radius: 4px; color: var(--text-muted); flex-shrink: 0; }
.nav-module.active .nav-module-id { border-color: var(--accent); color: var(--accent); }
.nav-topic { margin: 0 0 0 20px; padding: 4px 10px 4px 12px; border-left: 2px solid var(--border); border-radius: 0 6px 6px 0; font-size: 12.5px; color: var(--text-muted); }
.nav-topic .dot { width: 7px; height: 7px; }
.nav-topic.active { border-left-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.nav-module.active + .nav-topic, .nav-topic + .nav-topic { margin-top: 0; }
.toc { gap: 2px; }
.toc-link { display: flex; gap: 8px; align-items: baseline; padding: 3px 6px; border-radius: 5px; color: var(--text-muted) !important; line-height: 1.35; }
.toc-link:hover { background: var(--bg-sunk); text-decoration: none; }
.toc-link.active { background: var(--accent-soft); color: var(--accent) !important; font-weight: 600; }
.toc-num { font-family: var(--mono); font-size: 10.5px; min-width: 16px; color: var(--text-muted); }
.toc-text { flex: 1; }
.toc-dot { font-size: 10px; }
.lang-toggle { font-size: 12px; font-weight: 700; min-width: 36px; }

.py-select { font: inherit; font-size: 12px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--bg-sunk); color: var(--text); cursor: pointer; }
#runner-status .py-select { border: none; background: transparent; padding: 0; }

.nav-module-caret { display: inline-block; width: 1em; flex: none; text-align: center; opacity: 0.7; cursor: pointer; }
.nav-module-caret:hover { opacity: 1; }

/* History box: same shape as an anecdote, another colour */
.history { margin: 10px 0; border-left: 3px solid #d08770; background: color-mix(in srgb, #d08770 10%, transparent); border-radius: 0 8px 8px 0; padding: 6px 12px; }
.history summary { cursor: pointer; font-size: 14px; color: var(--text); }
.history .anecdote-kind { color: #d08770; }

/* LeetCode: modes, recognition game, pattern cards */
.lc-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.lc-mode { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; }
.lc-mode .row { gap: 14px; flex-wrap: wrap; font-size: 14px; }
.lc-list { display: flex; flex-direction: column; }
.lc-score { gap: 18px; flex-wrap: wrap; margin: 10px 0; font-size: 14px; color: var(--muted); }
.lc-choices { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.lc-clock { font-variant-numeric: tabular-nums; font-weight: 700; }
.lc-clock.late { color: #bf616a; }
.lc-pattern { margin: 10px 0; }
.lc-pattern summary { cursor: pointer; }
.callout.ok { border-left: 3px solid #a3be8c; }
.callout.bad { border-left: 3px solid #bf616a; }

/* Placement quiz: path through the bands (site/js/quiz.js) */
.quiz-journey { width: 100%; max-width: 620px; height: auto; display: block; margin: 8px 0; }
.quiz-journey .qj-grid { stroke: var(--border); stroke-width: 1; }
.quiz-journey .qj-label { fill: var(--text-muted); font-size: 12px; }
.quiz-journey .qj-line { fill: none; stroke: var(--text-muted); stroke-width: 2; stroke-linejoin: round; opacity: 0.6; }
.quiz-journey .qj-hit { fill: transparent; }
.quiz-journey .qj-dot { stroke: var(--bg-elev, var(--bg)); stroke-width: 2; }
.quiz-journey .qj-good .qj-dot { fill: var(--good); }
.quiz-journey .qj-mid .qj-dot { fill: var(--mid); }
.quiz-journey .qj-bad .qj-dot { fill: var(--bad); }
.quiz-journey .qj-skip .qj-dot { fill: var(--text-muted); }
.quiz-journey .qj-glyph { fill: #fff; font-size: 11px; font-weight: 700; pointer-events: none; }
.quiz-journey .qj-point:hover .qj-dot, .quiz-journey .qj-point:focus .qj-dot { r: 11; }
.quiz-journey .qj-point:focus { outline: none; }

/* Loading toast of the in-browser Python (js/pyrun.js): a small spinner before the text. */
.py-loading::before { content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 8px; vertical-align: -1px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: py-spin .8s linear infinite; }
@keyframes py-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .py-loading::before { animation: none; } }

/* Accounts (js/account.js) */
.account-form { display: grid; gap: 10px; max-width: 460px; }
.account-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.account-message:empty { display: none; }
.account-message.bad { color: var(--bad); }
.account-message.ok { color: var(--good); }
.account-or { text-align: center; font-size: 13px; }
.account-confirm { border-left: 3px solid var(--bad); padding-left: 12px; }
.account-form .small { font-size: 12px; margin: 0; }
.link-button { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.link-button:hover { text-decoration: underline; }
#account-button.signed-in { border-color: var(--accent); color: var(--accent); }
.admin-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 12px; }
.admin-tiles .admin-tile { margin: 0; }
.admin-tile-value { font-size: 26px; font-weight: 700; }
.admin-table td, .admin-table th { white-space: nowrap; }
#account-button[hidden] { display: none; }
