@layer ui-sdk;
/* Layout: app shell. Top bar with line tabs, then a left rail grouped by pipeline stage and one
   lesson card at a time. Radius scale 6 / 10 / 14. One accent; stage colors are data. */
:root {
  --bg: #ECEFF3; --surface: #FFFFFF; --sunk: #F3F5F8; --ink: #15202B; --muted: #5A6878; --line: #D8DEE5; --line-strong: #C3CBD5;
  --accent: #2A55D9;
  --c-net: #0F8478; --c-vad: #935A06; --c-stt: #2B6BD8; --c-llm: #7348D0; --c-tts: #C53A60;
  --good: #1B8546; --warn: #8C5A06; --bad: #C4352B; --bad-text: #A82A21; --control-border: #7F8C9C;
  --f-display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --f-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r-s: 6px; --r-m: 10px; --r-l: 14px;
  --shadow: 0 1px 2px rgb(20 32 43 / 0.05), 0 4px 16px rgb(20 32 43 / 0.06);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E141A; --surface: #151E26; --sunk: #1A242E; --ink: #E4EBF1; --muted: #97A5B4; --line: #26323D; --line-strong: #3A4856;
    --accent: #7C9BFF;
    --c-net: #3CC2B2; --c-vad: #E5A43A; --c-stt: #6FA2FF; --c-llm: #A98BFF; --c-tts: #FF7FA0;
    --good: #4CC57E; --warn: #E5A43A; --bad: #FF6B5E; --bad-text: #FF6B5E; --control-border: #647585;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 6px 20px rgb(0 0 0 / 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E141A; --surface: #151E26; --sunk: #1A242E; --ink: #E4EBF1; --muted: #97A5B4; --line: #26323D; --line-strong: #3A4856;
  --accent: #7C9BFF;
  --c-net: #3CC2B2; --c-vad: #E5A43A; --c-stt: #6FA2FF; --c-llm: #A98BFF; --c-tts: #FF7FA0;
  --good: #4CC57E; --warn: #E5A43A; --bad: #FF6B5E; --bad-text: #FF6B5E; --control-border: #647585;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 6px 20px rgb(0 0 0 / 0.25);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { touch-action: manipulation; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.55 var(--f-body); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--f-display); margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: 18px; line-height: 1.3; }
h2 { font-size: 16px; line-height: 1.3; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code, .mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
code { font-size: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.gutter { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.icon { width: 18px; height: 18px; flex: 0 0 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 15px; height: 15px; flex-basis: 15px; }

/* buttons */
.btn { height: 32px; padding: 0 14px; border-radius: var(--r-s); border: 1px solid var(--line-strong); background: var(--surface); font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; transition: transform 160ms var(--ease-out), border-color 150ms ease-out; }
.btn:active:not(:disabled) { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .btn:hover:not(:disabled) { border-color: var(--muted); } }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn:disabled { opacity: 0.45; cursor: default; }

/* top bar + line tabs (ui-sdk tabs) */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 24px; min-height: 52px; }
.brand { display: flex; align-items: center; gap: 10px; font: 700 15px var(--f-display); white-space: nowrap; }
@media (max-width: 560px) { .brand span { display: none; } .top-in { gap: 12px; } }
[data-slot="tabs-list"] { position: relative; display: flex; gap: 4px; align-self: stretch; }
[data-slot="tabs-tab"] { border: 0; background: transparent; padding: 0 10px; display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 14px; font-weight: 700; border-radius: var(--r-s); transition: color 150ms ease-out; }
[data-slot="tabs-tab"][data-selected] { color: var(--ink); }
@media (hover: hover) and (pointer: fine) { [data-slot="tabs-tab"]:hover { color: var(--ink); } }
[data-slot="tabs-tab"] .count { font: 400 12px var(--f-mono); color: var(--muted); }
[data-slot="tabs-indicator"] { position: absolute; left: 0; translate: var(--active-tab-left) 0; width: var(--active-tab-width); bottom: -1px; height: 2px; background: var(--ink); border-radius: 999px; transition: translate 200ms var(--ease-out), width 200ms var(--ease-out); }
[data-slot="tabs-indicator"]:not([data-visible]) { display: none; }
[data-slot="tabs-indicator"][data-activation-direction="none"] { transition: none; }

/* shell */
.shell { max-width: 1180px; margin: 0 auto; padding-block: 24px 48px; display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 820px) { .shell { grid-template-columns: minmax(0, 1fr); padding-block: 12px 40px; gap: 12px; } }
.rail { position: sticky; top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 8px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rail .group { display: flex; align-items: center; gap: 10px; padding: 10px 8px 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.rail .group:first-child { padding-top: 4px; }
.rail .dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--sc) 16%, transparent); color: var(--sc); }
.rail .dot .icon { width: 13px; height: 13px; flex-basis: 13px; }
.rail .link { border: 0; background: transparent; text-align: left; padding: 7px 10px 7px 40px; border-radius: var(--r-s); font-size: 14px; display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
.rail .link[aria-current] { background: color-mix(in srgb, var(--sc) 13%, var(--surface)); font-weight: 700; }
@media (hover: hover) and (pointer: fine) { .rail .link:hover:not([aria-current]) { background: var(--sunk); } }
.rail .link .icon { color: var(--good); }
@media (max-width: 820px) {
  .rail { position: static; flex-direction: row; overflow-x: auto; padding: 6px; gap: 6px; scroll-snap-type: x proximity; }
  .rail .group { display: none; }
  .rail .link { padding: 7px 12px; flex: 0 0 auto; white-space: nowrap; border: 1px solid var(--line); scroll-snap-align: start; }
}
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow); padding: 24px; display: flex; flex-direction: column; gap: 22px; min-width: 0; }
@media (max-width: 560px) { .panel { padding: 18px 16px; gap: 18px; } }
.panel > header { display: flex; gap: 14px; align-items: flex-start; }
.badge { width: 40px; height: 40px; border-radius: var(--r-m); display: grid; place-items: center; background: var(--sc); color: var(--surface); flex: 0 0 40px; }
.panel > header p { color: var(--muted); margin-top: 2px; }
@media (max-width: 420px) { .nx-t { display: none; } }
.panel > footer { display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); padding-top: 16px; }
.block { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.say p, .coach, .feedback span { max-width: 68ch; }
.say { background: var(--sunk); border-radius: var(--r-m); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.say h2 { font-size: 14px; display: flex; gap: 8px; align-items: center; }
.say h2 .icon { color: var(--sc); }
.copy { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: var(--r-s); overflow: hidden; background: var(--surface); min-width: 0; }
.copy code { padding: 8px 10px; flex: 1; overflow-x: auto; white-space: nowrap; align-self: center; }
.copy button:focus-visible { outline-offset: -2px; }
.copy button { border: 0; border-left: 1px solid var(--line); background: var(--sunk); padding: 0 12px; font-size: 12px; font-weight: 700; flex: 0 0 auto; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.between { justify-content: space-between; }

/* coach */
.coach { display: flex; flex-direction: column; gap: 6px; }
.coach .do { display: flex; gap: 10px; align-items: baseline; font-weight: 700; font-size: 16px; }
.coach .do .n { font: 400 12px var(--f-mono); color: var(--muted); flex: 0 0 auto; }
.coach .got { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); transition: opacity 200ms var(--ease-out), translate 200ms var(--ease-out); }
@starting-style { .coach .got { opacity: 0; translate: 0 4px; } }
.rail .link .icon { transition: opacity 200ms var(--ease-out), scale 200ms var(--ease-out); }
@starting-style { .rail .link .icon.fresh { opacity: 0; scale: 0.8; } }
.coach .got .icon { color: var(--good); margin-top: 1px; }

/* ui-sdk slider */
ui-slider { display: block; }
[data-slot="slider-control"] { display: flex; align-items: center; height: 24px; cursor: pointer; }
[data-slot="slider-track"] { position: relative; flex: 1; height: 4px; border-radius: 999px; background: var(--line); }
[data-slot="slider-indicator"] { height: 100%; border-radius: 999px; background: var(--sc, var(--accent)); }
[data-slot="slider-thumb"] { width: 18px; height: 18px; top: -7px; border-radius: 50%; background: var(--surface); border: 2px solid var(--sc, var(--accent)); box-shadow: 0 1px 3px rgb(0 0 0 / 0.18); transition: scale 150ms var(--ease-out); }
[data-slot="slider-thumb"]:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
[data-slot="slider-thumb"][data-dragging] { scale: 1.12; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field .lbl { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.field .lbl output { font: 600 12px var(--f-mono); }
.sl-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 64px; gap: 12px; align-items: center; font-size: 13px; }
.sl-row .sw { width: 8px; height: 8px; border-radius: 999px; display: inline-block; margin-right: 6px; background: var(--sc); }
.sl-row output { text-align: right; font: 600 12px var(--f-mono); }
@media (max-width: 560px) { .sl-row { grid-template-columns: minmax(0, 1fr) 60px; row-gap: 2px; } .sl-row ui-slider { grid-column: 1 / -1; grid-row: 2; } }

/* ui-sdk switch */
.switch-label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
[data-slot="switch"] { display: inline-flex; width: 34px; height: 20px; padding: 2px; border-radius: 999px; background: var(--control-border); transition: background 150ms ease-out; flex: 0 0 auto; }
[data-slot="switch"][data-checked] { background: var(--ink); }
[data-slot="switch-thumb"] { width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgb(0 0 0 / 0.2); transition: transform 150ms var(--ease-out); }
[data-slot="switch-thumb"][data-checked] { transform: translateX(14px); }

/* ui-sdk checkbox */
.check-label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
[data-slot="checkbox"] { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 1px; border: 1.5px solid var(--control-border); border-radius: 6px; display: inline-grid; place-items: center; background: var(--surface); color: #fff; transition: background 120ms ease-out, border-color 120ms ease-out; }
[data-slot="checkbox"][data-checked] { background: var(--good); border-color: var(--good); }
[data-slot="checkbox-indicator"] { display: grid; place-items: center; }
[data-slot="checkbox-indicator"]:not([data-checked]) { visibility: hidden; }
[data-slot="checkbox-indicator"] .icon { width: 13px; height: 13px; flex-basis: 13px; stroke-width: 2.6; }

/* ui-sdk segmented control */
[data-slot="segmented-control"] { position: relative; display: inline-flex; isolation: isolate; background: var(--sunk); border-radius: var(--r-m); padding: 3px; gap: 2px; }
[data-slot="segmented-control-indicator"] { position: absolute; z-index: -1; top: 0; left: 0; translate: var(--segmented-control-indicator-left) var(--segmented-control-indicator-top); width: var(--segmented-control-indicator-width); height: var(--segmented-control-indicator-height); background: var(--surface); border-radius: 7px; box-shadow: 0 1px 2px rgb(0 0 0 / 0.08), 0 0 0 1px var(--line); transition: translate 200ms var(--ease-out), width 200ms var(--ease-out); }
[data-slot="segmented-control-indicator"]:not([data-visible]) { display: none; }
[data-slot="segmented-control-item"] { border: 0; background: transparent; height: 28px; padding: 0 12px; border-radius: 7px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; }
[data-slot="segmented-control-item"][data-checked] { color: var(--ink); }

/* ui-sdk collapsible */
ui-collapsible { display: block; border: 1px solid var(--line); border-radius: var(--r-m); }
[data-slot="collapsible-trigger"] { width: 100%; text-align: left; border: 0; background: transparent; padding: 12px 14px; font-weight: 700; display: flex; gap: 10px; align-items: flex-start; border-radius: var(--r-m); }
[data-slot="collapsible-trigger"] .icon { transition: rotate 200ms var(--ease-out); color: var(--muted); margin-top: 2px; }
[data-slot="collapsible-trigger"][data-open] .icon { rotate: 90deg; }
[data-slot="collapsible-panel"] { height: var(--collapsible-panel-height); overflow: hidden; transition: height 200ms var(--ease-out); }
[data-slot="collapsible-panel"]:is([data-starting-style], [data-ending-style]) { height: 0; }
.cp-in { padding: 4px 14px 14px 42px; display: flex; flex-direction: column; gap: 12px; }

/* widget parts */
canvas { display: block; width: 100%; }
.lane-label { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.meter { height: 10px; background: var(--sunk); border-radius: 999px; overflow: hidden; position: relative; }
.meter i { position: absolute; inset: 0 auto 0 0; background: var(--c-tts); }
.meter.ghost i { background: color-mix(in srgb, var(--c-tts) 35%, transparent); }
.said { line-height: 1.7; font-size: 14px; overflow-wrap: anywhere; }
.said .heard { background: color-mix(in srgb, var(--c-tts) 16%, transparent); }
.said .queued { color: var(--muted); }
.said .dropped { color: var(--bad); text-decoration: line-through; }
.mono-box { font: 12px/1.55 var(--f-mono); background: var(--sunk); border-radius: var(--r-s); padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.status { display: inline-flex; gap: 6px; align-items: center; font-weight: 700; font-size: 13px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: 0 0 8px; }
.status.good { color: var(--good); } .status.warn { color: var(--warn); } .status.bad { color: var(--bad); } .status.idle { color: var(--muted); }
.stackbar { display: flex; height: 28px; border-radius: var(--r-s); overflow: hidden; background: var(--sunk); }
.stackbar span { height: 100%; }
.bigms { font: 700 32px/1 var(--f-display); font-variant-numeric: tabular-nums; }
.flow { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; position: relative; }
.flow::before { content: ""; position: absolute; top: 21px; left: 10%; right: 10%; height: 2px; background: var(--line); }
.flow ui-toggle { display: block; min-width: 0; }
.flow button { width: 100%; position: relative; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); padding: 0; }
.flow .ic { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--sunk); color: var(--sc); border: 2px solid var(--surface); transition: background 150ms ease-out, color 150ms ease-out, transform 160ms var(--ease-out); }
.flow button:active .ic { transform: scale(0.95); }
.flow ui-toggle.seen .ic { background: color-mix(in srgb, var(--sc) 18%, var(--sunk)); }
.flow button[data-pressed] { color: var(--ink); }
.flow button[data-pressed] .ic { background: var(--sc); color: var(--surface); }
.lane { position: relative; height: 26px; background: var(--sunk); border-radius: var(--r-s); overflow: hidden; }
.lane .pk { position: absolute; left: 0; top: 4px; height: 18px; border-radius: 999px; background: var(--c-net); transition: translate 300ms var(--ease-out); }
.lane .gap { transition: width 300ms var(--ease-out); }
.lane.live .pk, .lane.live .gap { transition: none; }
.lane .pk.lost { background: repeating-linear-gradient(45deg, var(--warn) 0 3px, transparent 3px 6px); }
.lane .gap { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--bad) 16%, transparent); border-left: 2px solid var(--bad); display: flex; align-items: center; padding-left: 6px; font: 600 11px var(--f-mono); color: var(--bad-text); white-space: nowrap; overflow: hidden; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { background: var(--sunk); border-radius: var(--r-s); padding: 10px 12px; }
.stat b { display: block; font: 600 16px var(--f-mono); }
.stat span { font-size: 12px; color: var(--muted); }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 700; font-size: 12px; }
.slow { color: var(--bad-text); }
select { height: 32px; border: 1px solid var(--control-border); background: var(--surface); border-radius: var(--r-s); padding: 0 8px; font-size: 13px; max-width: 100%; }
textarea { width: 100%; border: 1px solid var(--control-border); border-radius: var(--r-s); background: var(--surface); padding: 8px 10px; resize: vertical; min-height: 44px; font-size: 14px; }
@media (max-width: 560px) { textarea, select { font-size: 16px; } }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.field-col { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; }
.align { display: flex; flex-wrap: wrap; gap: 6px 4px; background: var(--sunk); padding: 10px; border-radius: var(--r-s); line-height: 1.3; }
.tok { display: inline-flex; flex-direction: column; align-items: center; padding: 2px 4px; border-radius: 6px; overflow-wrap: anywhere; }
.tok small { font-size: 11px; color: var(--muted); text-decoration: line-through; }
.tok.sub { background: color-mix(in srgb, var(--warn) 20%, transparent); }
.tok.del { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); text-decoration: line-through; }
.tok.ins { background: color-mix(in srgb, var(--c-stt) 18%, transparent); text-decoration: underline; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 999px; margin-right: 5px; vertical-align: -1px; }
.chart { display: grid; gap: 12px; }
.crow { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 10px; align-items: center; font-size: 13px; }
.cbars { position: relative; display: grid; gap: 3px; margin-right: 112px; }
.cbar { height: 12px; border-radius: 0 999px 999px 0; position: relative; }
.cbar em { position: absolute; left: calc(100% + 6px); top: -2px; font: 11px var(--f-mono); font-style: normal; white-space: nowrap; color: var(--muted); }
.gate { position: absolute; top: -4px; bottom: -4px; border-left: 2px dashed var(--bad); }
.scale { position: relative; height: 14px; font: 11px var(--f-mono); color: var(--muted); }
.scale b { position: absolute; transform: translateX(-50%); font-weight: 400; }

/* quiz */
.progress { height: 4px; background: var(--sunk); border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 100%; background: var(--ink); transform-origin: left; transition: scale 250ms var(--ease-out); }
.choices { display: grid; gap: 8px; }
.choices button { text-align: left; border: 1px solid var(--line-strong); background: var(--surface); padding: 11px 14px; border-radius: var(--r-m); display: flex; gap: 12px; align-items: flex-start; font-size: 14px; transition: border-color 150ms ease-out, transform 160ms var(--ease-out); }
.choices button:active:not(:disabled) { transform: scale(0.98); }
@media (hover: hover) and (pointer: fine) { .choices button:hover:not(:disabled) { border-color: var(--muted); } }
.choices .k { font: 400 12px var(--f-mono); color: var(--muted); padding-top: 2px; }
.choices .k .icon { width: 14px; height: 14px; flex-basis: 14px; }
.choices button.right .k { color: var(--good); } .choices button.wrong .k { color: var(--bad); }
.choices button.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 9%, var(--surface)); }
.choices button.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 7%, var(--surface)); }
.choices button:disabled { cursor: default; }
.feedback { border-radius: var(--r-m); padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; background: var(--sunk); }
.feedback .icon { margin-top: 1px; }
.feedback.good .icon { color: var(--good); } .feedback.bad .icon { color: var(--bad); }
.scorebig { font: 700 40px/1 var(--f-display); font-variant-numeric: tabular-nums; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.mockq { display: flex; flex-direction: column; gap: 12px; padding-top: 20px; border-top: 1px solid var(--line); }
.mockq:first-child { padding-top: 0; border-top: 0; }
ul.plain { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-property: opacity, color, background-color, border-color !important; animation: none !important; } }

