/* USAAIO study site. Tokens first; dark mode follows the system unless data-theme is set. */
:root {
  --bg: #f6f5f1; --surface: #ffffff; --surface-2: #f0efea; --surface-3: #e8e6df;
  --text: #1b1d20; --text-2: #40454d; --muted: #646a73; --border: #e1ded6; --border-strong: #c9c5bb;
  --accent: #2a57c0; --accent-hover: #2149a6; --accent-ink: #ffffff; --accent-soft: #e7edfa; --accent-line: #b9c9ef;
  --ok: #19703f; --ok-soft: #e3f3e8; --ok-line: #9fd3b1;
  --bad: #b3261e; --bad-soft: #fbe9e7; --bad-line: #efb2ab;
  --warn: #8a5a00; --warn-soft: #fdf3d8; --warn-line: #e9cf86;
  --violet: #6b3fb5; --violet-soft: #f1ebfa; --violet-line: #cdb8ef;
  --blank: #5b6573; --blank-soft: #eceef1;
  --code-bg: #f3f2ed; --code-fg: #22252a; --code-border: #e4e1d8;
  --syn-kw: #8d2fb0; --syn-str: #2f7d32; --syn-num: #b4500b; --syn-com: #61666e; --syn-def: #1f5fbf; --syn-builtin: #0b6f78;
  --syn-op: #5b5f66; --syn-prop: #22252a; --syn-meta: #a0522d;
  --c1: #2a57c0; --c2: #c2410c; --c3: #17804a; --c4: #8b3fb8; --c5: #a16207;
  --shadow: 0 1px 2px rgba(20, 20, 15, .06), 0 2px 8px rgba(20, 20, 15, .04);
  --shadow-lg: 0 10px 40px rgba(20, 20, 15, .18);
  --radius: 10px; --radius-sm: 7px;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-read: Charter, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, Monaco, Consolas, monospace;
  --topbar-h: 52px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111316; --surface: #191c20; --surface-2: #20242a; --surface-3: #2a2f36;
    --text: #e6e7e9; --text-2: #c3c7cd; --muted: #959ca6; --border: #2b3036; --border-strong: #3c434b;
    --accent: #7ea3ff; --accent-hover: #9ab7ff; --accent-ink: #0c1220; --accent-soft: #1b2741; --accent-line: #34508a;
    --ok: #5cc98d; --ok-soft: #12291c; --ok-line: #2a6141;
    --bad: #ff8a7f; --bad-soft: #341614; --bad-line: #7a3029;
    --warn: #e6b94f; --warn-soft: #2f250c; --warn-line: #6e5520;
    --violet: #c3a3ff; --violet-soft: #251b38; --violet-line: #4f3a7a;
    --blank: #a6afbb; --blank-soft: #252a31;
    --code-bg: #15181c; --code-fg: #dfe2e6; --code-border: #2a2f35;
    --syn-kw: #d49bf0; --syn-str: #93d18f; --syn-num: #f0a868; --syn-com: #7e8794; --syn-def: #82b1ff; --syn-builtin: #5fd0d8;
    --syn-op: #aab1ba; --syn-prop: #dfe2e6; --syn-meta: #e3a27a;
    --c1: #7ea3ff; --c2: #ff9b6a; --c3: #5cc98d; --c4: #c79bff; --c5: #e6b94f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111316; --surface: #191c20; --surface-2: #20242a; --surface-3: #2a2f36;
  --text: #e6e7e9; --text-2: #c3c7cd; --muted: #959ca6; --border: #2b3036; --border-strong: #3c434b;
  --accent: #7ea3ff; --accent-hover: #9ab7ff; --accent-ink: #0c1220; --accent-soft: #1b2741; --accent-line: #34508a;
  --ok: #5cc98d; --ok-soft: #12291c; --ok-line: #2a6141;
  --bad: #ff8a7f; --bad-soft: #341614; --bad-line: #7a3029;
  --warn: #e6b94f; --warn-soft: #2f250c; --warn-line: #6e5520;
  --violet: #c3a3ff; --violet-soft: #251b38; --violet-line: #4f3a7a;
  --blank: #a6afbb; --blank-soft: #252a31;
  --code-bg: #15181c; --code-fg: #dfe2e6; --code-border: #2a2f35;
  --syn-kw: #d49bf0; --syn-str: #93d18f; --syn-num: #f0a868; --syn-com: #7e8794; --syn-def: #82b1ff; --syn-builtin: #5fd0d8;
  --syn-op: #aab1ba; --syn-prop: #dfe2e6; --syn-meta: #e3a27a;
  --c1: #7ea3ff; --c2: #ff9b6a; --c3: #5cc98d; --c4: #c79bff; --c5: #e6b94f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15.5px/1.5 var(--font-ui); -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.08rem; }
p { margin: 0 0 .8em; }
code, kbd, pre, .mono { font-family: var(--font-mono); font-size: .9em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-soft); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
kbd { background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 .35em; font-size: .8em; color: var(--text-2); }

/* ------------------------------------------------------------------ top bar */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 18px; padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 7px; text-decoration: none; color: var(--text); flex: none; }
.brand-mark { width: 20px; height: 20px; border-radius: 6px; background: var(--accent);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='7'/%3E%3C/svg%3E"); position: relative; }
.brand-mark::after { content: ""; position: absolute; inset: 5px 4px 6px; border: 2.5px solid var(--accent-ink); border-top: 0; border-right-color: transparent;
  transform: skewX(0); clip-path: polygon(50% 0, 100% 100%, 0 100%); border: 0; background: var(--accent-ink); }
.brand-name { font-weight: 700; letter-spacing: .04em; font-size: .95rem; }
.brand-sub { color: var(--muted); font-size: .95rem; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--text-2); text-decoration: none; padding: 6px 11px; border-radius: 7px; white-space: nowrap; font-size: .93rem; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex: none; }
.countdown { font-size: .85rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* ------------------------------------------------------------------ session bar */
.session-bar { position: sticky; top: var(--topbar-h); z-index: 25; background: var(--surface); border-bottom: 1px solid var(--border); }
.session-inner { max-width: 1240px; margin: 0 auto; padding: 7px 20px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.session-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.session-steps { list-style: none; display: flex; gap: 4px; margin: 0; padding: 0; flex-wrap: wrap; }
.step { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  border-radius: 999px; padding: 3px 10px 3px 4px; font: inherit; font-size: .84rem; cursor: pointer; }
.step-n { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.step.current { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.step.current .step-n { background: var(--accent); color: var(--accent-ink); }
.step.done { color: var(--ok); }
.step.done .step-n { background: var(--ok); }
.step.done .step-n::after { content: ""; width: 8px; height: 4px; border: 2px solid var(--surface); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.session-progress { flex: 1; min-width: 80px; height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.session-progress-fill { height: 100%; background: var(--ok); border-radius: 99px; transition: width .3s; }
.session-actions { display: flex; gap: 6px; align-items: center; }
.session-done { color: var(--ok); font-weight: 600; font-size: .9rem; }

/* ------------------------------------------------------------------ layout */
main { outline: none; }
.page { max-width: 1120px; margin: 0 auto; padding: 28px 28px 80px; }
.page.wide { max-width: none; padding: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin: 4px 0 0; }
.eyebrow { font-size: .78rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 16px; }
.panel h2 { font-size: 1.1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }
.error-panel { border-color: var(--bad-line); background: var(--bad-soft); }
.error-panel h2 { color: var(--bad); }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 40px 0; justify-content: center; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 36px 20px; color: var(--text-2); }
.empty h2 { margin-bottom: 8px; }

/* ------------------------------------------------------------------ controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-size: .93rem; font-weight: 550; line-height: 1.2;
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn { max-width: 100%; }
.lesson-links .btn, .session-next, .quick a { white-space: normal; text-align: left; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { padding: 4px 10px; font-size: .84rem; }
.btn.big { padding: 12px 22px; font-size: 1.02rem; border-radius: 9px; }
.btn .kbd-hint { font-size: .75rem; opacity: .75; font-weight: 500; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { font: inherit; font-size: .9rem; padding: 6px 14px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
select, input[type="text"], input[type="number"], input[type="search"] { font: inherit; font-size: .93rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 7px 10px; }
select { padding-right: 28px; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: .85rem; color: var(--text-2); font-weight: 550; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: .76rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2);
  color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; line-height: 1.5; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.chip.muted { color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.bar { height: 7px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar.ok > span { background: var(--ok); }

/* toasts and dialogs */
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: min(440px, calc(100vw - 36px)); }
.toast { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-left: 4px solid var(--accent); border-radius: 8px;
  padding: 10px 14px; box-shadow: var(--shadow-lg); font-size: .92rem; transition: opacity .3s, transform .3s; }
.toast-error { border-left-color: var(--bad); }
.toast-ok { border-left-color: var(--ok); }
.toast.out { opacity: 0; transform: translateY(6px); }
.dialog { border: 1px solid var(--border); border-radius: 12px; padding: 22px 24px; max-width: 460px; width: calc(100vw - 40px); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.dialog::backdrop { background: rgba(10, 12, 16, .45); }
.dialog h2 { font-size: 1.15rem; }
.dialog p { color: var(--text-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ------------------------------------------------------------------ prose (lessons, statements, solutions) */
.prose { font-family: var(--font-read); font-size: 1.1rem; line-height: 1.62; color: var(--text); overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p, .prose ul, .prose ol { margin: 0 0 .9em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: .2em 0; }
.prose h2 { font-family: var(--font-ui); font-size: 1.3rem; margin: 1.8em 0 .55em; }
.prose h3 { font-family: var(--font-ui); font-size: 1.1rem; margin: 1.5em 0 .45em; }
.prose h4 { font-family: var(--font-ui); font-size: 1rem; margin: 1.3em 0 .4em; }
.prose strong { font-weight: 700; }
.prose :not(pre) > code { background: var(--code-bg); border: 1px solid var(--code-border); border-radius: 5px; padding: .05em .32em; font-size: .84em; color: var(--code-fg); overflow-wrap: anywhere; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.prose blockquote { margin: 0 0 1em; padding: .1em 1em; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.prose img { max-width: 100%; }
.table-wrap { overflow-x: auto; margin: 0 0 1em; }
.prose table { border-collapse: collapse; font-family: var(--font-ui); font-size: .92rem; min-width: 50%; }
.prose th, .prose td { border-bottom: 1px solid var(--border); padding: 7px 14px 7px 0; text-align: left; vertical-align: top; }
.prose th { font-weight: 650; color: var(--text-2); border-bottom-color: var(--border-strong); }
.code-block { background: var(--code-bg); border: 1px solid var(--code-border); border-radius: 8px; padding: 12px 14px; overflow-x: auto; margin: 0 0 1em;
  font-size: .86rem; line-height: 1.55; color: var(--code-fg); }
.code-block code { font-size: inherit; background: none; border: 0; padding: 0; white-space: pre; }
.math-block { overflow-x: auto; overflow-y: hidden; margin: .2em 0 1em; padding: 2px 0; }
.math-block .katex-display { margin: .4em 0; }
.prose .katex { font-size: 1.06em; }
.math-error { color: var(--bad); }
.gloss { border-bottom: 1.5px dotted var(--accent); cursor: help; text-decoration: none; }
.gloss:hover, .gloss:focus { background: var(--accent-soft); outline: none; border-radius: 2px; }
.gloss-tip { position: absolute; z-index: 50; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 9px; box-shadow: var(--shadow-lg);
  padding: 10px 13px; font-size: .9rem; line-height: 1.45; color: var(--text); }
.gloss-term { font-weight: 700; margin-bottom: 3px; text-transform: capitalize; }
.gloss-def code { background: var(--code-bg); border-radius: 4px; padding: 0 .25em; font-size: .85em; }

/* ------------------------------------------------------------------ lesson reader */
.reader { max-width: 72ch; margin: 0 auto; }
.reader-wrap { padding: 32px 28px 100px; }
.lesson-head { margin-bottom: 28px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.lesson-head h1 { font-size: 2rem; margin: 4px 0 10px; }
.lesson-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: .9rem; }
.lesson-goals { margin: 14px 0 0; color: var(--text-2); font-size: .98rem; }
.lesson-goals strong { color: var(--text); }
.reading-progress { position: fixed; top: var(--topbar-h); left: 0; height: 2px; background: var(--accent); z-index: 31; width: 0; transition: width .1s; }
.in-session .reading-progress { display: none; }
.lesson-foot { margin-top: 48px; padding-top: 22px; border-top: 1px solid var(--border); }
.lesson-done-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.lesson-links { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.prevnext a, .prevnext .disabled { display: block; padding: 12px 14px; border: 1px solid var(--border); border-radius: 9px; text-decoration: none; color: var(--text); background: var(--surface); }
.prevnext a:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.prevnext .dir { display: block; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 2px; }
.prevnext .next { text-align: right; }
.prevnext .disabled { color: var(--muted); background: transparent; border-style: dashed; }
.block { margin: 1.6em 0; }

/* callouts */
.callout { --c: var(--accent); --cs: var(--accent-soft); --cl: var(--accent-line); border: 1px solid var(--cl); border-left: 4px solid var(--c); background: var(--cs);
  border-radius: 8px; padding: 12px 16px; margin: 1.4em 0; }
.callout .prose { font-size: 1.02rem; }
.callout-label { font-family: var(--font-ui); font-size: .76rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--c); margin-bottom: 4px; }
.callout-label .t { text-transform: none; letter-spacing: 0; font-size: .92rem; color: var(--text); margin-left: 6px; font-weight: 650; }
.callout.tip { --c: var(--ok); --cs: var(--ok-soft); --cl: var(--ok-line); }
.callout.warn { --c: var(--warn); --cs: var(--warn-soft); --cl: var(--warn-line); }
.callout.example { --c: var(--violet); --cs: var(--violet-soft); --cl: var(--violet-line); }
.callout.deeper { --c: var(--muted); --cs: var(--surface); --cl: var(--border); padding: 0; }
.callout.deeper > summary { cursor: pointer; padding: 11px 16px; list-style: none; display: flex; align-items: center; gap: 8px; }
.callout.deeper > summary::-webkit-details-marker { display: none; }
.callout.deeper > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; flex: none; }
.callout.deeper[open] > summary::before { transform: rotate(45deg); }
.callout.deeper > summary .callout-label { margin: 0; }
.callout.deeper > .callout-body { padding: 0 16px 14px 31px; }

/* try cells */
.try { border: 1px solid var(--code-border); border-radius: 9px; overflow: hidden; background: var(--code-bg); margin: 1.4em 0; font-family: var(--font-ui); }
.try-bar { display: flex; align-items: center; gap: 8px; padding: 5px 8px 5px 12px; border-bottom: 1px solid var(--code-border); background: var(--surface-2); }
.try-bar .label { font-size: .76rem; font-weight: 700; color: var(--muted); letter-spacing: .07em; text-transform: uppercase; }
.try .CodeMirror { height: auto; background: var(--code-bg); font-size: 13.5px; }
.try .CodeMirror-scroll { max-height: 520px; }
.try-out { border-top: 1px solid var(--code-border); background: var(--surface); padding: 10px 14px; font-size: .86rem; }
.try-out pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: var(--font-mono); font-size: .84rem; line-height: 1.5; color: var(--text); }
.try-out .out-label { font-size: .72rem; font-weight: 700; letter-spacing: .07em; color: var(--muted); text-transform: uppercase; margin: 6px 0 2px; }
.try-out .out-label:first-child { margin-top: 0; }
.try-out .err { color: var(--bad); }
.try-out img { max-width: 100%; display: block; margin-top: 8px; border-radius: 6px; background: #fff; }
.try-out .none { color: var(--muted); font-style: italic; }

/* ------------------------------------------------------------------ CodeMirror theme */
.cm-s-study.CodeMirror { background: var(--code-bg); color: var(--code-fg); font-family: var(--font-mono); line-height: 1.55; }
.cm-s-study .CodeMirror-gutters { background: var(--code-bg); border-right: 1px solid var(--code-border); }
.cm-s-study .CodeMirror-linenumber { color: var(--muted); opacity: .75; padding: 0 8px 0 6px; }
.cm-s-study .CodeMirror-cursor { border-left: 2px solid var(--accent); }
.cm-s-study .CodeMirror-selected, .cm-s-study.CodeMirror-focused .CodeMirror-selected { background: var(--accent-soft) !important; }
.cm-s-study .CodeMirror-line::selection, .cm-s-study .CodeMirror-line > span::selection, .cm-s-study .CodeMirror-line > span > span::selection { background: var(--accent-soft); }
.cm-s-study .CodeMirror-matchingbracket { color: var(--ok) !important; font-weight: 700; background: var(--ok-soft); }
.cm-s-study .CodeMirror-nonmatchingbracket { color: var(--bad) !important; }
.cm-s-study .cm-keyword { color: var(--syn-kw); }
.cm-s-study .cm-string, .cm-s-study .cm-string-2 { color: var(--syn-str); }
.cm-s-study .cm-number { color: var(--syn-num); }
.cm-s-study .cm-comment { color: var(--syn-com); font-style: italic; }
.cm-s-study .cm-def { color: var(--syn-def); font-weight: 600; }
.cm-s-study .cm-builtin { color: var(--syn-builtin); }
.cm-s-study .cm-operator { color: var(--syn-op); }
.cm-s-study .cm-variable, .cm-s-study .cm-property, .cm-s-study .cm-variable-2 { color: var(--syn-prop); }
.cm-s-study .cm-variable-2 { color: var(--syn-def); }
.cm-s-study .cm-meta { color: var(--syn-meta); }
.cm-s-study .cm-atom { color: var(--syn-num); }
.cm-s-study .cm-error { color: var(--bad); }
.CodeMirror-focused { outline: none; }

/* ------------------------------------------------------------------ Part 1 items */
.item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin: 1.6em 0; box-shadow: var(--shadow); font-family: var(--font-ui); }
.item-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.item-num { font-weight: 700; font-size: .95rem; margin-right: 4px; }
.item-stem { font-size: 1.04rem; margin-bottom: 14px; }
.choices { display: grid; gap: 8px; }
.choice { display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: left; font: inherit; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--border-strong); border-radius: 9px; padding: 10px 12px; cursor: pointer; transition: border-color .12s, background .12s; position: relative; }
.choice:hover:not(:disabled) { border-color: var(--accent-line); background: var(--accent-soft); }
.choice.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.choice:disabled { cursor: default; }
.choice-letter { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem;
  border: 1.5px solid var(--border-strong); color: var(--text-2); background: var(--surface); }
.choice.selected .choice-letter { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.choice-body { padding-top: 2px; line-height: 1.45; flex: 1; min-width: 0; overflow-x: auto; }
.choice-body code { background: var(--code-bg); border: 1px solid var(--code-border); border-radius: 4px; padding: 0 .3em; font-size: .86em; }
.choice-mark { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 2px 7px; border-radius: 99px; align-self: center; flex: none; }
.choice-mark.ok { color: var(--ok); background: var(--ok-soft); }
.choice-mark.bad { color: var(--bad); background: var(--bad-soft); }
.choice.is-correct { border-color: var(--ok); background: var(--ok-soft); box-shadow: none; }
.choice.is-correct .choice-letter { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.choice.is-wrong { border-color: var(--bad); background: var(--bad-soft); box-shadow: none; }
.choice.is-wrong .choice-letter { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.answered .choice:not(.is-correct):not(.is-wrong) { opacity: .7; }
.choice.static { cursor: default; }
.int-answer { display: flex; flex-direction: column; gap: 6px; }
.int-answer label { font-size: .85rem; font-weight: 600; color: var(--text-2); }
.int-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.int-input { width: 4.6em; font-family: var(--font-mono) !important; font-size: 1.5rem !important; letter-spacing: .25em; text-align: center; padding: 6px 4px 6px 10px !important; border-width: 1.5px !important; }
.int-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.int-help { font-size: .82rem; color: var(--muted); }
.item-actions { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.item-hint { font-size: .85rem; color: var(--warn); }
.item-feedback { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.verdict { padding: 10px 14px; border-radius: 8px; font-size: .95rem; border: 1px solid; }
.verdict.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.verdict.bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }
.verdict.blank { background: var(--blank-soft); color: var(--text-2); border-color: var(--border); }
.verdict strong { font-weight: 700; }
.why-wrong, .solution { border-left: 3px solid var(--border-strong); padding: 2px 0 2px 14px; }
.why-wrong { border-left-color: var(--bad-line); }
.solution { border-left-color: var(--ok-line); }
.label { font-size: .75rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.why-wrong .prose, .solution .prose, .others .prose { font-size: 1rem; }
.coach { font-size: .9rem; color: var(--text-2); margin: 0; }
.others summary { cursor: pointer; color: var(--text-2); font-size: .9rem; }
.others dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 10px 0 0; }
.others dt { font-weight: 700; color: var(--muted); }
.others dd { margin: 0; }
.int-review { font-size: .98rem; }

/* ------------------------------------------------------------------ Today */
.hero { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; align-items: stretch; }
.hero > .panel, .grid-2 > .panel, .grid-3 > .panel, .stat-row > .panel, .mock-start > .panel { margin-top: 0; }
.days { display: flex; flex-direction: column; justify-content: space-between; }
.days-n { font-size: 3.2rem; font-weight: 750; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.days-l { color: var(--text-2); margin-top: 6px; }
.weekbar { margin-top: 16px; }
.weekbar .bar { height: 9px; position: relative; overflow: visible; }
.weekbar .band { position: absolute; top: -3px; bottom: -3px; border-left: 1.5px dashed var(--muted); border-right: 1.5px dashed var(--muted); }
.plan-list { list-style: none; margin: 0; padding: 0; }
.plan-item { display: grid; grid-template-columns: 30px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.plan-item:last-child { border-bottom: 0; }
.plan-n { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); color: var(--text-2); display: grid; place-items: center; font-size: .82rem; font-weight: 700; }
.plan-item.done .plan-n { background: var(--ok); color: var(--surface); }
.plan-kind { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.plan-title { font-weight: 600; }
.plan-detail { color: var(--muted); font-size: .88rem; }
.plan-min { color: var(--text-2); font-variant-numeric: tabular-nums; font-size: .92rem; white-space: nowrap; }
.start-row { display: flex; align-items: center; gap: 14px; margin-top: 18px; flex-wrap: wrap; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 16px; }
.quick a { display: block; padding: 14px 16px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); text-decoration: none; color: var(--text); }
.quick a:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.quick .q-t { font-weight: 650; display: block; }
.quick .q-d { color: var(--muted); font-size: .86rem; }

/* ------------------------------------------------------------------ Learn map */
.map-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.round-h { margin: 34px 0 6px; font-size: 1.4rem; }
.round-h:first-of-type { margin-top: 8px; }
.round-sub { color: var(--muted); margin: 0 0 14px; }
.track-h { display: flex; align-items: center; gap: 10px; margin: 22px 0 10px; font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; }
.track-h::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.units { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.unit { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.unit > summary { list-style: none; cursor: pointer; padding: 14px 16px 12px; display: block; }
.unit > summary::-webkit-details-marker { display: none; }
.unit-top { display: flex; align-items: baseline; gap: 8px; }
.unit-id { font-family: var(--font-mono); font-size: .78rem; color: var(--muted); }
.unit-title { font-weight: 650; font-size: 1.02rem; flex: 1; }
.unit-count { font-size: .8rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.unit-summary { color: var(--text-2); font-size: .88rem; margin: 4px 0 8px; }
.unit .bar { height: 5px; }
.lessons { list-style: none; margin: 0; padding: 4px 0 6px; border-top: 1px solid var(--border); }
.lesson-row { display: grid; grid-template-columns: 18px 1fr auto; gap: 10px; padding: 8px 16px; align-items: start; }
.lesson-row + .lesson-row { border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.lesson-row .st { margin-top: 5px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--accent); }
.lesson-row.done .st { background: var(--ok); border-color: var(--ok); }
.lesson-row.coming .st { border: 2px dashed var(--border-strong); }
.lesson-row a, .lesson-row .lt { font-weight: 560; text-decoration: none; color: var(--text); }
.lesson-row a:hover { color: var(--accent); text-decoration: underline; }
.lesson-row.coming .lt { color: var(--muted); }
.lesson-row .goals { font-size: .83rem; color: var(--muted); line-height: 1.4; margin-top: 1px; }
.lesson-row .lm { display: flex; gap: 6px; align-items: center; font-size: .8rem; color: var(--muted); white-space: nowrap; margin-top: 2px; }
.prio { font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; }
.prio.p1 { color: var(--accent); background: var(--accent-soft); }
.prio.p2 { color: var(--text-2); background: var(--surface-2); }
.prio.p3 { color: var(--muted); border: 1px solid var(--border); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .84rem; color: var(--text-2); align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .st { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--accent); display: inline-block; }
.legend .st.done { background: var(--ok); border-color: var(--ok); }
.legend .st.coming { border-style: dashed; border-color: var(--border-strong); }

/* ------------------------------------------------------------------ practice / cards runners */
.runner { max-width: 820px; margin: 0 auto; }
.runner-head { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; flex-wrap: wrap; }
.runner-head .count { font-weight: 650; }
.runner-head .bar { flex: 1; min-width: 120px; }
.runner .item { margin-top: 14px; }
.runner-next { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.summary-score { font-size: 2.6rem; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.summary-stats { display: flex; gap: 22px; margin: 10px 0 18px; flex-wrap: wrap; }
.summary-stats div { display: flex; flex-direction: column; }
.summary-stats b { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.summary-stats span { font-size: .82rem; color: var(--muted); }
.result-list { list-style: none; padding: 0; margin: 0; }
.result-list li { display: grid; grid-template-columns: 70px 1fr auto; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); align-items: baseline; }
.result-list .stem-snip { color: var(--text-2); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.chooser { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }

.card-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); margin-top: 14px; }
.card-prompt { font-size: 1.08rem; margin-bottom: 12px; }
.card-prompt code { background: var(--code-bg); border: 1px solid var(--code-border); border-radius: 4px; padding: 0 .3em; font-size: .88em; }
.card-setup { margin-bottom: 12px; }
.card-setup summary { cursor: pointer; font-size: .84rem; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.card-setup .code-block { margin: 0; }
.card-input { border: 1.5px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.card-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.card-input .CodeMirror { height: auto; min-height: 44px; font-size: 14.5px; padding: 4px 2px; }
.card-input .CodeMirror-scroll { min-height: 40px; max-height: 200px; }
.card-keys { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.card-result { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.card-result pre { margin: 0; }
.card-answer .code-block { margin: 4px 0 0; }
.card-alts { font-size: .9rem; color: var(--text-2); }
.card-alts code { background: var(--code-bg); border-radius: 4px; padding: 0 .3em; }
.card-err { font-family: var(--font-mono); font-size: .84rem; color: var(--bad); white-space: pre-wrap; }

/* ------------------------------------------------------------------ code lab */
.prob-group { margin-bottom: 26px; }
.prob-group h2 { font-size: 1rem; display: flex; gap: 8px; align-items: baseline; }
.prob-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.prob-table td, .prob-table th { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; font-size: .92rem; }
.prob-table th { font-size: .76rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; background: var(--surface-2); }
.prob-table tr:last-child td { border-bottom: 0; }
.prob-table a { font-weight: 600; text-decoration: none; color: var(--text); }
.prob-table a:hover { color: var(--accent); text-decoration: underline; }
.diff { display: inline-flex; gap: 3px; vertical-align: middle; }
.diff i { width: 7px; height: 7px; border-radius: 2px; background: var(--surface-3); display: block; }
.diff i.on { background: var(--accent); }

.ws { display: grid; grid-template-columns: minmax(340px, 44%) 1fr; height: calc(100vh - var(--topbar-h)); }
.in-session .ws { height: calc(100vh - var(--topbar-h) - 45px); }
.ws-left { overflow-y: auto; border-right: 1px solid var(--border); background: var(--surface); padding: 22px 26px 60px; }
.ws-left .prose { font-size: 1.02rem; }
.ws-left h1 { font-size: 1.4rem; margin-bottom: 8px; }
.restrict { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 18px; }
.ws-right { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ws-toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.ws-timer { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: .92rem; color: var(--text-2); padding: 4px 8px; border-radius: 6px; background: var(--surface-2); }
.ws-timer.over { color: var(--warn); background: var(--warn-soft); }
.ws-timer.low { color: var(--bad); background: var(--bad-soft); }
.save-state { font-size: .8rem; color: var(--muted); min-width: 64px; }
.save-state.bad { color: var(--bad); }
.ws-editor { flex: 1 1 55%; min-height: 160px; position: relative; overflow: hidden; }
.ws-editor .CodeMirror { position: absolute; inset: 0; height: 100%; font-size: 13.5px; }
.ws-bottom { flex: 1 1 45%; min-height: 120px; display: flex; flex-direction: column; border-top: 1px solid var(--border); background: var(--surface); }
.tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.tabs button { font: inherit; font-size: .86rem; padding: 8px 12px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 650; }
.tab-panel { flex: 1; overflow-y: auto; padding: 12px 16px; }
.res-summary { font-weight: 650; margin-bottom: 10px; padding: 9px 12px; border-radius: 8px; }
.res-summary.ok { background: var(--ok-soft); color: var(--ok); }
.res-summary.bad { background: var(--bad-soft); color: var(--bad); }
.res-summary.neutral { background: var(--surface-2); color: var(--text-2); }
.checks { list-style: none; padding: 0; margin: 0 0 12px; }
.checks li { display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: .9rem; align-items: baseline; }
.checks li:last-child { border-bottom: 0; }
.pf { font-size: .7rem; font-weight: 800; letter-spacing: .06em; padding: 1px 0; border-radius: 4px; text-align: center; }
.pf.ok { color: var(--ok); background: var(--ok-soft); }
.pf.bad { color: var(--bad); background: var(--bad-soft); }
.t-name { font-weight: 600; }
.t-msg { color: var(--text-2); font-size: .86rem; display: block; font-family: var(--font-mono); white-space: pre-wrap; word-break: break-word; }
.t-sec { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.res-h { font-size: .74rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 12px 0 4px; }
.res-pre { margin: 0; background: var(--code-bg); border: 1px solid var(--code-border); border-radius: 6px; padding: 8px 10px; font-size: .82rem; white-space: pre-wrap; max-height: 220px; overflow: auto; }
.res-error { color: var(--bad); background: var(--bad-soft); border: 1px solid var(--bad-line); border-radius: 8px; padding: 10px 12px; font-family: var(--font-mono); font-size: .84rem; white-space: pre-wrap; margin-bottom: 10px; }
.help-row { display: flex; gap: 8px; margin-bottom: 10px; }
.help-row input { flex: 1; font-family: var(--font-mono); }
.help-out { margin: 0; font-size: .8rem; white-space: pre-wrap; line-height: 1.45; }
.ref-code .code-block { margin-top: 8px; }

/* ------------------------------------------------------------------ mock exam (contest look) */
.mock-start { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.mock-opt { display: flex; flex-direction: column; gap: 6px; padding: 18px; }
.mock-opt h3 { margin: 0; }
.mock-opt .dur { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.mock-opt p { color: var(--text-2); font-size: .9rem; flex: 1; }
.exam { display: grid; grid-template-columns: 250px 1fr; min-height: calc(100vh - var(--topbar-h)); }
.exam-side { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 16px; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto; }
.exam-main { padding: 22px 32px 80px; max-width: 880px; width: 100%; }
.exam-clock { font-family: var(--font-mono); font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.exam-clock.low { color: var(--bad); }
.exam-part { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.saved { font-size: .8rem; color: var(--muted); margin: 4px 0 14px; display: flex; align-items: center; gap: 6px; }
.saved .dot { background: var(--ok); }
.saved.bad .dot { background: var(--bad); }
.qmap { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 10px 0 12px; }
.qmap button { aspect-ratio: 1; border: 1.5px solid var(--border-strong); border-radius: 7px; background: var(--surface); color: var(--text-2); font: inherit; font-size: .86rem;
  font-weight: 650; cursor: pointer; position: relative; font-variant-numeric: tabular-nums; }
.qmap button.answered { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.qmap button.current { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.qmap button.flagged::after { content: ""; position: absolute; top: -4px; right: -4px; width: 11px; height: 11px; border-radius: 50%; background: var(--warn); border: 2px solid var(--surface); }
.qmap-legend { display: grid; gap: 4px; font-size: .8rem; color: var(--text-2); margin-bottom: 14px; }
.qmap-legend span { display: inline-flex; gap: 7px; align-items: center; }
.qmap-legend i { width: 12px; height: 12px; border-radius: 3px; border: 1.5px solid var(--border-strong); display: inline-block; }
.qmap-legend i.a { background: var(--accent); border-color: var(--accent); }
.qmap-legend i.f { border-radius: 50%; background: var(--warn); border-color: var(--warn); }
.exam-nav { display: flex; gap: 8px; justify-content: space-between; margin-top: 8px; align-items: center; flex-wrap: wrap; }
.flag-btn[aria-pressed="true"] { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.exam-main .item { margin-top: 6px; }
.break-box { max-width: 560px; margin: 60px auto; text-align: center; }
.p2-tabs { display: flex; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); align-items: center; flex-wrap: wrap; }
.p2-tabs .btn[aria-selected="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.mock-p2 { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h)); }
.mock-p2 .ws { flex: 1; height: auto; min-height: 0; }
.score-big { display: flex; align-items: baseline; gap: 10px; }
.score-big b { font-size: 3rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.score-big span { color: var(--muted); font-size: 1.1rem; }
.mock-table { width: 100%; border-collapse: collapse; }
.mock-table td, .mock-table th { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; font-size: .9rem; }
.mock-table th { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .07em; }

/* ------------------------------------------------------------------ progress */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { padding: 16px 18px; }
.stat b { display: block; font-size: 1.8rem; font-weight: 720; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: .86rem; }
.ptable { width: 100%; border-collapse: collapse; }
.ptable th, .ptable td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; font-size: .88rem; vertical-align: middle; }
.ptable th { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; }
.ptable .metric { display: grid; grid-template-columns: 1fr 52px; gap: 8px; align-items: center; min-width: 120px; }
.ptable .metric small { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; font-size: .8rem; }
.ptable tr.round-row td { background: var(--surface-2); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 13px; font-family: var(--font-ui); }

/* ------------------------------------------------------------------ unit quizzes and progress checks */
.exam-title { font-size: 1.05rem; line-height: 1.3; margin: 0 0 6px; }
.quiz-start .quiz-facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0 0 14px; font-size: .95rem; }
.quiz-facts dt { color: var(--muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; padding-top: 2px; }
.quiz-facts dd { margin: 0; }
.quiz-start .start-row { margin-top: 12px; }
.quiz-running { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0 0; }
.score-pair { display: flex; gap: 40px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 12px; }
.score-pair .res-h { margin-top: 0; }
.score-big.small-score b { font-size: 2rem; }
.quiz-score .verdict { margin: 0 0 10px; }
.quiz-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.missed-lessons { margin: 10px 0 0; color: var(--text-2); }
.check-change { margin: 0 0 8px; }
.check-change .chip { margin-right: 6px; }
.by-unit { margin: 0 0 14px; max-width: 420px; }
.mock-table .num, .ttable .num { text-align: right; font-variant-numeric: tabular-nums; }
.review-list { max-width: 860px; margin: 0; }
.review-list .item { margin-top: 14px; }
.item > .why-wrong, .item > .solution, .item > .others, .item > .review-lesson { margin-top: 12px; }
.review-lesson { font-size: .88rem; color: var(--muted); margin-bottom: 0; }
.unit-quiz { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 9px 16px 11px; border-top: 1px solid var(--border); background: var(--surface-2); }
.uq-label { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-right: 2px; }
.lesson-time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.lesson-meta .lesson-time::before { content: "·"; margin-right: 8px; color: var(--border-strong); }
.ws-timer.idle { opacity: .6; }
.stat-row.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.check-latest { margin: 0 0 6px; display: flex; align-items: baseline; flex-wrap: wrap; }
.check-latest b { font-size: 2rem; font-weight: 720; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.check-latest > span:not(.chip) { color: var(--muted); margin-left: 4px; }
.chart .val { fill: var(--text-2); font-size: 12px; }
.chart .val.strong { fill: var(--text); font-weight: 700; font-size: 13px; }
.ttable { width: 100%; border-collapse: collapse; }
.ttable th, .ttable td { padding: 7px 8px; border-bottom: 1px solid var(--border); text-align: left; font-size: .9rem; }
.ttable thead th { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; white-space: nowrap; }
.ttable tbody th { font-weight: 560; white-space: nowrap; }
.ttable td.tbar { width: 40%; }
.ttable tr:last-child th, .ttable tr:last-child td { border-bottom: 0; }
.bar.warn > span { background: var(--warn); }
.qmetric .bar { position: relative; overflow: visible; }
.qmetric .bar > span { border-radius: 99px; }
.pass-tick { position: absolute; top: -3px; bottom: -3px; width: 0; border-left: 1.5px solid var(--text-2); }
.th-note { text-transform: none; letter-spacing: 0; font-weight: 500; }

/* ------------------------------------------------------------------ widgets */
.widget { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 14px 16px; margin: 1.6em 0; font-family: var(--font-ui); font-size: .92rem; box-shadow: var(--shadow); }
.widget-title { font-size: .76rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.widget svg { display: block; width: 100%; height: auto; touch-action: none; }
.widget .controls { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin: 8px 0; }
.widget .controls label { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: .86rem; }
.widget input[type="range"] { accent-color: var(--accent); width: 160px; }
.widget input[type="number"] { width: 4.2em; padding: 4px 6px; }
.widget input[type="text"] { width: 9em; padding: 4px 8px; font-family: var(--font-mono); }
.widget .readout { font-family: var(--font-mono); font-size: .84rem; color: var(--text-2); line-height: 1.6; }
.widget .readout b { color: var(--text); }
.widget .status { font-weight: 650; }
.widget .status.ok { color: var(--ok); } .widget .status.bad { color: var(--bad); } .widget .status.warn { color: var(--warn); }
.widget .w-grid { stroke: var(--border); stroke-width: 1; }
.widget .w-axis { stroke: var(--border-strong); stroke-width: 1.2; }
.widget .w-text { fill: var(--text-2); font-size: 12px; font-family: var(--font-ui); }
.widget .w-handle { cursor: grab; }
.widget .w-handle:focus { outline: none; }
.widget .w-handle:focus circle.ring { stroke: var(--accent); stroke-width: 3; }
.widget-error { color: var(--bad); }
.matrix { border-collapse: collapse; font-family: var(--font-mono); font-size: .86rem; }
.matrix td, .matrix th { border: 1px solid var(--border); padding: 5px 10px; text-align: center; }
.matrix th { color: var(--muted); font-weight: 600; font-family: var(--font-ui); font-size: .78rem; }

/* ------------------------------------------------------------------ narrow windows */
@media (max-width: 980px) {
  .hero, .grid-2 { grid-template-columns: 1fr; }
  .units { grid-template-columns: 1fr; }
  .mock-start, .grid-3 { grid-template-columns: 1fr; }
  .stat-row, .quick { grid-template-columns: repeat(2, 1fr); }
  .stat-row.five { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-row.five > :last-child { grid-column: 1 / -1; }
  .ws { grid-template-columns: 1fr; height: auto; }
  .ws-left { border-right: 0; border-bottom: 1px solid var(--border); max-height: none; }
  .ws-editor { min-height: 360px; flex: none; height: 360px; }
  .ws-bottom { min-height: 260px; }
  .exam { grid-template-columns: 1fr; }
  .exam-side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .qmap { grid-template-columns: repeat(10, 1fr); }
  .mock-p2 { height: auto; }
  .countdown { display: none; }
}
@media (max-width: 640px) {
  .page { padding: 18px 16px 60px; }
  .reader-wrap { padding: 20px 16px 80px; }
  .topbar { padding: 0 12px; gap: 10px; }
  .brand-sub { display: none; }
  .prose { font-size: 1.04rem; }
  .lesson-head h1 { font-size: 1.6rem; }
  .prevnext { grid-template-columns: 1fr; }
  .stat-row, .quick { grid-template-columns: 1fr; }
  .stat-row.five { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-row.five .stat { padding: 12px 14px; }
  .stat-row.five .stat b { font-size: 1.45rem; }
  .exam-main { padding: 16px; }
  .score-pair { gap: 22px; }
  .quiz-start .quiz-facts { grid-template-columns: 1fr; gap: 2px; }
  .quiz-facts dd { margin-bottom: 8px; }
  .ttable td.tbar { width: 28%; }
  .qmap { grid-template-columns: repeat(5, 1fr); }
  .item { padding: 14px; }
  .lesson-row { grid-template-columns: 18px 1fr; }
  .lesson-row .lm { grid-column: 2; }
  .ptable .metric { min-width: 80px; grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ------------------------------------------------------------------ features (settings, search, glossary, hints,
   summaries, placement, report links, narrow screens, print); added 2026-11-18 */
.brand-tag { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-2); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 1px 7px; margin-left: 2px; font-weight: 600; }
a.icon-btn { text-decoration: none; }
select { max-width: 100%; }
.field { min-width: 0; max-width: 100%; }
.nav-toggle { display: none; }
.weekbar .band.target { border-right: 0; border-left: 2px solid var(--text-2); }
.report-row { margin: 10px 0 0; font-size: .85rem; }
.report-link { color: var(--muted); }
.report-link:hover { color: var(--accent-hover); }
.lesson-foot .report-row { margin-top: 18px; }
.hints { margin: 18px 0 6px; padding-top: 12px; border-top: 1px solid var(--border); }
.hint { background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: var(--radius-sm); padding: 10px 14px; margin: 8px 0; }
.hint .label { font-size: .76rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--warn); margin-bottom: 4px; }
.hint .prose { font-size: .95rem; }
.hint .prose > :last-child { margin-bottom: 0; }
.colab-time { margin: 12px 0 0; color: var(--text-2); }
.narrow-note { display: none; }
.recorded-try .try-note { margin-left: 4px; }
.search-panel form { margin-bottom: 8px; }
.search-input { width: 100%; font: inherit; font-size: 1.05rem; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); }
.search-results { list-style: none; margin: 0; padding: 0; }
.search-results li + li { border-top: 1px solid var(--border); }
.search-hit { display: block; padding: 10px 4px; text-decoration: none; color: var(--text); border-radius: 6px; }
.search-hit:hover { background: var(--surface-2); color: var(--text); }
.search-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-title { font-weight: 600; color: var(--accent); }
.search-snip { display: block; color: var(--text-2); font-size: .9rem; margin-top: 3px; }
.search-snip mark, .gl-hit mark { background: var(--warn-soft); color: var(--text); border-radius: 2px; padding: 0 1px; }
.gl-jump { display: flex; flex-wrap: wrap; gap: 2px; margin: 0 0 12px; }
.gl-jump a { padding: 4px 8px; border-radius: 6px; text-decoration: none; font-weight: 600; font-size: .9rem; }
.gl-jump a:hover { background: var(--surface-2); }
.glossary-list { margin: 0; }
.glossary-list .gl-letter { font-size: 1.1rem; font-weight: 700; color: var(--muted); margin: 18px 0 4px; padding-bottom: 4px; border-bottom: 1px solid var(--border); scroll-margin-top: calc(var(--topbar-h) + 12px); }
.glossary-list .gl-letter:first-child { margin-top: 0; }
.glossary-list dt { font-weight: 650; margin-top: 12px; scroll-margin-top: calc(var(--topbar-h) + 40px); }
.glossary-list dd { margin: 2px 0 0; color: var(--text-2); }
.gl-lesson { margin-top: 3px; }
.glossary-list .gl-hit { background: var(--accent-soft); border-radius: 4px; }
#gl-filter { font: inherit; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); min-width: 220px; }
.settings-form { max-width: 640px; }
.set-field { margin: 0 0 18px; border: 0; padding: 0; }
.set-field > label, .set-field > legend { display: block; font-weight: 600; margin-bottom: 6px; padding: 0; }
.set-field input[type=date], .set-field input[type=number], .set-field select { font: inherit; padding: 6px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text); min-width: 200px; }
.set-field p { margin: 6px 0 0; }
.set-radio { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.set-out { list-style: none; padding: 0; margin: 0; }
.set-out li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); }
.set-out li .btn { margin-left: auto; }
.placement-table td { vertical-align: top; }
.sw-update { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 10px 14px; box-shadow: var(--shadow-lg); max-width: calc(100vw - 24px); flex-wrap: wrap; }
.summary-sheet .lesson-body { font-size: 1rem; }

/* The full nav needs about 1170 px (measured, public build). Below that, the Menu button, so no link is hidden. */
@media (max-width: 1180px) {
  .nav-toggle { display: grid; flex: none; }
  .topbar { position: sticky; }
  .nav { display: none; position: absolute; top: var(--topbar-h); left: 0; right: 0; flex-direction: column; gap: 2px; padding: 8px 12px 12px;
    background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-lg); overflow: visible; }
  .nav a { padding: 10px 12px; font-size: 1rem; }
  body.nav-open .nav { display: flex; }
  .topbar-right { margin-left: auto; }
}
@media (max-width: 760px) {
  .topbar-right { gap: 6px; }
  .narrow-note { display: block; background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: var(--radius-sm); padding: 8px 12px; font-size: .9rem; margin: 0 0 12px; }
  .brand-tag { font-size: .58rem; padding: 0 5px; letter-spacing: .06em; }
}
@media (max-width: 370px) { .brand-tag { display: none; } }
@media (max-width: 400px) {
  .topbar { gap: 6px; padding: 0 10px; }
  .topbar-right .icon-btn { width: 32px; height: 32px; }
}

@media print {
  @page { margin: 12mm 13mm; }
  :root, :root[data-theme="dark"] { --bg: #fff; --surface: #fff; --text: #000; --text-2: #222; --muted: #444; --border: #bbb; --code-bg: #f4f4f4; --code-fg: #000; color-scheme: light; }
  body { background: #fff; color: #000; font-size: 10pt; }
  .topbar, .session-bar, #site-foot, .toasts, .no-print, .reading-progress, .skip, .sw-update, .gloss-tip { display: none !important; }
  .page, .reader-wrap { padding: 0 !important; max-width: none; }
  .reader { max-width: none; }
  .summary-sheet .lesson-head h1 { font-size: 16pt; margin-bottom: 4pt; }
  .summary-sheet .eyebrow { margin-bottom: 2pt; }
  .summary-sheet .prose { font-size: 10pt; line-height: 1.38; }
  .summary-sheet .prose h2 { font-size: 12pt; margin: 9pt 0 3pt; break-after: avoid; }
  .summary-sheet .prose h3 { font-size: 10.5pt; margin: 6pt 0 2pt; break-after: avoid; }
  .summary-sheet .prose p, .summary-sheet .prose li { margin-bottom: 3pt; }
  .summary-sheet .prose ul, .summary-sheet .prose ol { margin: 0 0 4pt; }
  .summary-sheet table, .summary-sheet pre, .summary-sheet .callout, .summary-sheet .math-block { break-inside: avoid; }
  .summary-sheet pre, .summary-sheet .code-block { font-size: 8.5pt; padding: 4pt 6pt; margin: 4pt 0; }
  .summary-sheet .callout { padding: 4pt 8pt; margin: 6pt 0; }
  .summary-sheet .table-wrap { margin: 4pt 0; }
  .summary-sheet td, .summary-sheet th { padding: 2pt 5pt; }
  a { color: #000; text-decoration: none; }
}
.grid-2 > *, .grid-3 > *, .hero > * { min-width: 0; }
