/* Geant4 2.0 course pages — shared style.
   Layout: each page reads as one Geant4 run. Left rail = macro command, right = what it produces.
   Tokens are copied from the landing page (landing.html) so every week matches it exactly. */
:root {
  --bg: #F6F7F5;          /* ROOT canvas paper */
  --panel: #FFFFFF;
  --fg: #12161A;
  --muted: #59636D;
  --rule: rgba(18,22,26,0.16);
  --frame: #12161A;
  --neg: #D1323B;         /* Geant4 vis: negative = red */
  --neu: #1B7B4B;         /* neutral = green (darkened from #23935A for AA text contrast) */
  --pos: #2C55E0;         /* positive = blue */
  --hist: #2C55E0;
  --warn: #9A6A00;
  --display-bg: #10161B;  /* event display stays dark in both themes */
  --display-fg: #DCE3E8;
  --display-muted: #8FA0AC;
  --display-rule: rgba(220,227,232,0.16);
  --hit: #F2D06B;         /* hit marker in event displays */
  --tint-neu: rgba(27,123,75,0.10);
  --tint-neg: rgba(209,50,59,0.08);
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, "Noto Sans SC", monospace;
  --head: "IBM Plex Sans Condensed", "Arial Narrow", "Helvetica Neue", "Noto Sans SC", "PingFang SC", sans-serif;
  --sans: "IBM Plex Sans", "Helvetica Neue", Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --zh: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "IBM Plex Sans", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12181D; --panel: #182027; --fg: #E4E9EC; --muted: #93A0AA;
    --rule: rgba(228,233,236,0.14); --frame: #C9D2D8;
    --neg: #FF6369; --neu: #4FC98A; --pos: #7393FF; --hist: #7393FF; --warn: #E2B04A;
    --display-bg: #0B1014;
    --tint-neu: rgba(79,201,138,0.12); --tint-neg: rgba(255,99,105,0.10);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12181D; --panel: #182027; --fg: #E4E9EC; --muted: #93A0AA;
  --rule: rgba(228,233,236,0.14); --frame: #C9D2D8;
  --neg: #FF6369; --neu: #4FC98A; --pos: #7393FF; --hist: #7393FF; --warn: #E2B04A;
  --display-bg: #0B1014;
  --tint-neu: rgba(79,201,138,0.12); --tint-neg: rgba(255,99,105,0.10);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg); color: var(--fg);
  font: 400 16px/1.6 var(--sans);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 72px;
}
.wrap { max-width: 1100px; margin: 0 auto; }
code, .mono { font-family: var(--mono); font-size: 0.9em; }
a { color: var(--pos); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--pos); outline-offset: 2px; }
sub, sup { line-height: 0; }

/* ---------- language toggle: html[data-lang] = en | zh | both ---------- */
[lang="zh-Hans"] { font-family: var(--zh); }
html[data-lang="en"] [lang="zh-Hans"] { display: none !important; }
html[data-lang="zh"] [lang="en"]:not(.kt):not(html) { display: none !important; }
html[data-lang="both"] p[lang="zh-Hans"], html[data-lang="both"] li > span[lang="zh-Hans"],
html[data-lang="both"] div[lang="zh-Hans"] { color: var(--muted); }
html[data-lang="both"] p[lang="en"] + p[lang="zh-Hans"] { margin-top: -6px; }
html[data-lang="both"] .bi > [lang="zh-Hans"] { display: block; font-size: 0.92em; color: var(--muted); }
html[data-lang="both"] h1.bi > [lang="zh-Hans"], html[data-lang="both"] h2.bi > [lang="zh-Hans"] { font-size: 0.62em; font-weight: 600; margin-top: 8px; color: var(--muted); }
/* key terms: in Chinese mode the English term is shown next to the Chinese one; English mode shows English only */
.kt { font: 400 0.82em var(--zh); color: var(--muted); margin-left: 0.3em; white-space: nowrap; }
.kt[lang="en"] { font-family: var(--mono); font-size: 0.78em; }
html[data-lang="both"] .kt { display: none; }
dfn { font-style: normal; font-weight: 500; }

.lang { display: inline-flex; border: 1px solid var(--rule); border-radius: 3px; overflow: hidden; }
.lang button { font: 500 0.78rem/1 var(--mono); background: transparent; color: var(--muted); border: 0; padding: 7px 10px; cursor: pointer; }
.lang button + button { border-left: 1px solid var(--rule); }
.lang button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }

/* ---------- top bar ---------- */
.bar { display: flex; flex-wrap: wrap; gap: 10px 24px; justify-content: space-between; align-items: center;
  padding-block: 14px; border-bottom: 1px solid var(--rule); font: 500 0.82rem/1.4 var(--mono); color: var(--muted); }
.bar b { color: var(--fg); font-weight: 500; }
.bar a { color: inherit; text-decoration: none; }
.bar a:hover { color: var(--fg); }
.bar-r { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }

/* ---------- hero ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); gap: 40px; padding-block: 44px 48px; align-items: end; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; gap: 24px; padding-block: 28px 36px; } }
.hero > * { min-width: 0; }
.prompt { font: 400 0.85rem/1.5 var(--mono); color: var(--muted); margin: 0 0 18px; }
.prompt span { color: var(--neg); }
h1, h2, h3 { font-family: var(--head); font-weight: 700; letter-spacing: -0.01em; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(2.2rem, 5.2vw, 3.8rem); line-height: 1.02; }
h2 { font-size: clamp(1.5rem, 3.2vw, 2.15rem); line-height: 1.12; }
h3 { font-size: 1.2rem; line-height: 1.25; font-weight: 600; margin-top: 30px; }
.lede { font-size: 1.1rem; color: var(--muted); max-width: 52ch; margin: 20px 0 0; }
.meta { list-style: none; padding: 0; margin: 26px 0 0; display: flex; flex-wrap: wrap; gap: 8px 32px; font: 400 0.8rem/1.5 var(--mono); color: var(--muted); }
.meta b { display: block; color: var(--fg); font: 600 1.3rem/1.2 var(--head); }
.meta .stage b { color: var(--neg); }

/* ---------- run sections ---------- */
.run { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px 40px; padding-block: 48px; border-top: 1px solid var(--rule); }
@media (max-width: 760px) { .run { grid-template-columns: 1fr; gap: 14px; padding-block: 36px; } }
.run > * { min-width: 0; }
.cmd { font: 500 0.85rem/1.5 var(--mono); color: var(--neg); margin: 0; padding-top: 6px; word-break: break-word; }
.cmd span { display: block; color: var(--muted); font-weight: 400; }
@media (min-width: 761px) { .cmd { position: sticky; top: 16px; align-self: start; } }
.prose p, .prose li { max-width: 64ch; }
.prose p { color: var(--muted); }
.prose p strong, .prose li strong { color: var(--fg); font-weight: 500; }
.run h2 + p, .run h2 + div { margin-top: 14px; }
.prose ul, .prose ol { padding-left: 1.2em; color: var(--muted); }
.prose li + li { margin-top: 6px; }

/* goals */
.goals { list-style: none; padding: 0; margin: 22px 0 0; counter-reset: g; border-top: 1px solid var(--frame); }
.goals li { counter-increment: g; display: grid; grid-template-columns: 3.2em minmax(0, 1fr); gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); max-width: none; }
.goals li::before { content: "G" counter(g); font: 500 0.82rem/1.9 var(--mono); color: var(--neg); }
.goals li > span { grid-column: 2; }
.goals li > span[lang="zh-Hans"] { color: var(--muted); }

/* knowledge boxes (Definition / Example / Theorem): hairline frame, mono label */
.box { margin-top: 26px; border-top: 1px solid var(--frame); border-bottom: 1px solid var(--rule); padding: 12px 0 14px; }
.box-label { font: 500 0.74rem/1.4 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--neg); margin: 0 0 6px; }
.box-label span { color: var(--muted); text-transform: none; letter-spacing: 0; }
.box p { margin: 8px 0 0; color: var(--fg); max-width: 64ch; }
.box p[lang="zh-Hans"] { color: var(--muted); }
/* side notes: read as code comments */
.aside { margin-top: 22px; padding-left: 14px; border-left: 1px solid var(--rule); }
.aside-label { font: 500 0.78rem/1.4 var(--mono); color: var(--muted); margin: 0; }
.aside-label::before { content: "// "; color: var(--neu); }
.aside p { margin: 6px 0 0; color: var(--muted); max-width: 62ch; }

/* equations */
.eq { margin: 18px 0 4px; font: 400 1.15rem/1.6 var(--sans); font-style: normal; display: flex; flex-wrap: wrap; gap: 6px 40px; align-items: center; }
.eq i { font-family: "IBM Plex Sans", serif; font-style: italic; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.15; margin: 0 2px; }
.frac > span:first-child { border-bottom: 1px solid currentColor; padding: 0 3px 1px; }
.frac > span:last-child { padding: 1px 3px 0; }
.sqrt { display: inline-flex; align-items: center; }
.sqrt::before { content: "√"; font-size: 1.5em; line-height: 1; margin-right: 1px; }
.sqrt > span { border-top: 1px solid currentColor; padding: 2px 3px 0; }
.eqno { font: 400 0.78rem var(--mono); color: var(--muted); }

/* flow line (figure in mono) */
.flow { margin-top: 18px; font: 400 0.84rem/1.9 var(--mono); color: var(--fg); background: var(--panel); border: 1px solid var(--rule); border-radius: 4px; padding: 10px 14px; overflow-x: auto; white-space: nowrap; }
.flow .a { color: var(--muted); }
.flow b { font-weight: 500; color: var(--neg); }

