/* ==========================================================================
   trans-bench UI — design system
   Layout: fixed left navigation + one content column (max 1320px); pages are built from
   page heads, cards, data tables and charts. Every colour is a token with light and dark values.
   ========================================================================== */

:root {
  /* colour — light */
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --sunken: #eceef3;
  --line: #e1e4ea;
  --line-strong: #cbd1db;
  --ink: #10141b;
  --ink-2: #485061;
  --ink-3: #737a8b;
  --accent: #2747d6;
  --accent-hover: #1f3ab8;
  --accent-ink: #ffffff;
  --accent-soft: #e7ecff;
  --accent-line: #b9c6fb;
  --ok: #10805b;
  --ok-soft: #e1f3ea;
  --warn: #a84f05;
  --warn-soft: #fcefdf;
  --danger: #c1233d;
  --danger-soft: #fce6ea;
  --muted: #646c7e;
  --muted-soft: #eceef2;
  --shadow-sm: 0 1px 2px rgba(16, 20, 27, .06);
  --shadow-md: 0 1px 2px rgba(16, 20, 27, .05), 0 6px 18px -6px rgba(16, 20, 27, .12);
  --shadow-lg: 0 2px 4px rgba(16, 20, 27, .04), 0 24px 48px -12px rgba(16, 20, 27, .22);
  --scrim: rgba(12, 15, 21, .42);
  --code-bg: #f6f7fa;
  --heat-0: #e3e9fd;
  --heat-1: #2747d6;
  --on-dark: #ffffff;

  /* type */
  --font-display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --font-body: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --fs-xs: .75rem;
  --fs-sm: .8125rem;
  --fs-md: .875rem;
  --fs-base: .9375rem;
  --fs-lg: 1.0625rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
  --fs-3xl: 2.25rem;

  /* space, shape */
  --sidebar-w: 248px;
  --gutter: 28px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --content-max: 1320px;

  /* motion */
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --ease-spring: cubic-bezier(.34, 1.36, .64, 1);
  --t-fast: 140ms;
  --t-med: 240ms;
  --t-slow: 420ms;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0f14; --surface: #13171e; --surface-2: #171c24; --sunken: #0a0d11; --line: #222833; --line-strong: #323a47;
    --ink: #e8ebf1; --ink-2: #a7aebb; --ink-3: #7b8392; --accent: #8199ff; --accent-hover: #9cafff; --accent-ink: #0a0f22;
    --accent-soft: #1a2248; --accent-line: #34418a; --ok: #3cc98f; --ok-soft: #0f271d; --warn: #f2a54b; --warn-soft: #2c1e0e;
    --danger: #ff6c80; --danger-soft: #321219; --muted: #9aa1ad; --muted-soft: #1c2129;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 22px -8px rgba(0, 0, 0, .6);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .3), 0 28px 56px -14px rgba(0, 0, 0, .75); --scrim: rgba(0, 0, 0, .6);
    --code-bg: #0f1218; --heat-0: #1a2140; --heat-1: #8da3ff; --on-dark: #0c0f14; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0f14; --surface: #13171e; --surface-2: #171c24; --sunken: #0a0d11; --line: #222833; --line-strong: #323a47;
  --ink: #e8ebf1; --ink-2: #a7aebb; --ink-3: #7b8392; --accent: #8199ff; --accent-hover: #9cafff; --accent-ink: #0a0f22;
  --accent-soft: #1a2248; --accent-line: #34418a; --ok: #3cc98f; --ok-soft: #0f271d; --warn: #f2a54b; --warn-soft: #2c1e0e;
  --danger: #ff6c80; --danger-soft: #321219; --muted: #9aa1ad; --muted-soft: #1c2129;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 22px -8px rgba(0, 0, 0, .6);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, .3), 0 28px 56px -14px rgba(0, 0, 0, .75); --scrim: rgba(0, 0, 0, .6);
  --code-bg: #0f1218; --heat-0: #1a2140; --heat-1: #8da3ff; --on-dark: #0c0f14; color-scheme: dark;
}

