:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --text: #1c1c1a;
  --muted: #64625c;
  --border: #dddbd4;
  --accent: #76b900;
  --accent-ink: #3d6b00;
  --accent-text: #000000;
  --accent-soft: #eef6df;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --bad-text: #ffffff;
  --code-bg: #f3f2ee;
  --warp-0: #76b900;
  --warp-1: #7c3aed;
  --warp-2: #c2410c;
  --warp-3: #2563eb;
  --cls-3: #0d9488;
  --cls-4: #db2777;
  --lane-off: #e7e5df;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121413;
    --surface: #1a1d1c;
    --surface-2: #222624;
    --text: #e8e6e1;
    --muted: #a19f98;
    --border: #2f3431;
    --accent: #76b900;
    --accent-ink: #8fd400;
    --accent-text: #000000;
    --accent-soft: #1c260d;
    --ok: #4ade80;
    --ok-soft: #12321f;
    --bad: #f87171;
    --bad-soft: #3a1717;
    --bad-text: #1a0606;
    --code-bg: #161918;
    --warp-0: #76b900;
    --warp-1: #a78bfa;
    --warp-2: #fb923c;
    --warp-3: #60a5fa;
  --cls-3: #2dd4bf;
  --cls-4: #f472b6;
    --cls-3: #2dd4bf;
    --cls-4: #f472b6;
    --lane-off: #2a2e2c;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121413;
  --surface: #1a1d1c;
  --surface-2: #222624;
  --text: #e8e6e1;
  --muted: #a19f98;
  --border: #2f3431;
  --accent: #76b900;
  --accent-ink: #8fd400;
  --accent-text: #000000;
  --accent-soft: #1c260d;
  --ok: #4ade80;
  --ok-soft: #12321f;
  --bad: #f87171;
  --bad-soft: #3a1717;
  --bad-text: #1a0606;
  --code-bg: #161918;
  --warp-0: #76b900;
  --warp-1: #a78bfa;
  --warp-2: #fb923c;
  --warp-3: #60a5fa;
  --lane-off: #2a2e2c;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent-ink); }

code, pre, textarea { font-family: var(--mono); }

code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 0.9em;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.5;
}

:focus-visible { outline: 3px solid var(--accent-ink); outline-offset: 2px; }
/* #main gets focus on every route change for screen readers; it is a container, not a control. */
#main:focus { outline: none; }

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus { left: 16px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; }