/* code */
.code { margin-top: 18px; }
.code-head { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; border: 1px solid var(--rule); border-bottom: 0; border-radius: 4px 4px 0 0; padding: 7px 10px 7px 14px; background: var(--panel); font: 400 0.76rem/1.4 var(--mono); color: var(--muted); }
.code-head b { color: var(--fg); font-weight: 500; }
.code-head .l { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-width: 0; }
.code pre { border-radius: 0 0 4px 4px; }
pre { margin: 0; font: 400 0.82rem/1.6 var(--mono); background: var(--panel); border: 1px solid var(--rule); border-radius: 4px; padding: 14px 16px; overflow-x: auto; color: var(--fg); tab-size: 4; }
pre .c { color: var(--muted); }
pre .ok { color: var(--neu); }
pre .bad { color: var(--neg); }
pre .k { color: var(--pos); }
pre .p { color: var(--neg); }
pre mark { background: var(--tint-neu); color: inherit; border-radius: 2px; padding: 0 2px; }
.out pre { background: transparent; border-style: dashed; }
.copy { font: 500 0.74rem/1 var(--mono); background: transparent; color: var(--fg); border: 1px solid var(--rule); border-radius: 3px; padding: 6px 9px; cursor: pointer; }
.copy:hover { border-color: var(--frame); }
.tag { display: inline-block; font: 500 0.68rem/1 var(--mono); letter-spacing: 0.04em; padding: 4px 6px; border: 1px solid currentColor; border-radius: 999px; }
.tag.geant4 { color: var(--pos); }
.tag.analysis { color: var(--neu); }
.tag.musrsim { color: var(--neg); }
.cap { font: 400 0.76rem/1.5 var(--mono); color: var(--muted); margin: 8px 0 0; max-width: 72ch; }

/* tables */
.scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; margin-top: 22px; font-size: 0.96rem; }
.tbl th { text-align: left; font: 500 0.72rem/1.4 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 0 12px 8px 0; border-bottom: 1px solid var(--frame); }
.tbl td { padding: 12px 12px 12px 0; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
.tbl td.n { font: 500 0.85rem var(--mono); color: var(--neg); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl td.zh { color: var(--muted); }
.tbl td.wk { font: 400 0.85rem var(--mono); color: var(--muted); white-space: nowrap; }
.tbl td.m { color: var(--muted); }
.tbl td [lang="zh-Hans"] { display: block; color: var(--muted); font-size: 0.92em; }
html[data-lang="zh"] .tbl td [lang="zh-Hans"] { color: inherit; font-size: inherit; }

/* stat box (ROOT TPaveStats look) */
.statbox { border: 1px solid var(--frame); background: var(--panel); font: 400 0.84rem/1.5 var(--mono); font-variant-numeric: tabular-nums; }
.statbox div { display: flex; justify-content: space-between; gap: 16px; padding: 6px 12px; border-bottom: 1px solid var(--rule); }
.statbox div:first-child { justify-content: center; border-bottom: 1px solid var(--frame); font-weight: 500; }
.statbox div:last-child { border-bottom: 0; }
.statbox span:last-child { text-align: right; color: var(--muted); }
.statbox .good span:last-child { color: var(--neu); }
.statbox .bad span:last-child { color: var(--neg); }

/* event display + controls */
.display { background: var(--display-bg); color: var(--display-fg); border-radius: 4px 4px 0 0; overflow: hidden; }
.display-head { display: flex; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--display-rule); font: 400 0.75rem/1.4 var(--mono); color: var(--display-muted); }
.display-head .toy { color: var(--hit); }
.display canvas { display: block; width: 100%; max-width: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 10px 14px; border-top: 1px solid var(--display-rule); font: 400 0.75rem/1.4 var(--mono); color: var(--display-muted); }
.legend i { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 6px; }
.legend i.dot { width: 6px; height: 6px; border-radius: 50%; }
.legend i.dash { background: repeating-linear-gradient(90deg, currentColor 0 3px, transparent 3px 6px) !important; }
.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 22px; padding: 14px; background: var(--panel); border: 1px solid var(--rule); border-top: 0; }
.ctl { display: grid; gap: 6px; font: 500 0.76rem/1.4 var(--mono); color: var(--muted); min-width: 0; }
.ctl output { color: var(--fg); font-variant-numeric: tabular-nums; }
.ctl-row { display: flex; justify-content: space-between; gap: 8px; }
.ctl input[type=range] { width: 100%; accent-color: var(--neg); }
select { font: 400 0.92rem var(--sans); color: var(--fg); background: var(--panel); border: 1px solid var(--rule); border-radius: 3px; padding: 8px 10px; width: 100%; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 14px; background: var(--panel); border: 1px solid var(--rule); border-top: 0; }
.btns button, .btn { font: 500 0.82rem/1 var(--mono); background: transparent; color: var(--fg); border: 1px solid var(--frame); border-radius: 3px; padding: 10px 12px; cursor: pointer; }
.btns button.primary, .btn.primary { background: var(--fg); color: var(--bg); }
.btns small { font: 400 0.74rem/1.4 var(--mono); color: var(--muted); }
.panels { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 0; border: 1px solid var(--rule); border-top: 0; background: var(--panel); border-radius: 0 0 4px 4px; }
@media (max-width: 760px) { .panels { grid-template-columns: 1fr; } }
.panels > * { min-width: 0; padding: 14px; }
.panels > * + * { border-left: 1px solid var(--rule); }
@media (max-width: 760px) { .panels > * + * { border-left: 0; border-top: 1px solid var(--rule); } }
.panels canvas { display: block; width: 100%; max-width: 100%; }
.panel-title { font: 500 0.74rem/1.4 var(--mono); color: var(--muted); margin: 0 0 8px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

/* toy-model label */
.toybox { margin-top: 14px; font: 400 0.8rem/1.6 var(--mono); color: var(--muted); border: 1px dashed var(--rule); border-radius: 4px; padding: 10px 14px; }
.toybox b { color: var(--fg); font-weight: 500; }
.toybox p { margin: 0; max-width: none; color: var(--muted); }
.toybox p + p { margin-top: 6px; }

/* G4Exception */
.g4ex { margin-top: 22px; font: 400 0.82rem/1.65 var(--mono); background: var(--panel); border: 1px solid var(--rule); border-left: 3px solid var(--warn); border-radius: 0 4px 4px 0; padding: 14px 16px; overflow-x: auto; white-space: pre; color: var(--fg); }
.g4ex .w { color: var(--warn); }
.g4ex .e { color: var(--neg); }
.g4ex .d { color: var(--muted); }
.g4ex + .g4ex { margin-top: 12px; }
.g4ex [lang="zh-Hans"] { font-family: var(--mono), var(--zh); }

/* hands-on steps */
.steps { list-style: none; padding: 0; margin: 24px 0 0; counter-reset: s; }
.steps > li { counter-increment: s; border-top: 1px solid var(--rule); padding: 18px 0 20px; max-width: none; }
.steps > li:first-child { border-top: 1px solid var(--frame); }
.step-head { display: flex; gap: 12px; align-items: baseline; }
.step-head::before { content: "Step " counter(s); font: 500 0.78rem var(--mono); color: var(--neg); white-space: nowrap; }
html[data-lang="zh"] .step-head::before { content: "第 " counter(s) " 步"; }
.step-head h3 { margin: 0; font-size: 1.08rem; flex: 1; min-width: 0; }
.done { display: inline-flex; gap: 6px; align-items: center; font: 400 0.76rem var(--mono); color: var(--muted); cursor: pointer; white-space: nowrap; }
.done input { accent-color: var(--neu); width: 16px; height: 16px; }
.steps > li.is-done .step-head h3 { color: var(--muted); }
.steps p { color: var(--muted); max-width: 64ch; }
.progress { font: 400 0.8rem var(--mono); color: var(--muted); margin-top: 14px; }
.progress b { color: var(--neu); font-weight: 500; }

/* quiz */
.quiz { margin-top: 18px; display: grid; gap: 0; }
.q { border-top: 1px solid var(--rule); padding: 18px 0; }
.q:first-child { border-top: 1px solid var(--frame); }
.q-head { font: 500 0.76rem var(--mono); color: var(--neg); margin: 0 0 6px; }
.q-prompt { margin: 0; font-weight: 500; max-width: 64ch; }
.q-prompt [lang="zh-Hans"] { font-weight: 400; }
html[data-lang="both"] .q-prompt [lang="zh-Hans"] { display: block; color: var(--muted); margin-top: 2px; }
.q-opts { display: grid; gap: 8px; margin-top: 12px; max-width: 680px; }
.q-opts button { text-align: left; font: 400 0.95rem/1.45 var(--sans); color: var(--fg); background: var(--panel); border: 1px solid var(--rule); border-radius: 3px; padding: 10px 12px; cursor: pointer; display: grid; grid-template-columns: 1.6em minmax(0, 1fr); gap: 2px 8px; }
.q-opts button:hover:not([disabled]) { border-color: var(--frame); }
.q-opts button .o { font: 500 0.8rem/1.8 var(--mono); color: var(--muted); grid-row: span 2; }
html[data-lang="both"] .q-opts button [lang="zh-Hans"] { display: block; grid-column: 2; color: var(--muted); font-size: 0.9em; }
.q-opts button[disabled] { cursor: default; }
.q-opts button.right { border-color: var(--neu); background: var(--tint-neu); }
.q-opts button.wrong { border-color: var(--neg); background: var(--tint-neg); }
.q-fb { margin-top: 12px; max-width: 68ch; font-size: 0.95rem; color: var(--muted); }
.q-fb b { font: 500 0.82rem var(--mono); }
.q-fb b.right { color: var(--neu); }
.q-fb b.wrong { color: var(--neg); }
.q-fb p { margin: 4px 0 0; }
.score { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin-top: 16px; font: 400 0.84rem var(--mono); color: var(--muted); }
.score b { color: var(--fg); font-weight: 500; }

/* review checklist */
.review { list-style: none; padding: 0; margin: 18px 0 0; border-top: 1px solid var(--frame); }
.review li { padding: 10px 0; border-bottom: 1px solid var(--rule); max-width: none; }
.review label { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 2px 10px; cursor: pointer; }
.review input { accent-color: var(--neu); width: 16px; height: 16px; margin-top: 4px; grid-row: span 2; }
html[data-lang="both"] .review [lang="zh-Hans"] { display: block; grid-column: 2; color: var(--muted); }

/* figure / GIF */
.fig { margin: 22px 0 0; }
.fig img { display: block; max-width: 100%; height: auto; border-radius: 4px; border: 1px solid var(--rule); }
.fig figcaption { font: 400 0.76rem/1.5 var(--mono); color: var(--muted); margin-top: 8px; max-width: 72ch; }
.share { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 760px) { .share { grid-template-columns: 1fr; } }

/* pager */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-top: 1px solid var(--frame); margin-top: 8px; }
.pager a, .pager span.off { display: grid; gap: 4px; padding: 18px 0; text-decoration: none; color: var(--fg); min-width: 0; }
.pager .next { text-align: right; border-left: 1px solid var(--rule); padding-left: 16px; }
.pager .prev { padding-right: 16px; }
.pager small { font: 400 0.76rem var(--mono); color: var(--muted); }
.pager strong { font: 600 1.15rem/1.25 var(--head); }
.pager a:hover strong { color: var(--pos); }
.pager span.off strong { color: var(--muted); }