/* ── Base ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 var(--fs-base)/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; color: var(--ink); text-wrap: balance; }
h1, h2 { font-family: var(--font-display); font-weight: 650; letter-spacing: -.02em; }
h3, h4 { font-weight: 600; letter-spacing: -.005em; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
code, kbd, pre, .mono { font-family: var(--font-mono); font-feature-settings: "zero" 1; }
code { font-size: .92em; background: var(--sunken); padding: .08em .38em; border-radius: 5px; color: var(--ink); }
img, svg { max-width: 100%; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-soft); color: var(--ink); }
.num, td, .tabular { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: 12px; z-index: 200; background: var(--surface); padding: 8px 12px; border-radius: var(--radius); box-shadow: var(--shadow-md); transform: translateY(-200%); opacity: 0; transition: transform var(--t-fast), opacity var(--t-fast); }
.skip-link:focus { transform: none; opacity: 1; }

/* ── App frame ────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px; border-right: 1px solid var(--line); background: var(--surface);
  view-transition-name: sidebar; z-index: 40; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-mark .bm-edge { stroke: var(--ink-3); }
.brand-mark .bm-close { stroke: var(--accent); }
.brand-mark .bm-node { fill: var(--surface); stroke: var(--ink); }
.brand:hover .bm-close { stroke-dasharray: 40; animation: redraw .7s var(--ease-out); }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.12rem; letter-spacing: -.02em; line-height: 1; }
.brand-sub { font-size: var(--fs-xs); color: var(--ink-3); margin-top: 3px; }
.nav { position: relative; display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); padding: 14px 10px 6px; }
.nav-link {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border-radius: 8px; color: var(--ink-2); font-size: var(--fs-md); font-weight: 500;
  transition: color var(--t-fast) var(--ease-out), background var(--t-fast);
}
.nav-link > svg { width: 17px; height: 17px; flex: none; stroke-width: 1.8; }
.nav-link:hover { color: var(--ink); background: color-mix(in srgb, var(--sunken) 60%, transparent); }
.nav-link[aria-current="page"] { color: var(--ink); font-weight: 600; background: none; }
.nav-link[aria-current="page"] > svg { color: var(--accent); }
.nav-link .nav-count { margin-left: auto; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.nav-indicator {
  position: absolute; left: 0; right: 0; top: 0; z-index: 0; border-radius: 8px; background: var(--sunken);
  box-shadow: inset 2px 0 0 var(--accent);
  transition: transform var(--t-med) var(--ease-out), height var(--t-med) var(--ease-out), opacity var(--t-fast);
  pointer-events: none;
}
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 16px; }
.env-mini { font-size: var(--fs-xs); color: var(--ink-3); padding: 10px; border-top: 1px solid var(--line); line-height: 1.6; }
.env-mini b { color: var(--ink-2); font-weight: 550; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  height: 58px; padding-inline: var(--gutter); border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); view-transition-name: topbar;
}
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--fs-md); color: var(--ink-3); }
.crumbs a { color: var(--ink-2); white-space: nowrap; }
.crumbs a:hover { color: var(--ink); }
.crumbs .sep { color: var(--line-strong); }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.search-btn { justify-content: flex-start; width: 220px; color: var(--ink-3); }
.search-btn .kbd { margin-left: auto; }
.btn.menu-btn { display: none; }
.content { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 28px var(--gutter) 64px; view-transition-name: content; }

/* ── Page head ────────────────────────────────────────────────────────── */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: 24px; }
.page-head > div:first-child { min-width: 0; }
.page-head h1 { font-size: var(--fs-3xl); line-height: 1.08; overflow-wrap: anywhere; }
.page-head .lede { margin-top: 8px; color: var(--ink-2); max-width: 70ch; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.section-title { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; margin: 34px 0 14px; }
.section-title h2 { font-size: var(--fs-xl); }
.section-title .meta { font-size: var(--fs-sm); color: var(--ink-3); }

/* ── Layout helpers ───────────────────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.split.split-rev { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.spacer { flex: 1; }
.muted { color: var(--ink-3); }
.ink-2 { color: var(--ink-2); }
.small { font-size: var(--fs-sm); }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.prose { color: var(--ink-2); max-width: 75ch; }
.prose p + p { margin-top: 10px; }
.prose ul { padding-left: 18px; margin: 10px 0; }
.prose li + li { margin-top: 4px; }
.dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 18px; font-size: var(--fs-md); margin: 0; }
.dl dt { color: var(--ink-3); }
.dl dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }

/* ── Cards ────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.card-pad { padding: 20px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); min-height: 56px; }
.card-head h3 { font-size: var(--fs-base); display: flex; align-items: center; gap: 8px; }
.card-head h3 > svg { width: 17px; height: 17px; color: var(--ink-3); }
.card-body { padding: 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
a.card, .card.is-link { display: block; color: inherit; transition: transform var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out), border-color var(--t-med); }
a.card:hover, .card.is-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-strong); color: inherit; }
a.card:active { transform: translateY(0); }

/* KPI */
.kpi { padding: 18px 20px; }
.kpi-label { font-size: var(--fs-sm); color: var(--ink-2); display: flex; align-items: center; gap: 7px; }
.kpi-label > svg { width: 15px; height: 15px; color: var(--ink-3); }
.kpi-value { font-family: var(--font-display); font-weight: 650; font-size: 2rem; letter-spacing: -.03em; line-height: 1.1; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: var(--fs-sm); color: var(--ink-3); margin-top: 4px; }

/* Hero (dashboard) */
.hero { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); overflow: hidden; }
.hero-copy { padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.hero-copy h2 { font-size: var(--fs-2xl); line-height: 1.15; }
.hero-art { position: relative; min-height: 240px; border-left: 1px solid var(--line); background: radial-gradient(circle at 1px 1px, var(--line) 1px, transparent 0) 0 0 / 16px 16px; display: grid; place-items: center; padding: 16px; }
.hero-art svg { width: 100%; max-width: 360px; height: auto; }
.closure .e { stroke: var(--ink-3); stroke-width: 1.6; fill: none; }
.closure .c { stroke: var(--accent); stroke-width: 1.6; fill: none; stroke-dasharray: 4 5; opacity: 0; animation: closure-edge 6s var(--ease-in-out) infinite; animation-delay: calc(var(--i) * .35s); }
.closure .n { fill: var(--surface); stroke: var(--ink); stroke-width: 1.6; }
.closure text { font: 600 11px var(--font-mono); fill: var(--ink-2); text-anchor: middle; dominant-baseline: central; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  --b-bg: var(--surface); --b-fg: var(--ink); --b-line: var(--line-strong);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--b-line);
  background: var(--b-bg); color: var(--b-fg); font-size: var(--fs-md); font-weight: 550; white-space: nowrap;
  cursor: pointer; user-select: none; box-shadow: var(--shadow-sm); text-decoration: none;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast);
}
.btn > svg { width: 16px; height: 16px; stroke-width: 2; flex: none; }
.btn:hover { --b-bg: var(--surface-2); color: var(--b-fg); }
.btn:active { transform: translateY(1px) scale(.985); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }
.btn-primary { --b-bg: var(--accent); --b-fg: var(--accent-ink); --b-line: transparent; }
.btn-primary:hover { --b-bg: var(--accent-hover); }
.btn-ghost { --b-bg: transparent; --b-line: transparent; box-shadow: none; --b-fg: var(--ink-2); }
.btn-ghost:hover { --b-bg: var(--sunken); --b-fg: var(--ink); }
.btn-danger { --b-fg: var(--danger); --b-line: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn-danger:hover { --b-bg: var(--danger-soft); }
.btn-danger-solid { --b-bg: var(--danger); --b-fg: #fff; --b-line: transparent; }
.btn-danger-solid:hover { --b-bg: color-mix(in srgb, var(--danger) 88%, #000); }
.btn-sm { height: 30px; padding: 0 10px; font-size: var(--fs-sm); border-radius: 8px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: var(--fs-base); border-radius: 11px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > svg { opacity: 0; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--b-fg); border-right-color: transparent; animation: spin .7s linear infinite;
}
.kbd, kbd { display: inline-flex; align-items: center; gap: 2px; font: 500 11px/1 var(--font-mono); color: var(--ink-3); background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 3px 5px; }
.theme-btn .i-sun, .theme-btn .i-moon, .theme-btn .i-auto { display: none; }
:root[data-theme-pref="light"] .theme-btn .i-sun, :root[data-theme-pref="dark"] .theme-btn .i-moon, :root:not([data-theme-pref]) .theme-btn .i-auto, :root[data-theme-pref="auto"] .theme-btn .i-auto { display: block; }

/* ── Chips, badges, dots ──────────────────────────────────────────────── */
.chip {
  --c-fg: var(--ink-2); --c-bg: var(--sunken);
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 550; color: var(--c-fg); background: var(--c-bg); white-space: nowrap; border: 0;
}
.chip > svg { width: 13px; height: 13px; }
button.chip { cursor: pointer; transition: background var(--t-fast), color var(--t-fast); }
button.chip[aria-pressed="false"] { --c-bg: transparent; --c-fg: var(--ink-3); box-shadow: inset 0 0 0 1px var(--line); }
button.chip[aria-pressed="false"] .sys-mark { opacity: .45; }
button.chip.chip-outline[aria-pressed="true"] { background: var(--accent-soft); --c-fg: var(--ink); box-shadow: inset 0 0 0 1px var(--accent-line); }
button.chip:active { transform: scale(.96); }
.chip-ok { --c-fg: var(--ok); --c-bg: var(--ok-soft); }
.chip-warn { --c-fg: var(--warn); --c-bg: var(--warn-soft); }
.chip-danger { --c-fg: var(--danger); --c-bg: var(--danger-soft); }
.chip-accent { --c-fg: var(--accent); --c-bg: var(--accent-soft); }
.chip-muted { --c-fg: var(--muted); --c-bg: var(--muted-soft); }
.chip-outline { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.chip.mono { font-family: var(--font-mono); font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.sys-mark { display: inline-grid; place-items: center; width: 18px; height: 18px; flex: none; color: var(--mark, var(--ink)); }
.sys-mark svg { width: 14px; height: 14px; overflow: visible; }
.sys-badge { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; flex: none; background: color-mix(in srgb, var(--mark, var(--ink)) 12%, var(--surface)); color: var(--mark, var(--ink)); border: 1px solid color-mix(in srgb, var(--mark, var(--ink)) 24%, var(--line)); }
.sys-badge svg { width: 18px; height: 18px; overflow: visible; }
.live-dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.live-dot::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--ok); opacity: 0; animation: ping 1.6s var(--ease-out) infinite; }
.run-chip { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 999px; background: var(--ok-soft); color: var(--ok); font-size: var(--fs-sm); font-weight: 600; animation: rise var(--t-slow) var(--ease-spring); }
.run-chip:hover { color: var(--ok); filter: brightness(.97); }

/* ── Forms ────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: var(--fs-md); font-weight: 600; color: var(--ink); }
.label .opt { font-weight: 400; color: var(--ink-3); }
.hint { font-size: var(--fs-sm); color: var(--ink-3); }
.hint.err { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit; font-size: var(--fs-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input.mono, .textarea.mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); animation: shake .32s var(--ease-out); }
.select { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 17px) 16px, calc(100% - 12px) 16px; background-size: 5px 5px; background-repeat: no-repeat; }
.select.btn-sm, .input.btn-sm { height: 30px; background-position: calc(100% - 17px) 13px, calc(100% - 12px) 13px; font-size: var(--fs-sm); }
.input-group { display: flex; align-items: stretch; }
.input-group .addon { display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid var(--line-strong); border-right: 0; border-radius: 9px 0 0 9px; background: var(--surface-2); color: var(--ink-3); font: 500 var(--fs-sm) var(--font-mono); white-space: nowrap; }
.input-group .input { border-radius: 0 9px 9px 0; }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search .input { padding-left: 32px; }

.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: var(--fs-md); color: var(--ink); user-select: none; }
.check input { appearance: none; width: 17px; height: 17px; margin: 0; border-radius: 5px; border: 1.5px solid var(--line-strong); background: var(--surface); display: grid; place-items: center; transition: background var(--t-fast), border-color var(--t-fast); cursor: pointer; flex: none; }
.check input::after { content: ""; width: 9px; height: 5px; border: 2px solid var(--accent-ink); border-top: 0; border-right: 0; transform: rotate(-45deg) scale(0); transition: transform var(--t-fast) var(--ease-spring); margin-top: -2px; }
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { transform: rotate(-45deg) scale(1); }
.check input[type="radio"] { border-radius: 50%; }
.check input[type="radio"]::after { width: 7px; height: 7px; border: 0; border-radius: 50%; background: var(--accent-ink); margin: 0; transform: scale(0); }
.check input[type="radio"]:checked::after { transform: scale(1); }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: var(--fs-sm); color: var(--ink-2); user-select: none; }
.switch input { appearance: none; width: 32px; height: 18px; margin: 0; border-radius: 999px; background: var(--line-strong); position: relative; cursor: pointer; transition: background var(--t-med); flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--t-med) var(--ease-spring); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(14px); }

/* selectable cards */
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.pick {
  position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; user-select: none; min-width: 0;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast);
}
.pick:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.pick:active { transform: scale(.99); }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick .pick-box { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line-strong); flex: none; display: grid; place-items: center; margin-top: 1px; transition: background var(--t-fast), border-color var(--t-fast); }
.pick input[type="radio"] ~ .pick-box { border-radius: 50%; }
.pick .pick-box svg { width: 12px; height: 12px; stroke: var(--accent-ink); stroke-width: 3; fill: none; stroke-dasharray: 20; stroke-dashoffset: 20; transition: stroke-dashoffset var(--t-med) var(--ease-out); }
.pick:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); box-shadow: 0 0 0 1px var(--accent); }
.pick:has(input:checked) .pick-box { background: var(--accent); border-color: var(--accent); }
.pick:has(input:checked) .pick-box svg { stroke-dashoffset: 0; }
.pick:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.pick:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.pick-main { min-width: 0; flex: 1; }
.pick-title { font-weight: 600; font-size: var(--fs-md); display: flex; align-items: center; gap: 7px; min-width: 0; }
.pick-title > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-sub { font-size: var(--fs-sm); color: var(--ink-3); margin-top: 2px; line-height: 1.45; }
.pick-mini { width: 58px; height: 42px; flex: none; }

