/* Course app — one stylesheet for every course.
 * Colours are tokens; a course or chapter only sets --hue. Light by default,
 * dark follows the system unless the reader picks one (html[data-theme]). */

:root {
  --hue: 222;
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f1eee6;
  --ink: #1b1e28;
  --ink-2: #464c5c;
  --muted: #767c8a;
  --line: #e3dfd4;
  --acc: hsl(var(--hue) 68% 46%);
  --acc-ink: hsl(var(--hue) 70% 34%);
  --acc-soft: hsl(var(--hue) 85% 95%);
  --acc-line: hsl(var(--hue) 60% 84%);
  --idea: #a76a06;   --idea-soft: #fdf4de;  --idea-line: #f1d89b;
  --def: #2459c7;    --def-soft: #eaf1fd;   --def-line: #bcd0f5;
  --pit: #c0294f;    --pit-soft: #fdebf0;   --pit-line: #f3bccb;
  --ex: #17804a;     --ex-soft: #e8f6ee;    --ex-line: #b7e2c8;
  --chk: #6a3fd8;    --chk-soft: #f0ebfe;   --chk-line: #d3c6f7;
  --thm: #0c6f7c;    --thm-soft: #e6f4f5;   --thm-line: #a8d5da;
  --rec: #b5480b;    --rec-soft: #fdf0e6;   --rec-line: #f2c8a6;
  --ok: #17804a;     --bad: #c0294f;
  --shadow: 0 1px 2px rgb(30 25 10 / .05), 0 6px 24px -12px rgb(30 25 10 / .18);
  --r: 16px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1117; --surface: #171a23; --surface-2: #1e2230;
    --ink: #eceef2; --ink-2: #b7bdca; --muted: #8b92a1; --line: #2b3040;
    --acc: hsl(var(--hue) 85% 68%); --acc-ink: hsl(var(--hue) 90% 78%);
    --acc-soft: hsl(var(--hue) 40% 16%); --acc-line: hsl(var(--hue) 35% 30%);
    --idea: #f3c15a; --idea-soft: #2a2312; --idea-line: #5b4a1f;
    --def: #7fa7ff;  --def-soft: #15213b;  --def-line: #2c3f6b;
    --pit: #ff7c9d;  --pit-soft: #33161f;  --pit-line: #6a2b3c;
    --ex: #6fd79c;   --ex-soft: #11281c;   --ex-line: #235238;
    --chk: #b89cff;  --chk-soft: #221a3a;  --chk-line: #43357a;
    --thm: #63cfd9;  --thm-soft: #10272b;  --thm-line: #235a62;
    --rec: #ffa064;  --rec-soft: #2d1c11;  --rec-line: #6b4023;
    --ok: #6fd79c;   --bad: #ff7c9d;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 28px -12px rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1117; --surface: #171a23; --surface-2: #1e2230;
  --ink: #eceef2; --ink-2: #b7bdca; --muted: #8b92a1; --line: #2b3040;
  --acc: hsl(var(--hue) 85% 68%); --acc-ink: hsl(var(--hue) 90% 78%);
  --acc-soft: hsl(var(--hue) 40% 16%); --acc-line: hsl(var(--hue) 35% 30%);
  --idea: #f3c15a; --idea-soft: #2a2312; --idea-line: #5b4a1f;
  --def: #7fa7ff;  --def-soft: #15213b;  --def-line: #2c3f6b;
  --pit: #ff7c9d;  --pit-soft: #33161f;  --pit-line: #6a2b3c;
  --ex: #6fd79c;   --ex-soft: #11281c;   --ex-line: #235238;
  --chk: #b89cff;  --chk-soft: #221a3a;  --chk-line: #43357a;
  --thm: #63cfd9;  --thm-soft: #10272b;  --thm-line: #235a62;
  --rec: #ffa064;  --rec-soft: #2d1c11;  --rec-line: #6b4023;
  --ok: #6fd79c;   --bad: #ff7c9d;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 28px -12px rgb(0 0 0 / .6);
  color-scheme: dark;
}

/* --hue can be set on any element (chapter, lecture); re-derive the accent
   tokens there, since custom properties resolve where they are declared. */
[style*="--hue"] {
  --acc: hsl(var(--hue) 68% 46%); --acc-ink: hsl(var(--hue) 70% 34%);
  --acc-soft: hsl(var(--hue) 85% 95%); --acc-line: hsl(var(--hue) 60% 84%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) [style*="--hue"] {
    --acc: hsl(var(--hue) 85% 68%); --acc-ink: hsl(var(--hue) 90% 78%);
    --acc-soft: hsl(var(--hue) 40% 16%); --acc-line: hsl(var(--hue) 35% 30%);
  }
}
:root[data-theme="dark"] [style*="--hue"] {
  --acc: hsl(var(--hue) 85% 68%); --acc-ink: hsl(var(--hue) 90% 78%);
  --acc-soft: hsl(var(--hue) 40% 16%); --acc-line: hsl(var(--hue) 35% 30%);
}

/* Figures: one SVG per theme, the right one shown. */
.th-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .th-dark { display: block; }
  :root:not([data-theme="light"]) .th-light { display: none; }
}
:root[data-theme="dark"] .th-dark { display: block; }
:root[data-theme="dark"] .th-light { display: none; }

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 84px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.62 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: var(--acc-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--acc); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 99; background: var(--surface); padding: 8px 14px; border-radius: 8px; }
.skip:focus { left: 12px; }
.muted { color: var(--muted); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--acc-ink); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: .93em; }
.btn {
  display: inline-flex; align-items: center; gap: .4em; cursor: pointer;
  background: var(--acc); color: #fff; border: 0; border-radius: 999px;
  padding: .55em 1.15em; font-weight: 600; font-size: .95rem; text-decoration: none;
  box-shadow: 0 2px 0 hsl(var(--hue) 60% 32% / .35);
  transition: transform .12s ease, filter .12s ease;
}
:root[data-theme="dark"] .btn { color: #0f1117; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn { color: #0f1117; } }
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn-big { font-size: 1.05rem; padding: .8em 1.5em; }
.code {
  display: inline-block; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--acc-soft); color: var(--acc-ink); border: 1px solid var(--acc-line);
  padding: .05em .55em; border-radius: 999px; font-size: .85em;
}