/* course index list */
.weeks { margin-top: 22px; border-top: 1px solid var(--frame); }
.wk-row { display: grid; grid-template-columns: 4.5em minmax(0, 1fr) auto; gap: 4px 16px; align-items: baseline; padding: 14px 0; border-bottom: 1px solid var(--rule); text-decoration: none; color: var(--fg); }
.wk-row .num { font: 500 0.85rem var(--mono); color: var(--neg); }
.wk-row .t { font: 600 1.08rem/1.3 var(--head); }
.wk-row .t [lang="zh-Hans"] { font: 400 0.9rem var(--zh); color: var(--muted); }
html[data-lang="both"] .wk-row .t [lang="zh-Hans"] { display: block; }
.wk-row .ch { display: block; font: 400 0.76rem var(--mono); color: var(--muted); margin-top: 2px; }
.wk-row .st { font: 400 0.76rem var(--mono); color: var(--muted); white-space: nowrap; text-align: right; }
.wk-row .st.live { color: var(--neu); }
a.wk-row:hover .t { color: var(--pos); }
.wk-stage { font: 500 0.72rem/1.4 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 20px 0 6px; border-bottom: 1px solid var(--rule); }
.wk-stage b { color: var(--neg); font-weight: 500; }

footer { border-top: 1px solid var(--rule); padding-top: 20px; margin-top: 8px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; font: 400 0.8rem/1.5 var(--mono); color: var(--muted); }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* week event display: wide on desktop, tall on phones (stacked side + top views) */
.tele { aspect-ratio: 16 / 9; }
@media (max-width: 560px) { .tele { aspect-ratio: 4 / 5; } }

/* collapsible source files */
.files { margin-top: 18px; display: grid; gap: 8px; }
.files details { border: 1px solid var(--rule); border-radius: 4px; background: var(--panel); min-width: 0; }
.files summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; padding: 8px 12px; font: 400 0.78rem/1.4 var(--mono); color: var(--muted); }
.files summary::-webkit-details-marker { display: none; }
.files summary b { color: var(--fg); font-weight: 500; }
.files summary b::before { content: "+ "; color: var(--neg); }
.files details[open] summary b::before { content: "− "; }
.files details pre { border: 0; border-top: 1px solid var(--rule); border-radius: 0 0 4px 4px; }
.verbose pre { font-size: 0.74rem; line-height: 1.5; white-space: pre; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 760px) { .two { grid-template-columns: 1fr; } }
.two > * { min-width: 0; }

.panels.one { grid-template-columns: minmax(0, 1fr); border-top: 0; }
.panels.one > * + * { border-left: 0; }

/* long identifiers in running text must wrap on phones */
p code, li code, td code, .cap code { overflow-wrap: anywhere; }
/* bilingual inline labels and table cells (both mode): separator for labels, stacked lines in cells */
html[data-lang="both"] :is(.box-label, .aside-label, .cap, .panel-title, a) > span[lang="en"] + span[lang="zh-Hans"]::before { content: " · "; }
html[data-lang="both"] :is(td, th) > span[lang="zh-Hans"] { display: block; color: var(--muted); }