/* segmented control */
.seg { position: relative; display: inline-flex; padding: 3px; border-radius: 10px; background: var(--sunken); gap: 2px; isolation: isolate; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg button, .seg label { position: relative; z-index: 1; height: 28px; padding: 0 12px; border: 0; background: none; border-radius: 7px; font-size: var(--fs-sm); font-weight: 550; color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; transition: color var(--t-fast); }
.seg button svg, .seg label svg { width: 14px; height: 14px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg [aria-pressed="true"], .seg label:has(input:checked) { color: var(--ink); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg-thumb { position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 0; width: 0; border-radius: 7px; background: var(--surface); box-shadow: var(--shadow-sm); transition: transform var(--t-med) var(--ease-out), width var(--t-med) var(--ease-out); }

/* tabs */
.tabs { position: relative; display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 7px; height: 42px; padding: 0 12px; border: 0; background: none; color: var(--ink-2); font-size: var(--fs-md); font-weight: 550; cursor: pointer; white-space: nowrap; transition: color var(--t-fast); }
.tab > svg { width: 16px; height: 16px; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"] > svg { color: var(--accent); }
.tab .count { font-size: 11px; color: var(--ink-3); background: var(--sunken); border-radius: 999px; padding: 1px 7px; font-variant-numeric: tabular-nums; }
.tab-ink { position: absolute; bottom: 0; left: 0; width: 0; height: 2px; border-radius: 2px; background: var(--accent); transition: transform var(--t-med) var(--ease-out), width var(--t-med) var(--ease-out); }
.tab-panel { animation: panel-in var(--t-slow) var(--ease-out); }
.tab-panel:focus-visible { outline: none; }

/* ── Tables ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table-wrap.scroll-y { max-height: 560px; overflow-y: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-md); }
.table th { position: sticky; top: 0; z-index: 1; text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); background: var(--surface-2); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--surface-2); }
.table .r { text-align: right; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--ink); }
.table th[aria-sort="ascending"]::after { content: " ↑"; color: var(--accent); }
.table th[aria-sort="descending"]::after { content: " ↓"; color: var(--accent); }
.table .mono { font-size: var(--fs-sm); }
.table .clip { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table tbody tr.is-expanded .clip { white-space: pre-wrap; word-break: break-word; }

/* heat matrix */
.matrix-wrap { overflow-x: auto; padding: 4px 2px 8px; }
.matrix { border-collapse: separate; border-spacing: 3px; font-size: var(--fs-sm); }
.matrix th { font-weight: 600; color: var(--ink-2); padding: 6px 8px; text-align: left; white-space: nowrap; font-size: var(--fs-sm); }
.matrix thead th { text-align: center; vertical-align: bottom; font-size: var(--fs-xs); }
.matrix thead th .sys-mark { display: flex; margin: 0 auto 2px; }
.matrix tbody th { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.matrix td { min-width: 78px; height: 36px; padding: 0 9px; border-radius: 7px; text-align: right; font-family: var(--font-mono); font-size: 12px; position: relative; cursor: default; white-space: nowrap; transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast); animation: cell-in var(--t-slow) var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 7ms); }
.matrix td:hover { transform: scale(1.07); box-shadow: var(--shadow-md); z-index: 2; }
.matrix td.fail { text-align: center; font-family: var(--font-body); font-weight: 650; font-size: 10.5px; letter-spacing: .04em; }
.matrix td.f-timeout { background: var(--warn-soft); color: var(--warn); }
.matrix td.f-oom, .matrix td.f-error, .matrix td.f-killed { background: var(--danger-soft); color: var(--danger); }
.matrix td.f-unsupported, .matrix td.f-iteration_limit { background: var(--muted-soft); color: var(--muted); }
.matrix td.f-skipped { background: transparent; color: var(--ink-3); box-shadow: inset 0 0 0 1px var(--line); }
.matrix td.none { background: transparent; color: var(--line-strong); text-align: center; font-family: var(--font-body); }
.matrix td.wrong::before { content: "†"; position: absolute; left: 6px; top: 3px; color: var(--danger); font-weight: 700; }
.matrix td.best { box-shadow: inset 0 0 0 2px var(--ok); }
.legend-scale { display: flex; align-items: center; gap: 8px; font-size: var(--fs-xs); color: var(--ink-3); }
.legend-scale .bar { width: 120px; height: 8px; border-radius: 999px; background: linear-gradient(90deg, var(--heat-0), var(--heat-1)); }

/* tooltip */
.tip { position: fixed; z-index: 160; left: 0; top: 0; pointer-events: none; max-width: 300px; background: var(--ink); color: var(--bg); padding: 9px 11px; border-radius: 9px; font-size: var(--fs-sm); line-height: 1.45; box-shadow: var(--shadow-lg); opacity: 0; transition: opacity var(--t-fast); }
.tip.on { opacity: 1; }
.tip b { font-weight: 650; }
.tip .tip-dim { opacity: .72; }

/* ── Outcome bars ─────────────────────────────────────────────────────── */
.obar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--sunken); gap: 1px; }
.obar > span { height: 100%; transform-origin: left; animation: grow-x .7s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 50ms + 150ms); min-width: 2px; }
.o-ok { background: var(--ok); }
.o-timeout { background: var(--warn); }
.o-oom, .o-error, .o-killed { background: var(--danger); }
.o-unsupported, .o-iteration_limit { background: var(--muted); }
.o-skipped { background: var(--line-strong); }
.olegend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: var(--fs-xs); color: var(--ink-2); }
.olegend span { display: inline-flex; align-items: center; gap: 6px; }
.olegend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.series-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 70px; align-items: center; gap: 12px; padding: 7px 0; font-size: var(--fs-sm); }
.series-row + .series-row { border-top: 1px dashed var(--line); }
.series-row .name { display: flex; align-items: center; gap: 8px; font-weight: 550; min-width: 0; }
.series-row .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.series-row .n { text-align: right; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ── Progress ─────────────────────────────────────────────────────────── */
.progress { height: 8px; border-radius: 999px; background: var(--sunken); overflow: hidden; position: relative; }
.progress > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width var(--t-slow) var(--ease-out); position: relative; overflow: hidden; }
.progress.is-live > span::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent); animation: sheen 1.6s linear infinite; }
.progress.is-done > span { background: var(--ok); }
.progress.is-error > span { background: var(--danger); }
.ring { width: 148px; height: 148px; position: relative; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring .track { stroke: var(--sunken); }
.ring .value { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .6s var(--ease-out), stroke var(--t-med); }
.ring.is-done .value { stroke: var(--ok); }
.ring.is-error .value { stroke: var(--danger); }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-label b { font-family: var(--font-display); font-size: 2rem; font-weight: 650; letter-spacing: -.03em; display: block; line-height: 1; font-variant-numeric: tabular-nums; }
.ring-label span { font-size: var(--fs-xs); color: var(--ink-3); margin-top: 4px; }
.ring.is-done .ring-label b { animation: burst .6s var(--ease-spring); }

/* stepper (wizard) */
.stepper { display: flex; gap: 0; counter-reset: step; margin-bottom: 20px; }
.step { flex: 1; display: flex; align-items: center; gap: 10px; padding: 0 0 12px; position: relative; border: 0; background: none; text-align: left; cursor: pointer; color: var(--ink-3); font-size: var(--fs-md); font-weight: 550; min-width: 0; }
.step::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; border-radius: 3px; background: var(--line); }
.step::before { content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 0; border-radius: 3px; background: var(--accent); z-index: 1; transition: width var(--t-slow) var(--ease-out); }
.step + .step { margin-left: 8px; }
.step-num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 700; border: 1.5px solid var(--line-strong); color: var(--ink-3); flex: none; transition: all var(--t-med) var(--ease-out); }
.step-num svg { width: 14px; height: 14px; stroke-width: 3; }
.step-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step[aria-current="step"] { color: var(--ink); }
.step[aria-current="step"]::before, .step.is-done::before { width: 100%; }
.step[aria-current="step"] .step-num { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.step.is-done { color: var(--ink-2); }
.step.is-done .step-num { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.step:disabled { cursor: not-allowed; }
.wiz-panel { animation: wiz-in var(--t-slow) var(--ease-out); }
.wiz-panel.back { animation-name: wiz-in-back; }
.wiz-foot { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 14px 0; margin-top: 20px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

/* ── Terminal ─────────────────────────────────────────────────────────── */
.terminal { background: var(--code-bg); font: 12.5px/1.65 var(--font-mono); color: var(--ink-2); overflow: auto; padding: 10px 0; height: 460px; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.terminal .line { display: grid; grid-template-columns: 64px 14px minmax(0, 1fr); gap: 10px; padding: 0 16px; animation: line-in var(--t-med) var(--ease-out); }
.terminal .line:hover { background: var(--sunken); }
.terminal .ts { color: var(--ink-3); }
.terminal .lv { text-align: center; color: var(--ink-3); }
.terminal .msg { white-space: pre-wrap; word-break: break-word; color: var(--ink); }
.terminal .l-success .lv, .terminal .l-success .msg { color: var(--ok); }
.terminal .l-error .lv, .terminal .l-error .msg { color: var(--danger); }
.terminal .l-warn .lv, .terminal .l-warn .msg { color: var(--warn); }
.terminal .l-progress .msg { color: var(--ink-2); }
.terminal .empty-line { padding: 24px 16px; color: var(--ink-3); }

/* ── Code ─────────────────────────────────────────────────────────────── */
.codeblock { background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.codeblock-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--line); font: 500 var(--fs-xs) var(--font-mono); color: var(--ink-3); }
.codeblock pre { margin: 0; padding: 14px 16px; overflow: auto; font-size: 12.5px; line-height: 1.6; max-height: 560px; }
.codeblock pre code { background: none; padding: 0; color: var(--ink); }
.cmd { display: flex; align-items: flex-start; gap: 10px; padding: 10px 10px 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--code-bg); }
.cmd code { flex: 1; min-width: 0; background: none; padding: 0; font-size: 12.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; color: var(--ink); margin-top: 3px; }
.cmd .prompt { color: var(--ink-3); font-family: var(--font-mono); font-size: 12.5px; line-height: 1.65; user-select: none; margin-top: 3px; }
.hljs-keyword, .hljs-built_in, .hljs-selector-tag, .hljs-type { color: var(--accent); }
.hljs-string, .hljs-attr, .hljs-symbol { color: var(--ok); }
.hljs-number, .hljs-literal { color: var(--warn); }
.hljs-comment { color: var(--ink-3); font-style: italic; }
.hljs-title, .hljs-title.function_, .hljs-section { color: var(--danger); }
.hljs-params, .hljs-variable { color: var(--ink-2); }

/* CodeMirror themed from tokens */
.editor { height: 520px; border-top: 1px solid var(--line); }
.editor .CodeMirror { height: 100%; }
.cm-s-tb.CodeMirror { background: var(--code-bg); color: var(--ink); font: 13px/1.6 var(--font-mono); }
.cm-s-tb .CodeMirror-gutters { background: var(--code-bg); border-right: 1px solid var(--line); }
.cm-s-tb .CodeMirror-linenumber { color: var(--ink-3); }
.cm-s-tb .CodeMirror-cursor { border-left: 2px solid var(--accent); }
.cm-s-tb .CodeMirror-selected, .cm-s-tb.CodeMirror-focused .CodeMirror-selected { background: var(--accent-soft); }
.cm-s-tb .CodeMirror-activeline-background { background: var(--sunken); }
.cm-s-tb .cm-keyword, .cm-s-tb .cm-atom, .cm-s-tb .cm-builtin { color: var(--accent); }
.cm-s-tb .cm-string, .cm-s-tb .cm-string-2 { color: var(--ok); }
.cm-s-tb .cm-number { color: var(--warn); }
.cm-s-tb .cm-comment { color: var(--ink-3); font-style: italic; }
.cm-s-tb .cm-def, .cm-s-tb .cm-variable-2, .cm-s-tb .cm-meta, .cm-s-tb .cm-tag { color: var(--danger); }
.cm-s-tb .cm-property, .cm-s-tb .cm-attribute { color: var(--accent-hover); }
.cm-s-tb .cm-operator { color: var(--ink-2); }
.cm-s-tb .CodeMirror-matchingbracket { color: var(--ink) !important; background: var(--accent-soft); }

/* ── Pipeline (query phases) ──────────────────────────────────────────── */
.pipeline { display: flex; align-items: stretch; gap: 0; overflow-x: auto; padding-bottom: 4px; }
.phase { position: relative; flex: 1; min-width: 118px; padding: 12px 14px; border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius); animation: rise var(--t-slow) var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 80ms); }
.phase + .phase { margin-left: 26px; }
.phase + .phase::before { content: ""; position: absolute; left: -24px; top: 50%; width: 20px; height: 2px; background: var(--line-strong); }
.phase + .phase::after { content: ""; position: absolute; left: -9px; top: calc(50% - 4px); border: 5px solid transparent; border-left-color: var(--line-strong); }
.phase.is-timed { border-color: var(--accent-line); background: var(--accent-soft); }
.phase-name { font-weight: 600; font-size: var(--fs-md); display: flex; align-items: center; gap: 6px; }
.phase-sub { font-size: var(--fs-xs); color: var(--ink-3); margin-top: 3px; }