/* ===== v2: lessons from basics ===== */
.lede { font-size: 15px; color: var(--muted); max-width: 68ch; margin-top: 2px; }
.demos { display: flex; flex-direction: column; gap: 28px; }
.demo { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.demo + .demo { border-top: 1px solid var(--line); padding-top: 24px; }
.demo > header h2 { font-size: 16px; }
.demo > header p { color: var(--muted); margin-top: 2px; }
.demo-body { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* step-through stage */
.stepper { border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; background: var(--surface); }
.stage-area { background: var(--sunk); padding: 18px; min-height: 220px; display: flex; flex-direction: column; justify-content: center; gap: 12px; position: relative; overflow: hidden; }
.stage-area svg.scene { width: 100%; height: auto; display: block; overflow: visible; }
.stepbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 10px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.stepbar .cap { font-weight: 700; flex: 1 1 260px; min-width: 0; }
.stepnav { display: flex; align-items: center; gap: 6px; }
.stepnav .count { color: var(--muted); font-size: 12px; margin-right: 4px; }
.icon-btn { padding: 0 9px; }

/* scene parts, animated with transform and opacity only */
.scene text { fill: var(--muted); font: 12px var(--f-body); }
.scene .lbl-ink { fill: var(--ink); font-weight: 700; }
.scene .ln { stroke: var(--line-strong); stroke-width: 2; fill: none; }
.scene .mv { transition: transform 500ms var(--ease-out), opacity 400ms var(--ease-out); }
.scene .fade { transition: opacity 400ms var(--ease-out); }
.scene .off { opacity: 0; }
.scene .dim { opacity: 0.25; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 5px 10px; border-radius: var(--r-s); background: var(--surface); border: 1px solid var(--line); font-size: 13px; transition: opacity 300ms var(--ease-out), background 200ms ease-out; }
.chip.hot { background: color-mix(in srgb, var(--sc, var(--accent)) 16%, var(--surface)); border-color: color-mix(in srgb, var(--sc, var(--accent)) 45%, var(--line)); }
.chip.ghost { opacity: 0.35; }
.nodes { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.node { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; flex: 0 0 auto; transition: color 200ms ease-out; }
.node .ic { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); color: var(--muted); transition: background 200ms ease-out, color 200ms ease-out, border-color 200ms ease-out; }
.node.on { color: var(--ink); }
.node.on .ic { background: var(--sc, var(--accent)); color: var(--surface); border-color: transparent; }
.node.bad .ic { background: color-mix(in srgb, var(--bad) 18%, var(--surface)); color: var(--bad-text); }
.wire { flex: 1; height: 2px; background: var(--line-strong); position: relative; min-width: 16px; }
.wire.on { background: var(--sc, var(--accent)); }
.wire.cut { background: repeating-linear-gradient(90deg, var(--bad) 0 6px, transparent 6px 10px); }
.pkt { position: absolute; top: -5px; left: 0; width: 12px; height: 12px; border-radius: 50%; background: var(--sc, var(--accent)); transition: translate 700ms var(--ease-out), opacity 300ms ease-out; }
.note { font-size: 13px; color: var(--muted); }
.bigline { font: 700 22px/1.25 var(--f-display); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.kv b { font-family: var(--f-mono); font-weight: 600; font-variant-numeric: tabular-nums; }

/* start page path map */
.pathmap { display: grid; gap: 18px; }
.pm-group h2 { font-size: 14px; display: flex; gap: 8px; align-items: center; color: var(--muted); }
.pm-group h2 .dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--sc) 16%, transparent); color: var(--sc); }
.pm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-top: 8px; }
.pm-item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); text-decoration: none; color: var(--ink); transition: border-color 150ms ease-out; }
@media (hover: hover) and (pointer: fine) { .pm-item:hover { border-color: var(--muted); } }
.pm-item .num { font: 600 12px var(--f-mono); color: var(--muted); width: 20px; }
.pm-item .t { flex: 1; min-width: 0; font-weight: 700; font-size: 14px; }
.pm-item .icon { color: var(--good); }

h1[tabindex="-1"]:focus { outline: none; }