/* ---------- 3D event displays (assets/evdisplay.js) ---------- */
.evd-fig { margin: 22px 0 0; }
.evd { border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; background: var(--display-bg); }
.evd-stage { position: relative; aspect-ratio: 16 / 9; min-height: 260px; }
@media (max-width: 600px) { .evd-stage { aspect-ratio: 4 / 5; } }
.evd-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.evd-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.evd-labels .lbl { position: absolute; left: 0; top: 0; font: 500 10.5px/1.3 var(--mono); color: #A9B7C2; white-space: nowrap; text-shadow: 0 0 6px #0B1014, 0 0 2px #0B1014; }
.evd-labels .lbl.hi { color: #F2D06B; }
.evd-labels .lbl.neg { color: #FF6369; } .evd-labels .lbl.pos { color: #7393FF; } .evd-labels .lbl.neu { color: #4FC98A; }
html[data-lang="both"] .evd-labels .lbl [lang="zh-Hans"]::before { content: " · "; }
.evd-hud { position: absolute; left: 12px; top: 10px; right: 120px; font: 500 11px/1.55 var(--mono); color: #DCE3E8; pointer-events: none; text-shadow: 0 0 6px #0B1014; }
.evd-hud b { color: #F2D06B; font-weight: 500; }
.evd-hud .m { color: #8FA0AC; }
.evd-hud .neg { color: #FF6369; } .evd-hud .pos { color: #7393FF; } .evd-hud .neu { color: #4FC98A; }
html[data-lang="both"] .evd-hud [lang="zh-Hans"]::before { content: " · "; }
.evd-tag { position: absolute; right: 10px; top: 10px; font: 600 10px/1 var(--mono); letter-spacing: 0.08em; padding: 5px 7px; border-radius: 2px; pointer-events: none; }
.evd-tag .data { color: #0B1014; background: #4FC98A; padding: 5px 7px; border-radius: 2px; }
.evd-tag .toy { color: #0B1014; background: #F2D06B; padding: 5px 7px; border-radius: 2px; }
.evd-ctl { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100% - 20px); }
.evd-ctl button { font: 500 11px/1 var(--mono); color: #DCE3E8; background: rgba(11, 16, 20, 0.72); border: 1px solid rgba(220, 227, 232, 0.28); padding: 7px 9px; border-radius: 3px; cursor: pointer; }
.evd-ctl button:hover { border-color: rgba(220, 227, 232, 0.6); }
.evd-ctl button:focus-visible { outline: 2px solid #7393FF; outline-offset: 1px; }
html[data-lang="both"] .evd-ctl [lang="zh-Hans"] { display: none; }
.evd-poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--display-bg); display: none; }
.evd-fallback .evd-poster { display: block; }
.evd-fallback canvas, .evd-fallback .evd-ctl, .evd-fallback .evd-hud { display: none; }
.evd-msg { position: absolute; left: 10px; bottom: 8px; right: 10px; margin: 0; font: 400 10.5px/1.4 var(--mono); color: #A9B7C2; background: rgba(11, 16, 20, 0.75); padding: 4px 6px; }
.evd-cap { margin-top: 10px; font: 400 0.8rem/1.55 var(--sans); color: var(--muted); }
.evd-cap b { color: var(--fg); font-weight: 500; }

/* ---------- static figures ---------- */
.fig-svg { margin: 22px 0 0; }
.fig-svg svg { display: block; width: 100%; height: auto; max-width: 820px; }
.fig-svg svg text { font-family: var(--mono); font-size: 12px; fill: var(--fg); }
.fig-svg svg .m { fill: var(--muted); } .fig-svg svg .neg { fill: var(--neg); } .fig-svg svg .pos { fill: var(--pos); } .fig-svg svg .neu { fill: var(--neu); }
.fig-svg svg .s-fg { stroke: var(--fg); } .fig-svg svg .s-m { stroke: var(--muted); } .fig-svg svg .s-rule { stroke: var(--rule); }
.fig-svg svg .s-neg { stroke: var(--neg); } .fig-svg svg .s-pos { stroke: var(--pos); } .fig-svg svg .s-neu { stroke: var(--neu); } .fig-svg svg .s-hit { stroke: #E2B04A; }
.fig-svg svg .f-panel { fill: var(--panel); } .fig-svg svg .f-bg { fill: var(--bg); } .fig-svg svg .f-hit { fill: #E2B04A; }
.fig-svg svg .f-neg { fill: var(--neg); } .fig-svg svg .f-pos { fill: var(--pos); } .fig-svg svg .f-neu { fill: var(--neu); }
.fig-svg svg .f-soft { fill: var(--rule); }
html[data-lang="en"] .fig-svg svg [lang="zh-Hans"], html[data-lang="zh"] .fig-svg svg [lang="en"] { display: none; }
html[data-lang="both"] .fig-svg svg [lang="zh-Hans"] { display: none; }
.fig-svg figcaption { margin-top: 10px; font: 400 0.8rem/1.55 var(--sans); color: var(--muted); max-width: 72ch; }
/* narrow screens and 200% zoom: the figure scrolls inside its own frame, with a hint (see course.js) */
.fig-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.scroll-hint { display: none; margin: 0 0 6px; font: 500 0.78rem/1.4 var(--mono); color: var(--muted); }
.fig-svg.is-scrollable .scroll-hint { display: block; }
.fig-svg.is-scrollable:not(.at-end) .fig-scroll { -webkit-mask-image: linear-gradient(to right, #000 82%, transparent); mask-image: linear-gradient(to right, #000 82%, transparent); }
@media (max-width: 700px) {
  .fig-svg svg { min-width: 620px; }
}

/* =====================================================================
   v2 · learning-player design layer
   Tokens, icons, top bar, item navigator, item cards, quiz/lab cards,
   completion card and the course home. Everything above stays valid; this
   layer refines it. The Geant4 identity (macro commands, vis colours, dark
   event displays, ROOT plots, hairline tables) is kept on purpose.
   ===================================================================== */
:root {
  --accent: #2C55E0; --accent-ink: #FFFFFF; --accent-soft: rgba(44, 85, 224, 0.08);
  --surface: #FFFFFF; --surface-2: #ECEFEB;
  --line: rgba(18, 22, 26, 0.11); --line-strong: rgba(18, 22, 26, 0.24);
  --tint-warn: rgba(154, 106, 0, 0.09);
  --r-s: 6px; --r-m: 10px; --r-l: 14px;
  --sh-1: 0 1px 2px rgba(18, 22, 26, 0.05), 0 1px 4px rgba(18, 22, 26, 0.04);
  --sh-2: 0 10px 30px -12px rgba(18, 22, 26, 0.22), 0 2px 6px rgba(18, 22, 26, 0.05);
  --tb-h: 60px; --nav-w: 292px;
  --neu-ink: #17703F; --warn-ink: #7A5400; --neg-ink: #B3262F;   /* small text on light surfaces (WCAG AA) */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #7D9BFF; --accent-ink: #0B1014; --accent-soft: rgba(125, 155, 255, 0.12);
    --surface: #182027; --surface-2: #1F2931;
    --line: rgba(228, 233, 236, 0.10); --line-strong: rgba(228, 233, 236, 0.22);
    --tint-warn: rgba(226, 176, 74, 0.12);
    --sh-1: 0 1px 2px rgba(0, 0, 0, 0.3); --sh-2: 0 12px 32px -12px rgba(0, 0, 0, 0.6);
  --neu-ink: var(--neu); --warn-ink: var(--warn); --neg-ink: var(--neg);
  }
}
:root[data-theme="dark"] {
  --accent: #7D9BFF; --accent-ink: #0B1014; --accent-soft: rgba(125, 155, 255, 0.12);
  --surface: #182027; --surface-2: #1F2931;
  --line: rgba(228, 233, 236, 0.10); --line-strong: rgba(228, 233, 236, 0.22);
  --tint-warn: rgba(226, 176, 74, 0.12);
  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.3); --sh-2: 0 12px 32px -12px rgba(0, 0, 0, 0.6);
  --neu-ink: var(--neu); --warn-ink: var(--warn); --neg-ink: var(--neg);
}

/* icons and helpers */
svg.ic { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -0.14em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--fg); color: var(--bg); padding: 10px 14px; border-radius: var(--r-s); font: 600 0.9rem var(--sans); text-decoration: none; }
.skip:focus { left: 12px; }
.logo { width: 30px; height: 30px; flex: none; }
.logo-bg { fill: #10161B; }
.logo-mu { stroke: #FF6369; stroke-width: 2.4; stroke-linecap: round; fill: none; }
.logo-pos { stroke: #7D9BFF; stroke-width: 2.2; stroke-linecap: round; fill: none; }
.logo-neu { stroke: #4FC98A; stroke-width: 2; stroke-linecap: round; fill: none; stroke-dasharray: 2.6 2.6; }
.logo-v { fill: #F2D06B; }
.pbar { display: block; width: 120px; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.pbar i { display: block; height: 100%; width: 0; background: var(--neu); border-radius: inherit; transition: width 0.5s ease; }
.btn-p, .btn-s { display: inline-flex; align-items: center; gap: 8px; font: 600 0.95rem/1.2 var(--sans); padding: 11px 18px; border-radius: 8px; text-decoration: none; cursor: pointer; border: 1px solid transparent; transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease; }
.btn-p { background: var(--accent); color: var(--accent-ink); box-shadow: var(--sh-1); }
.btn-p:hover { box-shadow: var(--sh-2); transform: translateY(-1px); }
.btn-s { background: var(--surface); color: var(--fg); border-color: var(--line-strong); }
.btn-s:hover { border-color: var(--fg); }
.btn-p .ic, .btn-s .ic { width: 18px; height: 18px; }
html[data-lang="both"] :is(.btn-p, .btn-s, .mark, .next-item b, .nav-home, .hero-sum, .nav-total, .chip, .crumbs) > span[lang="en"] + span[lang="zh-Hans"]::before { content: " · "; }

/* ---------- player pages: top bar ---------- */
html.has-player body { padding: 0; }
html.has-player { scroll-padding-top: calc(var(--tb-h) + 12px); }
.topbar { position: sticky; top: 0; z-index: 40; background: var(--bg); background: color-mix(in srgb, var(--bg) 86%, transparent); -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.tb-in { max-width: 1440px; margin: 0 auto; height: var(--tb-h); display: flex; align-items: center; gap: 14px 18px; padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; font: 700 1.02rem/1 var(--head); white-space: nowrap; }
.tb-week { display: flex; align-items: baseline; gap: 10px; min-width: 0; font: 500 0.78rem/1.2 var(--mono); color: var(--muted); white-space: nowrap; padding-left: 16px; border-left: 1px solid var(--line); }
.tb-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; font: 600 0.95rem/1.2 var(--head); color: var(--fg); }
html[data-lang="both"] .topbar [lang="zh-Hans"] { display: none; }
.tb-prog { margin-left: auto; display: inline-flex; align-items: center; gap: 10px; font: 500 0.76rem/1 var(--mono); color: var(--muted); white-space: nowrap; }
.nav-toggle { display: none; align-items: center; justify-content: center; width: 40px; height: 40px; margin-left: -8px; border: 0; border-radius: 8px; background: transparent; color: var(--fg); cursor: pointer; }
.nav-toggle:hover { background: var(--surface-2); }
.nav-toggle .ic { width: 22px; height: 22px; }
.topbar .lang { flex: none; }

/* ---------- player layout ---------- */
.player { max-width: 1440px; margin: 0 auto; display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); gap: 0 56px; padding: 0 max(16px, env(safe-area-inset-right, 0px)) 72px max(16px, env(safe-area-inset-left, 0px)); }
.player > main { min-width: 0; max-width: 900px; padding-top: 22px; }
.player > main:focus { outline: none; }
.nav { position: sticky; top: var(--tb-h); height: calc(100vh - var(--tb-h)); height: calc(100dvh - var(--tb-h)); overflow-y: auto; overscroll-behavior: contain; border-right: 1px solid var(--line); scrollbar-width: thin; }
.nav-in { padding: 22px 16px 40px 0; }
.nav-home { display: inline-flex; align-items: center; gap: 8px; font: 500 0.8rem/1 var(--mono); color: var(--muted); text-decoration: none; padding: 6px 0; }
.nav-home:hover { color: var(--fg); }
.nav-week { margin: 18px 0 4px; font: 600 0.7rem/1.4 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--neg); }
.nav-title { margin: 0; font: 700 1.2rem/1.22 var(--head); }
html[data-lang="both"] .nav-title > [lang="zh-Hans"] { display: block; font-size: 0.8em; font-weight: 500; color: var(--muted); margin-top: 2px; }
.nav-prog { display: flex; align-items: center; gap: 10px; margin: 14px 0 18px; font: 500 0.74rem/1 var(--mono); color: var(--muted); white-space: nowrap; }
.nav-prog .pbar { flex: 1; width: auto; }
.nav-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-items a { position: relative; display: grid; grid-template-columns: 20px minmax(0, 1fr) 18px; gap: 11px; align-items: start; padding: 9px 10px; border-radius: 9px; color: var(--fg); text-decoration: none; font: 500 0.9rem/1.3 var(--sans); }
.nav-items a > .ic { width: 19px; height: 19px; color: var(--muted); margin-top: 1px; }
.nav-items .t { min-width: 0; }
.nav-items small { display: block; margin-top: 3px; font: 400 0.72rem/1.3 var(--mono); color: var(--muted); }
html[data-lang="both"] .nav-items .t > [lang="zh-Hans"] { display: block; font-size: 0.86em; font-weight: 400; color: var(--muted); }
html[data-lang="both"] .nav-items small > [lang="zh-Hans"] { display: none; }
.nav-items a:hover { background: var(--surface-2); }
.nav-items a[aria-current="true"] { background: var(--accent-soft); }
.nav-items a[aria-current="true"]::before { content: ""; position: absolute; left: -1px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--accent); }
.nav-items a[aria-current="true"] > .ic { color: var(--accent); }
.tick { width: 18px; height: 18px; margin-top: 1px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center; transition: background 0.2s, border-color 0.2s; }
.tick .ic { width: 11px; height: 11px; stroke-width: 3; color: #fff; opacity: 0; }
.nav-items a.is-done .tick { background: var(--neu); border-color: var(--neu); }
.nav-items a.is-done .tick .ic { opacity: 1; }
[data-theme="dark"] .tick .ic { color: #0B1014; }
.nav-total { display: flex; align-items: center; gap: 8px; margin: 16px 10px 0; font: 400 0.76rem/1.4 var(--mono); color: var(--muted); }
.nav-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(8, 12, 16, 0.45); }

@media (max-width: 1099px) {
  .player { grid-template-columns: minmax(0, 1fr); }
  .player > main { margin: 0 auto; width: 100%; }
  .nav-toggle { display: inline-flex; }
  .nav { position: fixed; z-index: 60; top: 0; left: 0; bottom: 0; height: auto; width: min(86vw, 340px); background: var(--bg); border-right: 1px solid var(--line); box-shadow: var(--sh-2); transform: translateX(-104%); transition: transform 0.25s ease; visibility: hidden; }
  .nav-in { padding: 18px 16px 40px max(16px, env(safe-area-inset-left, 0px)); }
  html.nav-open .nav { transform: none; visibility: visible; }
  .nav-items a[aria-current="true"]::before { display: none; }
}
@media (max-width: 760px) { .tb-week { display: none; } .tb-prog .pbar { width: 56px; } }
@media (max-width: 420px) { html:not(.is-home) .brand b { display: none; } .tb-prog .pn { display: none; } }

/* ---------- hero inside the player ---------- */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font: 400 0.78rem/1.5 var(--mono); color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
html[data-lang="both"] .crumbs [lang="zh-Hans"] { display: none; }
.player .hero { grid-template-columns: minmax(0, 1fr) minmax(0, 290px); gap: 28px 36px; padding: 18px 0 40px; align-items: start; }
@media (max-width: 900px) { .player .hero { grid-template-columns: minmax(0, 1fr); } }
.player .hero h1 { font-size: clamp(2rem, 4.2vw, 3.05rem); line-height: 1.05; }
.player .hero .prompt { margin-bottom: 14px; }
.player .lede { font-size: 1.08rem; line-height: 1.6; }
.player .meta { gap: 8px; margin-top: 22px; }
.player .meta li { display: inline-flex; align-items: baseline; gap: 8px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); }
.player .meta b { display: inline; font: 600 0.92rem/1.3 var(--head); }
.player .meta li > span { font-size: 0.74rem; }
.player .hero .statbox { border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; box-shadow: var(--sh-1); background: var(--surface); margin-top: 34px; }
.player .hero .statbox div:first-child { border-bottom-color: var(--line); background: var(--surface-2); font-size: 0.78rem; letter-spacing: 0.04em; }
.player .hero .statbox div { border-bottom-color: var(--line); padding: 8px 14px; }
@media (max-width: 900px) { .player .hero .statbox { margin-top: 0; } }
.hero-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px; margin-top: 26px; }
.hero-sum { display: inline-flex; align-items: center; gap: 7px; font: 400 0.8rem/1.3 var(--mono); color: var(--muted); }

/* ---------- items ---------- */
:is(.player, .home) .run { display: block; padding: 44px 0 34px; border-top: 1px solid var(--line); scroll-margin-top: calc(var(--tb-h) + 12px); }
:is(.player, .home) .run > .cmd { position: static; display: block; margin: 10px 0 16px; padding: 0; font: 500 0.78rem/1.5 var(--mono); }
:is(.player, .home) .run > .cmd > span { display: inline; color: var(--muted); }
:is(.player, .home) .run > .cmd > span::before { content: "  ·  "; white-space: pre; color: var(--line-strong); }
:is(.player, .home) .run h2 { font-size: clamp(1.5rem, 2.7vw, 2rem); line-height: 1.14; }
.item-tag { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0; font: 600 0.72rem/1.2 var(--mono); letter-spacing: 0.07em; text-transform: uppercase; color: var(--accent); }
.item-tag .ic { width: 28px; height: 28px; padding: 6px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.item-tag .d { color: var(--muted); font-weight: 400; letter-spacing: 0; text-transform: none; display: inline-flex; gap: 8px; }
.item-tag .d::before { content: "·"; }
html[data-lang="both"] .item-tag [lang="zh-Hans"] { display: none; }
[data-type="lab"] > .item-tag { color: var(--neg); }
[data-type="lab"] > .item-tag .ic { background: var(--tint-neg); color: var(--neg); }
:is([data-type="interactive"], [data-type="display"], [data-type="review"]) > .item-tag { color: var(--neu); }
:is([data-type="interactive"], [data-type="display"], [data-type="review"]) > .item-tag .ic { background: var(--tint-neu); color: var(--neu); }
[data-type="errors"] > .item-tag { color: var(--warn); }
[data-type="errors"] > .item-tag .ic { background: var(--tint-warn); color: var(--warn); }
.player .prose p, .player .prose li { max-width: 68ch; }
.player .prose p { line-height: 1.68; }

/* end of an item: mark complete + next */
.item-end { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 18px; margin-top: 34px; padding-top: 18px; border-top: 1px dashed var(--line-strong); }
.mark { display: inline-flex; align-items: center; gap: 9px; font: 600 0.88rem/1.2 var(--sans); padding: 9px 15px 9px 11px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); cursor: pointer; transition: background 0.2s, border-color 0.2s, color 0.2s; }
.mark:hover { border-color: var(--neu); }
.mark .tick { margin: 0; }
.mark[aria-pressed="true"] { background: var(--tint-neu); border-color: var(--neu); color: var(--neu); }
.mark[aria-pressed="true"] .tick { background: var(--neu); border-color: var(--neu); }
.mark[aria-pressed="true"] .tick .ic { opacity: 1; }
.next-item { display: inline-flex; align-items: center; gap: 12px; text-align: right; color: var(--accent); text-decoration: none; margin-left: auto; }
.next-item small { display: block; font: 400 0.72rem/1.3 var(--mono); color: var(--muted); }
.next-item b { display: block; font: 600 0.95rem/1.3 var(--sans); }
.next-item > .ic { width: 34px; height: 34px; padding: 8px; border-radius: 50%; background: var(--accent-soft); }
.next-item:hover > .ic { background: var(--accent); color: var(--accent-ink); }
html[data-lang="both"] .next-item b > [lang="zh-Hans"] { font-weight: 400; }

/* ---------- components, refined ---------- */
.player .box { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--neg); border-radius: 0 var(--r-m) var(--r-m) 0; padding: 14px 20px 16px; box-shadow: var(--sh-1); }
.player :is(.box, .aside) { max-width: 800px; }
.player .aside { background: var(--tint-neu); border-left: 3px solid var(--neu); border-radius: 0 var(--r-m) var(--r-m) 0; padding: 12px 18px 14px; }
.player .aside p { color: var(--fg); opacity: 0.88; }
.player .code-head { border-radius: var(--r-m) var(--r-m) 0 0; border-color: var(--line); background: var(--surface-2); }
.player pre { border-radius: var(--r-m); border-color: var(--line); }
.player .code pre { border-radius: 0 0 var(--r-m) var(--r-m); }
.player .out pre { border-color: var(--line-strong); }
.player .flow { border-radius: var(--r-m); border-color: var(--line); }
.player .g4ex { border-color: var(--line); border-left-color: var(--warn); border-radius: 0 var(--r-m) var(--r-m) 0; }
.player .files details { border-radius: var(--r-m); border-color: var(--line); }
.player .copy { border-radius: 6px; }
.player .copy:hover { border-color: var(--accent); color: var(--accent); }
.player .evd, .player .fig img { border-radius: var(--r-l); }
.player .display { border-radius: var(--r-m) var(--r-m) 0 0; }
.player .toybox { border-radius: var(--r-m); }
.player .btns button, .player .btn { border-radius: 7px; border-color: var(--line-strong); }
.player .btns button:hover, .player .btn:hover { border-color: var(--fg); }
.player .btns button.primary, .player .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* lab steps as cards */
.player .steps > li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 18px 20px 20px; margin-top: 12px; box-shadow: var(--sh-1); transition: border-color 0.2s; }
.player .steps > li:first-child { border-top: 1px solid var(--line); }
.player .steps > li.is-done { border-color: color-mix(in srgb, var(--neu) 55%, transparent); }
.player .step-head { align-items: center; }
.player .step-head::before { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 10px; border-radius: 99px; background: var(--tint-neg); color: var(--neg); font-size: 0.74rem; }
.player .steps > li.is-done .step-head::before { background: var(--tint-neu); color: var(--neu); }
.player .done { padding: 6px 10px; border: 1px solid var(--line); border-radius: 99px; }
.player .done:hover { border-color: var(--neu); }
.player .progress { padding: 10px 14px; border-radius: var(--r-m); background: var(--surface-2); display: inline-block; }

/* quiz cards */
.player .quiz { gap: 12px; }
.player .q { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 18px 20px 20px; box-shadow: var(--sh-1); }
.player .q:first-child { border-top: 1px solid var(--line); }
.player .q-head { color: var(--accent); }
.player .q-opts { max-width: none; }
.player .q-opts button { border-radius: 9px; border-color: var(--line); background: var(--bg); padding: 11px 14px; transition: border-color 0.15s, background 0.15s; }
.player .q-opts button:hover:not([disabled]) { border-color: var(--accent); background: var(--accent-soft); }
.player .score { background: var(--surface-2); border-radius: var(--r-l); padding: 14px 18px; }
.qsum { display: flex; align-items: center; gap: 14px; font: 400 0.84rem/1.4 var(--mono); color: var(--muted); }
.qsum .pbar { width: 140px; }

/* review checklist as a card */
.player .review { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 4px 18px; box-shadow: var(--sh-1); }
.player .review li:last-child { border-bottom: 0; }

/* pager as two cards */
.player .pager { gap: 14px; border-top: 0; margin-top: 18px; }
.player .pager a, .player .pager span.off { padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--surface); transition: box-shadow 0.15s, border-color 0.15s; }
.player .pager a:hover { box-shadow: var(--sh-2); border-color: var(--line-strong); }
.player .pager .next { border-left: 1px solid var(--line); padding-left: 20px; }
@media (max-width: 560px) { .player .pager { grid-template-columns: 1fr; } .player .pager .next { text-align: left; } }
.player footer { margin-top: 28px; }

/* completion card */
.wk-done { margin-top: 32px; padding: 26px 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--sh-1); }
.wk-done h2 { font-size: 1.35rem; }
.wk-done-body { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 18px 26px; align-items: center; margin-top: 16px; }
@media (max-width: 560px) { .wk-done-body { grid-template-columns: 1fr; } }
.ring { position: relative; width: 112px; height: 112px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring .bg { stroke: var(--surface-2); }
.ring .fg { stroke: var(--neu); stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; }
.ring b { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font: 700 1.5rem/1 var(--head); }
.ring b small { display: block; font: 400 0.66rem/1.2 var(--mono); color: var(--muted); text-align: center; margin-top: 2px; }
.done-stats { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font: 400 0.9rem/1.45 var(--sans); color: var(--muted); }
.done-stats li { display: flex; gap: 10px; align-items: center; }
.done-stats .ic { width: 18px; height: 18px; color: var(--neu); }
.done-stats b { color: var(--fg); font-weight: 600; }
.done-cta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.done-cta p { margin: 0; font: 400 0.84rem/1.5 var(--mono); color: var(--muted); }
.wk-done.all { border-color: color-mix(in srgb, var(--neu) 60%, transparent); background: linear-gradient(180deg, var(--tint-neu), var(--surface) 70%); }

@media (prefers-reduced-motion: reduce) {
  .nav, .pbar i, .ring .fg, .btn-p, .mark, .tick { transition: none !important; }
}

/* ---------- course home ---------- */
.home { max-width: 1200px; margin: 0 auto; padding: 0 max(16px, env(safe-area-inset-right, 0px)) 72px max(16px, env(safe-area-inset-left, 0px)); }
.home > main:focus { outline: none; }
.tb-link { font: 500 0.88rem/1 var(--sans); color: var(--muted); text-decoration: none; padding: 8px 4px; white-space: nowrap; }
.tb-link:hover { color: var(--fg); }
.is-home .tb-week + .tb-link { margin-left: auto; }
.is-home .tb-in { max-width: 1200px; }
html[data-lang="both"] .tb-link [lang="zh-Hans"] { display: none; }
@media (max-width: 760px) { .tb-link { display: none; } .is-home .topbar .lang { margin-left: auto; } }
.eyebrow { margin: 0 0 12px; font: 600 0.72rem/1.4 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--neg); }
html[data-lang="both"] .eyebrow > [lang="zh-Hans"]::before { content: " · "; }
.h-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 370px); gap: 40px 60px; padding: 52px 0 60px; align-items: start; }
@media (max-width: 960px) { .h-hero { grid-template-columns: minmax(0, 1fr); padding-top: 32px; } }
.h-hero h1 { font-size: clamp(2.4rem, 5.6vw, 4.1rem); line-height: 1.02; }
.h-hero .prompt { margin-bottom: 14px; }
.h-facts { list-style: none; padding: 0; margin: 30px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 28px; max-width: 640px; }
@media (max-width: 480px) { .h-facts { grid-template-columns: minmax(0, 1fr); } }
.h-facts li { display: flex; gap: 12px; align-items: flex-start; font: 400 0.8rem/1.45 var(--mono); color: var(--muted); }
.h-facts li > .ic { width: 22px; height: 22px; color: var(--accent); margin-top: 1px; }
.h-facts b { display: block; font: 600 1.02rem/1.3 var(--head); color: var(--fg); }
html[data-lang="both"] .h-facts li > span > span[lang="zh-Hans"] { display: block; }
.h-by { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 24px 0 0; font: 400 0.9rem/1.5 var(--sans); color: var(--muted); }
.h-by b { color: var(--fg); font-weight: 600; }
.h-by .ic { width: 18px; height: 18px; }
html[data-lang="both"] .h-by > span[lang="zh-Hans"]::before { content: " · "; }
.incl { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--sh-2); padding: 22px 24px 24px; }
.incl-prog { display: flex; gap: 16px; align-items: center; padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.incl-prog:empty { display: none; }
.incl-prog .ring { width: 84px; height: 84px; flex: none; }
.incl-prog .ring b { font-size: 1.15rem; }
.incl-prog .ring circle { stroke-width: 10; }
.incl-prog > div:last-child > b { display: block; font: 600 1.02rem/1.3 var(--head); }
.incl-prog > div:last-child > span { display: block; margin-top: 3px; font: 400 0.76rem/1.45 var(--mono); color: var(--muted); }
html[data-lang="both"] .incl-prog [lang="zh-Hans"] { display: none; }
.incl-h { font-size: 1.05rem; margin: 0 0 12px; }
.incl ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.incl li { display: flex; gap: 12px; align-items: center; font: 400 0.93rem/1.35 var(--sans); }
.incl li .ic { width: 32px; height: 32px; padding: 7px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); }
html[data-lang="both"] .incl li > [lang="zh-Hans"] { display: none; }
.h-sec { padding: 60px 0; border-top: 1px solid var(--line); scroll-margin-top: calc(var(--tb-h) + 8px); }
.h-sec h2 { font-size: clamp(1.65rem, 3.2vw, 2.4rem); line-height: 1.1; max-width: 30ch; }
.h-sec h3 { margin-top: 40px; font-size: 1.15rem; }
.h-p { color: var(--muted); max-width: 70ch; margin: 16px 0 0; }
.learn { list-style: none; padding: 0; margin: 28px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 36px; }
@media (max-width: 760px) { .learn { grid-template-columns: minmax(0, 1fr); } }
.learn li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 4px 12px; align-items: start; line-height: 1.55; }
.learn .ic { width: 20px; height: 20px; color: var(--neu); stroke-width: 2.5; margin-top: 3px; }
html[data-lang="both"] .learn li > [lang="zh-Hans"] { grid-column: 2; color: var(--muted); font-size: 0.92em; }
.chips { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 7px 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font: 500 0.86rem/1.3 var(--sans); }
.paths { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 28px; }
@media (max-width: 900px) { .paths { grid-template-columns: minmax(0, 1fr); } }
.path { display: flex; flex-direction: column; gap: 8px; padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--surface); color: var(--fg); text-decoration: none; transition: box-shadow 0.15s, border-color 0.15s; }
a.path:hover { box-shadow: var(--sh-2); border-color: var(--accent); }
.path-k { display: flex; gap: 8px; align-items: center; font: 600 0.72rem/1.3 var(--mono); letter-spacing: 0.07em; text-transform: uppercase; color: var(--accent); }
.path-k .ic { width: 18px; height: 18px; }
.path b { font: 700 1.2rem/1.25 var(--head); }
.path > span:last-child { color: var(--muted); font-size: 0.93rem; line-height: 1.55; }
html[data-lang="both"] .path > :is(b, span:last-child) > [lang="zh-Hans"] { display: block; font-size: 0.9em; font-weight: 400; color: var(--muted); }
html[data-lang="both"] .path-k > [lang="zh-Hans"]::before { content: " · "; }

/* syllabus accordion */
.syl { margin-top: 26px; display: grid; gap: 28px; }
.syl-sum { margin-top: 12px; }
.syl-sh { display: flex; gap: 10px; align-items: center; margin: 0 0 4px; font: 600 0.74rem/1.3 var(--mono); letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.syl-sh .ic { width: 18px; height: 18px; color: var(--neg); }
.syl-sn { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--neg); color: #fff; font-size: 0.72rem; letter-spacing: 0; }
html[data-lang="both"] .syl-sh > [lang="zh-Hans"]::before { content: " · "; }
.syl-w { margin-top: 10px; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--surface); overflow: hidden; transition: box-shadow 0.2s; }
.syl-w[open] { box-shadow: var(--sh-2); }
.syl-w summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 46px minmax(0, 1fr) auto 20px; gap: 6px 16px; align-items: center; padding: 14px 18px; }
.syl-w summary::-webkit-details-marker { display: none; }
.syl-w summary:hover .syl-t b { color: var(--accent); }
.syl-n { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 11px; background: var(--surface-2); font: 600 0.92rem/1 var(--mono); color: var(--neg); }
.syl-t b { display: block; font: 600 1.1rem/1.3 var(--head); }
.syl-t small { display: block; margin-top: 3px; font: 400 0.75rem/1.4 var(--mono); color: var(--muted); }
html[data-lang="both"] .syl-t b > [lang="zh-Hans"] { display: block; font: 400 0.9rem var(--zh); color: var(--muted); }
html[data-lang="both"] .syl-t small > [lang="zh-Hans"] { display: none; }
.syl-w summary > .ic { width: 20px; height: 20px; color: var(--muted); transition: transform 0.2s; }
.syl-w[open] summary > .ic { transform: rotate(180deg); }
.st-pill { display: inline-flex; gap: 5px; align-items: center; padding: 5px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font: 500 0.74rem/1 var(--mono); white-space: nowrap; }
.st-pill .ic { width: 12px; height: 12px; stroke-width: 3; }
.st-pill.go { background: var(--accent-soft); color: var(--accent); }
.st-pill.ok { background: var(--tint-neu); color: var(--neu); }
html[data-lang="both"] .st-pill [lang="zh-Hans"] { display: none; }
.syl-body { padding: 0 18px 18px 80px; }
.syl-body .pbar { width: 100%; margin: 2px 0 6px; }
.syl-body ol { list-style: none; padding: 0; margin: 0 0 16px; }
.syl-body li a { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto 18px; gap: 12px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); color: var(--fg); text-decoration: none; font: 400 0.93rem/1.35 var(--sans); }
.syl-body li a:hover .t { color: var(--accent); }
.syl-body li a > .ic { width: 18px; height: 18px; color: var(--muted); }
.syl-body small { font: 400 0.74rem/1.3 var(--mono); color: var(--muted); white-space: nowrap; }
html[data-lang="both"] .syl-body .t > [lang="zh-Hans"] { display: block; font-size: 0.86em; color: var(--muted); }
html[data-lang="both"] .syl-body small > [lang="zh-Hans"] { display: none; }
.syl-body li.is-done .tick { background: var(--neu); border-color: var(--neu); }
.syl-body li.is-done .tick .ic { opacity: 1; }
@media (max-width: 600px) {
  .syl-w summary { grid-template-columns: 40px minmax(0, 1fr) 20px; padding: 14px; }
  .syl-n { width: 40px; height: 40px; }
  .st-pill { grid-column: 2; grid-row: 2; justify-self: start; }
  .syl-w summary > .ic { grid-column: 3; grid-row: 1; }
  .syl-body { padding: 0 14px 16px; }
  .syl-body li a { grid-template-columns: 20px minmax(0, 1fr) 18px; }
  .syl-body li a small { grid-column: 2; grid-row: 2; margin-top: -6px; }
  .syl-body li a .tick { grid-column: 3; grid-row: 1; }
}
.how { list-style: none; padding: 0; margin: 26px 0 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; counter-reset: h; }
@media (max-width: 900px) { .how { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .how { grid-template-columns: minmax(0, 1fr); } }
.how li { counter-increment: h; padding: 16px 18px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); line-height: 1.5; }
.how li b { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; font: 600 0.78rem/1 var(--mono); color: var(--neg); }
.how li b::before { content: counter(h); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--tint-neg); }
html[data-lang="both"] .how li > [lang="zh-Hans"] { display: block; color: var(--muted); font-size: 0.92em; }
.instr { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 22px; align-items: start; margin-top: 6px; padding: 24px 26px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); max-width: 880px; }
@media (max-width: 560px) { .instr { grid-template-columns: minmax(0, 1fr); } }
.avatar { width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center; font: 700 1.6rem/1 var(--head); color: #fff; background: radial-gradient(circle at 30% 30%, #2C55E0, #10161B 75%); }
.instr-n { margin: 0; font: 700 1.35rem/1.2 var(--head); }
.instr-n span { margin-left: 6px; font: 400 1rem var(--zh); color: var(--muted); }
.instr-r { margin: 6px 0 0; font: 400 0.84rem/1.5 var(--mono); color: var(--muted); }
.instr .h-p { margin-top: 12px; }
.faq { margin-top: 22px; border-top: 1px solid var(--line); max-width: 900px; }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 18px 4px; font: 600 1.03rem/1.4 var(--sans); }
.faq summary::-webkit-details-marker { display: none; }
.faq summary:hover { color: var(--accent); }
.faq summary .ic { width: 20px; height: 20px; color: var(--muted); margin-top: 2px; transition: transform 0.2s; }
.faq details[open] summary .ic { transform: rotate(180deg); }
html[data-lang="both"] .faq summary > [lang="zh-Hans"] { display: block; font-weight: 400; color: var(--muted); }
html[data-lang="both"] .faq summary { flex-wrap: wrap; }
.faq details > div { padding: 0 4px 20px; }
.faq details p { margin: 0; color: var(--muted); max-width: 72ch; line-height: 1.65; }
.faq details p + p { margin-top: 8px; }
.home footer { margin-top: 12px; }
/* bilingual (EN+中) refinements for the player chrome */
html[data-lang="both"] :is(.nav-week, .nav-prog, .tb-prog, .nav-home) [lang="zh-Hans"] { display: none; }
html[data-lang="both"] .meta b > span[lang="en"] + span[lang="zh-Hans"]::before { content: " · "; }
html[data-lang="both"] .hero-sum > span[lang="zh-Hans"] { display: none; }
/* text-size uses of the vis colours take the darker "ink" shade on light surfaces */
.tag.analysis { color: var(--neu-ink); }
.progress b { color: var(--neu-ink); }
:is([data-type="interactive"], [data-type="display"], [data-type="review"]) > .item-tag { color: var(--neu-ink); }
[data-type="errors"] > .item-tag { color: var(--warn-ink); }
[data-type="lab"] > .item-tag { color: var(--neg-ink); }
.syl-n { color: var(--neg-ink); }
.st-pill.ok, .mark[aria-pressed="true"] { color: var(--neu-ink); }
.player .step-head::before { color: var(--neg-ink); }
.player .steps > li.is-done .step-head::before { color: var(--neu-ink); }
.q-fb b.right { color: var(--neu-ink); }
.tag.musrsim { color: var(--neg-ink); }
/* copy buttons sit beside, not inside, a file's <summary> */
.file { position: relative; min-width: 0; }
.file > .copy { position: absolute; right: 10px; top: 6px; z-index: 1; }
.file > details > summary { padding-right: 76px; }