/* ── Tree (results explorer) ──────────────────────────────────────────── */
.tree { font-size: var(--fs-md); padding: 6px; }
.tree details > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; cursor: pointer; color: var(--ink); font-weight: 550; user-select: none; }
.tree details > summary::-webkit-details-marker { display: none; }
.tree details > summary:hover { background: var(--sunken); }
.tree details > summary .chev { width: 14px; height: 14px; color: var(--ink-3); transition: transform var(--t-med) var(--ease-out); flex: none; }
.tree details[open] > summary .chev { transform: rotate(90deg); }
.tree details > summary > svg:not(.chev) { width: 15px; height: 15px; color: var(--ink-3); flex: none; }
.tree details > summary .count { margin-left: auto; font-size: 11px; color: var(--ink-3); font-weight: 500; }
.tree .branch { padding-left: 14px; margin-left: 14px; border-left: 1px solid var(--line); }
.tree details[open] > .branch { animation: panel-in var(--t-med) var(--ease-out); }
.tree .leaf { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 7px; color: var(--ink-2); cursor: pointer; font-size: var(--fs-sm); border: 0; background: none; width: 100%; text-align: left; }
.tree .leaf > svg { width: 14px; height: 14px; color: var(--ink-3); flex: none; }
.tree .leaf span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree .leaf:hover { background: var(--sunken); color: var(--ink); }
.tree .leaf[aria-current="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tree .leaf[aria-current="true"] > svg { color: var(--accent); }

/* ── Figures ──────────────────────────────────────────────────────────── */
.fig { display: flex; flex-direction: column; overflow: hidden; }
.fig-thumb { position: relative; aspect-ratio: 16 / 9; background: #fff; border-bottom: 1px solid var(--line); overflow: hidden; }
.fig-thumb iframe, .fig-thumb object { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; pointer-events: none; }
.fig-thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 60%, rgba(0, 0, 0, .04)); }
.fig-meta { padding: 12px 14px; display: flex; align-items: center; gap: 8px; }
.fig-meta .t { font-weight: 600; font-size: var(--fs-sm); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-frame { width: 100%; height: min(78vh, 900px); border: 0; display: block; background: #fff; }

/* ── Empty states ─────────────────────────────────────────────────────── */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 56px 24px; color: var(--ink-2); }
.empty-art { width: 128px; height: 88px; margin-bottom: 4px; }
.empty-art .e { stroke: var(--line-strong); stroke-width: 1.6; fill: none; stroke-dasharray: 4 5; }
.empty-art .n { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.6; }
.empty-art .n.hot { stroke: var(--accent); animation: breathe 2.4s var(--ease-in-out) infinite; transform-box: fill-box; transform-origin: center; }
.empty h3 { font-size: var(--fs-lg); color: var(--ink); }
.empty p { max-width: 50ch; font-size: var(--fs-md); }

/* ── Graph diagrams ───────────────────────────────────────────────────── */
.gdiag { display: block; width: 100%; height: auto; overflow: visible; }
.gdiag .e { stroke: var(--ink-3); stroke-width: 1.2; fill: none; stroke-linecap: round; opacity: .8; transition: stroke var(--t-med); }
.gdiag .n { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; transform-box: fill-box; transform-origin: center; }
.gdiag .loop { stroke: var(--accent); }
.gdiag .tc { stroke: var(--accent); stroke-width: .9; stroke-dasharray: 2.2 2; opacity: .75; }
.gdiag.animate .tc { stroke-dasharray: 2.2 2; stroke-dashoffset: 0; animation: tc-in .6s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 6ms); }
.gdiag.animate .e { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw .8s var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * 10ms + 120ms); }
.gdiag.animate .n { animation: pop var(--t-slow) var(--ease-spring) backwards; animation-delay: calc(var(--i, 0) * 14ms); }
a.card:hover .gdiag .e, .gdiag-wrap:hover .gdiag .e { stroke: var(--accent); }
.gdiag-wrap { background: radial-gradient(circle at 1px 1px, var(--line) 1px, transparent 0) 0 0 / 14px 14px; border-radius: var(--radius); padding: 14px; display: grid; place-items: center; }
.gdiag-wrap .gdiag { max-height: 100%; }
.topo-card { display: flex !important; flex-direction: column; }
.topo-card .gdiag-wrap { display: block; position: relative; aspect-ratio: 16 / 10; min-height: 0; overflow: hidden; margin: 12px 12px 0; }
.topo-card .gdiag { position: absolute; inset: 14px; width: calc(100% - 28px); height: calc(100% - 28px); max-width: none; }
.topo-meta { padding: 12px 16px 16px; }
.topo-meta h3 { font-size: var(--fs-base); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.topo-meta p { font-size: var(--fs-sm); color: var(--ink-3); margin-top: 4px; }
.math-block { padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); overflow-x: auto; }

