/* NEEDLEPOINT Studio: precision-instrument UI. No external resources. */

/* ------------------------------------------------------------------ fonts
   Bundled DejaVu (Bitstream Vera licence, see /static/fonts/LICENSE_DEJAVU), subset to the
   characters the Studio and its data use: the page renders identically on every OS, offline,
   and matches the logo wordmark (outlined DejaVu Sans Bold). 65 KB total. */
@font-face { font-family: "NP Sans"; src: url("/static/fonts/np-sans.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "NP Sans"; src: url("/static/fonts/np-sans-bold.woff2") format("woff2");
  font-weight: 600 800; font-style: normal; font-display: swap; }
@font-face { font-family: "NP Mono"; src: url("/static/fonts/np-mono.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap; }

/* ------------------------------------------------------------------ tokens */
:root {
  --font-ui: "NP Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: "NP Mono", ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-io: cubic-bezier(.65, 0, .35, 1);
  --t-fast: 150ms;
  --t-ui: 220ms;
  --t-slow: 300ms;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --brand-teal: #22D3EE;
  --brand-violet: #7C5CFF;
  --brand-red: #FF4D5E;
}

/* Dark is the default theme. */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070C17;
  --bg-2: #0B1220;
  --surface: rgba(22, 35, 63, .52);
  --surface-solid: #111B30;
  --surface-2: rgba(22, 35, 63, .82);
  --surface-hover: rgba(34, 52, 92, .6);
  --border: rgba(148, 163, 184, .16);
  --border-strong: rgba(148, 163, 184, .3);
  --text: #E8EEF7;
  --text-2: #B6C2D4;
  --muted: #8C9AB0;
  --accent: #22D3EE;          /* teal for UI */
  --accent-text: #5EE3F5;     /* teal used as text */
  --accent-ink: #04212A;      /* text on teal */
  --violet: #7C5CFF;
  --violet-text: #A895FF;
  --pass: #34D399;
  --pass-bg: rgba(52, 211, 153, .12);
  --fail: #FF4D5E;            /* alarm / failure only */
  --fail-text: #FF8591;
  --fail-bg: rgba(255, 77, 94, .12);
  --focus: #22D3EE;
  --grid-line: rgba(124, 150, 200, .07);
  --glow: rgba(34, 211, 238, .14);
  --glow-2: rgba(124, 92, 255, .14);
  --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 12px 40px -18px rgba(0, 0, 0, .7);
  --skeleton: rgba(148, 163, 184, .1);
  --skeleton-hi: rgba(148, 163, 184, .2);
  --overlay: rgba(3, 7, 15, .66);
  --img-bg: #0E1626;

  --m-gpt-6-2-astra: #3987e5;
  --m-claude-opus-5-5: #d95926;
  --m-gpt-6-luna: #199e70;
  --m-claude-haiku-5-5: #c98500;
  --m-gemini-3-1-flash-lite: #d55181;

  /* sequential heat scale endpoints (single hue) */
  --heat-lo: 214 40% 16%;
  --heat-hi: 190 85% 52%;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F4F6FA;
  --bg-2: #FFFFFF;
  --surface: rgba(255, 255, 255, .78);
  --surface-solid: #FFFFFF;
  --surface-2: rgba(255, 255, 255, .95);
  --surface-hover: rgba(226, 232, 244, .8);
  --border: rgba(15, 23, 42, .11);
  --border-strong: rgba(15, 23, 42, .22);
  --text: #0B1220;
  --text-2: #334155;
  --muted: #55627A;
  --accent: #0891B2;
  --accent-text: #0E7490;
  --accent-ink: #FFFFFF;
  --violet: #6A4BF2;
  --violet-text: #5536D8;
  --pass: #047857;
  --pass-bg: rgba(4, 120, 87, .09);
  --fail: #D92D41;
  --fail-text: #B4232F;
  --fail-bg: rgba(217, 45, 65, .08);
  --focus: #0891B2;
  --grid-line: rgba(15, 40, 90, .055);
  --glow: rgba(34, 211, 238, .18);
  --glow-2: rgba(124, 92, 255, .12);
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 12px 32px -16px rgba(15, 23, 42, .18);
  --skeleton: rgba(15, 23, 42, .06);
  --skeleton-hi: rgba(15, 23, 42, .12);
  --overlay: rgba(15, 23, 42, .45);
  --img-bg: #E8EDF5;

  --m-gpt-6-2-astra: #2a78d6;
  --m-claude-opus-5-5: #eb6834;
  --m-gpt-6-luna: #1baf7a;
  --m-claude-haiku-5-5: #eda100;
  --m-gemini-3-1-flash-lite: #e87ba4;

  --heat-lo: 200 40% 96%;
  --heat-hi: 200 85% 30%;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  font: 15px/1.55 var(--font-ui);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 500px at 85% -10%, var(--glow), transparent 70%),
    radial-gradient(700px 500px at -10% 30%, var(--glow-2), transparent 70%),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: auto, auto, 32px 32px, 32px 32px;
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--t-slow) var(--ease-out), color var(--t-slow) var(--ease-out);
}
img, svg { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.015em; margin: 0 0 .5em; }
h1 { font-size: clamp(1.7rem, 1.2rem + 2vw, 2.5rem); font-weight: 700; }
h2 { font-size: 1.12rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 1em; }
a { color: var(--accent-text); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
code, kbd, pre, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
kbd {
  font-size: .75em; padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 5px; background: var(--surface-2); color: var(--text-2);
}
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .82rem; margin: .35em 0 0; font-weight: 400; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[tabindex="-1"]:focus { outline: none; }

.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 1000;
  background: var(--accent); color: var(--accent-ink); padding: 10px 16px; border-radius: var(--r-sm);
  font-weight: 650; text-decoration: none; transition: top var(--t-ui) var(--ease-out);
}
.skip-link:focus { top: 12px; }