/* pilot fixes: tap targets, GIF fallback shape, home path cards */
.done input, .review input { width: 20px; height: 20px; }
.ctl input[type=range] { height: 28px; }
.evd-fallback .evd-stage { aspect-ratio: 16 / 9; min-height: 0; }
.paths { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.gif-play { display: inline-flex; margin-top: 10px; }
html[data-lang="both"] .gif-play > span[lang="zh-Hans"]::before { content: " · "; }
.dl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 16px 0 6px; }
.dl .btn-s { font-size: 0.9rem; padding: 9px 14px; }
.dl-all { font: 500 0.82rem/1.3 var(--mono); }
html[data-lang="both"] .dl .btn-s > span[lang="zh-Hans"]::before { content: " · "; }
html[data-lang="both"] .dl-all > span[lang="zh-Hans"]::before { content: " · "; }

/* ---------- optional AI assistant (assets/assistant.js) ---------- */
.ai-launches { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 4px; }
.ai-launch { display: inline-flex; align-items: center; gap: 8px; font: 600 0.88rem/1.2 var(--sans); padding: 9px 14px; border-radius: 8px; border: 1px dashed var(--accent); background: var(--accent-soft); color: var(--accent); cursor: pointer; }
.ai-launch:hover { border-style: solid; }
.ai-launch .ic { width: 18px; height: 18px; }
.ai-launch small { font: 400 0.72rem/1.2 var(--mono); color: var(--muted); margin-left: 4px; }
.ai-launch.alt { border-color: var(--neg-ink); color: var(--neg-ink); background: var(--tint-neg); }
html[data-lang="both"] .ai-launch > span[lang="en"] + span[lang="zh-Hans"]::before, html[data-lang="both"] .ai-launch small > span[lang="en"] + span[lang="zh-Hans"]::before { content: " · "; }
.ai-panel { position: fixed; inset: 0; z-index: 80; background: rgba(8, 12, 16, 0.45); display: flex; justify-content: flex-end; }
.ai-panel[hidden] { display: none; }
.ai-box { width: min(560px, 100%); height: 100%; height: 100dvh; background: var(--bg); border-left: 1px solid var(--line); box-shadow: var(--sh-2); display: flex; flex-direction: column; padding: 16px 18px max(16px, env(safe-area-inset-bottom, 0px)); gap: 10px; }
.ai-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.ai-title { margin: 0; display: flex; gap: 8px; align-items: center; font: 700 1.1rem/1.2 var(--head); }
.ai-title .ic { width: 22px; height: 22px; color: var(--accent); }
.ai-opt { font: 400 0.72rem var(--mono); color: var(--muted); margin-left: 6px; }
.ai-x { border: 0; background: transparent; color: var(--fg); width: 40px; height: 40px; border-radius: 8px; cursor: pointer; }
.ai-x:hover { background: var(--surface-2); }
.ai-x .ic { width: 20px; height: 20px; }
.ai-ctx { margin: 0; font: 400 0.76rem/1.5 var(--mono); color: var(--muted); }
.ai-ctx b { color: var(--fg); font-weight: 500; }
.ai-chat { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px; }
.ai-msg { max-width: 100%; font-size: 0.94rem; line-height: 1.55; }
.ai-msg p { margin: 0 0 8px; }
.ai-msg ul, .ai-msg ol { margin: 0 0 8px; padding-left: 1.2em; }
.ai-msg.assistant { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.ai-msg.err { border-color: var(--warn); background: var(--tint-warn); }
.ai-msg.user { align-self: flex-end; max-width: 92%; }
.ai-pre { margin: 6px 0; font: 400 0.8rem/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; max-height: 320px; overflow: auto; }
.ai-mine { background: var(--accent-soft); border-color: transparent; }
.ai-h { font-weight: 600; }
.ai-note { margin: 0; font: 400 0.84rem/1.5 var(--sans); color: var(--muted); }
.ai-form textarea { width: 100%; font: 400 0.88rem/1.5 var(--mono); color: var(--fg); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px; resize: vertical; min-height: 88px; }
.ai-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-top: 8px; }
.ai-link { border: 0; background: transparent; color: var(--accent); font: 500 0.84rem var(--sans); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; padding: 8px 4px; }
.ai-link .ic { width: 16px; height: 16px; }
.ai-box.busy .ai-send::after { content: "…"; }
.ai-settings { display: grid; gap: 12px; overflow-y: auto; }
.ai-settings label { display: grid; gap: 4px; font: 500 0.8rem var(--mono); color: var(--muted); }
.ai-settings input[type=password], .ai-settings input[type=text], .ai-settings input[type=url], .ai-settings select { font: 400 0.92rem var(--sans); color: var(--fg); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 9px 10px; }
.ai-settings .ai-check { grid-template-columns: 24px 1fr; align-items: start; font-family: var(--sans); }
.ai-sub { margin: 0; font: 600 0.95rem var(--sans); }
.ai-privacy { margin: 4px 0 0; padding-left: 1.1em; font-size: 0.84rem; color: var(--muted); line-height: 1.5; }
.ai-privacy li + li { margin-top: 6px; }
html[data-lang="both"] .ai-privacy li > [lang="zh-Hans"], html[data-lang="both"] .ai-settings label > [lang="zh-Hans"] { display: block; }
html.ai-open { overflow: hidden; }
.ai-panel [hidden] { display: none !important; }