/* ── Toasts ───────────────────────────────────────────────────────────── */
.toasts { position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 170; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; min-width: 260px; max-width: 420px; padding: 12px 12px 12px 14px; border-radius: 12px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow-lg); font-size: var(--fs-md); animation: toast-in var(--t-slow) var(--ease-spring); }
.toast > svg { width: 17px; height: 17px; flex: none; margin-top: 2px; }
.toast .toast-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast .toast-x { border: 0; background: none; color: inherit; opacity: .6; cursor: pointer; padding: 0; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 5px; }
.toast .toast-x:hover { opacity: 1; }
.toast .toast-x svg { width: 14px; height: 14px; }
.toast.t-success > svg { color: var(--ok); }
.toast.t-error > svg { color: var(--danger); }
.toast.t-warn > svg { color: var(--warn); }
.toast.t-info > svg { color: var(--accent); }
.toast.is-leaving { animation: toast-out var(--t-med) var(--ease-in-out) forwards; }

/* ── Dialog & command palette ─────────────────────────────────────────── */
dialog { border: 0; padding: 0; background: transparent; color: var(--ink); max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); overflow: visible; }
dialog::backdrop { background: var(--scrim); animation: fade-in var(--t-med) var(--ease-out); }
dialog[open] .dialog-card { animation: dialog-in var(--t-slow) var(--ease-spring); }
dialog.is-closing .dialog-card { animation: dialog-out var(--t-fast) var(--ease-in-out) forwards; }
dialog.is-closing::backdrop { animation: fade-out var(--t-fast) forwards; }
.dialog-card { width: 440px; max-width: 100%; max-height: calc(100vh - 24px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; }
.dialog-card.wide { width: min(1100px, calc(100vw - 24px)); }
.dialog-body { padding: 22px; overflow: auto; }
.dialog-body h3 { font-size: var(--fs-lg); margin-bottom: 6px; }
.dialog-body p { color: var(--ink-2); }
.dialog-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 14px; }
.dialog-icon.danger { background: var(--danger-soft); color: var(--danger); }
.dialog-icon svg { width: 20px; height: 20px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; background: var(--surface-2); border-top: 1px solid var(--line); }
.cmdk { width: 600px; }
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.cmdk-input svg { width: 18px; height: 18px; color: var(--ink-3); flex: none; }
.cmdk-input input { flex: 1; min-width: 0; height: 54px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: var(--fs-lg); outline: none; }
.cmdk-list { max-height: min(420px, 60vh); overflow-y: auto; padding: 6px 8px 8px; }
.cmdk-group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); padding: 10px 10px 4px; }
.cmdk-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--ink); cursor: pointer; font-size: var(--fs-md); }
.cmdk-item > svg { width: 16px; height: 16px; color: var(--ink-3); flex: none; }
.cmdk-item .hint { margin-left: auto; white-space: nowrap; }
.cmdk-item mark { background: none; color: var(--accent); font-weight: 650; }
.cmdk-item[aria-selected="true"] { background: var(--accent-soft); }
.cmdk-item[aria-selected="true"] > svg { color: var(--accent); }
.cmdk-foot { display: flex; flex-wrap: wrap; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: var(--fs-xs); color: var(--ink-3); background: var(--surface-2); }
.cmdk-foot span { display: inline-flex; align-items: center; gap: 5px; }
.cmdk-empty { padding: 28px; text-align: center; color: var(--ink-3); }

