/* ---------- Tokens ---------- */
:root,
:root[data-theme="dark"] {
  --bg: #0d1526;          /* field navy */
  --surface: #141f36;
  --surface-2: #1a2742;
  --line: #273756;
  --text: #e9eef7;
  --muted: #9aa8c2;
  --blue: #5b9bff;        /* alliance blue */
  --red: #ff5a6e;         /* alliance red */
  --py: #ffd43b;          /* python yellow, code only */
  --code-bg: #0a1120;
  --glow: 0 0 0 1px var(--line), 0 24px 60px -30px rgba(0, 0, 0, .7);
  --spot: rgba(91, 155, 255, .10);
  --series-1: #4a8af0;     /* chart colors, validated for this surface */
  --series-2: #f04b61;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #eef2f9;
  --surface: #ffffff;
  --surface-2: #f4f7fc;
  --line: #d5ddeb;
  --text: #0d1526;
  --muted: #4d5a73;
  --blue: #1d5fd8;
  --red: #d32840;
  --py: #9a6f00;
  --code-bg: #0d1526;     /* code stays dark in both themes */
  --glow: 0 0 0 1px var(--line), 0 20px 40px -28px rgba(13, 21, 38, .35);
  --spot: rgba(29, 95, 216, .07);
  --series-1: #1d5fd8;
  --series-2: #d32840;
  color-scheme: light;
}

/* ---------- Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 84px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.55;
  font-variation-settings: "opsz" 16;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s, color .3s;
}

[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.05; }
p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }

.wrap {
  width: min(1180px, 100% - 32px);
  margin-inline: auto;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 16px; top: -60px; z-index: 60;
  background: var(--blue); color: #fff; padding: 10px 14px; border-radius: 8px;
}
.skip:focus { top: 16px; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 4px; }

.kbd {
  font: 500 .72rem/1 "JetBrains Mono", monospace;
  padding: 4px 6px; border-radius: 6px;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line), inset 0 -2px 0 var(--line);
  color: var(--muted);
}

/* ---------- Scroll progress ---------- */
.progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 50; }
.progress span {
  display: block; height: 100%; width: 100%;
  transform-origin: 0 50%; transform: scaleX(var(--p, 0));
  background: linear-gradient(90deg, var(--blue), var(--red));
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.topbar.is-scrolled { border-bottom-color: var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 20px; padding-block: 14px; }
.mark {
  font-weight: 800; font-size: 1.1rem; text-decoration: none;
  letter-spacing: -.02em;
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--blue), var(--red));
  color: #fff;
}
.topbar nav { display: flex; gap: 22px; margin-left: auto; }
.topbar nav a { text-decoration: none; color: var(--muted); font-weight: 500; }
.topbar nav a:hover, .topbar nav a.is-active { color: var(--text); }
.topbar nav a.is-active { text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 2px; text-underline-offset: 6px; }

.jump {
  display: flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 8px 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  cursor: pointer;
}
.jump:hover { color: var(--text); }
.jump svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.theme-toggle {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  display: grid; place-items: center; cursor: pointer;
}
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* ---------- Hero ---------- */
.hero { padding-top: clamp(24px, 5vw, 64px); }

