/* LLM Variable Lab - styles. Tokens first; every component reads var(--*). */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --surface-3: #e9e8e3;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6b6a65;
  --line: #e1e0d9;
  --line-strong: #c9c8bf;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --accent-wash-2: rgba(42, 120, 214, 0.18);
  --focus: #2a78d6;
  --good: #0ca30c;
  --good-ink: #006300;
  --good-wash: rgba(12, 163, 12, 0.10);
  --warn: #fab219;
  --warn-ink: #7a5000;
  --warn-wash: rgba(250, 178, 25, 0.16);
  --bad: #d03b3b;
  --bad-ink: #b42828;
  --bad-wash: rgba(208, 59, 59, 0.09);
  --btn-primary-bg: #0b0b0b;
  --btn-primary-ink: #ffffff;
  --btn-primary-hover: #2b2b2a;
  --brand-bg: #0b0b0b;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --heat: 42, 120, 214;
  --shadow-card: 0 1px 2px rgba(11, 11, 11, 0.04);
  --shadow-pop: 0 10px 32px rgba(11, 11, 11, 0.14), 0 2px 6px rgba(11, 11, 11, 0.06);
  --radius-s: 6px;
  --radius: 8px;
  --radius-l: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --fast: 140ms;
  --med: 220ms;
}

@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;
    --muted: #9c9a91;
    --line: #2c2c2a;
    --line-strong: #43433f;
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --accent-wash: rgba(57, 135, 229, 0.16);
    --accent-wash-2: rgba(57, 135, 229, 0.26);
    --focus: #5598e7;
    --good: #0ca30c;
    --good-ink: #4cc94c;
    --good-wash: rgba(12, 163, 12, 0.16);
    --warn: #fab219;
    --warn-ink: #fab219;
    --warn-wash: rgba(250, 178, 25, 0.14);
    --bad: #e66767;
    --bad-ink: #f08a8a;
    --bad-wash: rgba(230, 103, 103, 0.14);
    --btn-primary-bg: #ffffff;
    --btn-primary-ink: #0b0b0b;
    --btn-primary-hover: #e4e3dd;
    --brand-bg: #2c2c2a;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --grid: #2c2c2a;
    --axis: #383835;
    --heat: 57, 135, 229;
    --shadow-card: none;
    --shadow-pop: 0 12px 36px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #222220;
  --surface-3: #2c2c2a;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #9c9a91;
  --line: #2c2c2a;
  --line-strong: #43433f;
  --accent: #3987e5;
  --accent-ink: #86b6ef;
  --accent-wash: rgba(57, 135, 229, 0.16);
  --accent-wash-2: rgba(57, 135, 229, 0.26);
  --focus: #5598e7;
  --good: #0ca30c;
  --good-ink: #4cc94c;
  --good-wash: rgba(12, 163, 12, 0.16);
  --warn: #fab219;
  --warn-ink: #fab219;
  --warn-wash: rgba(250, 178, 25, 0.14);
  --bad: #e66767;
  --bad-ink: #f08a8a;
  --bad-wash: rgba(230, 103, 103, 0.14);
  --btn-primary-bg: #ffffff;
  --btn-primary-ink: #0b0b0b;
  --btn-primary-hover: #e4e3dd;
  --brand-bg: #2c2c2a;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --grid: #2c2c2a;
  --axis: #383835;
  --heat: 57, 135, 229;
  --shadow-card: none;
  --shadow-pop: 0 12px 36px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* ------------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-ink); }
code, kbd, .mono { font-family: var(--mono); font-size: 0.92em; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.005em; }
p { margin: 0; }
svg { flex: none; }
.icon { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.icon.sm { width: 14px; height: 14px; vertical-align: -2px; }
.icon.lg { width: 20px; height: 20px; }
.icon.fill { fill: currentColor; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--accent-wash-2); }

.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.good-text { color: var(--good-ink); }
.warn-text { color: var(--warn-ink); }
.bad-text { color: var(--bad-ink); }

/* ------------------------------------------------------------------ app shell: sidebar + main column */

.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100vh;
  padding: 14px 10px 12px;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 12px; color: var(--ink); text-decoration: none; }