/* ── Skeletons, callouts ──────────────────────────────────────────────── */
.skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--sunken) 25%, var(--surface-2) 37%, var(--sunken) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease-in-out infinite; }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); font-size: var(--fs-md); color: var(--ink-2); }
.callout > svg { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--accent); }
.callout.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.callout.warn > svg { color: var(--warn); }
.callout.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.callout.danger > svg { color: var(--danger); }
.callout.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.callout.ok > svg { color: var(--ok); }
.callout b { color: var(--ink); }

/* ── Reveal ───────────────────────────────────────────────────────────── */
.reveal { animation: rise .5s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 50ms); }
.chart-box { position: relative; height: 340px; }
.chart-box.tall { height: 420px; }

/* ── Keyframes ────────────────────────────────────────────────────────── */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes panel-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes wiz-in { from { opacity: 0; transform: translateX(24px); } }
@keyframes wiz-in-back { from { opacity: 0; transform: translateX(-24px); } }
@keyframes cell-in { from { opacity: 0; transform: scale(.9); } }
@keyframes line-in { from { opacity: 0; transform: translateX(-6px); } }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes redraw { from { stroke-dashoffset: 40; } to { stroke-dashoffset: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.2); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ping { 0% { opacity: .7; transform: scale(.6); } 80%, 100% { opacity: 0; transform: scale(1.7); } }
@keyframes sheen { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.95); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(28px); } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(12px) scale(.97); } }
@keyframes dialog-out { to { opacity: 0; transform: scale(.98); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes burst { 0% { transform: scale(.6); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes breathe { 50% { transform: scale(1.18); } }
@keyframes tc-in { from { opacity: 0; } }
@keyframes closure-edge { 0%, 8% { opacity: 0; stroke-dashoffset: 18; } 22%, 70% { opacity: 1; stroke-dashoffset: 0; } 88%, 100% { opacity: 0; } }

@view-transition { navigation: auto; }
::view-transition-old(content) { animation: 150ms var(--ease-in-out) both fade-out; }
::view-transition-new(content) { animation: 300ms var(--ease-out) both rise; }

/* ── Motion layer ─────────────────────────────────────────────────────────
   Scroll reveals, pointer spotlight, navigation bar, theme reveal, shared-element page morphs. */
body {
  background:
    radial-gradient(1100px 520px at 78% -12%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 62%),
    radial-gradient(800px 420px at -10% 110%, color-mix(in srgb, var(--accent) 5%, transparent), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
.js [data-stagger]:not(.is-in) > *, .js [data-reveal]:not(.is-in) { opacity: 0; }
[data-stagger].is-in > * { animation: rise .6s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 55ms); }
[data-reveal].is-in { animation: rise .7s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 70ms); }

.card.is-link, a.card, .pick, .spot { isolation: isolate; }
a.card, .card.is-link, .spot { position: relative; }
a.card::before, .card.is-link::before, .pick::before, .spot::before {
  content: ""; position: absolute; inset: -1px; z-index: 2; border-radius: inherit; padding: 1px; pointer-events: none;
  background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--accent) 85%, transparent), transparent 65%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: 0; transition: opacity var(--t-med) var(--ease-out);
}
a.card::after, .card.is-link::after, .spot::after {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--accent) 7%, transparent), transparent 55%);
  opacity: 0; transition: opacity var(--t-med) var(--ease-out);
}
a.card:hover::before, .card.is-link:hover::before, .pick:hover::before, .spot:hover::before,
a.card:hover::after, .card.is-link:hover::after, .spot:hover::after { opacity: 1; }

