:root {
  color-scheme: light;
  --ink: #29495d;
  --muted: #667780;
  --imagine: #3a73b5;
  --imagine-ink: #2b5d8f;
  --imagine-soft: #edf3fa;
  --imagine-line: #9fbbdf;
  --narrate: #e0702c;
  --narrate-ink: #a8501c;
  --narrate-soft: #fdf3ec;
  --narrate-line: #ecb38f;
  --loss: #77529c;
  --frozen: #f1f3f5;
  --frozen-line: #b9c3cb;
  --wire: #80929e;
}
* { box-sizing: border-box; }
body { margin: 0; background: #f5f7f8; color: var(--ink); font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
main { max-width: 1160px; padding: 44px 24px; margin: auto; }
.eyebrow { margin: 0 0 6px; color: #6e808d; font-size: 11px; font-weight: 650; letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 0; font: 600 32px/1.2 Georgia, serif; letter-spacing: -.025em; }
.intro { margin: 10px 0 25px; color: var(--muted); }
.card { background: white; border: 1px solid #d7e0e6; border-radius: 12px; overflow: hidden; box-shadow: 0 8px 30px #29495d06; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--narrate); outline-offset: -3px; }

.steps { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid #e1e7ec; }
.step { padding: 15px 14px; border: 0; border-right: 1px solid #e1e7ec; background: white; color: #6c7b85; text-align: left; font-size: 12px; transition: background .2s; }
.step:last-child { border-right: 0; }
.step span { display: block; font-size: 10px; letter-spacing: .08em; margin-bottom: 3px; }
.step[aria-current="step"] { background: #eaf2f6; color: var(--ink); box-shadow: inset 0 -3px var(--imagine); }
.step:hover { background: #f2f6f8; }

.diagram-scroll { overflow-x: auto; padding: 4px 14px 0; }
svg.diagram { display: block; width: 100%; height: auto; min-width: 720px; }
svg text { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; fill: var(--ink); }
svg .math { font-family: "STIX Two Text", "STIXGeneral", "Cambria Math", "Times New Roman", serif; font-style: italic; }
svg .math .up { font-style: normal; }
svg .label { font-size: 14px; font-weight: 600; }
svg .small { font-size: 11.5px; fill: #617480; }
svg .tiny { font-size: 10.5px; fill: #6f828e; }
svg .lane { font-size: 12px; font-weight: 700; letter-spacing: .12em; }
svg .lane.narrate { fill: var(--narrate-ink); }
svg .lane.imagine { fill: var(--imagine-ink); }
svg .note-narrate { fill: var(--narrate-ink); }
svg .note-imagine { fill: var(--imagine-ink); }

.box { fill: white; stroke: #c3cfd8; stroke-width: 1.3; }
.box.narrate { fill: var(--narrate-soft); stroke: var(--narrate-line); }
.box.imagine { fill: var(--imagine-soft); stroke: var(--imagine-line); }
.box.frozen { fill: var(--frozen); stroke: var(--frozen-line); }
.box.loss { fill: #f5f1fa; stroke: #b49cc9; }
.latent rect { fill: var(--imagine); }
.latent.target rect { fill: #8fb0d9; }
.wire { fill: none; stroke: var(--wire); stroke-width: 1.6; marker-end: url(#arrow); }
.wire.narrate { stroke: #d39a76; marker-end: url(#arrow-narrate); }
.wire.imagine { stroke: #7f9fca; marker-end: url(#arrow-imagine); }
.wire.loss { stroke: var(--loss); stroke-dasharray: 4 4; marker-end: none; }
.wire.plain { marker-end: none; }

/* Elements revealed by the timeline */
.dyn { opacity: .14; transition: opacity .4s; }
.dyn.on { opacity: 1; }
.hot .wire, .wire.hot { stroke-dasharray: 6 4; animation: flow .8s linear infinite; }
.wire.loss.hot { animation: flow .8s linear infinite; }
.grad.hot { stroke: var(--loss); stroke-dasharray: 5 5; animation: flow-back .7s linear infinite; marker-end: none; }
@keyframes flow { to { stroke-dashoffset: -20; } }
@keyframes flow-back { to { stroke-dashoffset: 20; } }
.halo { fill: none; stroke: transparent; stroke-width: 6; transition: stroke .3s; }
.hot > .halo, .halo.hot { stroke: #3a73b52e; }
.narrate-halo.hot, .hot > .narrate-halo { stroke: #e0702c33; }
.paused .hot .wire, .paused .wire.hot, .paused .grad.hot { animation-play-state: paused; }

.description { margin: 0 24px; border-top: 1px solid #e5ebef; padding: 16px 0; min-height: 84px; display: grid; }
.description p { grid-area: 1 / 1; color: #586c7a; margin: 0; font-size: 14px; max-width: 760px; visibility: hidden; }
.description p.current { visibility: visible; }
.controls { display: flex; align-items: center; gap: 12px; padding: 15px 24px; background: #fafbfc; border-top: 1px solid #e5ebef; }
.control { padding: 7px 14px; border: 1px solid #cad6de; border-radius: 5px; background: white; color: var(--ink); font-size: 12px; min-width: 68px; }
.control:hover { background: #eaf2f6; }
input[type=range] { flex: 1; min-width: 50px; accent-color: var(--imagine); cursor: pointer; }
.time { white-space: nowrap; font-size: 11px; color: #71838f; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 18px; font-size: 12px; color: #647885; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.note { color: #778893; font-size: 12px; margin: 14px 2px 0; }

@media (max-width: 650px) {
  main { padding: 24px 12px; } h1 { font-size: 27px; } .intro { font-size: 13px; }
  .step { padding: 12px 8px; font-size: 11px; } .step span { font-size: 9px; }
  .description { margin: 0 16px; min-height: 120px; }
  .description p { font-size: 13px; }
  .controls { padding: 12px; gap: 8px; } .control { padding: 7px 10px; min-width: 54px; }
  .time { display: none; } .diagram-scroll { padding: 0 6px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .hot .wire, .wire.hot, .grad.hot { animation: none; }
}
.embedded body { background: white; }
.embedded main { max-width: none; padding: 0; }
.embedded .eyebrow, .embedded h1, .embedded .intro, .embedded .note { display: none; }
.embedded .legend { margin-top: 12px; padding: 0 2px 2px; }