/* --------------------------------------------------------------- header */
.top {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.top-in { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 14px; padding: 10px 20px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.mark {
  width: 38px; height: 38px; flex: none; border-radius: 12px; display: grid; place-items: center;
  font-size: 22px; font-weight: 800; color: #fff;
  background: conic-gradient(from 200deg, #ff6b9d, #c77dff, #6c9eff, #7ee787, #ffc861, #ff6b9d);
  box-shadow: inset 0 0 0 2px rgb(255 255 255 / .25);
  text-shadow: 0 1px 2px rgb(0 0 0 / .3);
}
.brand-t { display: flex; flex-direction: column; line-height: 1.15; }
.brand-t b { font-size: 1rem; }
.brand-t small { color: var(--muted); font-size: .78rem; white-space: nowrap; }
/* short_title in course.yml: one line, never broken */
.bt-short { white-space: nowrap; }
.mainnav { display: flex; gap: 2px; margin-left: 10px; }
.mainnav a { white-space: nowrap; text-decoration: none; color: var(--ink-2); padding: 6px 11px; border-radius: 999px; font-size: .93rem; font-weight: 500; }
.mainnav a:hover { background: var(--surface-2); color: var(--ink); }
.mainnav a[aria-current] { background: var(--ink); color: var(--bg); }
.search { position: relative; margin-left: auto; flex: 0 1 290px; }
.search input {
  width: 100%; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 8px 14px 8px 34px; font: inherit; font-size: .92rem;
  background-image: radial-gradient(circle at 16px 50%, transparent 5px, var(--muted) 5.5px, var(--muted) 6.8px, transparent 7.3px);
}
.search input:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }
.results {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(480px, 92vw); max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px;
}
.results a { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 9px 10px; border-radius: 10px; text-decoration: none; color: var(--ink); }
.results a:hover, .results a.sel { background: var(--acc-soft); }
.results .rk { grid-row: span 2; align-self: start; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--acc-ink); background: var(--acc-soft); border: 1px solid var(--acc-line); padding: 1px 7px; border-radius: 6px; margin-top: 2px; }
.results .rt { font-weight: 600; }
.results .rt small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.results .rs { font-size: .85rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .none { padding: 12px; color: var(--muted); font-size: .92rem; }
.help-btn {
  border: 1px solid var(--pit-line); background: var(--pit-soft); color: var(--pit);
  border-radius: 999px; padding: 7px 13px; font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap;
}
.theme-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; width: 36px; height: 36px; cursor: pointer; font-size: 18px; line-height: 1; }

.help { border: 0; border-radius: 20px; padding: 28px 30px; max-width: 540px; width: 92vw; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.help::backdrop { background: rgb(10 12 20 / .45); backdrop-filter: blur(2px); }
.help h2 { font-size: 1.4rem; margin-bottom: 14px; }
.help .x { position: absolute; right: 14px; top: 10px; border: 0; background: none; font-size: 28px; cursor: pointer; color: var(--muted); }
.help-steps { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 12px; }
.help-steps li { display: flex; gap: 12px; align-items: flex-start; }
.help-steps b { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--acc-soft); color: var(--acc-ink); }
.help-contact { border-top: 1px solid var(--line); padding-top: 12px; font-size: .92rem; color: var(--ink-2); }
.help-contact p { margin: .3em 0; }

/* --------------------------------------------------------------- heroes */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
.hero-in { max-width: 1240px; margin: 0 auto; padding: 44px 20px 40px; position: relative; }
.hero h1 { font-size: clamp(2rem, 4.6vw, 3.3rem); font-weight: 800; letter-spacing: -0.03em; margin: 10px 0 12px; max-width: 18ch; }
.hero .lede { font-size: 1.15rem; color: var(--ink-2); max-width: 62ch; }
.hero .lede p { margin: .3em 0; }
.kicker { color: var(--acc-ink); font-weight: 700; font-size: .9rem; letter-spacing: .02em; display: flex; gap: 8px; align-items: center; }
.hero-home { background:
    radial-gradient(900px 380px at 88% -10%, hsl(330 90% 70% / .22), transparent 60%),
    radial-gradient(700px 360px at 60% 120%, hsl(210 90% 65% / .20), transparent 60%),
    radial-gradient(600px 300px at 10% 0%, hsl(45 95% 60% / .16), transparent 60%); }
.hero-home h1 .h1-sub { display: block; font-size: .42em; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-top: 6px; }
.hero-home::after {
  content: ""; position: absolute; right: -60px; top: 20px; width: 520px; height: 260px; opacity: .5; pointer-events: none;
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 520 260'%3E%3Cpath d='M0 130 C 65 10, 130 10, 195 130 S 325 250, 390 130 S 455 10, 520 130' fill='none' stroke='%23ff6b9d' stroke-width='5' stroke-linecap='round'/%3E%3Cpath d='M0 60 C 65 10, 130 130, 195 190 S 325 250, 390 190 S 455 10, 520 60' fill='none' stroke='%236c9eff' stroke-width='4' stroke-linecap='round' opacity='.7'/%3E%3C/svg%3E");
}
.hero-cta { margin-top: 22px; display: flex; gap: 12px; flex-wrap: wrap; }
.stats { list-style: none; display: flex; gap: 28px; padding: 0; margin: 28px 0 0; flex-wrap: wrap; }
.stats li { display: flex; flex-direction: column; }
.stats b { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.stats span { color: var(--muted); font-size: .85rem; }

.hero-lec { background:
    radial-gradient(800px 320px at 85% 0%, hsl(var(--hue) 90% 70% / .22), transparent 65%),
    linear-gradient(180deg, var(--acc-soft), var(--bg)); }
.hero-lec .hero-in { padding-top: 34px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 40px; align-items: center; }
.hero-art { position: relative; }
.hero-art .fig-art { border-radius: 28px; padding: 18px; box-shadow: var(--shadow); transform: rotate(2deg); }
.hero-art::before { content: ""; position: absolute; inset: -14px 14px 14px -14px; border-radius: 30px; background: var(--acc); opacity: .14; transform: rotate(-4deg); }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; } .hero-art { display: none; } }
.meta { display: flex; gap: 18px; flex-wrap: wrap; color: var(--ink-2); font-size: .92rem; margin-top: 12px; }
.meta-prog:not(:empty) { color: var(--ok); font-weight: 600; }
.goals { margin-top: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 20px; max-width: 680px; box-shadow: var(--shadow); }
.goals h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
.goals ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.goals li { padding-left: 30px; position: relative; }
.goals li::before { content: "✓"; position: absolute; left: 0; top: 1px; width: 21px; height: 21px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 800; background: var(--ex-soft); color: var(--ex); border: 1px solid var(--ex-line); }
.hero-small .hero-in { padding: 34px 20px 26px; }
.hero-small h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); }