.muted { color: var(--muted); font-size: 14px; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
}
@media (max-width: 480px) {
  .topbar { gap: 8px; padding: 0 12px; }
  .brand { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
}

.progress-text { color: var(--muted); font-size: 14px; }

.icon-btn {
  min-width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

.menu-btn { display: none; }

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 16px 12px 32px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.nav-home {
  display: block;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.nav-level h2 {
  margin: 18px 10px 6px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-level ol { list-style: none; margin: 0; padding: 0; }

.nav-level a {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
  line-height: 1.35;
}

.nav-level a:hover, .nav-home:hover { background: var(--surface-2); }
.nav-level a[aria-current="page"], .nav-home[aria-current="page"] { background: var(--accent-soft); }
.nav-level .num { color: var(--muted); font-family: var(--mono); font-size: 13px; }
.nav-level .label { flex: 1; }
.nav-level .check { color: var(--ok); font-weight: 700; }

.site-foot {
  grid-column: -2 / -1; /* the content column, with or without the sidebar */
  padding: 16px 40px 24px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.scrim { display: none; }

main {
  padding: 32px 40px 64px;
  max-width: 1640px;
  outline: none;
}

@media (max-width: 960px) {
  .menu-btn { display: inline-block; }
  .progress-text { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .site-foot { padding: 16px 16px 24px; }
  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: min(300px, 85vw);
    height: auto;
    z-index: 15;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    visibility: hidden;
  }
  body.nav-open .sidebar { transform: none; visibility: visible; }
  body.nav-open .scrim {
    display: block;
    position: fixed;
    inset: 56px 0 0 0;
    background: rgb(0 0 0 / 0.35);
    z-index: 10;
  }
  main { padding: 20px 16px 48px; }
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.1); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 14px; }

/* ---------- home ---------- */

.hero { max-width: 760px; margin-bottom: 32px; }
.hero h1 { font-size: clamp(32px, 6vw, 48px); line-height: 1.1; margin: 8px 0 12px; }
.tagline { font-size: 20px; color: var(--muted); margin-top: 0; }

.levels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.level-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.level-card h2 { font-size: 18px; margin: 0 0 6px; }
.level-card p { color: var(--muted); margin: 0 0 12px; font-size: 15px; }
.level-card progress { width: 100%; height: 8px; accent-color: var(--accent); }
.level-card ol { margin: 12px 0 0; padding-left: 0; list-style: none; font-size: 15px; }
.level-card li { padding: 3px 0; }

.how { max-width: 760px; }
.steps { padding-left: 20px; }
.steps li { margin-bottom: 6px; }
.steps strong { margin-right: 6px; }

/* ---------- lesson ---------- */

.lesson { max-width: 780px; }

.lesson-top { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; }
.lesson-top > * { min-width: 0; }

@media (min-width: 1200px) {
  .lesson-top {
    grid-template-columns: minmax(0, 760px) minmax(360px, 1fr);
    gap: 40px;
    align-items: start;
  }
  .diagram { position: sticky; top: 80px; }
  .figures .diagram { position: static; }
}
.figures { display: grid; gap: 20px; }

/* ---------- lesson diagrams ---------- */

.diagram {
  margin: 0;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.diagram svg { display: block; width: 100%; max-width: 620px; height: auto; margin: 0 auto; }
.diagram figcaption { margin-top: 12px; color: var(--muted); font-size: 15px; }
.diagram text { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 13px; fill: var(--text); }
.diagram .d-title { font-size: 15px; font-weight: 700; }
.diagram .d-muted { fill: var(--muted); font-size: 12px; }
.diagram .d-code { font-family: var(--mono); font-size: 12px; }
.diagram .d-code-sm { font-family: var(--mono); font-size: 11px; }
.diagram .d-accent-text { fill: var(--accent-ink); font-weight: 600; }
.diagram .d-bad-text { fill: var(--bad); font-size: 12px; font-weight: 600; }
.diagram .d-muted.d-code-sm, .diagram .d-code-sm.d-muted { font-size: 11px; }
.d-box { fill: var(--surface); stroke: var(--border); stroke-width: 1.5; }
.d-soft { fill: var(--accent-soft); stroke: var(--border); stroke-width: 1; }
.d-hi { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
.d-on { fill: var(--accent); }
.d-off { fill: var(--lane-off); }
.d-line { stroke: var(--muted); stroke-width: 1.4; fill: none; }
.d-fan { stroke: var(--border); stroke-width: 1.2; fill: none; }
.d-grid { stroke: var(--border); stroke-width: 1; fill: none; }
.d-arrow { stroke: var(--accent-ink); stroke-width: 2; fill: none; }
.d-arrow-thin { stroke: var(--accent-ink); stroke-width: 1.2; fill: none; }
.d-head { fill: var(--accent-ink); }
.d-bar { stroke: var(--accent-ink); stroke-width: 2; stroke-dasharray: 6 5; fill: none; }
.d-bad-outline { fill: none; stroke: var(--bad); stroke-width: 2; }
.d-curve { stroke: var(--accent-ink); stroke-width: 2.5; fill: none; }
.d-bad-cell { fill: var(--bad-soft); stroke: var(--bad); stroke-width: 1.5; }
.d-dot { fill: var(--accent); }
.d-dot-bad { fill: var(--bad); }
.d-tile { fill: rgb(118 185 0 / 0.35); stroke: var(--accent-ink); stroke-width: 2; }

@media (prefers-reduced-motion: no-preference) {
  .d-pulse { animation: d-pulse 1.6s ease-in-out infinite; }
  .d-k { animation: d-k 2.4s infinite; }
  .d-k1 { animation-delay: 0.6s; }
  .d-k2 { animation-delay: 1.2s; }
  .d-k3 { animation-delay: 1.8s; }
  .d-step-1 { animation: d-step-1 6s infinite; }
  .d-step-2 { animation: d-step-2 6s infinite; }
  .d-step-3 { animation: d-step-3 6s infinite; }
  .d-tile-0 { animation: d-first 4s infinite; }
  .d-tile-1 { animation: d-second 4s infinite; }
}

@keyframes d-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes d-k { 0%, 24% { fill: var(--accent); } 25%, 100% { fill: var(--accent-soft); } }
@keyframes d-step-1 { 0%, 19% { opacity: 0.1; } 20%, 100% { opacity: 1; } }
@keyframes d-step-2 { 0%, 44% { opacity: 0.1; } 45%, 100% { opacity: 1; } }
@keyframes d-step-3 { 0%, 69% { opacity: 0.1; } 70%, 100% { opacity: 1; } }
@keyframes d-first { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0.12; } }
@keyframes d-second { 0%, 49% { opacity: 0.12; } 50%, 100% { opacity: 1; } }
.eyebrow { margin: 0; color: var(--muted); font-size: 14px; font-weight: 600; }
.lesson h1 { margin: 4px 0 16px; font-size: clamp(26px, 4vw, 34px); line-height: 1.2; }
.prose p, .prose ul { margin: 0 0 12px; }
/* Long inline code (a function call with its arguments) must wrap on phones instead of widening the page. */
.prose code { overflow-wrap: anywhere; }
.prose h3 { margin: 22px 0 8px; font-size: 18px; }
.prose .quiz { display: grid; gap: 8px; margin: 4px 0 12px; }
.prose .quiz details { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 10px 14px; }
.prose .quiz summary { cursor: pointer; font-weight: 600; }
.prose .quiz details[open] summary { color: var(--accent-ink); margin-bottom: 6px; }
.prose .quiz details p { margin: 0; }

.goal {
  margin: 20px 0 12px;
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.goal p { margin: 4px 0 0; }

.hint summary { cursor: pointer; color: var(--accent-ink); font-weight: 600; }
.hint p { margin: 8px 0 0; }

.lab {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  margin-top: 28px;
  align-items: start;
}

@media (max-width: 1180px) {
  .lab { grid-template-columns: minmax(0, 1fr); }
}

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }

/* ---------- editor: green-phosphor CRT ---------- */

.editor {
  --phosphor: #8fe03a;
  --phosphor-glow: rgb(118 185 0 / 0.6);
  position: relative;
  display: flex;
  height: 460px;
  padding: 6px 4px;
  border: 12px solid #1a1c19;
  border-radius: 22px;
  background: radial-gradient(ellipse at center, #0d1a06 0%, #060c03 70%, #020401 100%);
  box-shadow:
    inset 0 0 50px rgb(0 0 0 / 0.9),
    inset 0 0 12px rgb(118 185 0 / 0.18),
    0 0 0 1px #000,
    0 10px 28px rgb(0 0 0 / 0.35);
  overflow: hidden;
  animation: crt-on 0.45s ease-out;
}

/* scanlines */
.editor::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgb(0 0 0 / 0) 0,
    rgb(0 0 0 / 0) 2px,
    rgb(0 0 0 / 0.3) 3px,
    rgb(0 0 0 / 0) 4px
  );
}

/* curved-glass vignette, reflection and a faint flicker */
.editor::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  border-radius: 10px;
  background:
    radial-gradient(ellipse at center, transparent 58%, rgb(0 0 0 / 0.6) 100%),
    linear-gradient(155deg, rgb(255 255 255 / 0.07) 0%, transparent 30%);
  animation: crt-flicker 5s infinite;
}

@keyframes crt-on {
  0% { transform: scale(1, 0.02); filter: brightness(4); }
  60% { transform: scale(1, 1.02); filter: brightness(1.6); }
  100% { transform: none; filter: none; }
}

@keyframes crt-flicker {
  0%, 100% { opacity: 1; }
  48% { opacity: 1; }
  50% { opacity: 0.9; }
  52% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .editor, .editor::after { animation: none; }
}

.gutter {
  flex: none;
  width: 44px;
  padding: 12px 8px 12px 0;
  overflow: hidden;
  text-align: right;
  color: rgb(118 185 0 / 0.5);
  text-shadow: 0 0 4px rgb(118 185 0 / 0.35);
  font: 14px/21px var(--mono);
  border-right: 1px solid rgb(118 185 0 / 0.18);
  user-select: none;
}
.gutter span { display: block; }
.gutter span.err {
  color: #ffb000;
  font-weight: 700;
  background: rgb(255 176 0 / 0.14);
  text-shadow: 0 0 6px rgb(255 176 0 / 0.9);
}

.editor textarea {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 12px;
  resize: none;
  background: transparent;
  color: var(--phosphor);
  caret-color: #c4ff7a;
  text-shadow: 0 0 2px var(--phosphor-glow), 0 0 9px rgb(118 185 0 / 0.45);
  font: 14px/21px var(--mono);
  tab-size: 8;
  white-space: pre;
  overflow: auto;
  scrollbar-color: rgb(118 185 0 / 0.4) transparent;
}
.editor textarea::selection { background: #76b900; color: #000; text-shadow: none; }
.editor textarea:focus { outline: none; }
.editor:focus-within { outline: 3px solid var(--accent); outline-offset: 3px; }

@media (max-width: 600px) {
  .editor { height: 380px; border-width: 8px; border-radius: 16px; }
  .editor textarea, .gutter { font-size: 13px; line-height: 19px; }
}

.status {
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}
.status.pass { border-color: var(--ok); background: var(--ok-soft); color: var(--text); display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.status.fail { border-color: var(--bad); background: var(--bad-soft); color: var(--text); }
.status.pass strong { color: var(--ok); }
.status.fail strong { color: var(--bad); }
.status ul { margin: 6px 0 0; padding-left: 20px; }

.tabs {
  display: flex;
  gap: 4px;
  margin: 14px 0 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tabs button {
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

.panel { padding-top: 12px; }

/* memory */
.mem-window { margin: 0 0 16px; }
.mem-window figcaption { font: 600 14px var(--mono); margin-bottom: 6px; }
.cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 4px; }
.cell {
  display: flex;
  flex-direction: column;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-family: var(--mono);
  line-height: 1.25;
}
.cell .addr { font-size: 10px; color: var(--muted); }
.cell .val { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.cell.changed { border-color: var(--text); }
.cell.ok { background: var(--ok-soft); }
.cell.bad { background: var(--bad-soft); border-color: var(--bad); }
.math {
  margin: 14px 0;
  padding: 12px 16px;
  overflow-x: auto;
  text-align: center;
  font-family: "STIX Two Math", "Cambria Math", "Latin Modern Math", "Times New Roman", serif;
  font-size: 19px;
  line-height: 1.6;
  white-space: nowrap;
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 2px; font-size: 0.85em; line-height: 1.15; }
.frac > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 3px; }
.diagram .d-axis { stroke: var(--muted); stroke-width: 1.2; fill: none; }
.diagram .d-tangent { stroke: var(--bad); stroke-width: 2; stroke-dasharray: 6 4; fill: none; }
.diagram .d-before { stroke: var(--muted); stroke-width: 2; stroke-dasharray: 5 4; fill: none; }

/* ---------- Level 5 live figures (mlviz.js) ---------- */
.mv-art svg { display: block; width: 100%; max-width: 680px; height: auto; margin: 0 auto; }
.mv text { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 12px; fill: var(--text); }
.mv .mv-title { font-size: 14px; font-weight: 700; }
.mv .mv-label { font-size: 12px; fill: var(--muted); }
.mv .mv-big { font-size: 18px; font-weight: 700; }
.mv .mv-mono { font-family: var(--mono); font-size: 12px; }
.mv .mv-muted { fill: var(--muted); }
.mv-frame { fill: none; stroke: var(--border); stroke-width: 1.2; }
.diagram .d-c0-text { fill: var(--warp-3); font-weight: 700; }
.diagram .d-c1-text { fill: var(--warp-2); font-weight: 700; }
.diagram .d-on-dot { fill: #fff; font-weight: 700; }
.mv-c0 { fill: var(--warp-3); stroke: #fff; stroke-opacity: 0.85; stroke-width: 0.9; }
.mv-c1 { fill: var(--warp-2); stroke: #fff; stroke-opacity: 0.85; stroke-width: 0.9; }
.mv-c2 { fill: var(--warp-1); stroke: #fff; stroke-opacity: 0.85; stroke-width: 0.9; }
.mv-c3 { fill: var(--cls-3); stroke: #fff; stroke-opacity: 0.85; stroke-width: 0.9; }
.mv-c4 { fill: var(--cls-4); stroke: #fff; stroke-opacity: 0.85; stroke-width: 0.9; }
.mv-cx { fill: var(--muted); stroke: #fff; stroke-opacity: 0.85; stroke-width: 0.9; }
.mv-f0 { fill: var(--warp-3); }
.mv-f1 { fill: var(--warp-2); }
.mv-f2 { fill: var(--warp-1); }
.mv-f3 { fill: var(--cls-3); }
.mv-f4 { fill: var(--cls-4); }
.mv-centroid { stroke: var(--text); stroke-width: 2.2; }
.mv-trail { stroke: var(--text); stroke-width: 1.4; stroke-dasharray: 3 3; fill: none; }
.mv-cut { stroke: var(--bad); stroke-width: 3; fill: none; }
.mv-leaf { fill: none; stroke: var(--text); stroke-opacity: 0.45; stroke-width: 0.8; }
.mv-stem { stroke: var(--warp-3); stroke-width: 1.4; }
.mv-pos { stroke: var(--warp-2); stroke-opacity: 0.75; fill: none; }
.mv-px { fill: var(--text); }
.mv-wpos { fill: var(--warp-2); }
.mv-wneg { fill: var(--warp-3); }
.mv-window { fill: none; stroke: var(--bad); stroke-width: 2.2; }
.mv-arc { fill: none; stroke: var(--accent-ink); }
.mv-heat { fill: var(--accent-ink); }
.mv .mv-word { font-size: 14px; }
.mv .mv-word-q { font-weight: 800; fill: var(--accent-ink); }
.mv-neg { stroke: var(--warp-3); stroke-opacity: 0.75; fill: none; }
.mv-tangent-live { stroke: var(--bad); stroke-width: 2; stroke-dasharray: 5 4; fill: none; }
.mv-node { fill: var(--surface); stroke: var(--text); stroke-width: 1.2; }
.mv .mv-small { font-size: 10.5px; }
.mv .mv-accent { fill: var(--accent-ink); font-weight: 700; }
.mv .mv-bad { fill: var(--bad); font-weight: 700; }
.mv-miss { fill: none; stroke: var(--bad); stroke-width: 1.6; }
.mv-boundary { stroke: var(--text); stroke-width: 2; fill: none; }
.mv-curve { stroke: var(--accent-ink); stroke-width: 2; fill: none; }
.mv-link { stroke: var(--text); stroke-width: 1; stroke-opacity: 0.55; fill: none; }
.mv-reach { fill: none; stroke: var(--text); stroke-width: 1.2; stroke-dasharray: 4 3; }
.mv-query { stroke: var(--text); stroke-width: 2.5; }
.mv-win { stroke: var(--text); stroke-width: 2; }
.mv-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.mv-status { margin: 0 0 0 4px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mv-sliders { display: flex; flex-wrap: wrap; gap: 10px 24px; margin-top: 10px; }
.mv-slider { display: grid; grid-template-columns: auto minmax(110px, 160px) auto; align-items: center; gap: 10px; font-size: 14px; }
.mv-slider input { accent-color: var(--accent); width: 100%; }
.mv-slider output { min-width: 5.5em; font-weight: 600; color: var(--accent-ink); }
@media (max-width: 600px) { .mv-slider { grid-template-columns: 1fr; gap: 4px; } }
.pixel-row { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 8px; }
.pixel-fig { margin: 0; }
.pixel-fig figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
.pixels { display: block; width: 168px; max-width: 100%; height: auto; image-rendering: pixelated; border: 1px solid var(--border); border-radius: 4px; background: #000; }
.pixels.small { width: 60px; }
.mem-numbers summary { cursor: pointer; font-size: 13px; color: var(--accent-ink); margin-bottom: 6px; }

/* stats */
.stats { margin: 0; display: grid; gap: 2px; }
.stats div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.stats dt { font-weight: 600; }
.stats dt small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.stats dd { margin: 0; font: 600 16px var(--mono); white-space: nowrap; }

/* timeline */
.timeline-scroll {
  position: relative;
  max-height: 460px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 6px;
}
.timeline canvas { display: block; }
.tip {
  position: absolute;
  z-index: 5;
  max-width: 320px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font: 12px/1.4 var(--mono);
  white-space: pre-wrap;
  pointer-events: none;
}

/* program */
.program { width: 100%; border-collapse: collapse; font-size: 14px; }
.program th { text-align: left; color: var(--muted); font-weight: 600; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.program td { padding: 3px 8px; border-bottom: 1px solid var(--border); font-family: var(--mono); }
.program td code { border: 0; background: none; padding: 0; }
.program tr.cold td { color: var(--muted); }
.program tr.err td { background: var(--bad-soft); color: var(--bad); font-weight: 700; }

.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 32px; flex-wrap: wrap; }

/* ---------- level 4 and career ---------- */

.cta { display: flex; flex-wrap: wrap; gap: 10px; }

.code-card { margin: 0; }
.code-card .tabs { margin: 0 0 10px; }
.editor.code-screen { height: auto; max-height: 560px; }
.code-screen-text {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 14px 16px;
  border: 0;
  background: transparent;
  color: var(--phosphor);
  text-shadow: 0 0 2px var(--phosphor-glow), 0 0 9px rgb(118 185 0 / 0.45);
  font: 13px/20px var(--mono);
  overflow: auto;
  white-space: pre;
}
.code-screen-text:focus-visible { outline: none; }
.code-screen-text .cm { color: #6f8f55; text-shadow: none; }

.kernel-steps { counter-reset: kstep; list-style: none; padding: 0; display: grid; gap: 8px; }
.kernel-steps li { counter-increment: kstep; position: relative; padding-left: 38px; line-height: 1.55; }
.kernel-steps li::before {
  content: counter(kstep);
  position: absolute;
  left: 0;
  top: 1px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font: 700 13px/1 var(--mono);
  color: #0b0f0a;
  background: var(--accent);
}
.host-flow { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; counter-reset: hstep; }
.host-flow li {
  counter-increment: hstep;
  position: relative;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 14px;
  line-height: 1.45;
}
.host-flow li::before { content: counter(hstep) " · CPU"; display: block; font: 700 11px/1.4 var(--mono); color: var(--muted); letter-spacing: 0.04em; }
.host-flow li:nth-child(3) { border-color: var(--accent); background: var(--accent-soft); }
.host-flow li:nth-child(3)::before { content: "3 · CPU → GPU"; color: var(--accent-ink); }
.host-flow code { font-size: 12px; overflow-wrap: anywhere; }

.practice {
  margin-top: 32px;
  padding: 20px 24px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  max-width: 1100px;
}
.practice h2 { margin-top: 0; font-size: 22px; }
.practice h3 { margin-bottom: 4px; }
.colab-steps li { margin-bottom: 4px; }
.colab-look { margin: 4px 0 14px; }
.colab-look summary { cursor: pointer; font-weight: 600; color: var(--accent-ink); }
.colab-look figure { margin: 10px 0 0; }
.colab-look img { display: block; width: 100%; max-width: 900px; height: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.practice .stage-head { margin-top: 0; }
.expect { margin-top: 18px; padding: 4px 18px 8px; border-radius: var(--radius); background: var(--accent-soft); }
.expect ul { margin: 6px 0; padding-left: 20px; }
.expect li { margin-bottom: 4px; }
.jetson-box { margin-top: 18px; padding: 4px 18px 10px; border: 1px dashed var(--border); border-radius: var(--radius); }
.jetson-box h3 { margin-bottom: 4px; }
.results-chart .diagram { margin: 16px 0 0; }
.results-chart .eyebrow { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-ink); }
.r-b1 { fill: var(--accent); }
.r-b10 { fill: var(--accent-soft); stroke: var(--accent-ink); stroke-width: 1.5; stroke-dasharray: 4 3; }
.r-plot { fill: none; stroke: var(--border); stroke-width: 1; }
.r-roof { fill: none; stroke: var(--accent-ink); stroke-width: 2.5; }
.r-roof-orin { fill: none; stroke: var(--muted); stroke-width: 2; stroke-dasharray: 7 5; }
.diagram .r-roof-text { fill: var(--accent-ink); font-weight: 600; }
.r-pt { fill: var(--bad); }
.slots { display: grid; gap: 10px; }
.slots-title { margin: 0; font-weight: 600; }
.slot { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.slot.current { border-color: var(--accent); background: var(--accent-soft); }
.slot-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.slot-label, .card-form .slot-label { display: block; font-size: 14px; font-weight: 400; }
.slot-head .slot-label { flex: 1 1 260px; min-width: 0; }
.slot-this { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--accent); color: #0b0f0a; }
.slot-status { font-size: 13px; color: var(--muted); }
.slot-status.ok { color: var(--accent-ink); font-weight: 600; }
.slot-input { width: 100%; font-family: var(--mono); font-size: 13px; }
.slot-input.invalid { border-color: var(--bad); }
.slot-note { margin: 4px 0 0; font-size: 13px; color: var(--bad); }
.slot-note:empty { display: none; }
.slot-conclusion { width: 100%; }
.key-box { margin: 10px 0 14px; padding: 10px 14px; border-radius: var(--radius); background: var(--accent-soft); }
.key-box p { margin: 0 0 6px; }
.key-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.key-code { font-family: var(--mono); font-size: 18px; font-weight: 700; letter-spacing: 0.08em; user-select: all; }
.form-error ul { margin: 4px 0 0; padding-left: 20px; }
.form-error p { margin: 0; }
.jetson-box ul { margin: 6px 0; padding-left: 20px; }
.jetson-box li { margin-bottom: 4px; }

.walk-list { counter-reset: walk; list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.walk-list li { counter-increment: walk; position: relative; padding-left: 36px; min-width: 0; }
.walk-list li::before {
  content: counter(walk);
  position: absolute;
  left: 0;
  top: 6px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font: 700 12px/1 var(--mono);
  border: 2px solid var(--accent);
  color: var(--accent-ink);
}
.walk-code {
  display: block;
  padding: 8px 12px;
  overflow-x: auto;
  white-space: pre;
  border-radius: var(--radius);
  font: 13.5px/1.5 var(--mono);
  color: #b6f36a;
  background: #0b0f0a;
  border: 1px solid #1f2b17;
}
.walk-list p { margin: 6px 0 0; line-height: 1.55; max-width: 780px; }
.task-card textarea { width: 100%; box-sizing: border-box; font-family: var(--mono); font-size: 13.5px; }

table.map, table.skills { width: 100%; border-collapse: collapse; font-size: 15px; margin: 8px 0 16px; }
table.map th, table.map td, table.skills th, table.skills td {
  text-align: left;
  vertical-align: top;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
table.map thead th, table.skills thead th { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; }
.table-wrap { overflow-x: auto; }
/* Lesson tables come from HTML in the content: on a phone, a wide one scrolls sideways instead of being cut. */
@media (max-width: 600px) {
  .prose table.map { display: block; overflow-x: auto; }
  .prose table.map th, .prose table.map td { padding: 6px 8px; font-size: 14px; min-width: 9rem; }
  .prose table.map code { overflow-wrap: normal; word-break: normal; }
}

.career { max-width: 1100px; }
.career-hero {
  padding: clamp(24px, 4vw, 44px);
  border-radius: calc(var(--radius) + 10px);
  color: #e8f5d0;
  background:
    radial-gradient(90% 120% at 100% 0%, rgb(118 185 0 / 0.32), transparent 60%),
    repeating-linear-gradient(0deg, rgb(255 255 255 / 0.025) 0 1px, transparent 1px 3px),
    #0b0f0a;
  border: 1px solid #1f2b17;
}
.career-hero .eyebrow { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: #8fd400; }
.career-hero h1 { margin: 0 0 12px; font-size: clamp(30px, 5vw, 46px); line-height: 1.08; color: #fff; }
.career-hero .prose { max-width: 760px; color: #c9d8b8; font-size: 16px; }
.career-hero .prose strong, .career-hero .prose a { color: #b6f36a; }
.career-hero .lp-stats { margin: 22px 0 22px; }

.career-section {
  margin-top: 28px;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 8px);
  background: var(--surface);
  box-shadow: 0 1px 0 rgb(0 0 0 / 0.02), 0 12px 32px rgb(0 0 0 / 0.05);
}
.career-section h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: clamp(22px, 3vw, 28px); }
.career-section h2::before { content: ""; width: 6px; height: 1.1em; border-radius: 3px; background: var(--accent); }
.section-intro { margin: 0 0 16px; color: var(--muted); max-width: 820px; }

.card-table { border: 1px solid var(--border); border-radius: var(--radius); }
.card-table table.skills { margin: 0; }
table.skills thead th { background: #0b0f0a; color: #b6f36a; font-size: 12px; padding: 12px 14px; border-bottom: 0; }
table.skills tbody th, table.skills tbody td { padding: 12px 14px; }
table.skills tbody tr:nth-child(even) { background: var(--surface-2); }
table.skills tbody th { border-left: 4px solid var(--accent); font-weight: 700; }
table.skills tbody tr:hover { background: var(--accent-soft); }

.project-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.project {
  position: relative;
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 20px 20px 18px;
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: calc(var(--radius) + 4px);
  background: linear-gradient(180deg, var(--accent-soft), var(--surface) 55%);
}
.project-num {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font: 700 16px/1 var(--mono);
  color: #0b0f0a;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.project h3 { margin: 4px 0 0; font-size: 18px; line-height: 1.3; }
.project p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.55; }
.project p strong { color: var(--text); }

.faq details { border-bottom: 1px solid var(--border); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin: 8px 0 0; }
.interview { display: grid; gap: 10px; }
.interview details { border: 1px solid var(--border); border-radius: var(--radius); padding: 0; background: var(--surface-2); }
.interview summary { list-style: none; position: relative; padding: 14px 44px 14px 16px; }
.interview summary::-webkit-details-marker { display: none; }
.interview summary::after { content: "+"; position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font: 700 20px/1 var(--mono); color: var(--accent-ink); }
.interview details[open] { border-color: var(--accent); background: var(--surface); }
.interview details[open] summary::after { content: "−"; }
.interview p { margin: 0; padding: 0 16px 16px; color: var(--muted); line-height: 1.6; }

.ready { display: grid; gap: 8px; margin-bottom: 10px; }
.ready-count { margin: 0; font-weight: 700; }
.ready progress { width: 100%; height: 10px; accent-color: var(--accent); }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.checklist li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); }
.checklist li:has(input:checked) { background: var(--accent-soft); }
.checklist input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.resources { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.resources li { margin: 0; }
.resources a { display: inline-block; padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); text-decoration: none; font-weight: 600; color: var(--accent-ink); }
.resources a:hover { border-color: var(--accent); }

/* ---------- platform: accounts, tutor, certificate ---------- */

.signout-btn { white-space: nowrap; }
.btn.signout { border-color: var(--bad); color: var(--bad); font-weight: 700; }
.btn.signout:hover { background: var(--bad-soft); }
.account-link { white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.tag { margin-left: 6px; padding: 1px 6px; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: 10px; letter-spacing: 0.04em; vertical-align: middle; text-transform: uppercase; }
.lock { font-size: 12px; opacity: 0.7; }
.lock.open { opacity: 1; filter: drop-shadow(0 0 3px rgb(118 185 0 / 0.6)); }
.offer { font-weight: 600; }

.auth { max-width: 460px; margin: 24px auto; }
.auth h1 { font-size: 30px; }
.auth-links { margin-top: 16px; }
.card-form { display: grid; gap: 14px; }
.card-form label { display: grid; gap: 4px; font-weight: 600; font-size: 15px; }
.card-form input, .card-form textarea, .inline-form input, .chat-form textarea, .account input[type="search"] {
  font: inherit;
  font-weight: 400;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
.card-form textarea, .chat-form textarea { resize: vertical; }
.form-error { color: var(--bad); font-weight: 600; margin: 0; }
.form-error:empty, .form-ok:empty { display: none; }
.form-ok { color: var(--ok); font-weight: 600; margin: 0; }
.btn[aria-busy="true"] { cursor: progress; }
.sent-panel { display: grid; gap: 10px; justify-items: start; padding: 20px; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius); background: var(--accent-soft); outline: none; }
.sent-panel h2 { margin: 0; font-size: 22px; }
.sent-panel p { margin: 0; overflow-wrap: anywhere; }
.sent-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-size: 24px; font-weight: 700; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input { width: auto; flex: 1 1 220px; }
.inline-form.wrap input[type="number"] { flex: 0 0 110px; }

.locked { max-width: 1120px; }
.account { max-width: 1120px; }
.panel-card { margin: 18px 0; padding: 18px 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.panel-card h2 { margin-top: 0; font-size: 19px; }
.level-progress { list-style: none; padding: 0; display: grid; gap: 8px; }
.level-progress li { display: grid; grid-template-columns: minmax(0, 1fr) 160px 70px; gap: 12px; align-items: center; }
.level-progress progress { width: 100%; accent-color: var(--accent); }
@media (max-width: 600px) { .level-progress li { grid-template-columns: 1fr; gap: 2px; } }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 13px; background: var(--surface-2); }
.badge.approved { background: var(--ok-soft); color: var(--ok); }
.badge.changes_requested { background: var(--bad-soft); color: var(--bad); }
blockquote { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--border); color: var(--muted); }
.review-list { display: grid; gap: 12px; }
.review-list textarea { width: 100%; margin: 8px 0; font: inherit; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }

.tutor .consent { max-width: 560px; }
.tutor-trial { margin: 0 0 12px; padding: 8px 12px; border-left: 3px solid var(--accent); border-radius: 6px; background: var(--accent-soft); }
.chat { display: grid; gap: 10px; max-height: 420px; overflow-y: auto; margin-bottom: 12px; }
.chat:empty { display: none; }
.msg { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); }
.msg p { margin: 4px 0 0; white-space: pre-wrap; }
.msg.user { background: var(--surface-2); }
.msg.assistant { background: var(--accent-soft); border-color: var(--accent); }
.chat-form { display: grid; gap: 8px; }
.tutor-box { margin-top: 20px; }

/* Floating tutor: button + "need help?" bubble + side drawer, on every page (add-on owners). */
.tutor-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  color: #0b0f0a;
  background: var(--accent);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.25), 0 0 0 4px var(--accent-soft);
  cursor: pointer;
}
.tutor-fab:hover { filter: brightness(1.06); }
.tutor-fab:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
.tutor-bubble {
  position: fixed;
  right: 20px;
  bottom: 76px;
  z-index: 40;
  width: min(320px, calc(100vw - 40px));
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--border));
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.22);
}
.tutor-bubble::after {
  content: "";
  position: absolute;
  right: 36px;
  bottom: -8px;
  width: 14px;
  height: 14px;
  transform: rotate(45deg);
  background: var(--surface);
  border-right: 1px solid color-mix(in srgb, var(--accent) 50%, var(--border));
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 50%, var(--border));
}
.tutor-bubble p { margin: 0 0 10px; font-weight: 600; }
.tutor-bubble .toolbar { margin: 0; gap: 8px; }
.tutor-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: flex;
  flex-direction: column;
  width: min(440px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgb(0 0 0 / 0.2);
}
.tutor-drawer[hidden] { display: none; }
.tutor-drawer > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 18px 10px; border-bottom: 1px solid var(--border); }
.tutor-drawer h2 { margin: 0; font-size: 18px; }
.tutor-drawer header p { margin: 4px 0 0; }
.tutor-drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 18px 18px; }
.tutor-drawer .chat { max-height: none; }
body.tutor-open .tutor-fab { display: none; }
@media (max-width: 700px) {
  .tutor-fab { right: 14px; bottom: 14px; padding: 11px 15px; }
  .tutor-bubble { right: 14px; bottom: 66px; }
  .tutor-drawer { top: auto; height: 82vh; width: 100vw; border-left: 0; border-top: 1px solid var(--border); border-radius: 16px 16px 0 0; }
}
@media (prefers-reduced-motion: no-preference) {
  .tutor-drawer:not([hidden]) { animation: tutor-in 0.18s ease-out; }
  .tutor-bubble:not([hidden]) { animation: tutor-pop 0.2s ease-out; }
}
@keyframes tutor-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes tutor-pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@media print { .tutor-fab, .tutor-bubble, .tutor-drawer { display: none !important; } }
.tutor-box summary { cursor: pointer; font-weight: 600; color: var(--accent-ink); }

/* Certificate: a landscape diploma and a portrait transcript. Both are paper,
   so they keep light colours in dark mode too. Sizes on the diploma follow its
   width (container units), so the screen view and the printed A4 match. */
.cert-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cert-doc {
  --paper: #fdfbf5;
  --ink: #1f2a1a;
  --ink-soft: #5b6352;
  --rule: #3d6b00;
  --rule-soft: #c9d8b0;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --script: "Snell Roundhand", "Apple Chancery", "Segoe Script", "Brush Script MT", cursive;
  display: grid;
  gap: 28px;
  max-width: 1060px;
  margin: 12px auto 40px;
  color: var(--ink);
}
.diploma {
  container-type: inline-size;
  aspect-ratio: 297 / 210;
  padding: 2.2cqi;
  background:
    radial-gradient(ellipse at 50% 45%, rgb(118 185 0 / 0.07), transparent 62%),
    repeating-linear-gradient(45deg, rgb(61 107 0 / 0.025) 0 1px, transparent 1px 7px),
    var(--paper);
  border: 0.35cqi solid var(--rule);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.18);
  font-family: var(--serif);
  text-align: center;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}
.dip-frame {
  position: relative;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3.4cqi 7cqi 2.4cqi;
  border: 0.12cqi solid var(--rule);
  outline: 0.12cqi solid var(--rule-soft);
  outline-offset: -0.9cqi;
}
.dip-frame::before, .dip-frame::after {
  content: "";
  position: absolute;
  width: 6cqi;
  height: 6cqi;
  border: 0.3cqi solid var(--rule);
  pointer-events: none;
}
.dip-frame::before { top: 1.6cqi; left: 1.6cqi; border-right: 0; border-bottom: 0; }
.dip-frame::after { bottom: 1.6cqi; right: 1.6cqi; border-left: 0; border-top: 0; }
.dip-issuer { margin: 0; font-family: var(--serif); font-size: 1.35cqi; font-weight: 700; letter-spacing: 0.42em; text-transform: uppercase; color: var(--rule); }
.dip-title { margin: 1.6cqi 0 0; font-family: var(--serif); font-size: 6.4cqi; font-weight: 400; letter-spacing: 0.14em; text-transform: uppercase; line-height: 1; color: var(--ink); }
.dip-title span { display: block; margin-top: 0.9cqi; font-size: 2cqi; font-style: italic; letter-spacing: 0.04em; text-transform: none; color: var(--ink-soft); }
.dip-lead { margin: 2.6cqi 0 0; font-size: 1.7cqi; font-style: italic; color: var(--ink-soft); }
.dip-name {
  margin: 0.8cqi 0 0;
  padding: 0 4cqi 0.8cqi;
  font-size: 4.6cqi;
  font-weight: 600;
  line-height: 1.15;
  border-bottom: 0.1cqi solid var(--rule);
  min-width: 50%;
}
.dip-body { max-width: 72cqi; margin: 1.8cqi 0 0; font-size: 1.65cqi; line-height: 1.55; }
.dip-body em { font-weight: 600; }
.dip-foot {
  margin-top: auto;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 4cqi;
}
.dip-sig { display: flex; flex-direction: column; align-items: center; gap: 0.6cqi; }
.dip-sig-value { min-width: 70%; padding-bottom: 0.5cqi; border-bottom: 0.1cqi solid var(--ink); font-size: 1.6cqi; }
.dip-sig-value.script { font-family: var(--script); font-size: 2.9cqi; line-height: 1.1; }
.dip-sig-label { font-size: 1.15cqi; letter-spacing: 0.08em; color: var(--ink-soft); text-transform: uppercase; line-height: 1.5; }
.dip-seal { width: 11cqi; color: var(--rule); }
.dip-seal svg { display: block; width: 100%; height: auto; font-family: var(--serif); }
.dip-verify { display: flex; align-items: center; gap: 1.2cqi; margin-top: 1.6cqi; text-align: left; }
.dip-verify img { width: 5.4cqi; height: 5.4cqi; image-rendering: pixelated; }
.dip-verify p { margin: 0; font-size: 1.05cqi; line-height: 1.5; color: var(--ink-soft); }
.dip-verify strong { font-family: var(--mono); color: var(--ink); letter-spacing: 0.04em; }
.dip-verify .url { word-break: break-all; }

.transcript {
  padding: 44px 52px;
  background: var(--paper);
  border-top: 6px solid var(--rule);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.18);
  font-family: var(--serif);
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}
.tr-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; border-bottom: 1px solid var(--rule); padding-bottom: 10px; }
.tr-head .dip-issuer { font-size: 12px; }
.tr-head h2 { margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 400; letter-spacing: 0.06em; color: var(--ink); }
.tr-meta { display: grid; grid-template-columns: 1.2fr 1.1fr 0.8fr 1.4fr; gap: 12px 20px; margin: 18px 0 22px; }
.tr-meta dt { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); }
.tr-meta dd { margin: 2px 0 0; font-size: 16px; font-weight: 600; }
.tr-meta .mono { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.tr-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tr-table th, .tr-table td { padding: 5px 8px; text-align: left; vertical-align: top; }
.tr-table thead th { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); border-bottom: 1px solid var(--ink); }
.tr-table .num { text-align: right; white-space: nowrap; }
.tr-table tbody tr + tr td { border-top: 1px solid rgb(31 42 26 / 0.08); }
.tr-level th, .tr-level td { padding-top: 14px; font-weight: 700; color: var(--rule); border-bottom: 1px solid var(--rule-soft); }
.tr-level td { font-size: 12px; }
.tr-num { display: inline-block; min-width: 2.6em; font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }
.tr-total th, .tr-total td { padding-top: 10px; font-size: 16px; font-weight: 700; border-top: 2px solid var(--ink); }
.tr-criteria { margin: 18px 0 0; font-size: 13px; line-height: 1.55; color: var(--ink-soft); }
/* Stacked, not side by side: the legal line can never be pushed past the paper's edge. */
.tr-foot { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--rule-soft); }
.tr-foot .dip-verify { margin: 0; gap: 12px; max-width: 100%; }
.tr-foot .dip-verify p { min-width: 0; }
.tr-foot .dip-verify img { width: 64px; height: 64px; }
.tr-foot .dip-verify p { font-size: 12px; }
.tr-legal { margin: 0; font-size: 12px; font-style: italic; color: var(--ink-soft); }

/* Phones: the diploma stops being a fixed sheet and flows, with readable sizes. */
@media (max-width: 640px) {
  .diploma { aspect-ratio: auto; padding: 8px; }
  .dip-frame { padding: 28px 18px 18px; }
  .dip-frame::before, .dip-frame::after { width: 28px; height: 28px; border-width: 2px; top: 8px; left: 8px; }
  .dip-frame::after { top: auto; left: auto; bottom: 8px; right: 8px; }
  .dip-issuer { font-size: 11px; letter-spacing: 0.3em; }
  .dip-title { font-size: 34px; margin-top: 14px; }
  .dip-title span { font-size: 17px; margin-top: 6px; }
  .dip-lead { font-size: 15px; margin-top: 20px; }
  .dip-name { font-size: 28px; padding: 0 8px 6px; }
  .dip-body { font-size: 15px; margin-top: 14px; }
  .dip-foot { grid-template-columns: 1fr; gap: 20px; margin-top: 24px; justify-items: center; }
  .dip-seal { width: 96px; order: -1; }
  .dip-sig-value { font-size: 15px; }
  .dip-sig-value.script { font-size: 26px; }
  .dip-sig-label { font-size: 11px; }
  .dip-verify { margin-top: 18px; gap: 10px; }
  .dip-verify img { width: 64px; height: 64px; }
  .dip-verify p { font-size: 11px; }
  .transcript { padding: 24px 16px; }
  .tr-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tr-table { font-size: 13px; }
}

@page diploma { size: A4 landscape; margin: 0; }
@page transcript { size: A4 portrait; margin: 14mm 14mm 12mm; }
@media print {
  .topbar, .sidebar, .scrim, .site-foot, .no-print, .skip { display: none !important; }
  .layout { display: block; }
  main { padding: 0 !important; max-width: none; }
  body { background: #fff; }
  .cert-doc { display: block; max-width: none; margin: 0; }
  .diploma { page: diploma; width: 297mm; height: 210mm; aspect-ratio: auto; box-shadow: none; box-sizing: border-box; break-after: page; }
  .transcript { page: transcript; box-shadow: none; padding: 0; border: 0; background: #fff; }
  .tr-table tbody { break-inside: avoid; }
}

/* ---------- dialog (replaces confirm/alert) ---------- */

.app-dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 50px rgb(0 0 0 / 0.25);
}
.app-dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.app-dialog form { padding: 22px 22px 18px; }
.app-dialog h2 { margin: 0 0 8px; font-size: 19px; line-height: 1.3; }
.app-dialog p { margin: 0; color: var(--muted); line-height: 1.5; }
.app-dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: var(--bad-text); }
.btn.danger:hover { filter: brightness(1.1); }

/* ---------- my account ---------- */

.acct-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  border-radius: calc(var(--radius) + 6px);
  color: #e8f5d0;
  background:
    radial-gradient(120% 140% at 100% 0%, rgb(118 185 0 / 0.28), transparent 55%),
    repeating-linear-gradient(0deg, rgb(255 255 255 / 0.025) 0 1px, transparent 1px 3px),
    #0b0f0a;
  border: 1px solid #1f2b17;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.18);
}
.acct-id { display: flex; align-items: center; gap: 18px; min-width: 0; }
.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font: 700 24px/1 var(--mono);
  color: #0b0f0a;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgb(118 185 0 / 0.25), 0 0 24px rgb(118 185 0 / 0.45);
}
.acct-hero .eyebrow { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: #8fd400; }
.acct-hero h1 { margin: 2px 0 2px; font-size: clamp(26px, 4vw, 34px); color: #fff; }
.acct-sub { margin: 0; color: #a9b89a; overflow-wrap: anywhere; }
.acct-plan { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 10px 0 0; font-size: 14px; color: #c9d8b8; }
.plan { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.plan.free { background: rgb(255 255 255 / 0.1); color: #e8f5d0; border: 1px solid rgb(255 255 255 / 0.18); }
.plan.full, .plan.staff { background: var(--accent); color: #0b0f0a; }

.acct-overall { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.acct-overall .btn.primary { box-shadow: 0 0 18px rgb(118 185 0 / 0.35); }
.ring {
  --pct: 0;
  position: relative;
  flex: none;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), rgb(255 255 255 / 0.1) 0);
}
.ring::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: #0b0f0a; }
.ring > span { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring strong { font: 700 26px/1 var(--mono); color: #fff; }
.ring small { margin-top: 4px; font-size: 11px; color: #a9b89a; max-width: 80px; }

.acct-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; margin-top: 20px; }
.acct-grid .panel-card { margin: 0 0 20px; box-shadow: 0 1px 2px rgb(0 0 0 / 0.04); }
@media (max-width: 960px) { .acct-grid { grid-template-columns: 1fr; } }
@media (max-width: 600px) {
  .acct-hero { padding: 20px; }
  .acct-overall { width: 100%; }
  .acct-overall .btn { flex: 1 1 100%; }
}

.lvl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.lvl { display: grid; grid-template-columns: 40px minmax(0, 1fr) 128px; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--border); }
.lvl:first-child { border-top: 0; }
.lvl-num { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; font: 700 16px/1 var(--mono); background: var(--accent-soft); color: var(--accent-ink); }
.lvl.is-locked .lvl-num { background: var(--surface-2); color: var(--muted); }
.lvl-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; font-size: 15px; }
.lvl-head .muted { font: 13px var(--mono); white-space: nowrap; }
.meter { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter > span { display: block; height: 100%; min-width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent-ink), var(--accent)); transition: width 0.4s ease; }
.lvl-status { font-size: 13px; font-weight: 600; white-space: nowrap; justify-self: end; }
.lvl-status.ok { color: var(--ok); }
.lvl-status.locked { color: var(--muted); font-weight: 500; }
.lvl-status.go { color: var(--accent-ink); text-decoration: none; }
.lvl-status.go:hover { text-decoration: underline; }
@media (max-width: 600px) { .lvl { grid-template-columns: 36px minmax(0, 1fr); } .lvl-status { grid-column: 2; justify-self: start; } }

.upsell {
  margin: 0 0 20px;
  padding: 20px 22px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%);
}
.upsell h2 { margin: 0 0 10px; font-size: 19px; }
.upsell ul { margin: 0 0 16px; padding: 0; list-style: none; display: grid; gap: 6px; }
.upsell li { padding-left: 24px; position: relative; }
.upsell li::before { content: "✓"; position: absolute; left: 0; color: var(--accent-ink); font-weight: 700; }

.cert-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.cert-card-head h2 { margin: 0; }
.cert-card-head p { margin: 2px 0 0; }
.cert-seal { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; font-size: 20px; color: var(--accent-ink); background: var(--accent-soft); border: 2px dashed color-mix(in srgb, var(--accent) 60%, transparent); }
.steps { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 0; }
.steps li { position: relative; display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 14px; }
.steps li:not(:last-child)::after { content: ""; position: absolute; left: 10px; top: 29px; height: calc(100% - 22px); width: 2px; background: var(--border); }
.steps li.ok:not(:last-child)::after { background: var(--accent); }
.step-dot { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: 12px; font-weight: 700; border: 2px solid var(--border); background: var(--surface); }
.steps li.ok .step-dot { border-color: var(--accent); background: var(--accent); color: #0b0f0a; }
.steps li.ok { color: var(--text); }
.steps li:not(.ok) { color: var(--muted); }

.field-label { margin: 0 0 6px; font-weight: 600; font-size: 14px; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.small { font-size: 13px; }
.btn.block { width: 100%; }
.acct-side .inline-form { display: flex; flex-wrap: wrap; gap: 8px; }
.acct-side .inline-form input { flex: 1 1 160px; }

/* ---------- sign-in pages: form + dark side panel ---------- */

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 460px) minmax(0, 420px);
  justify-content: center;
  gap: 28px;
  align-items: stretch;
  margin: 24px auto;
  max-width: 960px;
}
.auth-shell .auth {
  margin: 0;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 6px);
  background: var(--surface);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.06);
}
.auth-shell .auth h1 { margin-top: 0; }
.auth-aside {
  display: flex;
  flex-direction: column;
  padding: 28px;
  border-radius: calc(var(--radius) + 6px);
  color: #e8f5d0;
  background:
    radial-gradient(120% 90% at 100% 0%, rgb(118 185 0 / 0.3), transparent 60%),
    repeating-linear-gradient(0deg, rgb(255 255 255 / 0.025) 0 1px, transparent 1px 3px),
    #0b0f0a;
  border: 1px solid #1f2b17;
}
.auth-aside .eyebrow { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: #8fd400; }
.auth-aside h2 { margin: 0 0 18px; font-size: 23px; line-height: 1.3; color: #fff; }
.auth-aside ul { margin: 0 0 24px; padding: 0; list-style: none; display: grid; gap: 10px; }
.auth-aside li { position: relative; padding-left: 26px; color: #c9d8b8; }
.auth-aside li::before { content: "▸"; position: absolute; left: 4px; color: var(--accent); }
.warp-art { margin-top: auto; display: grid; grid-template-columns: repeat(32, 1fr); gap: 3px; padding: 14px; border-radius: 10px; background: rgb(0 0 0 / 0.35); border: 1px solid rgb(118 185 0 / 0.2); }
.warp-art i { aspect-ratio: 1; border-radius: 2px; background: rgb(255 255 255 / 0.07); }
.warp-art i.on { background: var(--accent); box-shadow: 0 0 6px rgb(118 185 0 / 0.6); }
@media (max-width: 860px) {
  .auth-shell { grid-template-columns: minmax(0, 520px); }
  .auth-aside { display: none; }
}
@media (max-width: 600px) { .auth-shell .auth { padding: 20px; } }

/* ---------- locked lesson ---------- */

.lock-hero {
  position: relative;
  padding: 28px;
  border-radius: calc(var(--radius) + 6px);
  color: #e8f5d0;
  background:
    radial-gradient(110% 130% at 100% 0%, rgb(118 185 0 / 0.26), transparent 55%),
    repeating-linear-gradient(0deg, rgb(255 255 255 / 0.025) 0 1px, transparent 1px 3px),
    #0b0f0a;
  border: 1px solid #1f2b17;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.18);
}
.lock-badge {
  position: absolute;
  top: 24px;
  right: 24px;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  font-size: 24px;
  background: rgb(118 185 0 / 0.14);
  border: 1px solid rgb(118 185 0 / 0.45);
  box-shadow: 0 0 22px rgb(118 185 0 / 0.3);
}
.lock-hero .eyebrow { margin: 0; padding-right: 70px; font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #8fd400; }
.lock-hero h1 { margin: 6px 0 10px; padding-right: 70px; font-size: clamp(28px, 4.5vw, 40px); color: #fff; }
.lock-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 22px; }
.lock-meta span { padding: 4px 10px; border-radius: 999px; font-size: 13px; color: #c9d8b8; background: rgb(255 255 255 / 0.07); border: 1px solid rgb(255 255 255 / 0.12); }
.lock-hero h2 { margin: 0 0 6px; font-size: 19px; color: #fff; }
.lock-text { margin: 0 0 6px; max-width: 640px; color: #c9d8b8; }
.lock-hero .cta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 18px; }
.soon-chip { padding: 9px 14px; border-radius: var(--radius); font-weight: 600; font-size: 14px; color: #0b0f0a; background: var(--accent); box-shadow: 0 0 18px rgb(118 185 0 / 0.35); }
.btn.ghost { background: transparent; color: #e8f5d0; border-color: rgb(255 255 255 / 0.3); }
.btn.ghost:hover { background: rgb(255 255 255 / 0.08); }

.lock-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-top: 20px; align-items: start; }
.lock-grid .panel-card, .lock-grid .upsell { margin: 0; }
.lock-preview { grid-column: 1 / -1; }
.lock-preview .diagram { margin: 0; }
.lock-lessons { list-style: none; margin: 12px 0 0; padding: 0; display: grid; }
.lock-lessons li { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: 8px; }
.lock-lessons li.current { background: var(--accent-soft); font-weight: 600; }
.lock-lessons a { color: var(--text); text-decoration: none; }
.lock-lessons a:hover { text-decoration: underline; }
.ll-num { font: 13px var(--mono); color: var(--muted); }
@media (max-width: 600px) {
  .lock-hero { padding: 20px; }
  .lock-badge { width: 44px; height: 44px; top: 18px; right: 18px; font-size: 20px; }
}

/* ---------- lesson stages: understand → instructions → worked example → your turn ---------- */

.stage-head { display: flex; align-items: flex-start; gap: 12px; margin: 22px 0 12px; }
.stage-head h2 { margin: 2px 0 0; font-size: 20px; }
.stage-head p { margin: 2px 0 0; }
.stage-num {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font: 700 15px/1 var(--mono);
  color: #0b0f0a;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.lesson .stage-head { margin-top: 6px; }

.learn { display: grid; gap: 20px; margin-top: 28px; }
.learn-card { padding: 4px 22px 20px; border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); background: var(--surface); }
.learn-card h3 { margin: 4px 0 10px; font-size: 16px; }
.learn-card .prose { margin-top: 14px; }
.learn-card table { border-collapse: collapse; margin: 6px 0 12px; font-size: 14px; }
.learn-card th, .learn-card td { padding: 4px 12px 4px 0; text-align: left; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.example .listing + .prose { max-width: 780px; }

.isa-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.isa-list li { display: grid; gap: 4px; align-content: start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.isa-ex { justify-self: start; font-size: 13.5px; font-weight: 600; padding: 3px 8px; border-radius: 6px; background: var(--code-bg); color: var(--accent-ink); white-space: nowrap; }
.isa-text { font-size: 14px; line-height: 1.45; }
.isa-syntax { font-size: 12px; color: var(--muted); }
.isa-syntax code { font-size: 12px; overflow-wrap: anywhere; }

.listing {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  border-radius: var(--radius);
  font: 13.5px/1.6 var(--mono);
  color: #b6f36a;
  text-shadow: 0 0 6px rgb(118 185 0 / 0.35);
  background:
    repeating-linear-gradient(0deg, rgb(255 255 255 / 0.03) 0 1px, transparent 1px 3px),
    #0b0f0a;
  border: 1px solid #1f2b17;
}
.listing .cm { color: #6f8f55; text-shadow: none; }

.task-card {
  margin-top: 24px;
  padding: 4px 22px 18px;
  border-radius: calc(var(--radius) + 4px);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  background: linear-gradient(135deg, var(--accent-soft), var(--surface) 65%);
}
.task-card .goal { margin-top: 4px; background: var(--surface); }
.steps-plan h3 { margin: 16px 0 8px; font-size: 15px; }
.steps-plan ol { counter-reset: step; list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.steps-plan li { counter-increment: step; position: relative; padding-left: 36px; line-height: 1.5; }
.steps-plan li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font: 700 12px/1 var(--mono);
  color: var(--accent-ink);
  border: 2px solid var(--accent);
  background: var(--surface);
}
.task-card + .lab { margin-top: 18px; }
.learn > *, .learn-card, .task-card { min-width: 0; }
.listing { max-width: 100%; }

/* ---------- landing page ---------- */

.landing { max-width: 1080px; margin: 0 auto; }
.lp-hero {
  padding: clamp(28px, 5vw, 56px);
  border-radius: calc(var(--radius) + 10px);
  color: #e8f5d0;
  background:
    radial-gradient(90% 120% at 100% 0%, rgb(118 185 0 / 0.32), transparent 60%),
    repeating-linear-gradient(0deg, rgb(255 255 255 / 0.025) 0 1px, transparent 1px 3px),
    #0b0f0a;
  border: 1px solid #1f2b17;
}
.lp-hero .eyebrow { margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: #8fd400; }
.lp-hero h1 { margin: 0; font-size: clamp(38px, 7vw, 68px); line-height: 1.02; color: #fff; letter-spacing: -0.02em; }
.lp-subtitle { margin: 14px 0 0; font-size: clamp(18px, 2.6vw, 24px); font-weight: 600; color: #b6f36a; }
.lp-lead { max-width: 680px; margin: 16px 0 24px; font-size: 17px; line-height: 1.6; color: #c9d8b8; }
.lp-hero .btn.ghost { color: #e8f5d0; border-color: #3b4f2c; background: transparent; }
.lp-note { margin: 10px 0 0; font-size: 13px; color: #9fb48a; }
.lp-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 32px 0 0; }
.lp-stats div { padding: 14px 16px; border: 1px solid #23321a; border-radius: var(--radius); background: rgb(255 255 255 / 0.03); }
.lp-stats dt { font: 700 30px/1.1 var(--mono); color: #b6f36a; }
.lp-stats dd { margin: 4px 0 0; font-size: 13px; color: #9fb48a; }

.lp-film { position: relative; margin: 32px 0 0; border-radius: calc(var(--radius) + 10px); overflow: hidden; background: #0b0f0a; border: 1px solid #1f2b17; aspect-ratio: 16 / 7; }
.lp-film-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lp-film::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgb(11 15 10 / 0.88) 0%, rgb(11 15 10 / 0.45) 45%, transparent 75%); pointer-events: none; }
.lp-film-text { position: absolute; z-index: 1; left: clamp(20px, 5vw, 48px); bottom: clamp(20px, 5vw, 44px); max-width: 420px; }
.lp-film-text h2 { margin: 0 0 8px; font-size: clamp(24px, 3.4vw, 34px); line-height: 1.15; color: #fff; }
.lp-film-text p { margin: 0; font-size: 16px; line-height: 1.55; color: #c9d8b8; }
.lp-film-toggle { position: absolute; z-index: 1; right: 14px; bottom: 14px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid #3b4f2c; background: rgb(11 15 10 / 0.7); color: #e8f5d0; font-size: 14px; cursor: pointer; }
.lp-film-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 600px) {
  .lp-film { aspect-ratio: 4 / 5; }
  .lp-film::after { background: linear-gradient(0deg, rgb(11 15 10 / 0.9) 0%, rgb(11 15 10 / 0.4) 50%, transparent 80%); }
  .lp-film-text { right: 20px; }
  .lp-film-toggle { top: 14px; bottom: auto; }
}

.lp-demo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 32px; align-items: center; margin: 48px 0; }
.lp-demo h2, .lp-section h2, .lp-final h2 { font-size: clamp(24px, 3.4vw, 32px); line-height: 1.2; margin: 0 0 14px; }
.lp-demo p { color: var(--muted); font-size: 16px; line-height: 1.6; }
.lp-demo .diagram { margin: 0; }
.lp-section { margin: 56px 0; }
.lp-check, .lp-cross { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.lp-check li, .lp-cross li { position: relative; padding-left: 30px; line-height: 1.55; }
.lp-check li::before { content: "✓"; position: absolute; left: 4px; font-weight: 700; color: var(--accent-ink); }
.lp-cross li::before { content: "✕"; position: absolute; left: 5px; font-weight: 700; color: var(--muted); }
.lp-section > .lp-check { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px 28px; }

.lp-levels { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; counter-reset: lvl; }
.lp-levels li {
  counter-increment: lvl;
  position: relative;
  padding: 18px 20px 14px 64px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  background: var(--surface);
}
.lp-levels li::before {
  content: counter(lvl);
  position: absolute;
  left: 18px;
  top: 18px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font: 700 15px/1 var(--mono);
  color: #0b0f0a;
  background: var(--accent);
}
.lp-levels h3 { margin: 4px 0 6px; font-size: 18px; }
.lp-levels p { margin: 0 0 6px; line-height: 1.55; }

.lp-how { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; counter-reset: how; }
.lp-how li { counter-increment: how; display: grid; gap: 6px; padding: 18px; border-radius: calc(var(--radius) + 4px); background: var(--accent-soft); }
.lp-how li::before { content: counter(how); font: 700 13px/1 var(--mono); color: var(--accent-ink); }
.lp-how strong { font-size: 17px; }
.lp-how span { color: var(--muted); line-height: 1.5; }

.lp-for { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 28px; }
.lp-for h2 { font-size: clamp(22px, 3vw, 26px); }

.lp-plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.lp-plan { display: grid; gap: 14px; align-content: start; padding: 22px; border: 1px solid var(--border); border-radius: calc(var(--radius) + 6px); background: var(--surface); }
.lp-plan h3 { margin: 0; font-size: 22px; }
.lp-plan p { margin: 0; }
.lp-plan .btn { justify-self: start; }
.lp-plan.featured { border: 2px solid var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.lp-addon { margin-top: 16px; padding: 14px 18px; border-left: 4px solid var(--accent); border-radius: var(--radius); background: var(--surface); }
.lp-addon p { margin: 4px 0 0; color: var(--muted); }

.lp-faq { border-bottom: 1px solid var(--border); padding: 12px 0; }
.lp-faq summary { cursor: pointer; font-weight: 600; font-size: 16px; }
.lp-faq p { margin: 8px 0 0; color: var(--muted); line-height: 1.6; max-width: 760px; }
.lp-final { margin: 56px 0 24px; padding: 36px; text-align: center; border-radius: calc(var(--radius) + 10px); background: var(--accent-soft); }

@media (max-width: 760px) {
  .lp-demo { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- lesson 0: introduction ---------- */

.intro { max-width: 860px; }
.intro h1 { font-size: clamp(30px, 5vw, 44px); line-height: 1.1; margin: 6px 0 10px; }
.intro h2 { margin: 36px 0 12px; font-size: 24px; }
.intro .intro-lead { color: var(--muted); }
.jobs { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.job { display: grid; gap: 8px; align-content: start; padding: 18px; border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); background: var(--surface); }
.job h3 { margin: 0; font-size: 16px; line-height: 1.35; }
.job p { margin: 0; }
.job-company { font: 700 12px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-ink); }
.job-range { font-weight: 700; font-size: 15px; line-height: 1.4; }
.disclaimer { margin-top: 12px; padding: 10px 14px; border-left: 3px solid var(--border); }
.intro .map td { vertical-align: top; }

.lp-market {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
  margin: -24px 0 56px;
  padding: 18px 22px;
  border-radius: calc(var(--radius) + 4px);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%);
}
.lp-market p { margin: 0; max-width: 680px; line-height: 1.55; }
.lp-market a { font-weight: 700; color: var(--accent-ink); white-space: nowrap; }

/* ---------- marketing layout: visitors and the sales page, no course chrome ---------- */

.signup-link[hidden], .signout-btn[hidden] { display: none; }
body.marketing .sidebar, body.marketing .menu-btn, body.marketing .progress-text, body.marketing .scrim { display: none; }
body.marketing .layout { grid-template-columns: minmax(0, 1fr); }
body.marketing main { padding-left: clamp(16px, 4vw, 40px); padding-right: clamp(16px, 4vw, 40px); }
body:not(.marketing) .signup-link { display: none; }
.check-field { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--muted); }
.check-field input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.marketing-pref { display: grid; gap: 6px; justify-items: start; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.marketing-pref p { margin: 0; }

/* hero with the live matmul */
.lp-hero-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: clamp(20px, 4vw, 48px); align-items: center; }
.lp-demo-label { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: #9fb48a; }
.mm-demo { margin: 0; padding: 18px; border: 1px solid #23321a; border-radius: calc(var(--radius) + 4px); background: rgb(0 0 0 / 0.35); }
.mm-row { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.mm-matrix { display: grid; gap: 4px; justify-items: center; }
.mm-name { font: 700 13px/1 var(--mono); color: #9fb48a; }
.mm-grid { display: grid; grid-template-columns: repeat(4, 30px); gap: 3px; }
.mm-cell {
  display: grid;
  place-items: center;
  height: 30px;
  border-radius: 5px;
  font: 600 13px/1 var(--mono);
  color: #c9d8b8;
  background: rgb(255 255 255 / 0.05);
  border: 1px solid #23321a;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}
.mm-cell.hl { background: rgb(118 185 0 / 0.28); color: #fff; border-color: #76b900; }
.mm-cell.on { background: #76b900; color: #0b0f0a; transform: scale(1.06); }
.mm-cell.thread { background: rgb(118 185 0 / 0.5); color: #0b0f0a; font-size: 10px; animation: mm-pulse 0.9s ease-in-out; }
@keyframes mm-pulse { 50% { transform: scale(1.12); } }
.mm-op { font: 700 20px/1 var(--mono); color: #9fb48a; }
.mm-formula { min-height: 1.4em; margin: 14px 0 8px; text-align: center; font: 13px/1.4 var(--mono); color: #b6f36a; overflow-wrap: anywhere; }
.mm-demo figcaption { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.mm-mode { margin: 0; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.mm-mode.cpu { background: rgb(255 255 255 / 0.08); color: #e8f5d0; }
.mm-mode.gpu { background: #76b900; color: #0b0f0a; }
.mm-count { font: 700 13px/1 var(--mono); color: #9fb48a; }

/* neural network */
.nn-demo { margin: 0; padding: 16px; border: 1px solid var(--border); border-radius: calc(var(--radius) + 6px); background: var(--surface); }
.nn-canvas { display: block; width: 100%; height: 300px; }
.nn-demo figcaption { margin-top: 8px; font-size: 14px; color: var(--muted); line-height: 1.5; }

@media (max-width: 860px) {
  .lp-hero-grid { grid-template-columns: minmax(0, 1fr); }
  .mm-grid { grid-template-columns: repeat(4, 26px); }
  .mm-cell { height: 26px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .mm-cell { transition: none; }
  .mm-cell.thread { animation: none; }
}
.mm-eq { display: flex; align-items: center; gap: 8px; }
@media (max-width: 600px) { .lp-market a { white-space: normal; } }

/* CPU × GPU chip figure (lesson 0) */
.chip-fig { margin: 16px 0 8px; }
.diagram .cg-core { fill: #76b900; stroke: rgb(0 0 0 / 0.15); stroke-width: 1; }
.diagram .cg-ctl { fill: #f2c14e; }
.diagram .cg-l1 { fill: #7b4fb8; }
.diagram .cg-l2 { fill: #5b8fd6; }
.diagram .cg-dram { fill: #e0834a; }
.diagram .cg-label { fill: #fff; font-size: 11px; font-weight: 600; }
.diagram .cg-label-dark { fill: #3a2c05; font-size: 10px; font-weight: 700; }
@media (prefers-reduced-motion: no-preference) {
  .diagram .cg-c0, .diagram .cg-c1, .diagram .cg-c2, .diagram .cg-c3 { animation: cg-cpu 4s infinite; }
  .diagram .cg-c1 { animation-delay: 1s; }
  .diagram .cg-c2 { animation-delay: 2s; }
  .diagram .cg-c3 { animation-delay: 3s; }
  .diagram [class*="cg-w"] { animation: cg-warp 2.4s infinite; }
  .diagram .cg-w1 { animation-delay: 0.4s; }
  .diagram .cg-w2 { animation-delay: 0.8s; }
  .diagram .cg-w3 { animation-delay: 1.2s; }
  .diagram .cg-w4 { animation-delay: 1.6s; }
  .diagram .cg-w5 { animation-delay: 2s; }
}
@keyframes cg-cpu { 0%, 24% { fill: #b6f36a; } 25%, 100% { fill: #4d7a00; } }
@keyframes cg-warp { 0%, 30% { fill: #b6f36a; } 31%, 100% { fill: #4d7a00; } }

/* ---------- admin area ---------- */
.admin { max-width: 1280px; }
.admin-tabs { margin-bottom: 16px; }
.admin-h { font-size: 17px; margin: 22px 0 10px; }
.admin-warn { padding: 10px 14px; border-left: 4px solid var(--bad); border-radius: 6px; background: var(--bad-soft); color: var(--text); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.kpi p { margin: 0; }
.kpi .kpi-value { margin: 2px 0; }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 2px 0; overflow-wrap: anywhere; }
.kpi-note { color: var(--muted); font-size: 12px; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 110px; padding-top: 6px; }
.spark i { flex: 1; min-width: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }
.spark i.zero { background: var(--border); }
.admin-body input[type="search"] { width: 100%; max-width: 420px; margin-bottom: 12px; }
table.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.admin-table th, table.admin-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.admin-table thead th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
table.admin-table tbody tr:hover { background: var(--surface-2); }
table.admin-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.admin-table .mono { font-family: var(--mono); white-space: nowrap; }
table.admin-table td:first-child { white-space: nowrap; }
table.admin-table select { font: inherit; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
table.admin-table .badge { margin-left: 4px; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row-actions .days-input { width: 64px; padding: 4px 6px; font: inherit; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.badge.st-active { background: var(--ok-soft); color: var(--ok); }
.badge.st-refunded, .badge.st-chargeback, .badge.st-canceled { background: var(--bad-soft); color: var(--bad); }
.badge.st-expired { background: var(--surface-2); color: var(--muted); }
@media (max-width: 600px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 10px 12px; }
  .kpi-value { font-size: 20px; }
  .spark { gap: 1px; height: 80px; }
}
