/* OpenBLUP Studio
 * Colour roles follow one validated palette (categorical slot 1 = blue,
 * sequential blue ramp, blue <-> red diverging with a grey midpoint).
 * Light values first; dark values under the OS preference and the toggle. */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --surface-3: #ebeae4;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.18);
  --hover: rgba(11, 11, 11, 0.045);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --muted-series: #c3c2b7;
  --accent: #2a78d6;
  --accent-strong: #1c5cab;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --on-accent: #ffffff;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --warning-wash: rgba(250, 178, 25, 0.14);
  --critical: #d03b3b;
  --critical-wash: rgba(208, 59, 59, 0.10);
  --code-bg: #f3f2ee;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.04);
  --glow: radial-gradient(900px 420px at 12% -10%, rgba(42, 120, 214, 0.10), transparent 60%),
    radial-gradient(700px 380px at 95% 0%, rgba(235, 104, 52, 0.07), transparent 60%);
  --radius: 12px;
  --radius-sm: 8px;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #222220;
    --surface-3: #2c2c2a;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --ink-3: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --hover: rgba(255, 255, 255, 0.05);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --muted-series: #4a4a46;
    --accent: #3987e5;
    --accent-strong: #6da7ec;
    --accent-wash: rgba(57, 135, 229, 0.16);
    --good-text: #0ca30c;
    --warning-wash: rgba(250, 178, 25, 0.12);
    --critical-wash: rgba(208, 59, 59, 0.16);
    --code-bg: #121211;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25);
    --glow: radial-gradient(900px 420px at 12% -10%, rgba(57, 135, 229, 0.16), transparent 60%),
      radial-gradient(700px 380px at 95% 0%, rgba(217, 89, 38, 0.10), transparent 60%);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #222220;
  --surface-3: #2c2c2a;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --ink-3: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --hover: rgba(255, 255, 255, 0.05);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --muted-series: #4a4a46;
  --accent: #3987e5;
  --accent-strong: #6da7ec;
  --accent-wash: rgba(57, 135, 229, 0.16);
  --good-text: #0ca30c;
  --warning-wash: rgba(250, 178, 25, 0.12);
  --critical-wash: rgba(208, 59, 59, 0.16);
  --code-bg: #121211;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25);
  --glow: radial-gradient(900px 420px at 12% -10%, rgba(57, 135, 229, 0.16), transparent 60%),
    radial-gradient(700px 380px at 95% 0%, rgba(217, 89, 38, 0.10), transparent 60%);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--page);
  background-image: var(--glow);
  background-attachment: fixed;
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 20px;
  background: color-mix(in srgb, var(--page) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 16px; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand b { font-weight: 700; }
.brand-name { font-weight: 500; }
.brand svg { flex: none; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--ink-2); font-size: 12px; white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.badge.ready .dot { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
.badge.error .dot { background: var(--critical); }

.topbar-spacer { flex: 1; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; min-width: 34px; padding: 0 10px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }

/* ---------- shell ---------- */

.shell {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
  max-width: 1680px;
  margin: 0 auto;
  align-items: start;
}

.sidebar {
  position: sticky; top: 76px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
  padding-right: 4px;
  scrollbar-width: thin;
}

.main { min-width: 0; display: flex; flex-direction: column; gap: 16px; }

@media (max-width: 980px) {
  .shell { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .sidebar { position: static; max-height: none; overflow: visible; padding-right: 0; }
  .topbar { padding: 0 16px; }
  .topbar .badge { display: none; }
}

/* ---------- panels & cards ---------- */

.panel, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel { padding: 16px; }

.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.panel-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }
.step {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-wash); color: var(--accent-strong);
  font-size: 12px; font-weight: 700;
}
.panel-head .aside { margin-left: auto; color: var(--ink-3); font-size: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field > label, .field-label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.hint { color: var(--ink-3); font-size: 12px; }

select, input[type="text"], input[type="number"], input[type="search"] {
  height: 34px; padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  min-width: 0;
}
select { padding-right: 28px; }
select:hover, input:hover { border-color: var(--ink-3); }

.row { display: flex; gap: 8px; align-items: center; }
.row > * { min-width: 0; }
.grow { flex: 1; }

/* examples */
.examples { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.example {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left;
  padding: 10px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2);
}
.example:hover { border-color: var(--border-strong); background: var(--surface-3); }
.example[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-wash); }
.example strong { font-size: 13px; line-height: 1.25; }
.example span { font-size: 11.5px; color: var(--ink-2); line-height: 1.3; }
.example svg { color: var(--accent); }

.dropzone {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  border: 1px dashed var(--border-strong);
  color: var(--ink-2); cursor: pointer;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-wash); color: var(--ink); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone svg { flex: none; color: var(--accent); }
.dropzone .file-name { font-weight: 600; color: var(--ink); }

.dataset {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
}
.dataset-title { display: flex; justify-content: space-between; gap: 8px; }
.dataset-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dataset-title span { color: var(--ink-3); white-space: nowrap; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 12.5px; cursor: pointer; white-space: nowrap;
}
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
}
.chip.static { cursor: default; background: var(--surface-2); border-color: var(--border); }
.chip .kind { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.chip[aria-pressed="true"] .kind { color: inherit; opacity: 0.8; }
.chip .count { color: var(--ink-3); font-size: 11.5px; }
.chip .warn { color: var(--critical); font-size: 11.5px; }

.segmented {
  display: inline-flex; padding: 2px; gap: 2px;
  border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border);
}
.segmented button {
  height: 28px; padding: 0 10px; border: 0; border-radius: 7px;
  background: transparent; color: var(--ink-2); cursor: pointer; font-size: 12.5px;
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] {
  background: var(--surface); color: var(--ink); font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
.segmented.block { display: flex; }
.segmented.block button { flex: 1; }

/* random terms */
.term {
  padding: 10px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.term + .term { margin-top: 8px; }
.term .row select { flex: 1; }
.term .times { color: var(--ink-3); font-weight: 600; }
.term code { color: var(--ink-2); }
.term-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.link-btn {
  border: 0; background: none; padding: 4px 0; cursor: pointer;
  color: var(--accent); font-weight: 600; font-size: 12.5px;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--ink-3); font-weight: 500; }
.link-btn.danger:hover { color: var(--critical); }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.options .field { margin: 0; }

.fit-btn {
  width: 100%; height: 44px; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--on-accent);
  font-size: 15px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 6px 18px color-mix(in srgb, var(--accent) 30%, transparent);
}
.fit-btn:hover { background: var(--accent-strong); }
.fit-btn:disabled { opacity: 0.55; cursor: progress; }
.fit-btn kbd {
  font: 11px var(--sans); padding: 1px 6px; border-radius: 5px;
  background: rgba(255, 255, 255, 0.18);
}
.status { margin-top: 10px; font-size: 12.5px; color: var(--ink-2); min-height: 19px; }
.status.error { color: var(--critical); }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* code */
.code {
  position: relative; margin: 0; padding: 12px 14px;
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px;
  overflow-x: auto; white-space: pre; line-height: 1.55; color: var(--ink);
}
.copy-btn {
  position: absolute; top: 6px; right: 6px;
  height: 26px; padding: 0 8px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
  font: 12px var(--sans); cursor: pointer;
}
.copy-btn:hover { color: var(--ink); }