/* ======================================================================
   v3 brand layer — "From Track to Truth"
   Deep-space navy, cyan→electric-blue gradient, glass surfaces and
   Blender-rendered covers. Overrides the tokens above; light and dark kept.
   ====================================================================== */
:root {
  --bg: #F3F5F9; --panel: #FFFFFF; --fg: #0B1220; --muted: #4F5B6C;
  --pos: #2450F0; --hist: #2450F0; --accent: #2450F0; --accent-soft: rgba(36, 80, 240, 0.08);
  --surface: #FFFFFF; --surface-2: #E9EDF4;
  --line: rgba(11, 18, 32, 0.10); --line-strong: rgba(11, 18, 32, 0.22);
  --display-bg: #060B16;
  --cy: #22D3EE; --el: #3B6BFF; --vi: #8B7BFF;
  --grad: linear-gradient(95deg, #22D3EE 0%, #3B6BFF 55%, #8B7BFF 100%);
  --grad-ink: linear-gradient(95deg, #0E7490 0%, #2450F0 55%, #5B45E0 100%);
  --sh-2: 0 18px 40px -18px rgba(11, 30, 80, 0.28), 0 2px 6px rgba(11, 18, 32, 0.05);
  --glow: 0 0 0 1px rgba(34, 211, 238, 0.25), 0 10px 40px -10px rgba(59, 107, 255, 0.45);
  --space: #060B16;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070C18; --panel: #0D1528; --fg: #E6ECF5; --muted: #95A3B8;
    --pos: #6E93FF; --hist: #6E93FF; --accent: #6FB7FF; --accent-ink: #04101C; --accent-soft: rgba(111, 183, 255, 0.12);
    --surface: #0D1528; --surface-2: #131E36;
    --line: rgba(160, 190, 255, 0.11); --line-strong: rgba(160, 190, 255, 0.24);
    --grad-ink: var(--grad);
    --sh-2: 0 20px 44px -18px rgba(0, 0, 0, 0.75);
  }
}
:root[data-theme="dark"] {
  --bg: #070C18; --panel: #0D1528; --fg: #E6ECF5; --muted: #95A3B8;
  --pos: #6E93FF; --hist: #6E93FF; --accent: #6FB7FF; --accent-ink: #04101C; --accent-soft: rgba(111, 183, 255, 0.12);
  --surface: #0D1528; --surface-2: #131E36;
  --line: rgba(160, 190, 255, 0.11); --line-strong: rgba(160, 190, 255, 0.24);
  --grad-ink: var(--grad);
  --sh-2: 0 20px 44px -18px rgba(0, 0, 0, 0.75);
}
html { overflow-x: clip; }
.grad { font-style: normal; background: var(--grad-ink); -webkit-background-clip: text; background-clip: text; color: transparent; }
.eyebrow { color: var(--accent); }
h1 { letter-spacing: -0.02em; }

/* brand wordmark in the top bar */
.brand .wm { font-weight: 700; letter-spacing: -0.01em; }
.logo-bg { fill: var(--space) !important; }

/* primary buttons: electric gradient */
.btn-p { background: linear-gradient(95deg, #0B7AA3, #2450F0 60%, #4B3BD6) !important; color: #fff !important; border: 0 !important; box-shadow: 0 8px 24px -10px rgba(46, 91, 255, 0.7); }
.btn-p:hover { filter: brightness(1.08); box-shadow: 0 10px 30px -8px rgba(46, 91, 255, 0.85); }

/* ---------- course home: full-bleed dark hero with the Blender render ---------- */
.is-home .h-hero {
  position: relative; isolation: isolate; color: #E8EEF8;
  margin-inline: calc(50% - 50vw); padding: clamp(56px, 9vw, 120px) calc(50vw - 50% + max(16px, env(safe-area-inset-right, 0px))) clamp(56px, 7vw, 96px);
  background: var(--space); grid-template-columns: minmax(0, 1fr) minmax(0, 360px); align-items: end; min-height: min(86vh, 820px);
  overflow: hidden; border-bottom: 1px solid rgba(34, 211, 238, 0.18);
}
.h-hero-bg { position: absolute; inset: 0; z-index: -1; }
.h-hero-bg img { width: 100%; height: 100%; object-fit: cover; object-position: 70% 40%; display: block; }
.h-hero-bg::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(6, 11, 22, 0.94) 0%, rgba(6, 11, 22, 0.78) 34%, rgba(6, 11, 22, 0.15) 64%, rgba(6, 11, 22, 0.35) 100%),
              linear-gradient(0deg, rgba(6, 11, 22, 0.9) 0%, rgba(6, 11, 22, 0) 38%); }
.is-home .h-hero .h-hero-l { max-width: 680px; }
.pill { display: inline-flex; align-items: center; gap: 9px; margin: 0 0 22px; padding: 6px 14px 6px 10px; border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.35); background: rgba(34, 211, 238, 0.08); color: #BFF3FF; font: 500 0.76rem/1.2 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; }
.pill-dot { width: 7px; height: 7px; border-radius: 50%; background: #22D3EE; box-shadow: 0 0 10px #22D3EE; }
html[data-lang="both"] .pill > [lang="zh-Hans"] { display: none; }
.b-title { font: 700 clamp(3rem, 8.4vw, 6.6rem)/0.94 var(--head); letter-spacing: -0.035em; color: #F4F8FF; margin: 0; }
.b-title i { font-style: normal; font-weight: 300; color: rgba(232, 238, 248, 0.6); }
.b-title .grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 28px rgba(34, 211, 238, 0.35)); }
html[data-lang="both"] .b-title > [lang="zh-Hans"] { display: block; margin-top: 10px; font: 600 clamp(1.5rem, 3.4vw, 2.4rem)/1.15 var(--zh); letter-spacing: 0.02em; }
.b-sub { margin: 22px 0 0; max-width: 34em; font: 400 clamp(1.05rem, 1.6vw, 1.28rem)/1.5 var(--sans); color: #C9D6E8; }
html[data-lang="both"] .b-sub > [lang="zh-Hans"] { display: block; margin-top: 6px; font-size: 0.92em; color: #9FB0C8; }
.is-home .h-hero .lede { color: #A9B8CE; font-size: 0.98rem; max-width: 40em; }
.is-home .h-hero .h-facts b { color: #F0F5FF; }
.is-home .h-hero .h-facts, .is-home .h-hero .h-facts span, .is-home .h-hero .h-by { color: #9FB0C8; }
.is-home .h-hero .h-facts .ic { color: #22D3EE; background: rgba(34, 211, 238, 0.1); }
.is-home .h-hero .h-by b { color: #E8EEF8; }
.is-home .h-hero .btn-s { background: rgba(255, 255, 255, 0.06); color: #E8EEF8; border-color: rgba(255, 255, 255, 0.22); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.is-home .h-hero .btn-s:hover { background: rgba(255, 255, 255, 0.12); }
.is-home .h-hero .incl { background: rgba(12, 20, 40, 0.55); border: 1px solid rgba(140, 180, 255, 0.18); box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3); color: #DDE6F3; }
.is-home .h-hero .incl-h { color: #F4F8FF; }
.is-home .h-hero .incl li .ic { background: rgba(34, 211, 238, 0.12); color: #5CE1FF; }
.is-home .h-hero .incl-prog { border-bottom-color: rgba(140, 180, 255, 0.18); }
.is-home .h-hero .incl-prog > div:last-child > span { color: #9FB0C8; }
.is-home .h-hero :focus-visible { outline-color: #5CE1FF; }
@media (max-width: 960px) {
  .is-home .h-hero { grid-template-columns: minmax(0, 1fr); min-height: 0; padding-top: 240px; }
  .h-hero-bg img { height: 420px; object-position: 60% 30%; }
  .h-hero-bg::after { background: linear-gradient(180deg, rgba(6, 11, 22, 0.1) 0%, rgba(6, 11, 22, 0.55) 200px, var(--space) 420px); }
}
/* the hero sits right under the bar: make the bar dark over it */
.is-home .topbar { background: rgba(6, 11, 22, 0.72); border-bottom-color: rgba(140, 180, 255, 0.12); }
.is-home .topbar .brand, .is-home .topbar .tb-week, .is-home .topbar .tb-link { color: #E8EEF8; }
.is-home .topbar .lang button { color: #C9D6E8; }
.is-home .topbar .lang button[aria-pressed="true"] { color: #04101C; background: #E8EEF8; }

/* ---------- section headings on the home page ---------- */
.is-home .h-sec h2 { font-size: clamp(1.8rem, 3.6vw, 2.6rem); letter-spacing: -0.025em; }
.is-home .h-sec { border-top: 0; position: relative; }
.is-home .h-sec::before { content: ""; display: block; width: 48px; height: 3px; border-radius: 3px; background: var(--grad); margin-bottom: 18px; }

/* glassy cards */
.path, .syl-w, .instr, .faq details { border-radius: 16px; }
.path { transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s; }
a.path:hover { transform: translateY(-2px); box-shadow: var(--glow); border-color: rgba(59, 107, 255, 0.5); }

/* syllabus: rendered thumbnails instead of number tiles */
.syl-w summary { grid-template-columns: 112px minmax(0, 1fr) auto 20px; }
.syl-th { position: relative; width: 112px; height: 56px; border-radius: 10px; background-color: var(--space); background-size: cover; background-position: center; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(140, 180, 255, 0.18); }
.syl-th::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(6, 11, 22, 0.82), rgba(6, 11, 22, 0) 70%); }
.syl-th b { position: relative; z-index: 1; font: 700 1.05rem/1 var(--mono); color: #fff; letter-spacing: 0.02em; justify-self: start; margin-left: 10px; text-shadow: 0 0 12px rgba(34, 211, 238, 0.8); }
.syl-w summary:hover .syl-th { box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.7), 0 0 20px -4px rgba(34, 211, 238, 0.6); }
.syl-body { padding-left: 146px; }
@media (max-width: 640px) {
  .syl-w summary { grid-template-columns: 72px minmax(0, 1fr) 20px; }
  .syl-w summary > .syl-pill, .syl-w summary > :nth-child(3):not(.ic) { display: none; }
  .syl-th { width: 72px; height: 48px; }
  .syl-body { padding-left: 18px; }
}
.syl-sn { background: var(--grad); }

/* ---------- week pages: Blender cover banner ---------- */
.wk-cover { position: relative; margin: 18px 0 6px; border-radius: 20px; overflow: hidden; background: var(--space); aspect-ratio: 5 / 2; box-shadow: 0 30px 60px -36px rgba(6, 20, 60, 0.8); }
.wk-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wk-cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(6, 11, 22, 0.7) 0%, rgba(6, 11, 22, 0) 45%), linear-gradient(0deg, rgba(6, 11, 22, 0.55) 0%, rgba(6, 11, 22, 0) 40%); pointer-events: none; }
.wk-cover-n { position: absolute; z-index: 1; left: clamp(16px, 3vw, 32px); bottom: clamp(8px, 2vw, 18px); font: 700 clamp(3.2rem, 9vw, 7rem)/0.9 var(--head); letter-spacing: -0.04em;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 22px rgba(34, 211, 238, 0.4)); }
@media (max-width: 640px) { .wk-cover { aspect-ratio: 16 / 9; border-radius: 14px; margin-top: 10px; } .wk-cover img { object-position: 60% 50%; } }
.player .hero h1 { letter-spacing: -0.025em; }
.player .hero .statbox { border-color: var(--line-strong); }
.player .hero .statbox div:first-child { background: var(--space); color: #8FE9FF; border-bottom-color: rgba(34, 211, 238, 0.25); }
@media (min-width: 961px) {
  .h-hero-bg { left: 26%; }
  .h-hero-bg::after { background: linear-gradient(90deg, #060B16 0%, rgba(6, 11, 22, 0.55) 22%, rgba(6, 11, 22, 0) 50%, rgba(6, 11, 22, 0.25) 100%),
                                  linear-gradient(0deg, #060B16 0%, rgba(6, 11, 22, 0) 30%); }
}
.is-home .topbar { background: rgba(6, 11, 22, 0.94); }
.is-home .h-hero .ring b, .is-home .h-hero .ring small, .is-home .h-hero .ring span { color: #E8EEF8; }
.is-home .h-hero .incl-prog > div:last-child > b { color: #F4F8FF; }
@media (max-width: 520px) { .pill { letter-spacing: 0.03em; font-size: 0.7rem; } }
.is-home .h-hero .ring .bg { stroke: rgba(140, 180, 255, 0.16); } .is-home .h-hero .ring b small { color: #9FB0C8; }
.nav-week { color: var(--accent) !important; }
.player .hero .statbox div:first-child * { color: #8FE9FF; }
html[data-lang="both"] .h-facts b > [lang="zh-Hans"]::before, html[data-lang="both"] .incl-h > [lang="zh-Hans"]::before { content: " · "; }
html[data-lang="both"] .is-home .h-hero .lede[lang="zh-Hans"] { margin-top: 8px; }
