:root {
  --rose: #d38aaa;
  --mauve: #af86ac;
  --lavender: #8981af;
  --iris: #7378a8;
  --slate: #646da0;
  --ink: #23243a;
  --muted: #5d5f7a;
  --paper: #f7f5fa;
  --card: #ffffff;
  --line: #e4e0ec;
  --code: #1f2136;
  --ok: #3c8f78;
  --bad: #b2456b;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
a { color: var(--slate); }
img, video { max-width: 100%; display: block; border-radius: 10px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
:not(pre) > code { background: #eeeaf4; padding: 1px 5px; border-radius: 4px; font-size: .88em; overflow-wrap: anywhere; }

.hero {
  background: linear-gradient(115deg, var(--rose), var(--mauve) 30%, var(--lavender) 55%, var(--iris) 78%, var(--slate));
  color: #fff;
  padding: 36px 0 28px;
}
.wrap { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.home-link { display: inline-block; color: #fff; opacity: .8; text-decoration: none; font-size: 13px; letter-spacing: .08em;
  text-transform: uppercase; margin-bottom: 14px; }
.home-link:hover { opacity: 1; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 12.5px; opacity: .85; margin: 0; }
h1 { font-size: clamp(30px, 4.4vw, 50px); line-height: 1.08; margin: 8px 0 10px; letter-spacing: -.02em; }
.lede { font-size: 19px; max-width: 840px; opacity: .95; margin: 0 0 20px; }

.stage { background: rgba(20, 20, 40, .22); border-radius: 16px; padding: 12px; backdrop-filter: blur(4px); }
#viewer { width: 100%; aspect-ratio: 16 / 9; display: block; border-radius: 10px; background: #8981af; touch-action: none; }
.controls { display: grid; gap: 12px; margin-top: 12px; font-size: 14px; }
.ctl-row { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: flex-start; }
.ctl-playback { padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .18); }
.ctl { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ctl-label { font-size: 11px; letter-spacing: .13em; text-transform: uppercase; opacity: .78; padding-left: 3px; }
.controls button, .controls select { font: inherit; cursor: pointer; border: 0; }
/* Single choice: one joined control, the selected option filled. */
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 11px; background: rgba(23, 21, 43, .28); }
.seg button { color: #fff; background: transparent; padding: 0 12px; height: 30px; border-radius: 8px; white-space: nowrap; }
.seg button:hover { background: rgba(255, 255, 255, .14); }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(23, 21, 43, .25); }
/* On/off switches: separate pills with an indicator dot. */
.toggles { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.toggles button { color: #fff; background: rgba(23, 21, 43, .28); padding: 0 14px 0 11px; height: 36px; border-radius: 999px; white-space: nowrap; }
.toggles button::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%;
  border: 1.5px solid currentColor; vertical-align: 0; }
.toggles button[aria-pressed="true"] { background: rgba(255, 255, 255, .92); color: var(--ink); }
.toggles button[aria-pressed="true"]::before { background: var(--slate); border-color: var(--slate); }
.run { display: flex; gap: 4px; }
.run button, .run select { color: var(--ink); background: rgba(255, 255, 255, .92); border-radius: 8px; padding: 0 11px; height: 36px; }
.run select { max-width: 100%; }
.ctl-time { flex: 1 1 420px; }
.timeline { display: flex; gap: 12px; align-items: center; height: 36px; }
.timeline #play { min-width: 74px; height: 36px; color: var(--ink); background: #fff; border-radius: 8px; padding: 0 12px; font-weight: 600; }
.timeline input[type=range] { flex: 1; min-width: 120px; accent-color: #fff; }
.readout { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 8px; font: 14px/1.4 ui-monospace, Menlo, monospace; }
.readout b { font-weight: 600; }
.status-success { color: #c9ffe9; }
.status-moving { color: #fff3c4; }
.disclaimer { font-size: 13px; opacity: .85; margin: 8px 2px 0; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-top: 18px; }
.metric { background: rgba(255, 255, 255, .14); border-radius: 12px; padding: 12px 14px; }
.metric .value { font-size: 26px; font-weight: 650; letter-spacing: -.01em; }
.metric .label { font-size: 13px; opacity: .9; }

.scope { background: var(--card); border-left: 5px solid var(--rose); border-radius: 10px; padding: 14px 18px; margin: 26px 0 8px; }

nav.toc { position: sticky; top: 0; z-index: 5; background: rgba(247, 245, 250, .94); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
nav.toc .wrap { display: flex; gap: 14px; overflow-x: auto; padding: 9px 0; font-size: 14px; white-space: nowrap; }
nav.toc a { text-decoration: none; color: var(--muted); }
nav.toc a:hover { color: var(--slate); }

main section { padding: 38px 0 18px; border-bottom: 1px solid var(--line); }
section h2 { font-size: 29px; letter-spacing: -.015em; margin: 0 0 4px; }
section .when { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
section h3 { font-size: 20px; margin: 26px 0 8px; }
.prose { max-width: 820px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; }
figure { margin: 18px 0; }
figcaption { color: var(--muted); font-size: 14px; margin-top: 6px; }
.lesson { background: #efeaf6; border-radius: 10px; padding: 12px 16px; margin: 16px 0; max-width: 820px; }
.lesson strong { color: var(--slate); }
.failure { background: #fbeef3; border-radius: 10px; padding: 12px 16px; margin: 16px 0; max-width: 820px; }
.failure strong { color: var(--bad); }

table { border-collapse: collapse; width: 100%; font-size: 15px; margin: 12px 0; background: var(--card); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 8px 11px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #efeaf6; font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

pre { background: var(--code); color: #e9e7f3; border-radius: 10px; padding: 14px 16px; overflow-x: auto; font-size: 13.5px; line-height: 1.5; }
pre code.hljs { background: transparent; padding: 0; }
.codecap { font-size: 13px; color: var(--muted); margin: -4px 0 14px; }

.chart { background: var(--card); border-radius: 12px; padding: 10px 12px; border: 1px solid var(--line); }
.chart h4 { margin: 2px 4px 6px; font-size: 15px; }
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); margin: 6px 4px 0; }
.swatch { display: inline-block; width: 18px; height: 3px; vertical-align: middle; margin-right: 6px; border-radius: 2px; }

.network svg { width: 100%; height: auto; background: var(--card); border-radius: 12px; border: 1px solid var(--line); }
footer { padding: 30px 0 60px; color: var(--muted); font-size: 14px; }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .lede { font-size: 17px; }
  .metric .value { font-size: 22px; }
}
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 760px) { .charts { grid-template-columns: 1fr; } }
.charts.one { grid-template-columns: minmax(0, 640px); }
#compute-table td:first-child, #compute-table .num, #robustness-table .num, #insert-compute-table td:first-child,
#insert-compute-table .num { white-space: nowrap; }
.loop { list-style: none; counter-reset: step; display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 10px; padding: 0; margin: 18px 0; }
.loop li { counter-increment: step; position: relative; background: var(--card); border: 1px solid var(--line);
  border-top: 4px solid var(--slate); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.loop li::before { content: counter(step); font-size: 12px; color: var(--muted); display: block; }
.loop li:first-child { border-top-color: var(--rose); }
.loop li strong { display: block; }
.loop li span { color: var(--muted); font-size: 13px; }
.loop li:not(:last-child)::after { content: "\2192"; position: absolute; right: -9px; top: 50%; transform: translateY(-50%);
  color: var(--slate); font-weight: 700; }
.loop li:last-child::after { content: "\21BA  back to Plan"; display: block; margin-top: 6px; font-size: 12px; color: var(--slate); }
.glossary-title { margin: 30px 0 2px; font-size: 21px; }
.glossary { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-top: 12px; }
.glossary .part { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 0 0 10px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; font: inherit; color: var(--ink); }
.glossary .part:hover, .glossary .part:focus-visible { border-color: var(--slate); box-shadow: 0 2px 10px rgba(100, 109, 160, .18); }
.glossary .part img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; display: block; background: #8981af; }
.glossary .part-title { font-weight: 650; font-size: 15px; padding: 2px 10px 0; }
.glossary .part-specs { font-size: 12.5px; color: var(--muted); padding: 0 10px; line-height: 1.35; }
#glossary-view { border: 0; border-radius: 14px; padding: 0; width: min(1000px, calc(100vw - 32px)); background: var(--card); color: var(--ink); }
#glossary-view::backdrop { background: rgba(23, 21, 43, .72); }
#glossary-view img { width: 100%; display: block; aspect-ratio: 3 / 2; object-fit: cover; }
#glossary-view .glossary-text { padding: 12px 18px 4px; }
#glossary-view h3 { margin: 0 0 6px; font-size: 20px; }
#glossary-view .role { margin: 0 0 6px; }
#glossary-view .specs { margin: 0; color: var(--muted); font-size: 14px; }
#glossary-view .glossary-nav { display: flex; justify-content: space-between; gap: 8px; padding: 12px 18px 16px; }
#glossary-view .glossary-nav button { font: inherit; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 14px; cursor: pointer; }

/* Replay modes: controls and readouts that belong to one mode only. */
.stage[data-mode="0"] .align-only, .stage[data-mode="1"] .tube-only { display: none; }
.note-box { background: #f1f2fa; border-left: 4px solid var(--slate); border-radius: 8px; padding: 12px 16px; margin: 16px 0; max-width: 820px; }
.note-box strong { color: var(--slate); }

/* Learned insertion chapters. */
.result-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 18px 0 22px; }
.result-strip .tile { position: relative; overflow: hidden; border-radius: 14px; padding: 16px 18px 14px; color: #fff;
  background: linear-gradient(135deg, var(--iris), var(--slate)); box-shadow: 0 6px 18px rgba(100, 109, 160, .22); }
.result-strip .tile:nth-child(2) { background: linear-gradient(135deg, var(--lavender), var(--iris)); }
.result-strip .tile:nth-child(3) { background: linear-gradient(135deg, var(--mauve), var(--lavender)); }
.result-strip .tile:nth-child(4) { background: linear-gradient(135deg, var(--rose), var(--mauve)); }
.result-strip .big { font-size: 34px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.result-strip .big small { font-size: 16px; font-weight: 600; opacity: .85; margin-left: 4px; }
.result-strip .what { font-size: 13.5px; opacity: .95; margin-top: 4px; }
.result-strip .vs { font-size: 12.5px; opacity: .8; margin-top: 6px; border-top: 1px solid rgba(255, 255, 255, .28); padding-top: 6px; }

.spec-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 18px 0; }
.spec-cards .card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 10px;
  border-top: 4px solid var(--slate); }
.spec-cards .card:nth-child(1) { border-top-color: var(--rose); }
.spec-cards .card:nth-child(2) { border-top-color: var(--mauve); }
.spec-cards .card:nth-child(3) { border-top-color: var(--lavender); }
.spec-cards .card h4 { margin: 0 0 2px; font-size: 16px; }
.spec-cards .card .count { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.spec-cards .card ul { margin: 0; padding-left: 18px; font-size: 14.5px; line-height: 1.5; }
.spec-cards .card li { margin: 3px 0; }

tr.hl td { background: #f1f2fa; }
tr.hl td:first-child { box-shadow: inset 4px 0 0 var(--slate); font-weight: 600; }
.chart.wide { max-width: 760px; }
.video-card { background: var(--code); border-radius: 14px; padding: 10px; margin: 18px 0 6px; max-width: 980px; }
.video-card video { border-radius: 8px; width: 100%; aspect-ratio: 16 / 9; background: #17152b; object-fit: contain; }

.next-steps { list-style: none; counter-reset: next; padding: 0; margin: 18px 0; display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.next-steps li { counter-increment: next; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px 12px 58px; position: relative; font-size: 15px; }
.next-steps li::before { content: counter(next); position: absolute; left: 14px; top: 14px; width: 30px; height: 30px;
  border-radius: 50%; background: linear-gradient(135deg, var(--rose), var(--slate)); color: #fff; font-weight: 700;
  display: grid; place-items: center; font-size: 15px; }
.next-steps li strong { display: block; font-size: 16px; margin-bottom: 2px; }
.next-steps li .evidence { display: block; color: var(--muted); font-size: 13.5px; margin-top: 6px; }