/* lecture bar */
.lecbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.lecbar-in { max-width: 1240px; margin: 0 auto; padding: 8px 20px; display: flex; align-items: center; gap: 14px; }
.lb-title { font-weight: 600; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; font-size: .93rem; }
.lb-num { color: var(--acc-ink); font-weight: 800; margin-right: 4px; }
.tabs { display: flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.tabs a { text-decoration: none; color: var(--ink-2); padding: 5px 16px; border-radius: 999px; font-weight: 600; font-size: .9rem; }
.tabs a[aria-current] { background: var(--surface); color: var(--acc-ink); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.lb-nav { min-width: 44px; text-decoration: none; font-weight: 700; color: var(--muted); font-size: .9rem; }
.lb-nav:last-child { text-align: right; }

/* ------------------------------------------------------------ home path */
.home { max-width: 1240px; margin: 0 auto; padding: 36px 20px 60px; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 40px; }
.chapter { margin-bottom: 30px; }
.ch-title { font-size: 1rem; text-transform: uppercase; letter-spacing: .1em; color: var(--acc-ink); margin: 0 0 16px 58px; }
.path { list-style: none; margin: 0; padding: 0; position: relative; }
.path::before { content: ""; position: absolute; left: 21px; top: 10px; bottom: 10px; width: 4px; border-radius: 4px; background: linear-gradient(var(--acc-line), var(--line)); }
.node { position: relative; padding-left: 62px; margin-bottom: 18px; }
.dot {
  position: absolute; left: 0; top: 16px; width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 1.1rem;
  background: var(--acc); color: #fff; box-shadow: 0 0 0 5px var(--bg), 0 4px 12px -2px hsl(var(--hue) 70% 40% / .5);
}
.node.planned .dot { background: var(--surface-2); color: var(--muted); box-shadow: 0 0 0 5px var(--bg); border: 2px dashed var(--line); }
.node.done .dot { background: var(--ok); }
.node.done .dot::after { content: "✓"; position: absolute; right: -4px; bottom: -4px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); color: var(--ok); font-size: .75rem; display: grid; place-items: center; border: 2px solid var(--ok); }
.node-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); }
.node.planned .node-card { background: transparent; box-shadow: none; border-style: dashed; padding: 12px 18px; }
.node.planned h3 { color: var(--ink-2); }
.node-top { display: flex; gap: 8px; align-items: center; }
.tag { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border: 1px solid var(--line); padding: 1px 8px; border-radius: 999px; }
.node h3 { font-size: 1.22rem; margin: 8px 0 4px; }
.node h3 a { color: var(--ink); text-decoration: none; }
.node h3 a:hover { color: var(--acc-ink); }
.topics { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: .86rem; }
.topics li::before { content: "·"; margin-right: 6px; }
.topics li:first-child::before { display: none; }
.node.planned .topics { font-size: .82rem; }
.soon { display: none; }
.stops { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.stop {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 2px 10px; align-items: center;
  text-decoration: none; color: var(--ink); background: var(--surface-2); border: 1px solid transparent;
  border-radius: 12px; padding: 10px 12px; transition: border-color .15s, transform .15s;
}
.stop:hover { border-color: var(--acc-line); transform: translateY(-1px); }
.st-ic { grid-row: span 2; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; background: var(--acc-soft); color: var(--acc-ink); }
.stop-p .st-ic { background: var(--ex-soft); color: var(--ex); }
.st-t { display: flex; flex-direction: column; line-height: 1.2; }
.st-t small { color: var(--muted); font-size: .8rem; }
.bar { grid-column: 2; height: 5px; background: var(--line); border-radius: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--acc); border-radius: 5px; transition: width .6s ease; }
.stop-p .bar i { background: var(--ex); }
.home-side { display: flex; flex-direction: column; gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow); }
.home-side .card { position: sticky; top: 80px; }
.home-side .card + .card { position: static; }
.hl { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.hl li { display: flex; flex-direction: column; }
.hl span { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.hl b { font-weight: 600; }
.tools h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.tools a, .tools button { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); padding: 10px 12px; border-radius: 12px; margin: 0 -12px; text-align: left; background: none; border: 0; cursor: pointer; width: calc(100% + 24px); }
.tools a:hover, .tools button:hover { background: var(--surface-2); }
.tools span { color: var(--muted); font-size: .86rem; line-height: 1.4; }
.tools button b { color: var(--pit); }

/* ------------------------------------------------------------- theory */
.layout { max-width: 1240px; margin: 0 auto; padding: 30px 20px 60px; display: grid; grid-template-columns: 250px minmax(0, 760px); gap: 48px; justify-content: center; }
.toc-in { position: sticky; top: 84px; }
.toc-h { font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.toc ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; border-left: 2px solid var(--line); }
.toc a { display: flex; gap: 10px; align-items: baseline; text-decoration: none; color: var(--ink-2); padding: 6px 10px; margin-left: -2px; border-left: 2px solid transparent; font-size: .92rem; line-height: 1.35; }
.toc a:hover { color: var(--ink); }
.toc a.cur { border-left-color: var(--acc); color: var(--ink); font-weight: 600; background: linear-gradient(90deg, var(--acc-soft), transparent); }
.toc-n { flex: none; width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .72rem; font-weight: 700; background: var(--surface-2); color: var(--muted); transform: translateY(2px); }
.toc a.read .toc-n { background: var(--ok); color: #fff; }
.toc a.read .toc-n::after { content: "✓"; position: absolute; }
.toc a.read .toc-n { color: transparent; position: relative; }
.toc a.read .toc-n::after { color: #fff; }
.toc-p { display: inline-block; margin-top: 16px; font-weight: 700; text-decoration: none; color: var(--ex); background: var(--ex-soft); border: 1px solid var(--ex-line); padding: 7px 14px; border-radius: 999px; font-size: .9rem; }

.article { min-width: 0; }
.sec { padding-bottom: 36px; margin-bottom: 36px; border-bottom: 1px solid var(--line); }
.sec-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 18px; }
.sec-n { flex: none; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; font-size: 1.25rem; color: #fff; background: var(--acc); transform: rotate(-4deg); box-shadow: 0 6px 16px -6px hsl(var(--hue) 70% 40% / .6); }
.sec-head h2 { font-size: clamp(1.5rem, 3vw, 1.95rem); font-weight: 800; padding-top: 4px; }
.sec-hook { margin: 6px 0 0; color: var(--ink-2); font-size: 1.08rem; font-style: italic; }
.sec-end { height: 1px; }

.prose { font-size: 1.06rem; }
.prose p { margin: .75em 0; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose ul, .prose ol { padding-left: 1.4em; margin: .6em 0; }
.prose li { margin: .25em 0; }
.prose li::marker { color: var(--acc); font-weight: 700; }
.prose h3 { font-size: 1.22rem; font-weight: 800; margin: 1.4em 0 .4em; }
.prose h4 { font-size: 1.08rem; margin: 1.2em 0 .3em; }
.prose blockquote { margin: .8em 0; padding: .4em 1em; border-left: 4px solid var(--acc-line); color: var(--ink-2); background: var(--surface-2); border-radius: 0 10px 10px 0; }
.prose code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
.dm-wrap, .dm { display: block; overflow-x: auto; overflow-y: hidden; }
.dm-wrap { margin: .9em 0; }
.dm { padding: 2px 0; }
.table-wrap { overflow-x: auto; margin: 1em 0; }
.prose table { border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: .98rem; }
.prose th, .prose td { padding: 8px 16px; text-align: center; border-bottom: 1px solid var(--line); }
.prose tr:last-child td { border-bottom: 0; }
.prose th { background: var(--surface-2); font-weight: 700; }
.prose td:first-child, .prose th:first-child { text-align: left; }
.katex { font-size: 1.08em; }
.katex-display { margin: .6em 0; }
/* A wide display (a 3 x 4 matrix on a phone) scrolls inside its own box;
   the page itself never scrolls sideways. */
.katex-display { overflow-x: auto; overflow-y: hidden; max-width: 100%; padding: 3px 0; margin: calc(.6em - 3px) 0; }
.katex-display > .katex { white-space: nowrap; }
/* KaTeX's equation number (\tag) carries the class .tag as well: keep the
 * chip style of .tag (the "Coming" label) off it. */
.katex .tag { font-size: inherit; font-weight: inherit; text-transform: none; letter-spacing: normal; color: inherit; border: 0; padding: 0; border-radius: 0; }
/* A numbered formula: KaTeX puts the number on top of the right edge, so
 * keep the formula out from under it; on a phone the number gets a line of
 * its own below the formula. */
.katex-display > .katex > .katex-html:has(> .tag) { padding-right: 3.4em; }
@media (max-width: 720px) {
  .katex-display > .katex > .katex-html:has(> .tag) { padding-right: 0; }
  .katex-display > .katex > .katex-html > .tag { position: static; display: block; text-align: right; }
}
/* Grid children do not shrink below their content unless told to. */
.prose, .p-stem, .opt-t, .step, .probs > *, .cards > *, .rubric > li, .pf-steps > li, .thm-list > *, .e-parts > li { min-width: 0; }
.p-preview { overflow-x: auto; overflow-y: hidden; }
a.term { color: inherit; text-decoration: underline dotted var(--acc); text-decoration-thickness: 2px; text-underline-offset: 4px; cursor: help; }
a.term:hover { color: var(--acc-ink); }
.term-missing { color: var(--bad); }

.article > .sec > * + * { margin-top: 20px; }

/* figures */
.fig { margin: 0; }
.fig-art { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; place-items: center; }
.fig-art svg { width: 100%; max-width: 380px; height: auto; display: block; }
.fig-wide .fig-art > div, .check-q.fig-below .fig-art > div { width: 100%; }   /* `wide: true`: several panels in one figure */
.fig-wide .fig-art svg { max-width: 620px; margin-inline: auto; }
.fig figcaption { color: var(--muted); font-size: .88rem; margin-top: 8px; text-align: center; }
.fig-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 26px; align-items: center; }
.fig-row.fig-left .fig { order: 0; }
.fig-row.fig-right .fig { order: 2; }

/* callouts */
.co-label { display: flex; align-items: center; gap: 8px; font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.co-ic { width: 24px; height: 24px; border-radius: 8px; display: inline-grid; place-items: center; font-size: .9rem; letter-spacing: 0; }
.callout { border-radius: var(--r); padding: 16px 20px; border: 1px solid; }
.callout h3 { font-size: 1.12rem; margin: 8px 0 2px; }
.callout .prose { margin-top: 8px; }
.co-idea { background: var(--idea-soft); border-color: var(--idea-line); }
.co-idea .co-label { color: var(--idea); } .co-idea .co-ic { background: var(--idea); color: var(--surface); }
.co-idea .prose { font-size: 1.14rem; font-weight: 500; }
.co-def { background: var(--def-soft); border-color: var(--def-line); }
.co-def .co-label { color: var(--def); } .co-def .co-ic { background: var(--def); color: var(--surface); }
.co-pit { background: var(--pit-soft); border-color: var(--pit-line); }
.co-pit .co-label { color: var(--pit); } .co-pit .co-ic { background: var(--pit); color: var(--surface); font-weight: 900; }
/* recipe (a method): numbered steps, all visible */
.co-rec { background: var(--rec-soft); border-color: var(--rec-line); }
.co-rec .co-label { color: var(--rec); } .co-rec .co-ic { background: var(--rec); color: var(--surface); font-weight: 900; }
.rec-steps { list-style: none; counter-reset: rec; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.rec-steps > li { counter-increment: rec; position: relative; padding-left: 40px; min-width: 0; }
.rec-steps > li::before { content: counter(rec); position: absolute; left: 0; top: 1px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .82rem; font-weight: 800; color: var(--surface); background: var(--rec); }
.callout .rec-steps .prose, .callout .pf-steps .prose { margin-top: 0; }
.callout .rec-after { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--rec-line); }
/* A hidden justification under a callout (definition, pitfall, recipe): the
 * theorem's proof button, in the box's own colour. */
.co-def { --k: var(--def); --k-line: var(--def-line); }
.co-pit { --k: var(--pit); --k-line: var(--pit-line); }
.co-rec { --k: var(--rec); --k-line: var(--rec-line); }
.callout > .thm-proof { margin: 14px -20px -16px; border-top: 1px solid var(--k-line, var(--line)); border-radius: 0 0 calc(var(--r) - 1px) calc(var(--r) - 1px); overflow: hidden; }
.callout > .thm-proof .pf-toggle { color: var(--k, var(--thm)); }
.callout > .thm-proof .pf-toggle:hover { background: color-mix(in srgb, var(--k, var(--thm)) 10%, transparent); }
.callout > .thm-proof .pf-toggle, .callout > .thm-proof .pf-body { padding-left: 20px; padding-right: 20px; }   /* the callout's own gutter, at every width */
.callout > .thm-proof .pf-body { background: var(--surface); padding-top: 12px; }
.callout > .thm-proof .pf-steps > li::before { color: var(--k, var(--thm)); border-color: var(--k-line, var(--thm-line)); background: transparent; }
.callout > .thm-proof .qed { color: var(--k, var(--thm)); }

.formula {
  position: relative; border-radius: var(--r); padding: 16px 22px 18px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 22px 22px; background-position: -1px -1px;
}
.formula::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(90deg, var(--surface) 0%, color-mix(in srgb, var(--surface) 88%, transparent) 100%); }
.formula > * { position: relative; }
.formula .co-label { color: var(--acc-ink); } .formula .co-ic { background: var(--acc); color: var(--surface); }
.f-title { font-weight: 700; margin-top: 6px; }
.f-body { font-size: 1.12rem; }
.f-note { color: var(--ink-2); font-size: .95rem; margin-top: 6px; }

.fold { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.fold summary { cursor: pointer; padding: 13px 18px; list-style: none; display: flex; gap: 10px; align-items: center; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::after { content: "+"; margin-left: auto; font-size: 1.3rem; color: var(--muted); }
.fold[open] summary::after { content: "–"; }
.fold-k { font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.fold-t { font-weight: 600; }
.fold > .prose { padding: 0 20px 16px; }
.fold-recap .co-ic { background: var(--def-soft); color: var(--def); }
.fold-deep .co-ic { background: var(--chk-soft); color: var(--chk); }

/* theorem: statement, the idea (always visible), the proof behind a button */
.theorem { border: 1.5px solid var(--thm-line); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.theorem:target { border-color: var(--thm); box-shadow: 0 0 0 4px var(--thm-soft); }
.thm-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 9px 20px; background: var(--thm); color: var(--surface); }
.thm-k { font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; white-space: nowrap; }
.thm-name { font-weight: 700; font-size: 1.06rem; letter-spacing: -.005em; }
.thm-link { margin-left: auto; color: inherit; text-decoration: none; font-weight: 800; opacity: .45; padding: 0 4px; }
.thm-link:hover, .thm-link:focus-visible { opacity: 1; }
.thm-body { padding: 16px 20px; background: var(--thm-soft); }
.thm-statement { font-size: 1.1rem; }
.thm-note { margin-top: 8px; font-size: .95rem; color: var(--ink-2); }
.thm-idea { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; align-items: baseline; padding: 12px 20px; border-top: 1.5px dashed var(--thm-line); }
.thm-idea-k { font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--idea); white-space: nowrap; }
.thm-idea .prose { font-size: 1.04rem; color: var(--ink-2); }
.thm-proof { border-top: 1px solid var(--line); }
.pf-toggle { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: 0; cursor: pointer; padding: 10px 20px; text-align: left; font-weight: 700; font-size: .93rem; color: var(--thm); }
.pf-toggle:hover { background: var(--thm-soft); }
.pf-toggle:focus-visible { outline-offset: -3px; }
.pf-ic { display: inline-block; transition: transform .15s ease; }
.pf-toggle[aria-expanded="true"] .pf-ic { transform: rotate(90deg); }
.pf-n { margin-left: auto; font-weight: 500; font-size: .82rem; color: var(--muted); }
.pf-body { padding: 4px 20px 16px; animation: pop .3s ease; }
.pf-k { font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 8px; }
.pf-steps { list-style: none; counter-reset: pf; margin: 0; padding: 0; display: grid; gap: 12px; }
.pf-steps > li { counter-increment: pf; position: relative; padding-left: 38px; }
.pf-steps > li::before { content: counter(pf); position: absolute; left: 0; top: 2px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 800; color: var(--thm); border: 1.5px solid var(--thm-line); background: var(--thm-soft); }
.pf-steps > li:only-child { padding-left: 0; }
.pf-steps > li:only-child::before { display: none; }
.pf-lead { color: var(--ink); }
.pf-steps .prose { font-size: 1.02rem; }
.qed { text-align: right; color: var(--thm); font-size: 1.1rem; line-height: 1; margin-top: 6px; }
.proofs-all[aria-pressed="true"] { font-weight: 700; }
.toc-proofs { display: block; margin-top: 12px; background: none; border: 1px solid var(--thm-line); color: var(--thm); border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: .86rem; cursor: pointer; }
.toc-proofs:hover, .toc-proofs[aria-pressed="true"] { background: var(--thm-soft); }
a.itemref { text-decoration: underline dotted var(--thm); text-decoration-thickness: 2px; text-underline-offset: 4px; color: inherit; }
a.itemref:hover { color: var(--thm); }
.callout:target, .example:target { box-shadow: 0 0 0 4px var(--acc-soft); }
/* the Satser page */
.thm-list { display: grid; gap: 16px; }
.thm-from { display: block; padding: 10px 20px; border-top: 1px solid var(--line); font-size: .88rem; font-weight: 600; text-decoration: none; color: var(--thm); }
.thm-from:hover { background: var(--thm-soft); }

/* worked example */
.example { border-radius: var(--r); padding: 18px 20px; background: var(--ex-soft); border: 1px solid var(--ex-line); }
.example .co-label { color: var(--ex); } .example .co-ic { background: var(--ex); color: var(--surface); }
.example h3 { font-size: 1.15rem; margin: 8px 0 6px; }
.ex-lede { font-size: .88rem; color: var(--muted); margin: 10px 0 0; font-style: italic; }
.steps { list-style: none; counter-reset: st; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
.step { counter-increment: st; background: var(--surface); border-radius: 12px; padding: 12px 16px 12px 50px; position: relative; border: 1px solid var(--ex-line); animation: pop .35s ease; }
.step::before { content: counter(st); position: absolute; left: 14px; top: 12px; width: 24px; height: 24px; border-radius: 50%; background: var(--ex); color: var(--surface); font-weight: 800; font-size: .8rem; display: grid; place-items: center; }
.ex-answer { margin-top: 12px; background: var(--surface); border: 2px solid var(--ex); border-radius: 12px; padding: 10px 16px; animation: pop .35s ease; }
.ex-answer > span { font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--ex); }
.ex-btns { display: flex; gap: 16px; align-items: center; margin-top: 14px; }
.example .btn { background: var(--ex); box-shadow: none; }
.ex-count { opacity: .75; font-weight: 500; font-size: .85em; }
.example.done .ex-btns { display: none; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* check yourself */
.check { border-radius: var(--r); padding: 18px 20px; background: var(--chk-soft); border: 1px solid var(--chk-line); }
.check .co-label { color: var(--chk); } .check .co-ic { background: var(--chk); color: var(--surface); font-weight: 900; }
.check-lede { font-size: .88rem; color: var(--muted); margin: 6px 0 10px; font-style: italic; }
.check-q { display: grid; gap: 16px; }
.check-q.has-fig { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: center; }
.check-q .fig-art { padding: 8px; }
.check-q .fig-art svg { max-width: 220px; }
.check-q.fig-below { grid-template-columns: minmax(0, 1fr); }   /* `figure_wide: true` */
.check-q.fig-below .fig-art svg { max-width: 560px; margin-inline: auto; }
.opts { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.opt {
  width: 100%; display: flex; gap: 12px; align-items: center; text-align: left; cursor: pointer;
  background: var(--surface); border: 2px solid var(--line); border-radius: 12px; padding: 10px 14px;
  transition: border-color .15s, transform .1s;
}
.opt:hover { border-color: var(--chk-line); transform: translateX(2px); }
.opt-l { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; background: var(--surface-2); color: var(--ink-2); font-size: .85rem; }
.opt.picked-bad { border-color: var(--bad); background: var(--pit-soft); }
.opt.picked-bad .opt-l { background: var(--bad); color: #fff; }
.opt.is-ok { border-color: var(--ok); background: var(--ex-soft); }
.opt.is-ok .opt-l { background: var(--ok); color: #fff; }
.opt-mis { margin: 6px 0 4px 40px; font-size: .92rem; color: var(--ink-2); animation: pop .3s ease; }
.opt-mis b { color: var(--pit); }
.check-fb { font-weight: 700; margin-top: 10px; min-height: 1px; }
.check-fb.ok { color: var(--ok); } .check-fb.bad { color: var(--bad); }
.check-expl { margin-top: 12px; background: var(--surface); border-radius: 12px; padding: 14px 18px; border: 1px solid var(--chk-line); animation: pop .35s ease; }
.check-expl .co-label { color: var(--chk); margin-bottom: 6px; }

/* animation & video */
.anim, .video { border-radius: var(--r); padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.anim .co-label { color: #d14d8b; } .anim .co-ic { background: linear-gradient(135deg, #ff6b9d, #c77dff); color: #fff; }
.anim h3, .video h3 { font-size: 1.15rem; margin: 8px 0 6px; }
.anim-frame { margin-top: 14px; height: var(--h); border-radius: 14px; overflow: hidden; background: #0f1117; position: relative; display: grid; place-items: center;
  background-image: radial-gradient(circle at 30% 40%, rgb(255 107 157 / .25), transparent 40%), radial-gradient(circle at 70% 60%, rgb(108 158 255 / .25), transparent 45%); }
.anim-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.anim-start { display: flex; flex-direction: column; align-items: center; gap: 10px; background: none; border: 0; color: #e8eaed; cursor: pointer; font-weight: 600; }
.anim-start .play { width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; font-size: 28px; padding-left: 6px; background: rgb(255 255 255 / .12); border: 2px solid rgb(255 255 255 / .5); transition: transform .15s; }
.anim-start:hover .play { transform: scale(1.08); background: rgb(255 255 255 / .2); }
.video .co-label { color: var(--muted); } .video .co-ic { background: var(--surface-2); }
.video-frame { aspect-ratio: 16/9; margin-top: 12px; border-radius: 12px; overflow: hidden; }
.video-frame iframe { width: 100%; height: 100%; border: 0; }
.video-ph { margin-top: 12px; height: 84px; border-radius: 12px; border: 2px dashed var(--line); display: grid; place-items: center; color: var(--muted); font-size: 2rem; background: repeating-linear-gradient(45deg, transparent 0 12px, var(--surface-2) 12px 24px); }

/* section footer */
.sec-foot { background: var(--surface-2); border-radius: 14px; padding: 12px 16px; display: grid; gap: 8px; font-size: .9rem; }
.sec-foot > div { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sf-k { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-right: 6px; }
.chip { display: inline-block; text-decoration: none; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); border-radius: 999px; padding: 2px 11px; font-size: .86rem; }
.chip:hover { border-color: var(--acc); color: var(--acc-ink); }
.chip-p { border-color: var(--ex-line); color: var(--ex); }
.chip-p.solved { background: var(--ex); color: #fff; border-color: var(--ex); }

.summary { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 22px 26px; box-shadow: var(--shadow); border-top: 5px solid var(--acc); margin-bottom: 30px; }
.summary h2, .reflect h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 10px; }
.reflect { margin-bottom: 30px; }
.reflect ol { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 12px; counter-reset: rf; }
.reflect li { counter-increment: rf; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 20px 12px; min-width: 0; }
.rf-q h3 { font-size: 1.08rem; margin-bottom: 6px; }
.rf-q h3::before { content: counter(rf) "  "; color: var(--acc); font-weight: 800; }
.reflect details { margin-top: 8px; }
.reflect summary { cursor: pointer; color: var(--acc-ink); font-weight: 600; font-size: .92rem; }
.reflect details .prose { margin-top: 8px; padding: 10px 14px; background: var(--surface-2); border-radius: 10px; font-size: 1rem; }

.cta-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 10px; }
.cta { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 22px; transition: transform .15s, border-color .15s; }
.cta:hover { transform: translateY(-2px); border-color: var(--acc-line); }
.cta small { color: var(--muted); font-weight: 700; text-transform: uppercase; font-size: .72rem; letter-spacing: .1em; }
.cta b { font-size: 1.3rem; }
.cta span { color: var(--ink-2); font-size: .92rem; }
.cta-main { background: var(--acc); border-color: var(--acc); color: #fff; }
.cta-main small, .cta-main span { color: rgb(255 255 255 / .85); }
:root[data-theme="dark"] .cta-main { color: #0f1117; }
:root[data-theme="dark"] .cta-main small, :root[data-theme="dark"] .cta-main span { color: rgb(15 17 23 / .75); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cta-main { color: #0f1117; } :root:not([data-theme="light"]) .cta-main small, :root:not([data-theme="light"]) .cta-main span { color: rgb(15 17 23 / .75); } }

/* ------------------------------------------------------------ problems */
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; align-items: center; }
.lvl, .kind { font-size: .78rem; font-weight: 700; border-radius: 999px; padding: 2px 10px; border: 1px solid var(--line); background: var(--surface); white-space: nowrap; }
.lvl { letter-spacing: .02em; }
.lvl-1 { color: var(--ex); border-color: var(--ex-line); }
.lvl-2 { color: var(--idea); border-color: var(--idea-line); }
.lvl-3 { color: var(--pit); border-color: var(--pit-line); }
.kind-auto { color: var(--def); border-color: var(--def-line); background: var(--def-soft); }
.kind-self { color: var(--chk); border-color: var(--chk-line); background: var(--chk-soft); }
.probpage { max-width: 900px; margin: 0 auto; padding: 30px 20px 60px; }
.grp { margin-bottom: 40px; }
.g-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; margin-bottom: 14px; }
.g-head h2 { font-size: 1.5rem; font-weight: 800; }
.g-read { font-size: .9rem; font-weight: 600; text-decoration: none; }
.g-intro { color: var(--ink-2); margin-bottom: 12px; }
.probs { display: grid; gap: 14px; }
.prob { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 20px; box-shadow: var(--shadow); position: relative; transition: border-color .3s; }
.prob:target { border-color: var(--acc); box-shadow: 0 0 0 4px var(--acc-soft); }
.prob.solved { border-color: var(--ex-line); }
.prob.solved::after { content: "✓"; position: absolute; right: -10px; top: -10px; width: 30px; height: 30px; border-radius: 50%; background: var(--ok); color: #fff; font-weight: 800; display: grid; place-items: center; box-shadow: 0 0 0 4px var(--bg); animation: pop .4s ease; }
.p-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.p-num { font-weight: 800; color: var(--ink); text-decoration: none; margin-right: 4px; }
.p-title { font-size: 1.08rem; margin: 0 0 6px; }
.p-stem, .p-stem-static { font-size: 1.06rem; }
.p-form { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.p-in { flex: 1 1 240px; font: inherit; font-family: var(--mono); font-size: 1rem; padding: 9px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); }
.p-in:focus { outline: none; border-color: var(--acc); background: var(--surface); }
.p-in.ok { border-color: var(--ok); } .p-in.bad { border-color: var(--bad); animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.p-preview { min-height: 1.6em; margin-top: 8px; font-size: .92rem; color: var(--muted); }
.p-preview .katex { font-size: 1.12em; color: var(--ink); }
.p-fb { font-weight: 700; }
.p-fb.ok { color: var(--ok); } .p-fb.bad { color: var(--bad); }
.p-tools { display: flex; gap: 18px; margin-top: 8px; flex-wrap: wrap; }
.p-hintbox, .p-ans { margin-top: 10px; background: var(--surface-2); border-radius: 10px; padding: 10px 14px; animation: pop .3s ease; }
.p-ans b { color: var(--ex); margin-right: 8px; }
.p-hintd { margin-top: 10px; }
.p-hintd summary { cursor: pointer; color: var(--acc-ink); font-weight: 600; font-size: .93rem; }
.p-hintd .prose { margin-top: 6px; background: var(--surface-2); border-radius: 10px; padding: 10px 14px; }
.selfsol { background: none; border: 0; padding: 0; margin-top: 8px; }
.selfsol .btn { background: var(--chk); }
.selfsol .step { border-color: var(--chk-line); }
.selfsol .step::before { background: var(--chk); }
.selfrep { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .92rem; background: var(--surface-2); padding: 10px 12px; border-radius: 12px; }
.selfrep span { font-weight: 700; margin-right: 6px; }
.selfrep button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.selfrep button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.stuck { display: inline-block; margin-top: 12px; font-size: .87rem; color: var(--muted); text-decoration: none; }
.stuck:hover { color: var(--acc-ink); }
.grp-mixed .g-head h2::before { content: "★ "; color: var(--idea); }

/* exam-style problems: write, open the solution, tick the rubric */
.grp-exam .g-head h2::before { content: "✍ "; }
.e-sum { font-size: .9rem; color: var(--muted); font-weight: 600; }
.e-sum b { color: var(--ok); }
.pts { font-size: .78rem; font-weight: 800; border-radius: 999px; padding: 2px 10px; white-space: nowrap; color: var(--idea); border: 1px solid var(--idea-line); background: var(--idea-soft); font-variant-numeric: tabular-nums; }
.kind-exam { color: var(--thm); border-color: var(--thm-line); background: var(--thm-soft); }
.e-model { font-size: .78rem; color: var(--muted); margin-left: auto; }
.e-parts { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.e-parts li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: baseline; }
.e-pl { font-weight: 800; color: var(--acc-ink); }
.e-write { margin-top: 14px; }
.e-write label { display: block; font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 6px; }
.e-draft { display: block; width: 100%; min-height: 7.5em; resize: vertical; font: inherit; font-size: 1rem; line-height: 1.5; padding: 10px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--ink);
  background-image: linear-gradient(transparent calc(1.5em - 1px), var(--line) calc(1.5em - 1px)); background-size: 100% 1.5em; background-position: 0 10px; background-attachment: local; }
.e-draft:focus { outline: none; border-color: var(--acc); }
.e-note { font-size: .82rem; color: var(--muted); margin: 6px 0 0; }
.e-assess { margin-top: 14px; border: 1px solid var(--ex-line); background: var(--ex-soft); border-radius: 14px; padding: 14px 16px; animation: pop .35s ease; }
.e-assess .co-label { color: var(--ex); } .e-assess .co-ic { background: var(--ex); color: var(--surface); }
.e-lede { font-size: .88rem; color: var(--ink-2); margin: 6px 0 10px; font-style: italic; }
.rubric { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rubric label { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 10px; align-items: baseline; background: var(--surface); border: 1.5px solid var(--ex-line); border-radius: 12px; padding: 10px 14px; cursor: pointer; }
.rubric label:has(input:checked) { border-color: var(--ok); }
.rubric input { width: 18px; height: 18px; accent-color: var(--ok); transform: translateY(3px); }
.r-pts { font-size: .78rem; font-weight: 800; color: var(--ex); white-space: nowrap; }
.r-part { font-weight: 800; color: var(--acc-ink); }
.r-text { font-size: .98rem; }
.e-score { margin-top: 12px; font-weight: 600; }
.e-score b { font-size: 1.25rem; color: var(--ok); }
.e-errors { margin-top: 10px; }
.e-errors summary { cursor: pointer; font-weight: 700; color: var(--pit); font-size: .93rem; }
.e-errors ul { margin: 8px 0 0; padding-left: 1.3em; font-size: .98rem; }
.e-errors li { margin: .35em 0; }
.e-refs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 14px; font-size: .9rem; }
.chip-ref { border-color: var(--thm-line); color: var(--thm); }
.chip-off { color: var(--muted); border-style: dashed; border-color: var(--line); }
/* mock exams */
.hero-mock .kicker a { color: inherit; text-decoration: none; }
.grades { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 16px; }
.grade { font-size: .86rem; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 2px 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.grade.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.mock-info { margin-bottom: 30px; }
.mock-how-to-use { border-top: 5px solid var(--acc); }
.mock-total { margin: 0 0 24px; border-top: 5px solid var(--ok); }
.mock-total h2 { font-size: 1.1rem; }
.mock-sum { font-size: 1.15rem; margin: 6px 0; }
.mock-sum b { font-size: 1.9rem; color: var(--ok); }
.mock-grade { font-weight: 700; }
.mock-card .meta { margin-top: 6px; gap: 12px; font-size: .86rem; }
.mock-score:not(:empty) { color: var(--ok); font-weight: 700; margin-top: 4px; }

/* ------------------------------------------------------------- pages */
.narrow { max-width: 820px; margin: 0 auto; padding: 30px 20px 60px; }
.wide { max-width: 1240px; margin: 0 auto; padding: 30px 20px 60px; }
.letters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.letters a { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; font-weight: 700; color: var(--ink); }
.letters a:hover { border-color: var(--acc); }
.letter { margin-bottom: 26px; }
.letter h2 { font-size: 2rem; color: var(--acc); font-weight: 800; border-bottom: 2px solid var(--line); padding-bottom: 4px; margin-bottom: 8px; }
.letter dl { margin: 0; }
.term-row { display: grid; grid-template-columns: 220px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.term-row:target { background: var(--acc-soft); border-radius: 10px; }
.term-row dt { font-weight: 700; font-size: 1.05rem; }
.term-row dt small { display: block; font-weight: 400; color: var(--muted); font-size: .82rem; }
.term-row dd { margin: 0; }
.term-row dd a { font-size: .88rem; font-weight: 600; text-decoration: none; }
.fsec { margin-bottom: 34px; }
.fsec h2 { font-size: 1.35rem; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }
.fcard .katex { font-size: .98em; }
.fcard .prose { overflow-x: auto; }
.fcard { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 18px; transition: border-color .15s, transform .15s; }
.fcard:hover { border-color: var(--acc); transform: translateY(-2px); }
.fcard .prose { font-size: 1rem; }
.f-from { font-size: .82rem; color: var(--acc-ink); font-weight: 600; margin-top: auto; }
.cards { display: grid; gap: 16px; }
.info h2 { font-size: 1.25rem; margin-bottom: 8px; }

.foot { max-width: 1240px; margin: 0 auto; padding: 26px 20px 40px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1080px) {
  .mainnav { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
  .home { grid-template-columns: minmax(0, 1fr); }
  .home-side .card { position: static; }
}
@media (max-width: 680px) {
  body { font-size: 16px; }
  .top-in { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .brand-t small { display: none; }
  .search { order: 5; flex: 1 1 100%; }
  .hero-in { padding: 28px 16px; }
  .layout, .probpage, .home, .narrow, .wide { padding-left: 16px; padding-right: 16px; }
  .fig-row, .check-q.has-fig { grid-template-columns: minmax(0, 1fr); }
  .fig-row.fig-right .fig { order: 0; }
  .stops { grid-template-columns: 1fr; }
  .term-row { grid-template-columns: 1fr; gap: 4px; }
  .lb-title { display: none; }
  .lecbar-in { justify-content: space-between; }
  .hero-home::after { opacity: .18; }
  .anim-frame { height: min(var(--h), 78vh); }
  .fgrid { grid-template-columns: 1fr; }
  .thm-head, .thm-body, .thm-idea, .pf-toggle, .pf-body { padding-left: 14px; padding-right: 14px; }
  .thm-idea { grid-template-columns: minmax(0, 1fr); }
  .pf-steps > li { padding-left: 32px; }
  .e-model { margin-left: 0; flex-basis: 100%; }
  .rubric label { grid-template-columns: auto minmax(0, 1fr); }
  .rubric .r-pts { order: 3; grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print {
  .top, .lecbar, .toc, .cta-row, .foot, .anim-frame, .ex-btns, .p-form, .p-tools { display: none !important; }
  .step, .ex-answer, .check-expl { display: block !important; }
  /* Proofs print open, whatever is open on screen (the screen state is not touched). */
  .pf-body { display: block !important; animation: none; }
  .pf-toggle, .proofs-all, .thm-link { display: none !important; }
  .theorem, .callout, .example, .check, .formula { break-inside: avoid; box-shadow: none; }
  /* An exam problem prints as the paper: the solution only if it was opened. */
  .prob.exam .step[hidden], .prob.exam .ex-answer[hidden] { display: none !important; }
  .prob.exam .e-write, .prob.exam .e-assess[hidden] { display: none !important; }
  .katex-display { overflow: visible; }
}

/* ------------------------------------------------------------------------
   Server mode: sign-in panel and account bar (decisions.md D23). Only pages
   built with --server contain #signin; the static build never shows any of
   this.
   ------------------------------------------------------------------------ */
.signin { background: var(--surface); border: 1px solid var(--acc-line); border-radius: var(--r); padding: 18px 22px 16px; box-shadow: var(--shadow); margin: 0 0 26px; }
.signin h2 { margin: 0 0 .3em; font-size: 1.2rem; }
.si-lede { color: var(--ink-2); margin: 0 0 16px; max-width: 62ch; }
.si-forms { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 26px; }
@media (max-width: 640px) { .si-forms { grid-template-columns: 1fr; } }
.si-form label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
.si-row { display: flex; gap: 8px; align-items: center; }
.si-row input { flex: 1; min-width: 0; font-family: var(--mono); letter-spacing: .04em; text-transform: uppercase; }
.si-row input::placeholder { text-transform: none; letter-spacing: .08em; }
.btn-ghost { background: transparent; color: var(--acc-ink); box-shadow: inset 0 0 0 1.5px var(--acc-line); }
:root[data-theme="dark"] .btn-ghost { color: var(--acc-ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-ghost { color: var(--acc-ink); } }
.si-err { color: var(--bad); font-weight: 600; min-height: 1.3em; margin: 10px 0 0; }
.si-err:empty { margin: 0; min-height: 0; }
.si-priv { margin: 8px 0 0; font-size: .9rem; }
.si-code { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 8px 0 12px; }
.si-code code { font-family: var(--mono); font-size: 1.45rem; letter-spacing: .08em; background: var(--acc-soft); color: var(--acc-ink); padding: .25em .6em; border-radius: 10px; user-select: all; }
.si-warn { background: var(--idea-soft); border: 1px solid var(--idea-line); border-radius: 12px; padding: 10px 14px; margin: 0 0 14px; max-width: 62ch; }
.signin.si-bar { padding: 9px 16px; display: flex; gap: 6px 16px; align-items: center; flex-wrap: wrap; font-size: .92rem; box-shadow: none; border-color: var(--line); }
.signin.si-bar span { color: var(--ink-2); }
.prob.locked .p-stem { color: var(--muted); font-style: italic; }