.name {
  font-size: clamp(4.2rem, 17vw, 13.5rem);
  font-weight: 800;
  font-variation-settings: "opsz" 96, "wdth" 75;
  letter-spacing: -.025em;
  line-height: .86;
  margin-bottom: clamp(28px, 5vw, 56px);
  background: linear-gradient(100deg, var(--text) 55%, var(--blue) 78%, var(--red) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- Bento + cards ---------- */
.bento { display: grid; gap: 16px; }

.card {
  position: relative;
  background: var(--surface);
  border-radius: 22px;
  box-shadow: var(--glow);
  padding: 28px;
  margin: 0;
}
/* cursor spotlight, set from main.js */
@media (hover: hover) {
  .card::before {
    content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
    background: radial-gradient(360px circle at var(--mx, -999px) var(--my, -999px), var(--spot), transparent 70%);
    opacity: 0; transition: opacity .25s;
  }
  .card:hover::before { opacity: 1; }
  .editor::before, .player::before { display: none; }
}

.hero-grid { grid-template-columns: repeat(12, 1fr); grid-template-rows: 1fr auto; }
.editor { grid-column: span 8; grid-row: span 2; }
.photo  { grid-column: span 4; }
.now    { grid-column: span 4; }

/* Editor card */
.editor {
  background: var(--code-bg);
  padding: 0;
  overflow: hidden;
  display: flex; flex-direction: column;
  border-radius: 14px; /* tighter radius: it's a window, not a tile */
}
.editor-bar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid #1d2a45;
}
.dots { display: flex; gap: 7px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; background: #2a3a5c; }
.dots i:first-child { background: #ff5a6e; }
.dots i:nth-child(2) { background: #3a4d74; }
.dots i:last-child { background: #5b9bff; }
.tab {
  font: 500 .8rem/1 "JetBrains Mono", monospace; color: #c9d4ea;
  padding: 6px 10px; border-radius: 6px; background: #16223a;
}

.editor-body {
  flex: 1;
  padding: 22px 24px 26px;
  overflow-x: auto;
  font: 400 clamp(.78rem, 1.3vw, .95rem)/1.75 "JetBrains Mono", monospace;
  color: #d7e0f2;
  scrollbar-width: thin; scrollbar-color: #273756 transparent;
}

.code { margin: 0; font: inherit; white-space: pre; }

/* Python syntax colors, shared by the editor and snippets */
.k  { color: #ff7b93; }
.f  { color: #7cb4ff; }
.s  { color: #ffd43b; }
.n  { color: #9ee6c5; }
.c  { color: #66789c; font-style: italic; }
.p  { color: #8b9ab8; }
.o  { color: #ffd43b; }
.e  { color: #ff7b93; }



/* Photo / monogram card */
.photo { padding: 0; overflow: hidden; min-height: 280px; }  /* grows to fill the space beside the editor */
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.monogram {
  position: relative; height: 100%;
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--blue) 35%, transparent), transparent 60%),
    radial-gradient(circle at 80% 85%, color-mix(in srgb, var(--red) 30%, transparent), transparent 55%),
    var(--surface-2);
}
.monogram span {
  font-weight: 800; font-size: clamp(5rem, 11vw, 8.5rem);
  font-variation-settings: "opsz" 96, "wdth" 75;
  letter-spacing: 0; color: var(--text);
}
/* camera-frame corners: a nod to the vision work */
.corner { position: absolute; width: 26px; height: 26px; border: 2px solid var(--muted); opacity: .7; }
.corner.tl { top: 18px; left: 18px; border-right: 0; border-bottom: 0; }
.corner.tr { top: 18px; right: 18px; border-left: 0; border-bottom: 0; }
.corner.bl { bottom: 18px; left: 18px; border-right: 0; border-top: 0; }
.corner.br { bottom: 18px; right: 18px; border-left: 0; border-top: 0; }

/* Now card */
.now { display: flex; flex-direction: column; gap: 14px; }
.now-status { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--muted); }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 0 var(--red); animation: pulse 2.2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.now-text { font-size: 1.3rem; line-height: 1.3; font-variation-settings: "opsz" 32; }
.now-text strong { color: var(--red); font-weight: 700; }

/* ---------- Sections ---------- */
.section { padding-top: clamp(96px, 13vw, 170px); }
.section-head { max-width: 44rem; margin-bottom: 40px; }
.section-head h2,
.contact h2 {
  font-size: clamp(2.4rem, 6vw, 4.4rem);
  font-weight: 800;
  font-variation-settings: "opsz" 96, "wdth" 85;
  letter-spacing: -.02em;
}
.section-head .status { margin-bottom: 12px; }
.section-head p:not(.status) { margin-top: 16px; color: var(--muted); font-size: 1.15rem; }

.status { font-weight: 600; font-size: .9rem; color: var(--blue); }
.status.is-red { color: var(--red); }

/* ---------- Seasons track ---------- */
.xp { margin-bottom: 28px; }
.xp-bar { height: 8px; border-radius: 99px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.xp-bar span {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--blue), var(--red)); border-radius: inherit;
  transform-origin: 0 50%;
}
.js .xp-bar span { transform: scaleX(0); transition: transform 1.4s cubic-bezier(.2, .8, .2, 1); }
.js .xp.is-filled .xp-bar span { transform: scaleX(1); }
.xp-label { margin-top: 10px; font-size: .9rem; color: var(--muted); font-weight: 500; }

.track {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
}
.stop {
  background: var(--surface); box-shadow: var(--glow);
  border-radius: 18px; padding: 24px;
  display: flex; flex-direction: column; gap: 18px;
  border-top: 4px solid var(--blue);
}
.stop.is-red, .stop.is-now { border-top-color: var(--red); }
.stop.is-now { background: linear-gradient(180deg, color-mix(in srgb, var(--red) 12%, var(--surface)), var(--surface) 60%); }
.lvl {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800; font-size: 1.05rem;
  background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--blue); color: var(--blue);
}
.is-red .lvl, .is-now .lvl { box-shadow: inset 0 0 0 2px var(--red); color: var(--red); }
.is-now .lvl { background: var(--red); color: #fff; }
.when { color: var(--muted); font-weight: 500; font-size: .95rem; }
.stop h3 { font-size: 1.3rem; font-weight: 700; margin: 6px 0 4px; line-height: 1.2; letter-spacing: -.01em; }
.role { font-weight: 700; color: var(--blue); margin-bottom: 10px; }
.is-red .role, .is-now .role { color: var(--red); }
.stop p:last-child { color: var(--muted); font-size: 1rem; }

.ftc-grid { grid-template-columns: repeat(3, 1fr); margin-top: 16px; }

.project h3, .award h3, .stack h3, .toolset h3 {
  font-size: clamp(1.5rem, 2.4vw, 2rem); font-weight: 800;
  font-variation-settings: "opsz" 48, "wdth" 90;
  letter-spacing: -.02em; margin: 10px 0 14px;
}
.project p:not(.status), .toolset p { color: var(--muted); max-width: 60ch; }

.award { background: linear-gradient(160deg, color-mix(in srgb, var(--py) 16%, var(--surface)), var(--surface) 65%); }
.award svg { width: 52px; height: 52px; fill: none; stroke: var(--py); stroke-width: 2; stroke-linejoin: round; }
.award p { color: var(--muted); }

/* ---------- AI car: frame player ---------- */
.player {
  display: grid; grid-template-columns: 1.35fr 1fr; gap: 36px;
  padding: 16px 32px 16px 16px;
  align-items: center;
}
.screen {
  position: relative; border-radius: 14px; overflow: hidden;
  aspect-ratio: 4 / 3; background: #0a1120;
}
.lap-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block;
  image-rendering: pixelated;       /* show the real 160x120 pixels */
}
.screen-hud {
  position: absolute; inset: 14px 14px auto 14px; z-index: 1;
  display: flex; justify-content: space-between;
  font: 600 .78rem/1 "JetBrains Mono", monospace; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.8);
}
.rec { display: flex; align-items: center; gap: 6px; }
.rec i { width: 8px; height: 8px; border-radius: 50%; background: #ff5a6e; animation: blink 1.2s steps(1) infinite; }
@keyframes blink { 50% { opacity: .2; } }
.gauge { position: absolute; left: 50%; bottom: 10px; width: 46%; transform: translateX(-50%); z-index: 1; overflow: visible; }
.gauge-track { fill: none; stroke: rgba(10,17,32,.55); stroke-width: 14; stroke-linecap: round; }
.gauge-mid { stroke: rgba(255,255,255,.5); stroke-width: 2; }
.gauge-needle { stroke: #ffd43b; stroke-width: 5; stroke-linecap: round; filter: drop-shadow(0 0 4px rgba(0,0,0,.6)); }
.gauge-hub { fill: #ffd43b; }
#needle { transform-origin: 100px 100px; }

.player-side h3 { font-size: clamp(1.6rem, 2.6vw, 2.2rem); font-weight: 800; font-variation-settings: "opsz" 48, "wdth" 90; letter-spacing: -.02em; margin-bottom: 14px; }
.player-side > p { color: var(--muted); }
.player-side > p + p { margin-top: 12px; }
.readout { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 24px 0 18px; }
.readout div { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; box-shadow: inset 0 0 0 1px var(--line); }
.readout dt { font-size: .82rem; color: var(--muted); }
.readout dd { margin: 2px 0 0; font: 600 1.25rem/1.2 "JetBrains Mono", monospace; font-variant-numeric: tabular-nums; }
#steer-val { color: var(--py); }
.controls { display: flex; align-items: center; gap: 14px; }
.play {
  width: 44px; height: 44px; border-radius: 50%; flex: none; cursor: pointer;
  display: grid; place-items: center;
  background: var(--text); color: var(--bg); border: 0;
}
.play svg { width: 18px; height: 18px; fill: currentColor; }
.play .i-play { display: none; }
.play.is-paused .i-play { display: block; }
.play.is-paused .i-pause { display: none; }
#scrub { flex: 1; accent-color: var(--red); height: 24px; }

.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 16px 0 72px; }
.stat {
  background: var(--surface); box-shadow: var(--glow); border-radius: 18px; padding: 22px 24px;
  display: flex; flex-direction: column; gap: 6px;
}
.stat b { font-size: clamp(1.8rem, 3.2vw, 2.6rem); font-weight: 800; font-variation-settings: "opsz" 96, "wdth" 85; letter-spacing: -.02em; line-height: 1; }
.stat span { color: var(--muted); font-size: .95rem; line-height: 1.35; }

/* ---------- AI car: pipeline tabs ---------- */
.steps { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 4px; }
.steps button {
  display: flex; align-items: center; gap: 10px; white-space: nowrap;
  padding: 10px 16px 10px 10px; border-radius: 99px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-weight: 600;
}
.steps button span {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: .85rem; background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--line);
}
.steps button:hover { color: var(--text); }
.steps button[aria-selected="true"] { color: var(--text); border-color: var(--blue); background: color-mix(in srgb, var(--blue) 12%, var(--surface)); }
.steps button[aria-selected="true"] span { background: var(--blue); color: #fff; box-shadow: none; }

.panel { display: grid; grid-template-columns: 1fr 1.25fr; gap: 32px; align-items: start; }
.panel[hidden] { display: none; }
.panel h3 { font-size: clamp(1.6rem, 2.6vw, 2.2rem); font-weight: 800; font-variation-settings: "opsz" 48, "wdth" 90; letter-spacing: -.02em; margin-bottom: 14px; }
.panel-copy > p:not(.file) { color: var(--muted); }
.file { font: 500 .8rem/1 "JetBrains Mono", monospace; color: var(--muted); margin-top: 20px; }
.file::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--py); margin-right: 8px; }

.snippet {
  margin: 0; background: var(--code-bg); color: #d7e0f2;
  border-radius: 12px; padding: 20px 22px;
  font: 400 .84rem/1.7 "JetBrains Mono", monospace;
  overflow-x: auto; white-space: pre;
  box-shadow: inset 0 0 0 1px #1d2a45;
  scrollbar-width: thin; scrollbar-color: #273756 transparent;
}
.js .panel:not([hidden]) { animation: panel-in .28s ease-out; }
@keyframes panel-in { from { opacity: 0; transform: translateY(6px); } }

.tags { list-style: none; padding: 0; margin: 24px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.tags li {
  font: 500 .8rem/1 "JetBrains Mono", monospace;
  padding: 7px 10px; border-radius: 8px;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
}
.tags li:first-child { color: var(--py); }

/* ---------- Vision system: flow ---------- */
.flow-wrap { padding: 28px; }
.flow-hint { color: var(--muted); margin-bottom: 22px; }
.flow {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(9, 1fr); gap: 0;
  counter-reset: stage;
}
.flow li { position: relative; display: flex; justify-content: center; }
.flow li + li::before {          /* connector line between stages */
  content: ""; position: absolute; top: 50%; right: 50%; width: 100%; height: 2px;
  background: var(--line); z-index: 0;
}
.flow li.is-passed + li::before,
.flow li.is-passed::before { background: linear-gradient(90deg, var(--blue), var(--red)); }
.flow button {
  position: relative; z-index: 1;
  font: 600 .88rem/1.15 "Bricolage Grotesque", sans-serif;
  padding: 10px 12px; border-radius: 12px; cursor: pointer; text-align: center;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
  min-width: 0;
}
.flow button:hover { color: var(--text); border-color: var(--blue); }
.flow li.is-passed button { color: var(--text); }
.flow button[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 0 0 5px color-mix(in srgb, var(--red) 22%, transparent); }
.flow-detail { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); min-height: 7.5em; }
.flow-detail p { max-width: 62ch; }
.flow-detail h3 { font-size: 1.5rem; font-weight: 800; font-variation-settings: "opsz" 48, "wdth" 90; margin-bottom: 8px; }
.flow-detail p { color: var(--muted); }

.vision-grid { grid-template-columns: repeat(4, 1fr); margin-top: 16px; }
.vision-grid .stat { padding: 22px 24px; }
.config { grid-column: span 4; padding: 24px; }
.config .file { margin: 0 0 14px; }

/* ---------- Toolbox ---------- */
.tool-grid { grid-template-columns: repeat(4, 1fr); }
.stack h3 { margin-top: 0; }
.stack ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.stack li { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.stack li:last-child { border-bottom: 0; }
.lang { font: 600 1.05rem/1.2 "JetBrains Mono", monospace; }
.lang.py { color: var(--py); }
.note { color: var(--muted); font-size: .9rem; }
.toolset h3 { margin-top: 0; }

/* ---------- Contact ---------- */
.socials { list-style: none; margin: 28px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 12px; }
.socials a {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: 12px;
  background: var(--surface); box-shadow: var(--glow);
  text-decoration: none; font-weight: 600;
}
.socials a:hover { box-shadow: 0 0 0 1px var(--blue), 0 20px 40px -28px rgba(0, 0, 0, .6); }
.socials svg { width: 20px; height: 20px; fill: currentColor; }

/* ---------- Footer ---------- */
.footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  margin-top: clamp(80px, 12vw, 140px);
  padding-block: 28px 40px;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: .9rem;
}

/* ---------- Command palette ---------- */
.palette {
  width: min(560px, 100% - 32px); padding: 0; border: 0; border-radius: 16px;
  margin: 12vh auto auto;
  background: var(--surface); color: var(--text);
  box-shadow: 0 0 0 1px var(--line), 0 40px 80px -20px rgba(0, 0, 0, .6);
}
.palette::backdrop { background: rgba(5, 9, 18, .55); backdrop-filter: blur(3px); }
.palette[open] { animation: pal-in .16s ease-out; }
@keyframes pal-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
#palette-input {
  width: 100%; border: 0; outline: 0; padding: 18px 20px;
  background: transparent; color: var(--text); font: 500 1.1rem/1.2 "Bricolage Grotesque", sans-serif;
  border-bottom: 1px solid var(--line);
}
#palette-list { list-style: none; margin: 0; padding: 8px; max-height: 50vh; overflow-y: auto; }
#palette-list li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 11px 12px; border-radius: 10px; cursor: pointer;
}
#palette-list li small { color: var(--muted); }
#palette-list li[aria-selected="true"] { background: color-mix(in srgb, var(--blue) 18%, var(--surface)); }
#palette-list .empty { color: var(--muted); cursor: default; }
.palette-foot { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 10px 16px; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); }

/* ---------- Links out to deep-dive pages ---------- */
.more {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 28px;
  padding: 12px 18px; border-radius: 12px; text-decoration: none; font-weight: 700;
  background: var(--text); color: var(--bg);
}
.more:hover { background: var(--blue); color: #fff; }
.more svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.more.is-quiet { background: var(--surface); color: var(--text); box-shadow: var(--glow); }
.more.is-quiet:hover { box-shadow: 0 0 0 1px var(--blue); background: var(--surface); color: var(--text); }
.more-row { display: flex; flex-wrap: wrap; gap: 12px; }
.more-row .more { margin-top: 0; }
.section .more-row { margin-top: 28px; }

.vision-teaser { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.vision-teaser .card:first-child h3 { font-size: clamp(1.6rem, 2.6vw, 2.2rem); font-weight: 800; font-variation-settings: "opsz" 48, "wdth" 90; letter-spacing: -.02em; margin-bottom: 14px; }
.vision-teaser .card:first-child p { color: var(--muted); }
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- Deep-dive pages ---------- */
.page-hero { padding-top: clamp(40px, 7vw, 88px); }
.crumb { display: inline-flex; gap: 8px; align-items: center; color: var(--muted); text-decoration: none; font-weight: 600; margin-bottom: 22px; }
.crumb:hover { color: var(--text); }
.crumb svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.page-title {
  font-size: clamp(3rem, 10vw, 7.5rem); font-weight: 800;
  font-variation-settings: "opsz" 96, "wdth" 78; letter-spacing: -.025em; line-height: .9;
  max-width: 12ch;
}
.lede { margin-top: 24px; font-size: clamp(1.15rem, 1.8vw, 1.35rem); color: var(--muted); max-width: 44rem; line-height: 1.5; }
.facts { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 28px 0 0; padding: 0; list-style: none; }
.facts li { display: flex; flex-direction: column; }
.facts b { font-size: .82rem; color: var(--muted); font-weight: 500; }
.facts span { font-weight: 700; }

.page-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 56px; align-items: start; }
.toc { position: sticky; top: 92px; }
.toc p { font-weight: 700; margin-bottom: 12px; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.toc a {
  display: block; padding: 7px 0 7px 16px; margin-left: -2px; border-left: 2px solid transparent;
  color: var(--muted); text-decoration: none; font-size: .95rem; line-height: 1.3;
}
.toc a:hover { color: var(--text); }
.toc a.is-active { color: var(--text); border-left-color: var(--red); font-weight: 600; }
.toc a.is-done::after { content: " \2713"; color: var(--blue); font-weight: 700; }
.toc .guide-progress { margin-top: 22px; }

.chapter { padding-top: clamp(64px, 9vw, 110px); }
.chapter:first-child { padding-top: 0; }
.chapter > h2 {
  font-size: clamp(2rem, 4.6vw, 3.4rem); font-weight: 800;
  font-variation-settings: "opsz" 96, "wdth" 85; letter-spacing: -.02em; margin-bottom: 18px;
}
.prose { max-width: 68ch; }
.prose p, .prose ul, .prose ol { color: var(--muted); margin: 0 0 16px; }
.prose li { margin-bottom: 6px; }
.prose strong { color: var(--text); }
.prose a { color: var(--blue); }
.prose code, .step code, .callout code, td code, .player-side code {
  font: 500 .88em/1 "JetBrains Mono", monospace; padding: 2px 6px; border-radius: 6px;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); color: var(--text);
}
.chapter > .card, .chapter > .bento, .chapter > figure, .chapter > .table-wrap { margin-top: 24px; }

/* Program explainer cards on the robotics page */
.season-block { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 24px; }
.season-block .card h3 { font-size: 1.35rem; font-weight: 800; margin-bottom: 10px; font-variation-settings: "opsz" 32, "wdth" 90; }
.season-block .card p { color: var(--muted); }
.season-block .card p + p { margin-top: 10px; }
.season-block .card.is-leo { border-top: 4px solid var(--red); }
.kicker { font-weight: 600; font-size: .9rem; color: var(--blue); margin-bottom: 8px; }
.is-leo .kicker { color: var(--red); }

/* ---------- 404 ---------- */
.notfound { min-height: 60vh; }
.traceback { margin: 32px 0 28px; max-width: 720px; }
.traceback .editor-body { overflow-x: auto; }

/* ---------- Guides ---------- */
.guide-progress { display: grid; gap: 8px; }
.guide-progress .bar { height: 8px; border-radius: 99px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.guide-progress .bar span { display: block; height: 100%; width: 100%; transform-origin: 0 50%; transform: scaleX(var(--done, 0)); background: linear-gradient(90deg, var(--blue), var(--red)); transition: transform .4s ease; }
.guide-progress p { font-size: .88rem; color: var(--muted); font-weight: 500; margin: 0; }

.steps-list { list-style: none; margin: 24px 0 0; padding: 0; display: grid; gap: 16px; counter-reset: step; }
.step { padding: 28px; }
.step-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.step-num {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800;
  background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--blue); color: var(--blue);
}
.step.is-done .step-num { background: var(--blue); color: #fff; box-shadow: none; }
.step-head h3 { flex: 1; font-size: clamp(1.3rem, 2.2vw, 1.7rem); font-weight: 800; font-variation-settings: "opsz" 48, "wdth" 90; letter-spacing: -.015em; padding-top: 3px; }
.done-toggle {
  flex: none; display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 7px 12px; border-radius: 99px; font-size: .88rem; font-weight: 600; color: var(--muted);
  border: 1px solid var(--line); background: var(--surface-2); user-select: none;
}
.done-toggle input { accent-color: var(--blue); width: 16px; height: 16px; margin: 0; }
.done-toggle:has(input:checked) { color: var(--text); border-color: var(--blue); }
.step-body { padding-left: 52px; }
.step-body > * + * { margin-top: 14px; }
.step-body p, .step-body li { color: var(--muted); }
.step-body ul, .step-body ol { padding-left: 20px; margin-bottom: 0; }
.step-body .file { margin: 0 0 -6px; }

.codeblock { position: relative; }
.copy {
  position: absolute; top: 10px; right: 10px;
  font: 600 .75rem/1 "Bricolage Grotesque", sans-serif;
  padding: 7px 10px; border-radius: 8px; cursor: pointer;
  color: #c9d4ea; background: #16223a; border: 1px solid #22314f;
  opacity: .85;
}
.copy:hover { opacity: 1; border-color: #5b9bff; }
.snippet.shell { white-space: pre-wrap; padding-right: 76px; }

.callout {
  display: flex; gap: 14px; padding: 16px 18px; border-radius: 14px;
  background: color-mix(in srgb, var(--blue) 10%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blue) 35%, var(--line));
}
.callout.is-warn { background: color-mix(in srgb, var(--py) 10%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--py) 40%, var(--line)); }
.callout svg { flex: none; width: 22px; height: 22px; margin-top: 2px; fill: none; stroke: var(--blue); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.callout.is-warn svg { stroke: var(--py); }
.callout p { color: var(--text) !important; margin: 0; }
.callout b { font-weight: 700; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: 16px; box-shadow: var(--glow); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.data th, table.data td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { font-size: .82rem; color: var(--muted); font-weight: 600; background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.is-star td { background: color-mix(in srgb, var(--red) 8%, var(--surface)); }
.method { font: 600 .75rem/1 "JetBrains Mono", monospace; padding: 4px 7px; border-radius: 6px; }
.method.get { color: var(--blue); background: color-mix(in srgb, var(--blue) 14%, transparent); }
.method.post { color: var(--red); background: color-mix(in srgb, var(--red) 14%, transparent); }
.method.delete { color: var(--py); background: color-mix(in srgb, var(--py) 14%, transparent); }
.caption { color: var(--muted); font-size: .9rem; margin-top: 12px; max-width: 68ch; }

/* ---------- Loss chart ---------- */
.chart-card { padding: 24px 24px 18px; }
.chart-card h3 { font-size: 1.25rem; font-weight: 800; margin-bottom: 4px; }
.chart-card .sub { color: var(--muted); font-size: .92rem; }
.legend { display: flex; gap: 18px; list-style: none; padding: 0; margin: 14px 0 6px; font-size: .9rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend i { width: 18px; height: 3px; border-radius: 2px; }
.legend .s1 { background: var(--series-1); }
.legend .s2 { background: var(--series-2); }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font: 500 11px "Bricolage Grotesque", sans-serif; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.s1 { stroke: var(--series-1); }
.chart .line.s2 { stroke: var(--series-2); }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .dot.s1 { fill: var(--series-1); }
.chart .dot.s2 { fill: var(--series-2); }
.chart .label { font: 600 12px "Bricolage Grotesque", sans-serif; fill: var(--text); }
.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .best { stroke: var(--text); stroke-width: 1; }
.tip {
  position: absolute; pointer-events: none; z-index: 2;
  background: var(--surface-2); color: var(--text); border-radius: 10px; padding: 10px 12px;
  box-shadow: 0 0 0 1px var(--line), 0 12px 30px -12px rgba(0,0,0,.5);
  font-size: .85rem; line-height: 1.5; white-space: nowrap; transform: translate(-50%, -110%);
}
.tip b { font-weight: 700; }
.tip i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
details.table-toggle { margin-top: 10px; }
details.table-toggle summary { cursor: pointer; color: var(--muted); font-size: .9rem; font-weight: 600; }
details.table-toggle .table-wrap { margin-top: 12px; max-height: 300px; overflow-y: auto; box-shadow: none; border: 1px solid var(--line); }

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
  .page-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toc { display: none; }
  .vision-teaser { grid-template-columns: 1fr; }
  .editor { grid-column: span 12; grid-row: auto; }
  .photo, .now { grid-column: span 6; }
  .photo { aspect-ratio: 1 / 1; min-height: 0; }
  .track { grid-template-columns: repeat(2, 1fr); }
  .player, .panel { grid-template-columns: 1fr; }
  .player { padding: 16px 16px 24px; gap: 24px; }
  .stats-row, .vision-grid, .tool-grid { grid-template-columns: repeat(2, 1fr); }
  .config { grid-column: span 2; }
  .flow { grid-template-columns: repeat(3, 1fr); row-gap: 14px; }
  .flow li::before { display: none; }
  .flow button { width: calc(100% - 12px); }
  .jump-label { display: none; }
}

@media (max-width: 720px) {
  .topbar nav { display: none; }
  .jump { margin-left: auto; }
  .ftc-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .season-block { grid-template-columns: 1fr; }
  .step { padding: 22px 18px; }
  .step-body { padding-left: 0; }
  .step-head { flex-wrap: wrap; }
  .done-toggle { order: 3; margin-left: 52px; }
  .photo, .now { grid-column: span 12; }
  .photo { aspect-ratio: 4 / 3; }
  .track { grid-template-columns: 1fr; }
  .card:not(.editor):not(.photo):not(.player) { padding: 22px; }
  .editor-body { padding: 16px 14px 18px; font-size: .74rem; }
  .code { white-space: pre; }
    .stats-row, .vision-grid, .tool-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 16px; }
  .tool-grid { grid-template-columns: 1fr; }
  .flow { grid-template-columns: repeat(2, 1fr); }
  .snippet { font-size: .74rem; padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .pulse, .rec i { animation: none; }
  body { transition: none; }
  .js .xp-bar span { transition: none; }
  .js .panel:not([hidden]), .palette[open] { animation: none; }
}