.btn-primary { overflow: hidden; }
.btn-primary::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .28) 50%, transparent 65%);
  transform: translateX(-120%); transition: transform .7s var(--ease-out);
}
.btn-primary:hover::before { transform: translateX(120%); }

.nav-progress { position: fixed; z-index: 300; top: 0; left: 0; right: 0; height: 2px; pointer-events: none; transform-origin: left; transform: scaleX(0); opacity: 0;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 40%, #fff)); box-shadow: 0 0 10px var(--accent); }
.nav-progress.loading { opacity: 1; animation: navload 6s cubic-bezier(.1, .7, .1, 1) forwards; }
.nav-progress.done { animation: navdone .5s var(--ease-out); }
@keyframes navload { from { transform: scaleX(0); } to { transform: scaleX(.9); } }
@keyframes navdone { 0% { opacity: 1; transform: scaleX(1); } 100% { opacity: 0; transform: scaleX(1); } }

/* theme switch: the new theme grows as a circle (app.js cycleTheme) */
html.theme-switching .sidebar, html.theme-switching .topbar, html.theme-switching .content, html.theme-switching [style*="view-transition-name"] { view-transition-name: none !important; }
html.theme-switching::view-transition-old(root), html.theme-switching::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

/* list → detail morphs: elements with the same view-transition-name on both pages travel between them */
::view-transition-group(*) { animation-duration: .5s; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }
::view-transition-old(*), ::view-transition-new(*) { height: 100%; }

/* topology cards show what their closure adds on hover */
.tc-layer .tc { transition: opacity .45s var(--ease-out); transition-delay: calc(var(--i, 0) * 3ms); }
.tc-layer.is-off .tc { opacity: 0; }
a.card:hover .tc-layer.is-off .tc { opacity: .65; }
a.card:hover .gdiag .n { stroke: var(--accent); transition: stroke var(--t-med); }

/* sparkline */
.spark { display: block; width: 100%; height: 28px; overflow: visible; }
.spark path.l { fill: none; stroke: var(--c, var(--accent)); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.spark path.a { fill: color-mix(in srgb, var(--c, var(--accent)) 14%, transparent); stroke: none; opacity: 0; }
.is-in .spark path.l, .spark.go path.l { animation: draw 1.1s var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * 70ms + 200ms); }
.is-in .spark path.a, .spark.go path.a { animation: fade-in .8s var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * 70ms + 600ms); }
@keyframes fade-in-to { to { opacity: 1; } }
.is-in .spark path.a, .spark.go path.a { animation-name: fade-in-to; }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .split.split-rev { grid-template-columns: minmax(0, 1fr); }
  .search-btn { width: auto; }
  .search-btn .lbl { display: none; }
}
@media (max-width: 900px) {
  :root { --gutter: 16px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(290px, 86vw); height: 100%; transform: translateX(-104%); transition: transform var(--t-slow) var(--ease-out), visibility 0s linear var(--t-slow); visibility: hidden; box-shadow: var(--shadow-lg); padding-top: calc(18px + env(safe-area-inset-top, 0px)); view-transition-name: none; }
  .sidebar.is-open { transform: none; visibility: visible; transition: transform var(--t-slow) var(--ease-out); }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 35; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity var(--t-med); }
  .sidebar.is-open + .sidebar-scrim { opacity: 1; pointer-events: auto; }
  .btn.menu-btn { display: inline-flex; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-art { border-left: 0; border-top: 1px solid var(--line); min-height: 200px; }
  .page-head h1 { font-size: var(--fs-2xl); }
  .topbar .hide-sm { display: none; }
  .series-row { grid-template-columns: 112px minmax(0, 1fr) 56px; }
  .step-text { display: none; }
  .step[aria-current="step"] .step-text { display: block; }
  .terminal { height: 380px; }
  .editor { height: 420px; }
  .chart-box, .chart-box.tall { height: 300px; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .content { padding-top: 20px; }
  .card-body, .card-pad, .hero-copy { padding: 16px; }
  .card-head { padding: 12px 16px; }
  .toasts { left: 16px; right: 16px; align-items: stretch; }
  .toast { min-width: 0; max-width: none; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .terminal .line { grid-template-columns: 14px minmax(0, 1fr); }
  .terminal .ts { display: none; }
  .dl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .dl dd { margin-bottom: 8px; }
}
@media (min-width: 901px) { .sidebar-scrim { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  .gdiag.animate .e { stroke-dashoffset: 0; }
  .closure .c { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

@media print {
  .sidebar, .topbar, .toasts, .page-actions { display: none !important; }
  .app { display: block; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* read-only public copy: no controls that write */
.read-only [data-write] { display: none !important; }
.ro-banner { border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