.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background:
    linear-gradient(var(--series-1), var(--series-1)) 5px 5px / 9px 3px no-repeat,
    linear-gradient(var(--series-2), var(--series-2)) 5px 10px / 13px 3px no-repeat,
    linear-gradient(var(--series-3), var(--series-3)) 5px 15px / 7px 3px no-repeat,
    var(--brand-bg);
}
.brand-name { font-weight: 600; font-size: 14.5px; white-space: nowrap; }
.sb-nav-wrap { position: relative; flex: 1 1 auto; }
.sb-nav { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 2px; }
.sb-indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  z-index: 0;
  border-radius: var(--radius);
  background: var(--surface-3);
  opacity: 0;
  pointer-events: none;
  transition: transform 340ms var(--ease), width 340ms var(--ease), height 340ms var(--ease), opacity var(--med) var(--ease);
}
.sb-indicator.on { opacity: 1; }
.sb-indicator.no-anim { transition: none; }
.sb-item {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-2);
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.sb-item:hover { background: var(--surface-2); color: var(--ink); }
.sb-item[aria-current="page"] { background: var(--surface-3); color: var(--ink); }
.has-ind .sb-item[aria-current="page"], .has-ind .sb-item[aria-current="page"]:hover { background: transparent; }
.sb-item .icon { width: 17px; height: 17px; }
.sb-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-badge { font-size: 11.5px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.sb-group { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.sb-run { min-width: 0; padding: 2px 10px 8px; }
.sb-run-k { font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.sb-run-t { margin-top: 3px; font-weight: 500; line-height: 1.35; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sb-run-s { display: flex; align-items: center; gap: 6px; margin-top: 5px; font-size: 12px; color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.good { background: var(--good); }
.dot.warn { background: var(--warn); }
.dot.accent { background: var(--accent); }
.dot.bad { background: var(--bad); }
.sb-foot { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.sb-foot-row { display: flex; align-items: center; gap: 6px; }
.sb-foot .key-pill { flex: 1 1 auto; min-width: 0; }
.sb-account { display: flex; align-items: center; gap: 6px; min-width: 0; padding-left: 12px; }
.sb-account-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 30px;
  padding: 0 8px;
  margin-left: -8px;
  border-radius: var(--radius-s);
  font-size: 12.5px;
  color: var(--ink-2);
  text-decoration: none;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.sb-account-name:hover { background: var(--surface-2); color: var(--ink); }
.sb-account-name[aria-current="page"] { background: var(--surface-3); color: var(--ink); }
.sb-account-name .icon { width: 15px; height: 15px; }
.sb-account-name span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-text { overflow: hidden; text-overflow: ellipsis; }
.sb-backdrop { position: fixed; inset: 0; z-index: 79; background: rgba(0, 0, 0, 0.32); }
.main-col { display: flex; flex-direction: column; min-width: 0; }
.mobile-bar { display: none; }

.page-head { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px 16px; padding: 22px 16px 2px; }
.ph-text { flex: 1 1 340px; min-width: 0; }
.ph-eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.page-head h1 { margin-top: 2px; font-size: 21px; line-height: 1.3; word-break: break-word; }
.ph-sub { margin-top: 4px; font-size: 13.5px; color: var(--ink-2); }
.ph-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.save-state { font-size: 12px; color: var(--muted); white-space: nowrap; }
.save-state.error { color: var(--bad-ink); }

.key-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}
.key-pill:hover { background: var(--surface-2); }
.key-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.key-pill.ok .dot { background: var(--good); }
.key-pill.bad .dot { background: var(--bad); }
.key-pill.warn .dot { background: var(--warn); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:active:not(:disabled) { transform: scale(0.92); }
.icon-btn.sm { width: 26px; height: 26px; border-radius: var(--radius-s); }
.icon-btn:disabled { opacity: 0.4; cursor: default; background: transparent; }
.icon-btn.danger:hover { color: var(--bad-ink); background: var(--bad-wash); }

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 12px 16px 0;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius);
  background: var(--surface);
}
.banner.bad { border-left-color: var(--bad); }

main { padding: 16px; }
.tab-panel { min-width: 0; }

/* ------------------------------------------------------------------ cards & forms */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 0;
}
.card-head h2 { font-size: 15px; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 12px 16px 16px; }
.section-label { font-size: 12px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field > .label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.input, .select, .textarea {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.input.lg { height: 42px; padding: 0 12px; font-size: 14.5px; }
.textarea { height: auto; min-height: 64px; padding: 8px 10px; line-height: 1.5; resize: vertical; }
.textarea.code { font-family: var(--mono); font-size: 12.5px; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-wash); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.input.invalid, .textarea.invalid { border-color: var(--bad); }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 0.85; }
.select {
  appearance: none;
  padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.select option { background: var(--surface); color: var(--ink); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; color: var(--ink-2); }
.check input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { background: var(--surface-3); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; background: var(--surface); border-color: var(--line-strong); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: var(--radius-s); gap: 5px; }
.btn.lg { height: 42px; padding: 0 20px; font-size: 14.5px; gap: 8px; }
.btn.primary { background: var(--btn-primary-bg); color: var(--btn-primary-ink); border-color: var(--btn-primary-bg); }
.btn.primary:hover { background: var(--btn-primary-hover); border-color: var(--btn-primary-hover); }
.btn.primary:disabled { background: var(--btn-primary-bg); color: var(--btn-primary-ink); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { color: var(--bad-ink); }
.btn.danger:hover { background: var(--bad-wash); border-color: var(--bad); }

.seg {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.seg button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line-strong); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.badge.accent { background: var(--accent-wash); border-color: transparent; color: var(--accent-ink); }
.badge.good { background: var(--good-wash); border-color: transparent; color: var(--good-ink); }
.badge.warn { background: var(--warn-wash); border-color: transparent; color: var(--warn-ink); }
.badge.bad { background: var(--bad-wash); border-color: transparent; color: var(--bad-ink); }

.issue { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 1.45; }
.issue .icon { margin-top: 1px; }
.issue.error { color: var(--bad-ink); }
.issue.warn { color: var(--warn-ink); }
.issue.info { color: var(--ink-2); }
.issue-list { display: flex; flex-direction: column; gap: 6px; }

/* ------------------------------------------------------------------ setup page: one column of numbered steps */

.setup { display: flex; flex-direction: column; gap: 16px; max-width: 960px; margin: 0 auto; }
#d-lock:empty { display: none; }
.step {
  padding: 22px 24px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
}
.step-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  flex: none;
  transition: background var(--med) var(--ease), border-color var(--med) var(--ease), color var(--med) var(--ease);
}
.step.is-current .step-num { background: var(--accent-wash-2); border-color: var(--accent); color: var(--accent-ink); }
.step-titles { flex: 1 1 auto; min-width: 0; padding-top: 2px; }
.step-titles h2 { font-size: 16.5px; font-weight: 500; line-height: 1.35; }
.step-sub { margin-top: 3px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.step-meta {
  flex: none;
  max-width: 40%;
  margin-top: 3px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.step-meta:empty { display: none; }
.step-body { display: flex; flex-direction: column; gap: 16px; min-width: 0; padding-left: 42px; }

.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.preset {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.preset:hover { border-color: var(--line-strong); background: var(--surface-2); transform: translateY(-1px); }
.preset:active { transform: scale(0.985); }
.preset[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-wash); }
.preset-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.preset-name { font-weight: 500; font-size: 13.5px; }
.preset-desc { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.preset-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  flex: none;
  transform: scale(0);
}
.preset-check .icon { width: 11px; height: 11px; stroke-width: 3; }
.preset[aria-pressed="true"] .preset-check { transform: scale(1); animation: pop 320ms var(--ease); }
.preset-why {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.55;
  animation: fadeUp 260ms var(--ease) backwards;
}
.preset-why strong { color: var(--ink); font-weight: 600; }

.step details.fold { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.step details.fold > summary { gap: 8px; padding: 11px 14px; border-radius: var(--radius); font-weight: 500; transition: background var(--fast) var(--ease); }
.step details.fold > summary:hover { background: var(--surface-2); }
.step details.fold > .fold-body { margin-top: 0; padding: 6px 14px 14px; }
.fold-sum { min-width: 0; margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; font-weight: 400; color: var(--muted); }
.step details.fold::details-content { block-size: 0; overflow: hidden; transition: block-size 280ms var(--ease), content-visibility 280ms allow-discrete; }
.step details.fold[open]::details-content { block-size: auto; }
:root { interpolate-size: allow-keywords; }
.field-grid.wide { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

.cases { display: flex; flex-direction: column; gap: 10px; }
.case {
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.case:hover, .case:focus-within { border-color: var(--line-strong); }
.case-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.case-label { flex: 0 1 200px; height: 32px; }
.case-param { flex: 0 1 200px; min-width: 110px; }
.case-actions { display: flex; gap: 2px; margin-left: auto; }
.case-val { margin-top: 10px; }
.case-val .textarea { min-height: 42px; }
.idx {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  flex: none;
}
.idx::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 2px;
  height: 3px;
  border-radius: 2px;
  background: var(--swatch, transparent);
}
.var-note { padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); color: var(--ink-2); font-size: 13px; }

.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.settings-main { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px 16px; }
.field.disabled-var > label::after { content: " (varied)"; color: var(--accent-ink); font-weight: 500; }

.plan-hero { display: flex; flex-direction: column; gap: 12px; padding: 18px 20px; border-radius: var(--radius-l); background: var(--surface-2); }
.plan-eq { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; font-size: 14px; color: var(--ink-2); }
.plan-eq b { display: inline-block; margin-right: 2px; font-size: 24px; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.plan-eq .x { color: var(--muted); font-size: 18px; }
.plan-eq .total b { color: var(--accent-ink); }
.plan-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--ink-2); font-size: 13px; }
.progress.wide { width: 100%; height: 8px; background: var(--surface-3); }
.start-row { gap: 10px; }

/* model catalog */
.selected-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.selected-models { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.sel-model {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 8px 10px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color var(--fast) var(--ease);
}
.sel-model:hover { border-color: var(--line-strong); }
.sel-model .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-model .sub, .cat-main .sub { display: flex; align-items: baseline; gap: 8px; min-width: 0; margin-top: 1px; }
.company { flex: none; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.sel-model .id { min-width: 0; font-family: var(--mono); font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-model .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.sel-model .actions { display: flex; gap: 2px; }
.empty-note { padding: 14px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); font-size: 13px; text-align: center; }

.catalog { display: flex; flex-direction: column; gap: 10px; padding-top: 18px; border-top: 1px solid var(--line); }
.catalog-title { font-size: 14px; font-weight: 500; }
.catalog-tools { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }

/* Company logo tile: always a light tile, so dark marks stay visible in dark mode. */
.mlogo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 11px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(11, 11, 11, 0.09);
  overflow: hidden;
  user-select: none;
}
.mlogo img { width: 74%; height: 74%; object-fit: contain; }
.mlogo.mono { background: hsl(var(--h, 210) 70% 94%); color: hsl(var(--h, 210) 55% 30%); font-size: 18px; font-weight: 600; }
.mlogo.xl { width: 56px; height: 56px; border-radius: 14px; }
.mlogo.xl.mono { font-size: 24px; }
.model-head { display: flex; align-items: center; gap: 14px; }
.model-head .company { font-size: 14px; font-weight: 500; color: var(--ink); }
.search-wrap { position: relative; }
.search-wrap .icon { position: absolute; left: 10px; top: 9px; color: var(--muted); pointer-events: none; }
.search-wrap .input { padding-left: 32px; }
.catalog-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.catalog-filters .select { width: auto; height: 30px; font-size: 13px; }
.catalog-count { font-size: 12px; color: var(--muted); }
.catalog-list {
  overflow: clip;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.cat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 26px;
  gap: 10px;
  align-items: center;
  padding: 10px 8px 10px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.cat-row:last-child { border-bottom: 0; }
.cat-row { transition: background var(--fast) var(--ease); }
.cat-row:hover { background: var(--surface-2); }
.cat-row[aria-selected="true"] { background: var(--accent-wash); }
.cat-toggle {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.logo-wrap { position: relative; display: inline-flex; flex: none; }
.sel-badge {
  position: absolute;
  right: -5px;
  bottom: -5px;
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 1.5px var(--line-strong);
  color: var(--ink-2);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.sel-badge .icon { width: 11px; height: 11px; stroke-width: 3; }
.cat-row:hover .sel-badge, .cat-toggle:focus-visible .sel-badge { opacity: 1; transform: none; }
.cat-toggle[aria-pressed="true"] .sel-badge { opacity: 1; transform: none; background: var(--accent); box-shadow: 0 0 0 2px var(--surface); color: #fff; animation: pop 320ms var(--ease); }
.cat-main { display: flex; flex-direction: column; min-width: 0; }
.cat-main .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-main .id { min-width: 0; font-family: var(--mono); font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-main .tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.cat-row .right { text-align: right; font-size: 12px; color: var(--ink-2); white-space: nowrap; line-height: 1.5; }
.cat-row .right .muted { font-size: 11.5px; }
.cat-more { padding: 10px; text-align: center; }

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

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar .spacer { flex: 1 1 auto; }
.progress {
  position: relative;
  width: 180px;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress > span { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 999px; transition: width var(--med) var(--ease); }
.progress > span.err { background: var(--bad); }
.run-stats { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }

.matrix-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--surface);
}
.matrix { display: grid; }
.mx-corner, .mx-colhead, .mx-rowhead, .mx-cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mx-corner {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 4;
  background: var(--surface-2);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--muted);
}
.mx-colhead {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface-2);
  padding: 10px 12px;
  min-width: 0;
}
.mx-colhead .lbl, .mx-rowhead .lbl { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 13px; }
.mx-colhead .txt, .mx-rowhead .txt {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.mx-rowhead {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  padding: 10px 12px;
  min-width: 0;
}
.mx-rowhead .id { font-family: var(--mono); font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; background: var(--swatch, var(--muted)); }
.mx-cell { padding: 10px 12px; min-width: 0; display: flex; flex-direction: column; gap: 8px; background: var(--surface); }
.mx-cell:hover { background: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); }
.reps { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.rep {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
}
.rep:hover { border-color: var(--line-strong); color: var(--ink); }
.rep[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); }
.rep .st { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.rep.done .st { background: var(--good); }
.rep.error .st { background: var(--bad); }
.rep.running .st { background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
.rep.queued .st { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
.rep.stale .st { background: var(--warn); }
@keyframes pulse { 50% { opacity: 0.3; } }
.cell-preview {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 7;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}
.cell-preview.empty { color: var(--muted); font-style: italic; }
.cell-state { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.cell-error { font-size: 12.5px; color: var(--bad-ink); word-break: break-word; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.cell-metrics { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cell-metrics b { color: var(--ink-2); font-weight: 500; }
.cell-foot { display: flex; align-items: center; gap: 6px; margin-top: auto; }
.flag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 500; }
.flag.warn { color: var(--warn-ink); }
.flag.bad { color: var(--bad-ink); }
.flag.good { color: var(--good-ink); }
.flag.info { color: var(--accent-ink); }

.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--accent-wash-2); border-top-color: var(--accent); animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.compare-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.compare-controls .select { width: auto; max-width: 340px; }
.compare-wrap { overflow-x: auto; padding-bottom: 6px; }
.compare-cols { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(320px, 400px); gap: 12px; align-items: start; }
.cmp-col { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); min-width: 0; display: flex; flex-direction: column; }
.cmp-head { padding: 12px 14px 10px; border-bottom: 1px solid var(--line); }
.cmp-head .lbl { display: flex; align-items: center; gap: 7px; font-weight: 600; }
.cmp-head .sub { font-size: 11.5px; color: var(--muted); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 14px; }
.cmp-rep { display: flex; flex-direction: column; gap: 8px; }
.cmp-rep + .cmp-rep { border-top: 1px dashed var(--line); padding-top: 12px; }
.cmp-rep-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); }
.dtable { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.dtable th, .dtable td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: top; }
.dtable th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); font-weight: 600; color: var(--ink-2); cursor: pointer; user-select: none; }
.dtable th.sorted { color: var(--ink); }
.dtable td.num, .dtable th.num { text-align: right; font-variant-numeric: tabular-nums; }
.dtable tbody tr { cursor: pointer; }
.dtable tbody tr:hover td { background: var(--surface-2); }
.dtable td.text { white-space: normal; min-width: 260px; max-width: 460px; }
.dtable td.text .clip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ------------------------------------------------------------------ runs page */

.runs-filters { margin-bottom: 12px; }
.runs-search { flex: 1 1 260px; max-width: 440px; }
.runs-total { align-self: center; padding-top: 18px; }
.runs-table th, .runs-table td { padding: 8px; }
.runs-table th:first-child, .runs-table td:first-child { padding-left: 12px; }
.runs-table td { vertical-align: middle; }
.runs-table th.nosort { cursor: default; }
.runs-table td.rt-main { min-width: 180px; max-width: 420px; white-space: normal; }
.rt-title { font-weight: 500; line-height: 1.35; color: var(--ink); }
.rt-sub { margin-top: 2px; font-size: 12px; color: var(--ink-2); }
.runs-table td.rt-wrap { min-width: 110px; max-width: 260px; white-space: normal; }
.runs-table td.rt-status { white-space: nowrap; }
.runs-table td.rt-wrap .clip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.runs-table tbody tr:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.runs-table tr.is-open td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.spinner.xs { width: 10px; height: 10px; border-width: 1.5px; }

.lock-note {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 12px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
}
.lock-note > .icon { color: var(--accent-ink); }
.lock-note .grow { display: flex; flex-direction: column; gap: 2px; flex: 1 1 320px; }
.design-locked .input:disabled, .design-locked .select:disabled, .design-locked .textarea:disabled { color: var(--ink); cursor: default; }
.design-locked .textarea:disabled { resize: none; }
.design-locked .check { cursor: default; }

/* ------------------------------------------------------------------ drawer */

.drawer-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.32); animation: fade var(--med) var(--ease); }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 61;
  width: min(720px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  animation: slide-in 300ms var(--ease);
}
@keyframes slide-in { from { transform: translateX(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } }
.drawer-head { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer-head .titles { min-width: 0; flex: 1 1 auto; }
.drawer-head .t1 { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; flex-wrap: wrap; }
.drawer-head .t2 { font-size: 12px; color: var(--muted); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-body { flex: 1 1 auto; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.drawer-foot { padding: 10px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.metric { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.metric .k { font-size: 11.5px; color: var(--muted); }
.metric .v { font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.block-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.block-head h3 { font-size: 13px; }
.output-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: var(--surface); }
.output-box.raw { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.55; }
.pre {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 360px;
  overflow: auto;
}
details.fold > summary { cursor: pointer; font-weight: 600; font-size: 13px; list-style: none; display: flex; align-items: center; gap: 6px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: ""; width: 0; height: 0; border-top: 4px solid transparent; border-bottom: 4px solid transparent; border-left: 5px solid var(--muted); transition: transform var(--fast) var(--ease); }
details.fold[open] > summary::before { transform: rotate(90deg); }
details.fold > :not(summary) { margin-top: 8px; }

.stars { display: inline-flex; gap: 2px; }
.star {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--line-strong);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.star:hover { background: var(--surface-2); }
.star.on { color: var(--series-4); }
.star .icon { width: 19px; height: 19px; fill: currentColor; stroke: currentColor; stroke-width: 1; }
.star-mini { display: inline-flex; align-items: center; gap: 2px; color: var(--ink-2); font-size: 11.5px; }
.star-mini .icon { width: 12px; height: 12px; fill: var(--series-4); stroke: var(--series-4); stroke-width: 1; }

/* ------------------------------------------------------------------ markdown */

.md { font-size: 14px; line-height: 1.6; word-break: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 0.75em; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin: 1.1em 0 0.45em; line-height: 1.3; }
.md h1 { font-size: 1.35em; }
.md h2 { font-size: 1.2em; }
.md h3 { font-size: 1.07em; }
.md h4, .md h5, .md h6 { font-size: 1em; }
.md ul, .md ol { margin: 0 0 0.75em; padding-left: 1.4em; }
.md li { margin: 0.18em 0; }
.md blockquote { margin: 0 0 0.75em; padding: 2px 12px; border-left: 3px solid var(--line-strong); color: var(--ink-2); }
.md code { padding: 1px 5px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); }
.md pre { margin: 0 0 0.75em; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); overflow: auto; }
.md pre code { padding: 0; border: 0; background: none; font-size: 12.5px; }
.md table { border-collapse: collapse; margin: 0 0 0.75em; font-size: 13px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
.md.report { font-size: 14.5px; }
.md.report h1 { font-size: 1.6em; margin-top: 0; }
.md.report h2 { font-size: 1.3em; padding-top: 0.6em; border-top: 1px solid var(--line); }
.md.report h3 { font-size: 1.08em; }

/* ------------------------------------------------------------------ analysis */

.analysis-grid { display: flex; flex-direction: column; gap: 16px; max-width: 1500px; margin: 0 auto; }
.filters-row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; }
.filters-row .field { min-width: 200px; }
.heat-wrap { overflow: auto; }
.heat { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%; }
.heat th, .heat td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.heat th { font-weight: 600; color: var(--ink-2); background: var(--surface-2); position: sticky; top: 0; }
.heat th:first-child, .heat td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.heat th:first-child { background: var(--surface-2); z-index: 2; }
.heat td.cellv { font-variant-numeric: tabular-nums; cursor: default; }
.heat td .sd { color: var(--muted); font-size: 11.5px; }
.heat td .n { color: var(--muted); font-size: 11px; margin-left: 4px; }
.heat tr.foot td { font-weight: 500; background: var(--surface-2); }
.heat tr.foot td:first-child { background: var(--surface-2); }
.heat .colsep { border-left: 1px solid var(--line-strong); }
.th-inner { display: inline-flex; align-items: center; gap: 6px; }

.chart-card .card-body { padding-top: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 4px 0 10px; font-size: 12.5px; color: var(--ink-2); }
.legend .item { display: inline-flex; align-items: center; gap: 7px; }
.legend .key { width: 12px; height: 12px; border-radius: 3px; background: var(--swatch); }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-svg text { fill: var(--muted); font-size: 11.5px; font-family: var(--font); }
.chart-svg .lbl { fill: var(--ink-2); font-size: 12px; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; }
.chart-svg .axis { stroke: var(--axis); stroke-width: 1; }
.chart-svg .whisker { stroke: var(--ink-2); stroke-width: 1; }
.chart-svg .bar { transition: opacity var(--fast) var(--ease); }
.chart-svg .hit { fill: transparent; cursor: default; }
.chart-svg .hit:focus { outline: none; }
.chart-svg g.mark:hover .bar, .chart-svg g.mark:focus-within .bar { opacity: 0.78; }
.chart-svg g.mark:focus .bar { stroke: var(--ink); stroke-width: 1.5; }

.obs { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--ink-2); }
.obs b { color: var(--ink); font-weight: 600; }

/* ------------------------------------------------------------------ report */

.report-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; max-width: 1400px; margin: 0 auto; align-items: start; }
.report-side { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 12px; }
.report-doc { padding: 28px 36px; }

/* ------------------------------------------------------------------ overlays */

.tooltip {
  position: fixed;
  z-index: 90;
  max-width: 320px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  font-size: 12.5px;
  color: var(--ink-2);
  pointer-events: none;
}
.tooltip .tv { font-size: 14px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.tooltip .tk { display: inline-block; width: 12px; height: 2px; border-radius: 1px; margin-right: 6px; vertical-align: 4px; background: var(--swatch); }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  max-width: 420px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  font-size: 13px;
  animation: toast-in var(--med) var(--ease);
}
.toast.good { border-left-color: var(--good); }
.toast.warn { border-left-color: var(--warn); }
.toast.bad { border-left-color: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.dialog {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-l);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
}
.dialog.wide { width: min(980px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
.dialog-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 15px; flex: 1 1 auto; }
.dialog-body { padding: 16px; overflow: auto; max-height: calc(100vh - 200px); display: flex; flex-direction: column; gap: 12px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }

.empty-state { max-width: 560px; margin: 48px auto; text-align: center; color: var(--ink-2); display: flex; flex-direction: column; gap: 12px; align-items: center; }
.empty-state h2 { font-size: 17px; color: var(--ink); }

/* ------------------------------------------------------------------ section rail: dots right of the sidebar */

.rail {
  position: fixed;
  top: 50%;
  left: calc(240px + 10px);
  z-index: 35;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateY(-50%);
  animation: railIn 380ms var(--ease) backwards;
}
.rail-dot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  padding: 7px 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  animation: fade 300ms var(--ease) backwards;
  animation-delay: calc(var(--i, 0) * 40ms);
}
.rail-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: height 300ms var(--ease), background-color 300ms var(--ease), transform var(--fast) var(--ease);
}
.rail-dot:hover::before { background: var(--muted); transform: scale(1.3); }
.rail-dot[aria-current="true"]::before { height: 24px; background: var(--accent); transform: none; }
.rail-dot:focus-visible { outline: none; }
.rail-dot:focus-visible::before { box-shadow: 0 0 0 2px var(--page), 0 0 0 4px var(--focus); }
.rail-label {
  position: absolute;
  top: 50%;
  left: calc(100% + 2px);
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  color: var(--ink);
  font-size: 12.5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-4px, -50%);
  transition: opacity var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.rail-dot:hover .rail-label, .rail-dot:focus-visible .rail-label { opacity: 1; transform: translate(0, -50%); }
[data-rail] { scroll-margin-top: 16px; }

/* ------------------------------------------------------------------ sign-in page */

.auth { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.auth-aside { display: none; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 600; }
.auth-main { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 72px 20px 40px; background: var(--page); }
.auth-top { position: absolute; top: 16px; right: 16px; }
#theme-btn .when-dark, #theme-btn[data-mode="dark"] .when-light { display: none; }
#theme-btn[data-mode="dark"] .when-dark { display: block; }
.auth-form { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 380px; animation: panelIn 420ms var(--ease) backwards; }
.auth-form.shake { animation: shake 420ms var(--ease); }
.auth-form > .auth-brand { color: var(--ink); margin-bottom: 8px; }
.auth-title h1 { font-size: 26px; line-height: 1.2; letter-spacing: -0.015em; }
.auth-title p { margin-top: 6px; color: var(--ink-2); font-size: 14px; }
.auth-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--bad);
  border-radius: var(--radius);
  background: var(--bad-wash);
  color: var(--bad-ink);
  font-size: 13px;
  line-height: 1.45;
  animation: fadeUp 260ms var(--ease) backwards;
}
.auth-notice.warn { border-color: var(--warn); background: var(--warn-wash); color: var(--warn-ink); }
.auth-notice.info { border-color: var(--line-strong); background: var(--surface-2); color: var(--ink-2); }
.auth-notice .icon { flex: none; margin-top: 1px; }
.auth-notice b { font-weight: 600; font-variant-numeric: tabular-nums; }
.field-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.field-row > label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.caps-hint { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--warn-ink); }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 46px; }
.pw-toggle { position: absolute; top: 5px; right: 5px; }
.pw-toggle .when-shown, .pw-toggle[aria-pressed="true"] .when-hidden { display: none; }
.pw-toggle[aria-pressed="true"] .when-shown { display: block; }
.auth-remember { align-self: flex-start; }
.auth-submit { width: 100%; }
.auth-submit .spinner { display: none; border-color: color-mix(in srgb, currentColor 30%, transparent); border-top-color: currentColor; }
.auth-submit[aria-busy="true"] { cursor: progress; }
.auth-submit[aria-busy="true"] .spinner { display: inline-block; }
.auth-secure { display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 12.5px; color: var(--muted); text-align: center; }

@media (min-width: 960px) {
  .auth { grid-template-columns: minmax(440px, 46%) minmax(0, 1fr); }
  .auth-form > .auth-brand { display: none; }
  /* The panel keeps its dark look in both themes. */
  .auth-aside {
    position: relative;
    display: flex;
    overflow: hidden;
    padding: 40px 52px;
    background: #0e0e0d;
    color: #f4f3ef;
    border-right: 1px solid #22221f;
  }
  .auth-aside::before {
    content: "";
    position: absolute;
    inset: -30% 20% 45% -30%;
    background: radial-gradient(closest-side, rgba(57, 135, 229, 0.22), transparent);
    pointer-events: none;
  }
  .auth-aside .brand-mark { --brand-bg: #262624; }
}
.auth-aside-inner { position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 36px; width: 100%; max-width: 540px; margin: 0 auto; }
.auth-story { display: flex; flex-direction: column; gap: 36px; }
.auth-kicker { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: #8f8d85; }
.auth-pitch h2 { margin-top: 12px; font-size: clamp(30px, 2.7vw, 40px); line-height: 1.12; font-weight: 600; letter-spacing: -0.02em; }
.auth-pitch p:last-child { max-width: 440px; margin-top: 16px; color: #b5b3aa; font-size: 15px; line-height: 1.55; }
.auth-demo { padding: 18px 20px; border: 1px solid #2a2a27; border-radius: 14px; background: #161615; }
.demo-grid { display: grid; grid-template-columns: 118px repeat(3, minmax(0, 1fr)); gap: 12px 14px; align-items: center; }
.demo-col { font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: #8f8d85; }
.demo-model { display: flex; align-items: center; gap: 9px; font-size: 13px; color: #e8e7e2; }
.demo-model .mlogo { width: 26px; height: 26px; border-radius: 7px; }
.demo-bar { position: relative; height: 8px; border-radius: 4px; background: #262624; overflow: hidden; }
.demo-bar > i {
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: var(--c);
  transform-origin: left center;
  transform: scaleX(var(--a));
  animation: demoBar var(--t, 5s) var(--ease) var(--d, 0s) infinite alternate;
}
.auth-points { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; font-size: 13.5px; color: #b5b3aa; }
.auth-points li { display: flex; align-items: center; gap: 10px; }
.auth-points .icon { color: #8fb8ee; }

/* ------------------------------------------------------------------ account page */

.acct { display: flex; flex-direction: column; gap: 16px; max-width: 900px; }
.acct .card-head { flex-wrap: wrap; }
.acct .card-head .sub { flex: 1 1 260px; }
.sess-list, .ev-list, .protect-list { margin: 0; padding: 0; list-style: none; }
.sess { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.sess:first-child { padding-top: 4px; border-top: 0; }
.sess-ic { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); }
.sess-ic .icon { width: 18px; height: 18px; }
.sess.current .sess-ic { background: var(--accent-wash); color: var(--accent-ink); }
.sess-name { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 500; }
.sess-meta { margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.sess.item-out { animation: itemOut 260ms var(--ease) forwards; }
.acct-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding-top: 4px; }
.pw-form { display: grid; gap: 14px; max-width: 440px; }
.pw-meter { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin-top: 2px; }
.pw-meter span { height: 4px; border-radius: 2px; background: var(--surface-3); transition: background-color var(--med) var(--ease); }
.pw-meter[data-score="1"] span:nth-child(1) { background: var(--bad); }
.pw-meter[data-score="2"] span:nth-child(-n+2) { background: var(--warn); }
.pw-meter[data-score="3"] span:nth-child(-n+3) { background: var(--good); }
.pw-meter[data-score="4"] span { background: var(--good); }
.field .pw-meter-text { font-size: 12px; color: var(--muted); }
.field-error { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--bad-ink); }
.field-error .icon { flex: none; margin-top: 2px; }
.ev { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13px; }
.ev:first-child { padding-top: 2px; border-top: 0; }
.ev > .icon { width: 15px; height: 15px; margin-top: 2px; color: var(--muted); }
.ev.good > .icon { color: var(--good-ink); }
.ev.bad > .icon, .ev.bad .ev-what { color: var(--bad-ink); }
.ev-what { font-weight: 500; }
.ev-meta { margin-top: 1px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.ev-time { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.protect-list { display: grid; gap: 10px; }
.protect-list li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; font-size: 13.5px; color: var(--ink-2); }
.protect-list .icon { width: 16px; height: 16px; margin-top: 2px; color: var(--good-ink); }
.acct-off { max-width: 620px; }

/* ------------------------------------------------------------------ motion */

@keyframes panelIn { from { opacity: 0; transform: translateY(8px); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(4px); } }
@keyframes itemIn { from { opacity: 0; transform: translateY(-6px) scale(0.985); } }
@keyframes pop { 0% { transform: scale(0.4); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes bump { 35% { transform: translateY(-3px) scale(1.12); } }
@keyframes rowIn { from { opacity: 0; transform: translateY(6px); } }
@keyframes rowFlash { from { background-color: var(--accent-wash-2); } }
@keyframes railIn { from { opacity: 0; transform: translate(-8px, -50%); } }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
@keyframes demoBar { from { transform: scaleX(var(--a)); } to { transform: scaleX(var(--b)); } }
@keyframes itemOut { to { opacity: 0; transform: translateX(12px); } }

.panel-in { animation: panelIn 340ms var(--ease) backwards; }
.reveal { opacity: 0; transform: translateY(16px); transition: opacity 520ms var(--ease), transform 520ms var(--ease); }
.reveal.is-in { opacity: 1; transform: none; }
.item-in { animation: itemIn 300ms var(--ease) backwards; }
.bump { animation: bump 460ms var(--ease); }
.runs-table tbody tr.rows-in { animation: rowIn 380ms var(--ease) backwards; animation-delay: calc(min(var(--i, 0), 16) * 26ms); }
.rep.fresh .st { animation: pop 420ms var(--ease); }
.cell-preview.fresh { animation: fadeUp 500ms var(--ease) backwards; }
.dtable tr.fresh td { animation: rowFlash 1400ms var(--ease); }
.theme-anim, .theme-anim *, .theme-anim *::before, .theme-anim *::after {
  transition: background-color 380ms var(--ease), border-color 380ms var(--ease), color 380ms var(--ease), fill 380ms var(--ease), stroke 380ms var(--ease), box-shadow 380ms var(--ease) !important;
}

/* ------------------------------------------------------------------ responsive */

@media (min-width: 861px) {
  main { padding-left: 58px; }
  .page-head { padding-left: 58px; }
  .banner { margin-left: 58px; }
}

@media (max-width: 1320px) {
  .report-layout { grid-template-columns: minmax(0, 1fr); }
  .report-side { position: static; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 80;
    width: 280px;
    max-width: 86vw;
    height: 100%;
    box-shadow: var(--shadow-pop);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 300ms var(--ease), visibility 0s linear 300ms;
  }
  body.sb-open .sidebar { transform: none; visibility: visible; transition: transform 300ms var(--ease); }
  .mobile-bar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 50px;
    padding: 0 10px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
  }
  .mobile-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
  .rail { display: none; }
  [data-rail] { scroll-margin-top: 64px; }
}
@media (max-width: 720px) {
  main { padding: 12px; }
  .page-head { padding: 14px 12px 0; }
  .page-head h1 { font-size: 18px; }
  .step { padding: 16px 14px 18px; }
  .step-head { gap: 10px; margin-bottom: 14px; }
  .step-body { padding-left: 0; }
  .step-meta { display: none; }
  .case-head { flex-wrap: wrap; }
  .mlogo { width: 36px; height: 36px; border-radius: 9px; }
  .auth-main { justify-content: flex-start; padding: 64px 16px 32px; }
  .auth-title h1 { font-size: 23px; }
  .cat-toggle { gap: 12px; }
  .case-label { flex: 1 1 140px; }
  .plan-hero { padding: 14px 16px; }
  .plan-eq b { font-size: 20px; }
  .start-row .btn.lg { flex: 1 1 auto; }
  .report-doc { padding: 18px 16px; }
  .progress { width: 100px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