/* ---------- main: hero ---------- */

.hero {
  padding: 40px 36px;
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 32px; align-items: center;
}
.hero h1 { font-size: 40px; line-height: 1.08; letter-spacing: -0.03em; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { color: var(--ink-2); font-size: 15.5px; max-width: 56ch; margin: 14px 0 0; }
.hero ul { margin: 18px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.hero li { display: flex; gap: 10px; align-items: baseline; color: var(--ink-2); }
.hero li::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--accent); flex: none; transform: translateY(-2px); }
.hero-art { width: 100%; height: auto; }
@media (max-width: 1180px) { .hero { grid-template-columns: 1fr; } .hero-art { max-width: 420px; } }
@media (max-width: 560px) { .hero { padding: 24px 18px; } .hero h1 { font-size: 30px; } }

/* ---------- results ---------- */

.results-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 16px 18px;
}
.results-head h2 { font-size: 20px; }
.formula {
  font-family: var(--mono); font-size: 12.5px; color: var(--ink-2);
  padding: 4px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border);
  overflow-x: auto; white-space: nowrap; max-width: 100%;
}
.results-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  cursor: pointer; font-size: 13px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }

.callout {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 14px; border-radius: 10px; font-size: 13px;
  border: 1px solid var(--border);
}
.callout svg { flex: none; margin-top: 2px; }
.callout.warning { background: var(--warning-wash); border-color: color-mix(in srgb, var(--warning) 45%, transparent); }
.callout.warning svg { color: #b57f00; }
.callout.error { background: var(--critical-wash); border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.callout.error svg { color: var(--critical); }
.callout.note { background: var(--surface); color: var(--ink-2); }
.callout.note svg { color: var(--ink-3); }
.callout ul { margin: 0; padding-left: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.tile .label { font-size: 12.5px; color: var(--ink-2); }
.tile .value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
.tile .sub { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.tile .sub.good { color: var(--good-text); }
.tile .sub.bad { color: var(--critical); }
.tile.hero-tile .value { color: var(--ink); }
.meter { height: 6px; border-radius: 3px; background: var(--accent-wash); overflow: hidden; margin-top: 6px; }
.meter > div { height: 100%; border-radius: 3px; background: var(--accent); }

.tabs {
  display: flex; gap: 2px; overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.tabs button {
  height: 40px; padding: 0 14px; border: 0; background: none; cursor: pointer;
  color: var(--ink-2); font-weight: 500; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .count { color: var(--ink-3); font-weight: 400; margin-left: 4px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2 > .span-2 { grid-column: 1 / -1; }
@media (max-width: 1280px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
.stack { display: flex; flex-direction: column; gap: 16px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters label { font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }

/* figures */
.figure { margin: 0; padding: 16px 16px 14px; min-width: 0; }
.figure-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.figure-head h3 { font-size: 14.5px; }
.figure-head p { margin: 2px 0 0; color: var(--ink-2); font-size: 12.5px; }
.figure-head .segmented { margin-left: auto; flex: none; }
.figure-body { min-width: 0; position: relative; }
.figure-foot { margin-top: 8px; color: var(--ink-3); font-size: 12px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 2px 0 10px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.legend i.line { width: 14px; height: 2px; border-radius: 1px; }
.legend b { color: var(--ink); font-weight: 600; }

svg.chart { display: block; overflow: visible; font-family: var(--sans); }
svg.chart text { fill: var(--ink-3); font-size: 11.5px; }
svg.chart text.label { fill: var(--ink-2); font-size: 12px; }
svg.chart text.value { fill: var(--ink); font-size: 12px; font-weight: 600; }
svg.chart text.axis-title { fill: var(--ink-2); font-size: 12px; }
svg.chart text.cell { font-size: 11px; font-weight: 600; }
svg.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
svg.chart .baseline { stroke: var(--baseline); stroke-width: 1; shape-rendering: crispEdges; }
svg.chart .ref { stroke: var(--ink-3); stroke-width: 1; }
svg.chart .mark { fill: var(--series-1); }
svg.chart .mark-stroke { stroke: var(--series-1); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
svg.chart .interval { stroke: var(--series-1); stroke-width: 2; stroke-linecap: round; opacity: 0.4; }
svg.chart .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
svg.chart .whisker { stroke: var(--ink-2); stroke-width: 1.5; }
svg.chart .muted-line { stroke: var(--muted-series); stroke-width: 1.25; fill: none; }
svg.chart .hit { fill: transparent; cursor: default; }
svg.chart .hit:hover, svg.chart .hit:focus, svg.chart .hit.active { fill: var(--hover); outline: none; }
svg.chart .crosshair { stroke: var(--ink-3); stroke-width: 1; pointer-events: none; }
svg.chart .focus-ring { fill: none; stroke: var(--ink); stroke-width: 2; pointer-events: none; }
svg.chart .cell-rect { shape-rendering: crispEdges; }
svg.chart .cell-rect.missing { fill: var(--surface-2); stroke: var(--grid); }
svg.chart .cell-hit:hover, svg.chart .cell-hit:focus { stroke: var(--ink); stroke-width: 2; outline: none; }

.scale-legend { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink-3); margin-top: 8px; }
.scale-legend .ramp { width: 160px; height: 10px; border-radius: 3px; }

/* tables */
.table-wrap { overflow: auto; max-height: 520px; border: 1px solid var(--border); border-radius: 10px; }
table.data { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.data th, table.data td { padding: 7px 10px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--grid); }
table.data th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--ink-2); font-weight: 600; font-size: 12px;
}
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover td { background: var(--hover); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .muted { color: var(--ink-3); }
.flag {
  display: inline-block; padding: 0 6px; border-radius: 5px; font-size: 11px; font-weight: 600;
  background: var(--warning-wash); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--warning) 50%, transparent);
}
.stars { color: var(--ink-2); font-weight: 600; }

/* tooltip */
.tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  min-width: 120px; max-width: 280px;
  padding: 8px 10px; border-radius: 8px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border-strong);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  font-size: 12px;
}
.tooltip .tt-title { color: var(--ink-2); margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; }
.tooltip .tt-row + .tt-row { margin-top: 2px; }
.tooltip .tt-key { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.tooltip .tt-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.tooltip .tt-label { color: var(--ink-2); }

.empty { padding: 36px; text-align: center; color: var(--ink-2); }

.loading-bar { height: 2px; background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 50% 100%; animation: slide 1.1s linear infinite; }
@keyframes slide { from { background-position: -50% 0; } to { background-position: 150% 0; } }
.main.busy .results { opacity: 0.55; transition: opacity 0.15s; }

.foot { color: var(--ink-3); font-size: 12px; text-align: center; padding: 8px 0 24px; }

/* 3D stage */
.stage {
  position: relative; overflow: hidden;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2);
  min-height: 320px;
}
.stage canvas { display: block; width: 100%; outline: none; touch-action: none; }
.stage canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.stage-overlay {
  position: absolute; left: 14px; top: 12px; right: 14px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  pointer-events: none;
}
.stage-caption {
  max-width: 460px; padding: 8px 12px; border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  font-size: 12.5px; color: var(--ink-2);
}
.stage-caption strong { display: block; color: var(--ink); font-size: 13.5px; margin-bottom: 2px; }
.stage-legend {
  padding: 8px 12px; border-radius: 10px; font-size: 11.5px; color: var(--ink-2);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px; min-width: 170px;
}
.stage-legend .ramp { width: 150px; height: 8px; border-radius: 3px; }
.stage-legend .ends { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.stage-legend .key { display: flex; align-items: center; gap: 8px; }
.stage-legend .key i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.stage-legend .key i.dot { width: 9px; height: 9px; border-radius: 50%; }
.stage-status {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--ink-2); font-size: 13px; pointer-events: none;
}
.stage-hint { position: absolute; right: 12px; bottom: 10px; font-size: 11.5px; color: var(--ink-3); pointer-events: none; }
.btn.recording { border-color: var(--critical); color: var(--critical); }
.btn .rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--critical); display: inline-block; }
@media (max-width: 700px) {
  .stage-overlay { flex-direction: column; }
  .stage-legend { display: none; }
}
.stage-status[hidden] { display: none; }