/* ------------------------------------------------------------------ top bar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 16px; min-height: 60px;
}
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); flex-shrink: 0; border-radius: 6px; }
.brand-wordmark { height: 28px; width: auto; display: block; }
.brand-on-light { display: none; }
:root[data-theme="light"] .brand-on-dark { display: none; }
:root[data-theme="light"] .brand-on-light { display: block; }
.brand-studio {
  font: 600 .7rem/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent-text); border: 1px solid var(--border-strong); padding: 4px 6px; border-radius: 6px;
}
.primary-nav { margin-left: auto; }
.primary-nav ul { list-style: none; display: flex; gap: 2px; margin: 0; padding: 0; }
.primary-nav a {
  display: block; padding: 8px 12px; border-radius: var(--r-sm); text-decoration: none;
  color: var(--text-2); font-weight: 550; font-size: .92rem; position: relative;
  transition: color var(--t-fast) var(--ease-out), background-color var(--t-fast) var(--ease-out);
}
.primary-nav a:hover { color: var(--text); background: var(--surface-hover); }
.primary-nav a[aria-current="page"] { color: var(--text); }
.primary-nav a[aria-current="page"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 2px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--brand-teal), var(--brand-violet));
  animation: grow-x var(--t-slow) var(--ease-out);
}
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 36px; min-height: 36px; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text-2); cursor: pointer; font: inherit; font-size: .85rem;
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-hover); }
.icon-btn:active { transform: scale(.96); }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; }
.nav-toggle { display: none; margin-left: auto; }
.theme-toggle .i-moon { display: none; }
:root[data-theme="light"] .theme-toggle .i-sun { display: none; }
:root[data-theme="light"] .theme-toggle .i-moon { display: block; }
.theme-toggle-label { font-size: .82rem; }

/* ------------------------------------------------------------------ layout */
main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 32px 20px 64px; outline: none; }
.view { animation: view-in 420ms var(--ease-out) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.view-head { margin: 8px 0 28px; max-width: 760px; }
.lede { color: var(--text-2); font-size: 1.04rem; margin: 0; }
.eyebrow {
  font: 600 .72rem/1.4 var(--font-mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent-text); margin: 0 0 10px; display: flex; align-items: center; gap: 8px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 20px;
}

/* ------------------------------------------------------------------ buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--r-sm);
  border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .92rem;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform var(--t-fast) var(--ease-out), background-color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-ui), color var(--t-fast);
}
.btn:active { transform: translateY(1px) scale(.985); }
.btn-lg { min-height: 46px; padding: 10px 20px; font-size: .98rem; }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: .84rem; }
.btn-primary {
  color: #04121A; background: linear-gradient(135deg, #22D3EE, #67E8F9 60%, #A5B4FC);
  box-shadow: 0 0 0 1px rgba(34, 211, 238, .4), 0 8px 24px -8px rgba(34, 211, 238, .55);
}
.btn-primary:hover { box-shadow: 0 0 0 1px rgba(34, 211, 238, .7), 0 10px 32px -8px rgba(34, 211, 238, .75); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-ghost { color: var(--text); background: var(--surface); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-hover); }
.btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

.input, select {
  font: inherit; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  min-height: 40px; padding: 6px 10px; width: 100%;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:hover, select:hover { border-color: var(--muted); }
.input:focus-visible, select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.input-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.select-wrap { position: relative; }
.select-wrap select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer; }
.select-wrap::after {
  content: ""; position: absolute; right: 13px; top: 50%; width: 7px; height: 7px; pointer-events: none;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-70%) rotate(45deg);
}

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend, .ctl-label { display: block; font-size: .78rem; font-weight: 650; color: var(--text-2); margin-bottom: 6px; letter-spacing: .02em; padding: 0; }
legend .hint { display: inline; font-size: .75rem; }

.segmented {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--border-strong);
}
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
  display: inline-flex; align-items: center; min-height: 32px; padding: 4px 14px; border-radius: 7px;
  font-size: .88rem; font-weight: 600; color: var(--text-2); cursor: pointer;
  transition: background-color var(--t-ui) var(--ease-out), color var(--t-fast);
}
.segmented input:checked + span { background: var(--surface-hover); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong) inset; }
.segmented input:checked + span::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 8px; }
.segmented input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-toggle {
  min-width: 40px; min-height: 36px; padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--bg-2); color: var(--text-2);
  font: 600 .88rem var(--font-mono); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: all var(--t-fast) var(--ease-out);
}
.chip-toggle:hover { border-color: var(--muted); color: var(--text); }
.chip-toggle[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: var(--accent); color: var(--text);
}
.chip-toggle .tick { width: 12px; height: 12px; opacity: 0; transform: scale(.4); transition: all var(--t-fast) var(--ease-out); }
.chip-toggle[aria-pressed="true"] .tick { opacity: 1; transform: none; }

.switch { display: inline-flex; align-items: center; gap: 10px; background: none; border: 0; padding: 4px 0; color: var(--text-2); font: inherit; font-size: .88rem; cursor: pointer; min-height: 36px; }
.switch-track { width: 40px; height: 24px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--border-strong); position: relative; transition: background-color var(--t-ui); }
.switch-thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform var(--t-ui) var(--ease-out), background-color var(--t-ui); }
.switch[aria-checked="true"] .switch-track, .switch[aria-pressed="true"] .switch-track { background: color-mix(in srgb, var(--accent) 30%, transparent); border-color: var(--accent); }
.switch[aria-checked="true"] .switch-thumb, .switch[aria-pressed="true"] .switch-thumb { transform: translateX(16px); background: var(--accent); }
.switch:focus-visible { outline: none; }
.switch:focus-visible .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ------------------------------------------------------------------ skeletons */
.skeleton { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--skeleton) 0%, var(--skeleton-hi) 50%, var(--skeleton) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk-num { height: 34px; width: 60%; margin-bottom: 10px; }
.sk-line { height: 12px; width: 85%; }
.sk-title { height: 18px; width: 40%; margin-bottom: 16px; }
.sk-block { height: 260px; width: 100%; }
.sk-img { aspect-ratio: 4 / 3; width: 100%; border-radius: 10px; }

/* ------------------------------------------------------------------ home */
.hero { display: grid; grid-template-columns: 1.15fr .85fr; gap: 40px; align-items: center; padding: 24px 0 12px; }
.hero-title { font-size: clamp(2rem, 1.2rem + 3.6vw, 3.6rem); line-height: 1.05; letter-spacing: -.03em; margin-bottom: 20px; }
.grad-text { background: linear-gradient(100deg, var(--brand-teal), #8FA7FF 55%, var(--brand-violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
:root[data-theme="light"] .grad-text { background: linear-gradient(100deg, #0E7490, #4F46E5 60%, #5B3FE0); -webkit-background-clip: text; background-clip: text; }
.hero-lede { color: var(--text-2); font-size: 1.08rem; max-width: 600px; margin-bottom: 28px; }
.hero-ctas { display: flex; flex-wrap: wrap; gap: 12px; }
.dot-live { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-teal); box-shadow: 0 0 0 0 rgba(34, 211, 238, .6); animation: pulse 2.4s var(--ease-out) infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34, 211, 238, .55); } 70% { box-shadow: 0 0 0 10px rgba(34, 211, 238, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0); } }

.hero-visual { position: relative; aspect-ratio: 1; max-width: 460px; width: 100%; justify-self: center; }
.hero-visual svg { width: 100%; height: 100%; display: block; overflow: visible; }
.hero-visual::before {
  content: ""; position: absolute; inset: 8%; border-radius: 50%;
  background: radial-gradient(circle, var(--glow) 0%, transparent 65%); filter: blur(10px);
}
.hg-face { fill: url(#hg-face); stroke: var(--border-strong); stroke-width: .5; }
:root[data-theme="light"] .hg-face { fill: url(#hg-face-light); }
.hg-tick { stroke: #CBD5E1; stroke-linecap: round; opacity: .5; }
.hg-tick.major { opacity: .9; }
.hg-num { fill: #94A3B8; font: 600 5px var(--font-mono); text-anchor: middle; dominant-baseline: middle; }
.hg-readout { fill: var(--text-2); font: 600 4.2px var(--font-mono); letter-spacing: .25em; text-anchor: middle; }
.hg-readout-val { fill: var(--accent-text); font: 700 6px var(--font-mono); text-anchor: middle; letter-spacing: .05em; }
.hg-ring { fill: none; stroke: var(--accent); stroke-width: .6; opacity: 0; }

.stats { list-style: none; padding: 0; margin: 40px 0 32px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px 20px;
  position: relative; overflow: hidden; box-shadow: var(--shadow);
}
.stat::before { content: ""; position: absolute; inset: 0 0 auto; height: 2px; background: linear-gradient(90deg, var(--brand-teal), var(--brand-violet)); opacity: .7; }
.stat-num { display: block; font: 700 clamp(1.7rem, 1.2rem + 1.4vw, 2.3rem)/1.1 var(--font-mono); letter-spacing: -.02em; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--text-2); font-size: .88rem; }
.pillars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 14px; }
.pillar h2 { font-size: 1.02rem; margin-top: 12px; }
.pillar p { color: var(--text-2); font-size: .93rem; margin: 0; }
.pillar-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; color: var(--accent-text); background: color-mix(in srgb, var(--accent) 12%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.finding { display: flex; gap: 24px; align-items: center; justify-content: space-between; background: linear-gradient(120deg, color-mix(in srgb, var(--violet) 12%, var(--surface-solid)), var(--surface)); }
.finding p:last-child { margin: 0; color: var(--text-2); }
.finding h2 { font-size: 1.25rem; }

/* ------------------------------------------------------------------ factory */
.controls { display: flex; flex-wrap: wrap; gap: 18px 26px; align-items: flex-start; margin-bottom: 20px; }
.controls #profile-ctl { width: 170px; }
.controls .ctl-num { width: 96px; }
.controls .ctl-seed { width: 236px; }
.ctl-go { margin-left: auto; align-self: center; }
.seed-row { display: flex; gap: 6px; }
.seed-row .input { min-width: 0; }
.seed-row .icon-btn { min-height: 40px; min-width: 40px; }
#dice-btn svg { transition: transform 500ms var(--ease-out); }
#dice-btn.rolling svg { transform: rotate(360deg); }

.pipeline { margin-bottom: 20px; overflow: hidden; }
.pipe-stages { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; position: relative; }
.pipe-stage { position: relative; text-align: center; padding-top: 44px; font-size: .84rem; color: var(--muted); font-weight: 600; transition: color var(--t-ui); }
.pipe-stage::before {
  content: ""; position: absolute; top: 19px; left: calc(-50% + 18px); right: calc(50% + 18px); height: 2px;
  background: var(--border-strong);
}
.pipe-stage:first-child::before { display: none; }
.pipe-stage::after {
  content: ""; position: absolute; top: 19px; left: calc(-50% + 18px); right: calc(50% + 18px); height: 2px;
  background: linear-gradient(90deg, var(--brand-teal), var(--brand-violet)); transform: scaleX(0); transform-origin: left;
  transition: transform 380ms var(--ease-out);
}
.pipe-stage:first-child::after { display: none; }
.pipe-stage.done::after, .pipe-stage.active::after { transform: scaleX(1); }
.pipe-node {
  position: absolute; top: 2px; left: 50%; width: 36px; height: 36px; margin-left: -18px; border-radius: 50%;
  display: grid; place-items: center; border: 2px solid var(--border-strong); background: var(--bg-2); color: var(--muted);
  transition: border-color var(--t-ui), background-color var(--t-ui), color var(--t-ui), box-shadow var(--t-ui);
}
.pipe-node svg { width: 16px; height: 16px; }
.pipe-stage.active { color: var(--text); }
.pipe-stage.active .pipe-node { border-color: var(--accent); color: var(--accent-text); box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 16%, transparent); animation: node-pulse 1s var(--ease-io) infinite; }
.pipe-stage.done { color: var(--text-2); }
.pipe-stage.done .pipe-node { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
@keyframes node-pulse { 50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 6%, transparent); } }
.pipe-gates-title { font: 600 .72rem var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.gate-lamps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.gate-lamp {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 10px 5px 8px; border-radius: 999px;
  border: 1px solid var(--border); font-size: .8rem; color: var(--muted); background: var(--bg-2);
  transition: all 260ms var(--ease-out);
}
.gate-lamp .lamp { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); transition: all 260ms var(--ease-out); }
.gate-lamp .gid { font-family: var(--font-mono); font-weight: 700; }
.gate-lamp.lit { color: var(--text); border-color: color-mix(in srgb, var(--pass) 50%, transparent); background: var(--pass-bg); }
.gate-lamp.lit .lamp { background: var(--pass); box-shadow: 0 0 10px var(--pass); }
.gate-lamp.checking .lamp { background: var(--accent); box-shadow: 0 0 10px var(--accent); }

.run-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 24px; margin: 4px 0 16px; }
.run-pick { min-width: 260px; }
.run-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--text-2); font-size: .88rem; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); font-size: .8rem; color: var(--text-2); min-height: 28px;
}
.pill .mono { color: var(--text); }
.pill button { all: unset; cursor: pointer; display: inline-flex; padding: 2px; border-radius: 4px; color: var(--muted); }
.pill button:hover { color: var(--text); }
.pill button:focus-visible { outline: 2px solid var(--focus); }

.funnel { display: grid; grid-template-columns: minmax(220px, 1fr) 1.3fr; gap: 24px; margin-bottom: 20px; animation: view-in 400ms var(--ease-out) both; }
.funnel h2 { font-size: .95rem; margin-bottom: 10px; }
.funnel-big { font: 700 2rem/1 var(--font-mono); margin-bottom: 6px; }
.funnel-big small { font-size: .95rem; color: var(--muted); font-weight: 500; }
.funnel-bar { height: 12px; border-radius: 999px; background: var(--fail-bg); overflow: hidden; margin: 12px 0 8px; border: 1px solid var(--border); }
.funnel-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-teal), var(--brand-violet)); border-radius: 999px; transform-origin: left; animation: bar-in 800ms var(--ease-out) both; }
@keyframes bar-in { from { transform: scaleX(0); } }
.rej-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rej-row { display: grid; grid-template-columns: minmax(120px, 190px) 1fr 28px; gap: 10px; align-items: center; font-size: .84rem; }
.rej-row .rej-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rej-track { height: 8px; border-radius: 99px; background: var(--skeleton); overflow: hidden; }
.rej-track span { display: block; height: 100%; background: var(--fail); opacity: .8; border-radius: 99px; transform-origin: left; animation: bar-in 700ms var(--ease-out) both; }
.rej-row .mono { text-align: right; }
details.rej-log { margin-top: 12px; font-size: .84rem; }
details.rej-log summary { cursor: pointer; color: var(--accent-text); font-weight: 600; min-height: 24px; }
details.rej-log ul { margin: 8px 0 0; padding-left: 18px; color: var(--text-2); }
details.rej-log li { margin-bottom: 4px; }

.task-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.task-card { animation: card-in 520ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes card-in { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.task-btn {
  all: unset; box-sizing: border-box; display: flex; flex-direction: column; width: 100%; height: 100%; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow);
  transition: transform var(--t-ui) var(--ease-out), border-color var(--t-ui), box-shadow var(--t-ui);
}
.task-btn:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: var(--shadow), 0 16px 40px -20px color-mix(in srgb, var(--accent) 60%, transparent); }
.task-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.task-thumb { position: relative; aspect-ratio: 4 / 3; background: var(--img-bg); overflow: hidden; }
.task-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity 400ms var(--ease-out), transform 600ms var(--ease-out); }
.task-thumb img.loaded { opacity: 1; }
.task-btn:hover .task-thumb img { transform: scale(1.03); }
.task-thumb .skeleton { position: absolute; inset: 0; border-radius: 0; }
.task-info { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.task-tags { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.op-badge {
  font: 700 .7rem/1 var(--font-mono); letter-spacing: .06em; padding: 5px 7px; border-radius: 6px;
  color: var(--violet-text); background: color-mix(in srgb, var(--violet) 14%, transparent); border: 1px solid color-mix(in srgb, var(--violet) 35%, transparent);
}
.diff { display: inline-flex; align-items: center; gap: 3px; font: 600 .72rem var(--font-mono); color: var(--muted); }
.diff i { width: 6px; height: 10px; border-radius: 2px; background: var(--border-strong); display: inline-block; }
.diff i.on { background: var(--accent); }
.twin-badge { font-size: .72rem; color: var(--text-2); display: inline-flex; gap: 4px; align-items: center; }
.task-q { font-size: .88rem; color: var(--text); margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.cert-mark { margin-top: auto; display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; color: var(--pass); font-weight: 600; }
.empty { color: var(--muted); padding: 40px; text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--r-lg); grid-column: 1 / -1; }
.error-box { border: 1px solid color-mix(in srgb, var(--fail) 50%, transparent); background: var(--fail-bg); color: var(--text); border-radius: var(--r-md); padding: 12px 16px; margin-bottom: 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.error-box strong { color: var(--fail-text); }

/* ------------------------------------------------------------------ inspector drawer */
.drawer-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 80; backdrop-filter: blur(3px); animation: fade-in 220ms var(--ease-out); }
@keyframes fade-in { from { opacity: 0; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 90; width: min(1180px, 96vw);
  background: var(--bg); border-left: 1px solid var(--border-strong); box-shadow: -30px 0 80px -30px rgba(0, 0, 0, .6);
  display: flex; flex-direction: column; animation: drawer-in 340ms var(--ease-out);
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 32px 32px;
}
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } }
.drawer.closing { animation: drawer-out 200ms var(--ease-io) forwards; }
@keyframes drawer-out { to { transform: translateX(40px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 85%, transparent); }
.drawer-title-wrap { min-width: 0; }
.drawer-head .eyebrow { margin-bottom: 2px; }
.drawer-head h2 { margin: 0; font-size: 1.05rem; font-family: var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.kbd-hint { color: var(--muted); font-size: .76rem; margin-right: 8px; display: inline-flex; gap: 3px; align-items: center; }
.insp-pos { font: 600 .8rem var(--font-mono); color: var(--muted); min-width: 52px; text-align: center; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; overscroll-behavior: contain; }
.insp-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr); gap: 20px; align-items: start; animation: view-in 300ms var(--ease-out) both; }
.insp-main, .insp-side { display: grid; gap: 16px; min-width: 0; }
.figure-card { padding: 12px; }
.figure-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.figure-toolbar .hint { margin: 0; }
.proof-stage { position: relative; border-radius: 10px; overflow: hidden; background: var(--img-bg); aspect-ratio: 4 / 3; }
.proof-stage img { display: block; width: 100%; height: 100%; object-fit: contain; }
.proof-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.verdicts { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.verdict {
  display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px; border-radius: 10px; font-size: .86rem;
  border: 1px solid var(--border); background: var(--surface-2); animation: view-in 300ms var(--ease-out) both;
}
.verdict.ok { border-color: color-mix(in srgb, var(--pass) 45%, transparent); background: var(--pass-bg); }
.verdict.bad { border-color: color-mix(in srgb, var(--fail) 50%, transparent); background: var(--fail-bg); }
.verdict .mono { font-weight: 600; }
.vi { flex-shrink: 0; width: 20px; height: 20px; margin-top: 1px; }
.ok .vi, .pass .vi { color: var(--pass); }
.bad .vi, .fail .vi { color: var(--fail); }
.proof-off-note { color: var(--muted); font-size: .84rem; margin: 10px 0 0; }

/* proof overlay shapes (image pixel space) */
.pf-target { fill: rgba(34, 211, 238, .07); stroke: #22D3EE; stroke-width: 2; stroke-dasharray: 8 6; }
.pf-target-label rect { fill: #22D3EE; }
.pf-target-label text { fill: #04212A; font: 700 15px var(--font-mono); }
.pf-face { fill: none; stroke: #A895FF; stroke-width: 3.5; }
.pf-tick { fill: #F8FAFC; stroke: #7C5CFF; stroke-width: 2; }
.pf-ocr { fill: rgba(124, 92, 255, .12); stroke: #A895FF; stroke-width: 1.5; }
.pf-ocr-text { fill: #F8FAFC; font: 700 12px var(--font-mono); paint-order: stroke; stroke: #1E1B4B; stroke-width: 3px; stroke-linejoin: round; }
.pf-needle { stroke: #22D3EE; stroke-width: 6; stroke-linecap: round; fill: none; filter: drop-shadow(0 0 4px rgba(34, 211, 238, .9)); }
.pf-trace { stroke: #22D3EE; stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; fill: none; filter: drop-shadow(0 0 4px rgba(34, 211, 238, .9)); }
.pf-trace-head { fill: #22D3EE; stroke: #04212A; stroke-width: 2; }
.pf-anim { transform-box: fill-box; transform-origin: center; opacity: 0; animation: pf-fade 420ms var(--ease-out) forwards; animation-delay: var(--d, 0ms); }
@keyframes pf-fade { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
.pf-anim-dot { transform-box: fill-box; transform-origin: center; }
.pf-draw { animation: pf-draw var(--dur, 900ms) var(--ease-out) forwards; animation-delay: var(--d, 0ms); }
@keyframes pf-draw { to { stroke-dashoffset: 0; } }

.q-card h3 { font-size: .78rem; font-family: var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.q-text { font-size: 1.05rem; line-height: 1.5; margin-bottom: 14px; }
.answer-box { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.answer-val { font: 700 1.2rem var(--font-mono); padding: 8px 14px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 12%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); animation: reveal 420ms var(--ease-out) both; }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }

.cert-card h3 { display: flex; align-items: center; gap: 8px; font-size: .98rem; }
.cert-seal { width: 22px; height: 22px; color: var(--pass); }
.gate-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 4px; }
.gate-row { display: grid; grid-template-columns: 22px auto 1fr; gap: 4px 10px; align-items: start; padding: 7px 10px; border-radius: 8px; font-size: .84rem; border: 1px solid transparent; transition: background-color 200ms, border-color 200ms; }
.gate-row .vi { width: 18px; height: 18px; }
.gate-row .g-id { font: 700 .74rem var(--font-mono); color: var(--muted); padding-top: 2px; }
.gate-row .g-label { font-weight: 600; }
.gate-row .g-state { font: 700 .7rem var(--font-mono); letter-spacing: .06em; text-transform: uppercase; margin-left: 6px; }
.gate-row.pass .g-state { color: var(--pass); }
.gate-row.fail .g-state { color: var(--fail-text); }
.gate-row .g-detail { grid-column: 3; color: var(--muted); font-size: .8rem; font-family: var(--font-mono); word-break: break-word; }
.gate-row.fail { background: var(--fail-bg); border-color: color-mix(in srgb, var(--fail) 45%, transparent); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; margin: 0 0 14px; font-size: .84rem; align-items: center; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; display: flex; align-items: center; gap: 6px; min-width: 0; font-family: var(--font-mono); }
.kv dd span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-btn { min-width: 28px; min-height: 28px; padding: 4px; }
.trace-details { margin: 0 0 14px; }
.trace-list { margin: 8px 0 0; padding-left: 22px; font: .84rem var(--font-mono); color: var(--text-2); }
.sig-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sig-chip { font: .74rem var(--font-mono); padding: 4px 8px; border-radius: 6px; background: var(--bg-2); border: 1px solid var(--border); color: var(--text-2); }
.sig-chip b { color: var(--text); font-weight: 600; }
.sub-h { font: 600 .72rem var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }

.twin-card h3 { font-size: .98rem; }
.twin-stage { position: relative; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: var(--img-bg); --wipe: 50%; }
.twin-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.twin-stage .twin-top { clip-path: inset(0 0 0 var(--wipe)); }
.twin-divider { position: absolute; top: 0; bottom: 0; left: var(--wipe); width: 2px; margin-left: -1px; background: var(--brand-teal); box-shadow: 0 0 12px var(--brand-teal); pointer-events: none; }
.twin-divider::after { content: "⟷"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 30px; height: 30px; border-radius: 50%; background: var(--brand-teal); color: #04212A; display: grid; place-items: center; font-size: 14px; font-weight: 700; }
.twin-labels { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; justify-content: space-between; pointer-events: none; }
.twin-labels span { font: 700 .7rem var(--font-mono); padding: 3px 7px; border-radius: 5px; background: rgba(11, 18, 32, .8); color: #F8FAFC; }
.twin-range { width: 100%; margin: 12px 0 6px; accent-color: var(--accent); min-height: 24px; }
.twin-cap { font-size: .84rem; color: var(--text-2); margin: 0; }

/* ------------------------------------------------------------------ lab */
.fault-grid { list-style: none; margin: 0 0 20px; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.fault-btn {
  all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: 8px; width: 100%; height: 100%;
  padding: 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  transition: transform var(--t-ui) var(--ease-out), border-color var(--t-ui), background-color var(--t-ui);
  animation: card-in 500ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 60ms);
}
.fault-btn:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.fault-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.fault-btn[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.fault-btn .f-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fault-btn .f-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--violet-text); background: color-mix(in srgb, var(--violet) 12%, transparent); border: 1px solid color-mix(in srgb, var(--violet) 30%, transparent); }
.fault-btn .f-gate { font: 700 .7rem var(--font-mono); color: var(--muted); }
.fault-btn h2 { font-size: 1rem; margin: 4px 0 0; }
.fault-btn p { font-size: .86rem; color: var(--text-2); margin: 0; }
.fault-btn .f-cta { margin-top: auto; font-size: .8rem; font-weight: 650; color: var(--accent-text); padding-top: 6px; }
.lab-stage { scroll-margin-top: 84px; margin-bottom: 20px; display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(280px, 1fr); gap: 20px; animation: view-in 360ms var(--ease-out) both; }
.lab-images { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-content: start; }
.lab-img figure { margin: 0; }
.lab-img figcaption { font-size: .8rem; font-weight: 650; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.lab-img .frame { aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: var(--img-bg); border: 1px solid var(--border); position: relative; }
.lab-img .frame img { width: 100%; height: 100%; object-fit: contain; display: block; }
.lab-img.defect .frame { border-color: color-mix(in srgb, var(--fail) 55%, transparent); }
.lab-q { grid-column: 1 / -1; font-size: .88rem; color: var(--text-2); margin: 4px 0 0; }
.lab-gates { position: relative; }
.lab-gates .gate-row { opacity: .45; }
.lab-gates .gate-row.checked { opacity: 1; }
.lab-gates .gate-row.scanning { opacity: 1; background: color-mix(in srgb, var(--accent) 10%, transparent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.lab-gates .gate-row.pending .vi { color: var(--muted); }
.stamp {
  margin-top: 14px; display: inline-flex; flex-direction: column; gap: 2px; padding: 10px 16px; border-radius: 10px;
  border: 3px solid var(--fail); color: var(--fail-text); transform: rotate(-4deg);
  font: 800 1rem/1.2 var(--font-mono); letter-spacing: .04em; text-transform: uppercase;
  background: var(--fail-bg); animation: stamp 520ms cubic-bezier(.2, 1.6, .4, 1) both;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--fail) 25%, transparent) inset;
}
.stamp small { font-size: .72rem; font-weight: 700; letter-spacing: .08em; opacity: .9; }
@keyframes stamp { 0% { opacity: 0; transform: rotate(-12deg) scale(1.8); } 60% { opacity: 1; transform: rotate(-3deg) scale(.95); } 100% { transform: rotate(-4deg) scale(1); } }
.stamp.missed { border-color: var(--muted); color: var(--text-2); background: var(--surface-2); }
.recall-card h2 { margin-bottom: 4px; }

/* ------------------------------------------------------------------ tables */
.tbl-wrap { overflow-x: auto; border-radius: var(--r-md); border: 1px solid var(--border); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .86rem; }
.tbl caption { text-align: left; padding: 0 0 8px; color: var(--muted); font-size: .8rem; }
.tbl th, .tbl td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; background: var(--surface-2); position: sticky; top: 0; }
.tbl tbody tr:last-child td, .tbl tbody tr:last-child th { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--surface-hover); }
.tbl td.num, .tbl th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tbl tfoot td, .tbl tfoot th { font-weight: 700; border-top: 1px solid var(--border-strong); border-bottom: 0; }
.status-pass { color: var(--pass); font-weight: 650; display: inline-flex; gap: 6px; align-items: center; }
.status-pass .vi, .status-fail .vi { width: 16px; height: 16px; }
.status-fail { color: var(--fail-text); font-weight: 650; display: inline-flex; gap: 6px; align-items: center; }
.basis { font: 600 .72rem var(--font-mono); padding: 3px 7px; border-radius: 5px; border: 1px solid var(--border-strong); color: var(--text-2); white-space: nowrap; }
.basis.measured { color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 50%, transparent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: baseline; flex-shrink: 0; }

/* ------------------------------------------------------------------ capability map */
.map-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.chart-card { min-width: 0; animation: card-in 520ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 70ms); }
.chart-card.span-2 { grid-column: 1 / -1; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.chart-head h2 { margin: 0 0 2px; }
.chart-head p { margin: 0; color: var(--muted); font-size: .84rem; max-width: 620px; }
.chart-body { position: relative; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg text { font-family: var(--font-ui); fill: var(--text-2); font-size: 12px; }
.chart-svg .axis-label { fill: var(--muted); font-size: 11px; }
.chart-svg .tick-label { fill: var(--muted); font-size: 11px; font-family: var(--font-mono); }
.chart-svg .grid { stroke: var(--border); stroke-width: 1; }
.chart-svg .axis { stroke: var(--border-strong); stroke-width: 1; }
.chart-svg .direct-label { fill: var(--text); font-size: 12px; font-weight: 600; }
.chart-svg .direct-val { fill: var(--text-2); font-size: 11px; font-family: var(--font-mono); }
.chart-svg .series-line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .pt { stroke: var(--bg-2); stroke-width: 2; cursor: pointer; transition: r 150ms var(--ease-out); }
.chart-svg .pt:focus { outline: none; }
.chart-svg .pt:focus-visible, .chart-svg .pt.hot { stroke: var(--text); stroke-width: 3; }
.chart-svg .frontier { stroke: var(--muted); stroke-dasharray: 5 5; fill: none; stroke-width: 1.5; }
.chart-svg .ci { stroke-width: 2; stroke-linecap: round; opacity: .75; }
.chart-svg .annot { fill: var(--muted); font-size: 11px; font-style: italic; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; list-style: none; padding: 0; margin: 0 0 10px; font-size: .8rem; color: var(--text-2); }
.legend li { display: inline-flex; align-items: center; }
.legend .swatch { width: 14px; height: 4px; border-radius: 2px; margin-right: 6px; }

.heat-scroll { position: relative; overflow-x: auto; padding: 4px; }
.heat { display: grid; gap: 3px; font-size: .8rem; --heat-rh: 118px; --heat-col: 52px; }
.heat-row { display: contents; }
.heat-colhead { font: 600 .72rem var(--font-ui); color: var(--text-2); padding: 4px 2px 8px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 5px; line-height: 1.2; word-break: break-word; }
.heat-colhead .swatch { margin: 0; width: 18px; height: 4px; }
.heat-rowhead { font: 600 .78rem var(--font-mono); color: var(--text-2); display: flex; align-items: center; padding-right: 8px; white-space: nowrap; }
.heat-rowhead small { color: var(--muted); font-weight: 500; margin-right: 4px; }
.heat-cell {
  border-radius: 6px; min-height: 36px; display: grid; place-items: center; font: 700 .82rem var(--font-mono);
  cursor: default; transition: transform 150ms var(--ease-out), box-shadow 150ms; position: relative; border: 1px solid transparent;
  animation: fade-in 500ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 12ms);
}
.heat-cell:hover, .heat-cell:focus-visible { transform: scale(1.06); z-index: 2; box-shadow: 0 0 0 2px var(--focus); outline: none; }
.heat-cell.na { background: transparent; border: 1px dashed var(--border-strong); color: var(--muted); font-weight: 500; }
.heat-scale { display: flex; align-items: center; gap: 10px; margin-top: 12px; font: .74rem var(--font-mono); color: var(--muted); }
.heat-scale .bar { flex: 0 1 220px; height: 8px; border-radius: 99px; }
.tooltip {
  position: fixed; left: 0; top: 0; z-index: 200; pointer-events: none; max-width: min(280px, calc(100vw - 16px)); visibility: hidden;
  background: var(--surface-solid); color: var(--text); border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 8px 11px; font-size: .8rem; box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .5);
  opacity: 0; transform: translateY(4px); transition: opacity 120ms var(--ease-out), transform 120ms var(--ease-out);
}
.tooltip.show { opacity: 1; transform: none; visibility: visible; }
.tooltip b { font-family: var(--font-mono); }
.tooltip .tt-sub { color: var(--muted); font-size: .76rem; }
.fail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px 24px; }
.fail-model h3 { font-size: .9rem; display: flex; align-items: center; margin-bottom: 8px; }
.fail-model h3 small { color: var(--muted); font-weight: 500; margin-left: auto; font-size: .76rem; }
.fbar { display: grid; grid-template-columns: 1fr 32px; gap: 2px 8px; align-items: center; margin-bottom: 6px; font-size: .78rem; }
.fbar .fl { grid-column: 1 / -1; color: var(--text-2); display: flex; gap: 6px; }
.fbar .fl .mono { color: var(--text); font-weight: 600; font-size: .74rem; }
.fbar .ft { height: 8px; border-radius: 99px; background: var(--skeleton); overflow: hidden; }
.fbar .ft span { display: block; height: 100%; border-radius: 99px; transform-origin: left; animation: bar-in 800ms var(--ease-out) both; }
.fbar .fv { font: 600 .78rem var(--font-mono); text-align: right; }
.stat-rows { display: grid; gap: 10px; }
.srow { display: grid; grid-template-columns: minmax(130px, 170px) 1fr 120px; gap: 12px; align-items: center; font-size: .84rem; }
.srow .sm { display: flex; align-items: center; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow .strack { height: 10px; background: var(--skeleton); border-radius: 99px; position: relative; overflow: visible; }
.srow .strack span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; transform-origin: left; animation: bar-in 800ms var(--ease-out) both; }
.srow .strack .ci-band { position: absolute; top: -3px; bottom: -3px; border-left: 2px solid var(--text-2); border-right: 2px solid var(--text-2); opacity: .5; }
.srow .sv { font: 600 .82rem var(--font-mono); text-align: right; }
.mini-h { font: 600 .78rem var(--font-ui); color: var(--text); margin: 4px 0 10px; }
.mini-note { font-size: .8rem; color: var(--muted); margin: 10px 0 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.table-toggle[aria-pressed="true"] { border-color: var(--accent); color: var(--text); }

/* ------------------------------------------------------------------ ship */
.ship-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.ship-side { display: grid; gap: 16px; min-width: 0; }
.estimator { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; min-width: 0; }
.est-result, .export-card, .code-card { min-width: 0; }
.estimator h2 { margin: 0; }
.est-n-row { display: grid; grid-template-columns: 1fr 140px; gap: 12px; align-items: center; }
input[type="range"] { accent-color: var(--accent); width: 100%; min-height: 24px; cursor: pointer; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.check {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-2); cursor: pointer; font-size: .86rem; min-height: 40px; transition: border-color var(--t-fast), background-color var(--t-fast);
}
.check:hover { border-color: var(--border-strong); }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex-shrink: 0; }
.check:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: color-mix(in srgb, var(--accent) 8%, var(--bg-2)); }
.check .prov { margin-left: auto; color: var(--muted); font-size: .74rem; font-family: var(--font-mono); }
.est-opts { display: flex; gap: 28px; flex-wrap: wrap; align-items: start; }
.est-total { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 14px 0 6px; }
.est-total .big { font: 700 2rem/1 var(--font-mono); letter-spacing: -.02em; }
.est-total .gen { font-size: .84rem; color: var(--text-2); }
.export-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.export-card .select-wrap { margin-top: 8px; }
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.code-head h2 { margin: 0; }
.code-wrap { position: relative; }
pre.code {
  margin: 0; padding: 14px 16px; padding-right: 72px; border-radius: 10px; background: #060A13; color: #D6E2F2;
  border: 1px solid var(--border-strong); font-size: .8rem; line-height: 1.6; overflow-x: auto; white-space: pre;
}
pre.code .c-k { color: #5EE3F5; }
pre.code .c-s { color: #C4B5FD; }
pre.code .c-m { color: #8C9AB0; }
.copy-code { position: absolute; top: 8px; right: 8px; }

/* ------------------------------------------------------------------ how it works */
.diagram-card { margin: 0 0 16px; padding: 24px; }
.how-diagram svg { width: 100%; height: auto; display: block; }
.dg-node rect { fill: var(--surface-solid); stroke: var(--border-strong); stroke-width: 1.2; }
.dg-node.key rect { stroke: var(--accent); stroke-width: 1.6; }
.dg-node text { fill: var(--text); font: 650 13px var(--font-ui); text-anchor: middle; }
.dg-node .dg-sub { fill: var(--muted); font: 500 10.5px var(--font-mono); }
.dg-node .dg-num { fill: var(--accent-text); font: 700 10px var(--font-mono); text-anchor: start; }
.dg-edge { fill: none; stroke: var(--border-strong); stroke-width: 1.6; }
.dg-flow { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 4 10; animation: flow 1.2s linear infinite; opacity: .85; }
@keyframes flow { to { stroke-dashoffset: -28; } }
.dg-reject { fill: none; stroke: var(--fail); stroke-width: 1.4; stroke-dasharray: 3 4; }
.dg-reject-text { fill: var(--fail-text); font: 600 11px var(--font-mono); }
.dg-arrow { fill: var(--border-strong); }
.how-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.how-card p { color: var(--text-2); font-size: .93rem; margin: 0; }

/* ------------------------------------------------------------------ toast & footer */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 300; opacity: 0; pointer-events: none;
  background: var(--surface-solid); color: var(--text); border: 1px solid var(--border-strong); border-radius: 999px;
  padding: 8px 16px; font-size: .86rem; font-weight: 600; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .5);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.footer { border-top: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 85%, transparent); }
.footer-inner { max-width: 1240px; margin: 0 auto; padding: 20px; display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; font-size: .84rem; }
.footer-inner p { margin: 0; }
.footer-links { margin-left: auto !important; }
.footer-mark { border-radius: 7px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .insp-grid { grid-template-columns: minmax(0, 1fr); }
  .kbd-hint { display: none; }
}
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 16px; }
  .hero-visual { max-width: 340px; order: -1; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .pillars { grid-template-columns: 1fr; }
  .finding { flex-direction: column; align-items: flex-start; }
  .map-grid { grid-template-columns: minmax(0, 1fr); }
  .chart-card.span-2 { grid-column: auto; }
  .ship-grid { grid-template-columns: minmax(0, 1fr); }
  .fault-grid { grid-template-columns: repeat(2, 1fr); }
  .lab-stage { grid-template-columns: minmax(0, 1fr); }
  .funnel { grid-template-columns: 1fr; }
  .how-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-flex; }
  .primary-nav {
    position: absolute; top: 100%; left: 0; right: 0; margin: 0; padding: 8px 12px 14px;
    background: var(--bg); border-bottom: 1px solid var(--border); display: none;
  }
  .primary-nav.open { display: block; animation: view-in 200ms var(--ease-out); }
  .primary-nav ul { flex-direction: column; }
  .primary-nav a { padding: 12px; }
  .primary-nav a[aria-current="page"]::after { left: 0; right: auto; top: 10px; bottom: 10px; width: 3px; height: auto; }
  .topbar-inner { position: relative; }
  .theme-toggle-label { display: none; }
}
@media (max-width: 640px) {
  main { padding: 20px 16px 48px; }
  .topbar-inner { padding: 8px 16px; gap: 8px; }
  .brand-studio { display: none; }
  .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .controls #profile-ctl, .controls .ctl-num, .controls .ctl-seed { width: auto; }
  .controls .ctl-wide, .controls .ctl-seed, .controls .ctl-go, .controls > fieldset:first-child { grid-column: 1 / -1; }
  .controls #profile-ctl { order: 1; }
  .controls .ctl-wide { order: 0; }
  .controls .ctl-num { order: 1; }
  .controls .ctl-seed { order: 2; }
  .controls .ctl-go { order: 3; }
  .ctl-go { margin-left: 0; }
  .ctl-go .btn { width: 100%; }
  .fault-grid { grid-template-columns: 1fr; }
  .lab-images { grid-template-columns: 1fr; }
  .stats { gap: 10px; }
  .stat { padding: 14px; }
  .drawer { width: 100vw; border-left: 0; }
  .drawer-head { padding: 10px 12px; }
  .drawer-body { padding: 12px; }
  .insp-pos { display: none; }
  .run-pick { min-width: 0; width: 100%; }
  .srow { grid-template-columns: 1fr 70px; }
  .srow .strack { grid-column: 1 / -1; grid-row: 2; }
  .est-n-row { grid-template-columns: 1fr; }
  .rej-row { grid-template-columns: 1fr 28px; }
  .rej-row .rej-track { grid-column: 1 / -1; grid-row: 2; }
  .card { padding: 16px; }
  .heat { --heat-rh: 92px; --heat-col: 42px; gap: 2px; }
  .heat-rowhead small { display: none; }
  .heat-rowhead { font-size: .72rem; padding-right: 4px; }
  .heat-cell { font-size: .74rem; min-height: 32px; }
  .heat-colhead { font-size: .66rem; }
  .footer-links { margin-left: 0 !important; }
  .hero-ctas .btn { width: 100%; }
}
@media (max-width: 380px) {
  .stats { grid-template-columns: 1fr; }
  .brand-wordmark { height: 24px; }
}

/* ------------------------------------------------------------------ reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 1ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important;
    transition-duration: 1ms !important; transition-delay: 0ms !important;
  }
  .skeleton { animation: none; }
  .dg-flow { display: none; }
}
:root.reduce-motion *, :root.reduce-motion *::before, :root.reduce-motion *::after {
  animation-duration: 1ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important;
  transition-duration: 1ms !important; transition-delay: 0ms !important;
}
:root.reduce-motion .dg-flow { display: none; }

@media (forced-colors: active) {
  .heat-cell { border: 1px solid CanvasText; }
  .btn-primary { border: 1px solid ButtonText; }
}
