/* ================================================================
   AI Behavior Research — Lab Notebook design system
   Blue theme only (Light = :root, Dark = [data-theme="dark"]).
   Ported from the design-reference prototype; tone variants removed.
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Geist:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Type */
  --font-sans: 'Geist', ui-sans-serif, system-ui, sans-serif;
  --font-serif: 'Instrument Serif', 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  /* Light theme — cool slate-blue (default) */
  --bg:        oklch(0.970 0.010 240);
  --bg-2:      oklch(0.945 0.013 240);
  --panel:     oklch(0.988 0.006 240);
  --panel-2:   oklch(0.978 0.008 240);
  --ink:       oklch(0.20 0.020 250);
  --ink-2:     oklch(0.34 0.018 250);
  --muted:     oklch(0.54 0.018 250);
  --faint:     oklch(0.70 0.014 245);
  --line:      oklch(0.88 0.014 240);
  --line-2:    oklch(0.92 0.012 240);
  --hover:     oklch(0.93 0.014 240);

  /* Accents — matched chroma 0.13 */
  --accent:        oklch(0.58 0.16 30);   /* vermillion — divergence / deception */
  --accent-soft:   oklch(0.58 0.16 30 / .12);
  --coop:          oklch(0.55 0.10 180);  /* teal — cooperation */
  --coop-soft:     oklch(0.55 0.10 180 / .12);
  --amber:         oklch(0.72 0.13 75);
  --amber-soft:    oklch(0.72 0.13 75 / .15);
  --violet:        oklch(0.55 0.13 285);
  --violet-soft:   oklch(0.55 0.13 285 / .12);

  /* Status */
  --ok:        oklch(0.55 0.10 155);
  --warn:      oklch(0.68 0.14 70);
  --err:       oklch(0.55 0.18 25);

  --radius: 6px;
  --radius-lg: 10px;
  --radius-xl: 14px;

  --shadow-sm: 0 1px 0 oklch(0 0 0 / .04);
  --shadow:    0 1px 0 oklch(0 0 0 / .04), 0 2px 8px oklch(0 0 0 / .04);
  --shadow-lg: 0 10px 40px oklch(0 0 0 / .08);
}

[data-theme="dark"] {
  --bg:        oklch(0.175 0.035 250);
  --bg-2:      oklch(0.215 0.040 250);
  --panel:     oklch(0.225 0.042 250);
  --panel-2:   oklch(0.260 0.045 250);
  --ink:       oklch(0.955 0.010 240);
  --ink-2:     oklch(0.85 0.014 240);
  --muted:     oklch(0.68 0.030 245);
  --faint:     oklch(0.50 0.035 248);
  --line:      oklch(0.34 0.040 250);
  --line-2:    oklch(0.30 0.040 250);
  --hover:     oklch(0.30 0.045 250);

  --accent:        oklch(0.72 0.17 30);
  --accent-soft:   oklch(0.72 0.17 30 / .18);
  --coop:          oklch(0.72 0.12 180);
  --coop-soft:     oklch(0.72 0.12 180 / .18);
  --amber:         oklch(0.80 0.14 75);
  --amber-soft:    oklch(0.80 0.14 75 / .20);
  --violet:        oklch(0.72 0.14 285);
  --violet-soft:   oklch(0.72 0.14 285 / .20);

  --ok:        oklch(0.72 0.13 155);
  --warn:      oklch(0.78 0.14 70);
  --err:       oklch(0.70 0.18 25);

  --shadow-sm: 0 1px 0 oklch(0 0 0 / .25);
  --shadow:    0 1px 0 oklch(0 0 0 / .25), 0 4px 16px oklch(0 0 0 / .35);
  --shadow-lg: 0 16px 50px oklch(0 0 0 / .55);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
}

button { font-family: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App shell ────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 224px 1fr;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sb {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sb-brand {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 6px 18px;
  text-decoration: none; color: inherit;
}
.sb-brand:hover { text-decoration: none; }
.sb-brand-mark {
  width: 22px; height: 22px;
  border-radius: 5px;
  background: var(--ink);
  position: relative;
  display: grid; place-items: center;
}
.sb-brand-mark::before, .sb-brand-mark::after {
  content: "";
  position: absolute;
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--bg);
}
.sb-brand-mark::before { left: 4px; top: 6px; }
.sb-brand-mark::after  { right: 4px; bottom: 6px; background: var(--accent); }
.sb-brand-name {
  font-family: var(--font-serif);
  font-size: 18px;
  letter-spacing: -0.01em;
  line-height: 1;
}
.sb-brand-name em { font-style: italic; }
.sb-brand-sub {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 2px;
}

.sb-section {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  padding: 14px 8px 6px;
}
.sb-nav { display: flex; flex-direction: column; gap: 1px; }
.sb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px;
  border-radius: 5px;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 13px;
  position: relative;
  text-decoration: none;
}
.sb-item:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.sb-item.is-active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.sb-item.is-active::before {
  content: "";
  position: absolute; left: -12px; top: 9px; bottom: 9px;
  width: 2px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.sb-icon {
  width: 14px; height: 14px;
  display: inline-grid; place-items: center;
  color: var(--muted);
  flex-shrink: 0;
}
.sb-item.is-active .sb-icon { color: var(--ink); }
.sb-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
}
.sb-spacer { flex: 1; }

.sb-status {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px;
  margin: 0 -2px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 11.5px;
}
.sb-status-row {
  display: flex; justify-content: space-between; align-items: center;
  color: var(--muted);
}
.sb-status-row b {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--ink);
  font-size: 11px;
}
.sb-logout { margin-top: 10px; width: 100%; justify-content: center; }
.sb-logout form { margin: 0; width: 100%; }

/* ── Header ──────────────────────────────────────────────────── */
.hd {
  display: flex; align-items: center;
  height: 52px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky; top: 0; z-index: 30;
  gap: 14px;
}
.crumbs {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.crumb { color: var(--muted); cursor: default; text-decoration: none; }
.crumb:hover { color: var(--ink); text-decoration: none; }
.crumb.is-last { color: var(--ink); font-weight: 500; }
.crumb-sep {
  font-family: var(--font-mono);
  color: var(--faint);
  font-size: 11px;
}

.hd-search {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: text;
  min-width: 220px;
}
.hd-search:hover { border-color: var(--line); background: var(--panel-2); }
.hd-kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--faint);
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg);
}
.hd-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-2);
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
}
.hd-btn:hover { background: var(--hover); }
.hd-btn.is-primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.hd-btn.is-primary:hover { opacity: 0.9; }

/* ── Main content ─────────────────────────────────────────────── */
.main { min-width: 0; min-height: 100vh; display: flex; flex-direction: column; }
.view { padding: 28px 32px 80px; max-width: 1320px; }
.view-wide { max-width: none; }
.view h1.page-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0 0 4px;
}
.view h1.page-title em { font-style: italic; color: var(--accent); }
.view .page-sub {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0 0 26px;
  max-width: 640px;
}

/* ── Atoms ───────────────────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  border-radius: 3px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  white-space: nowrap;
  line-height: 1.5;
}
.tag.accent  { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tag.coop    { background: var(--coop-soft); color: var(--coop); border-color: transparent; }
.tag.amber   { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.tag.violet  { background: var(--violet-soft); color: var(--violet); border-color: transparent; }
.tag.dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.ok    { color: var(--ok); }
.status.run   { color: var(--amber); }
.status.run::before { animation: pulse 1.6s ease-in-out infinite; }
.status.err   { color: var(--err); }
.status.draft { color: var(--muted); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.serif-num {
  font-family: var(--font-serif);
  font-feature-settings: "lnum";
  font-variant-numeric: lining-nums;
}

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover { opacity: 0.9; }
.btn-accent { background: var(--accent); color: white; border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--hover); }
.btn-sm { padding: 3px 8px; font-size: 11.5px; }

.input, .select, .textarea {
  width: 100%;
  padding: 7px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 13px;
  outline: none;
  transition: border-color .12s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--ink); background: var(--panel-2); }
.input.mono { font-family: var(--font-mono); font-size: 12.5px; }
.textarea { min-height: 64px; resize: vertical; font-family: inherit; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

/* ── Studies list ─────────────────────────────────────────────── */
.studies-toolbar { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.studies-filter {
  display: flex; gap: 1px; padding: 2px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 7px;
}
.studies-filter button {
  padding: 4px 11px; background: transparent;
  border: 0; border-radius: 5px; font-size: 12px; color: var(--muted); cursor: pointer;
}
.studies-filter button.is-on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow-sm); }

.studies-list {
  display: grid; grid-template-columns: 1fr;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); overflow: hidden;
}
.studies-row {
  display: grid;
  grid-template-columns: minmax(280px, 2fr) 130px 130px 110px 130px 90px;
  gap: 24px; padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  align-items: center; cursor: pointer; text-decoration: none; color: inherit;
}
.studies-row:last-child { border-bottom: 0; }
.studies-row:hover { background: var(--panel-2); text-decoration: none; }
.studies-row.header {
  background: var(--bg-2); padding: 8px 18px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted); cursor: default;
}
.studies-row.header:hover { background: var(--bg-2); }
.study-name { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.study-name b { font-weight: 500; font-size: 14px; letter-spacing: -0.005em; }
.study-name .hint { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bar { position: relative; height: 4px; border-radius: 2px; background: var(--bg-2); overflow: hidden; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ink); border-radius: 2px; }
.bar.coop > i { background: var(--coop); }
.bar.accent > i { background: var(--accent); }
.bar.amber > i { background: var(--amber); }

/* ── Config layout ───────────────────────────────────────────── */
.cfg { display: grid; grid-template-columns: 220px 1fr 280px; gap: 28px; align-items: start; }
.cfg-toc { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 2px; padding-top: 4px; }
.cfg-toc-item {
  display: flex; align-items: baseline; gap: 10px; padding: 5px 8px;
  border-radius: 5px; font-size: 12.5px; color: var(--muted); cursor: pointer; text-decoration: none;
}
.cfg-toc-item:hover { color: var(--ink); text-decoration: none; }
.cfg-toc-item.is-on { color: var(--ink); background: var(--hover); }
.cfg-toc-item .n { font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); width: 18px; }
.cfg-toc-item.is-on .n { color: var(--accent); }

.cfg-sections { display: flex; flex-direction: column; gap: 22px; }
.cfg-section {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 22px 24px 24px;
}
.cfg-section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 0 0 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.cfg-section-head .num-tag {
  font-family: var(--font-mono); font-size: 10.5px; color: var(--faint);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.cfg-section h2 {
  font-family: var(--font-serif); font-weight: 400; font-size: 22px;
  letter-spacing: -0.01em; margin: 4px 0 0;
}
.cfg-row {
  display: grid; grid-template-columns: 200px 1fr; gap: 24px; padding: 14px 0;
  border-bottom: 1px dashed var(--line); align-items: start;
}
.cfg-row:last-child { border-bottom: 0; }
.cfg-row > .lbl { padding-top: 8px; }
.cfg-row .lbl-name { font-weight: 500; font-size: 13px; color: var(--ink); }
.cfg-row .lbl-hint { color: var(--muted); font-size: 12px; margin-top: 2px; }

.cfg-side { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 14px; }
.cfg-summary { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; }
.cfg-summary h3 {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); margin: 0 0 12px; font-weight: 600;
}
.cfg-summary-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px;
}
.cfg-summary-row:last-child { border-bottom: 0; }
.cfg-summary-row .v { font-family: var(--font-mono); font-size: 12px; color: var(--ink); }
.cfg-cost { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; }
.cfg-cost .big { font-family: var(--font-serif); font-size: 32px; line-height: 1; letter-spacing: -0.015em; }
.cfg-cost .big em { font-style: italic; color: var(--muted); font-size: 18px; }
.cfg-cost .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.range-row { display: flex; align-items: center; gap: 12px; }
.range {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 2px; background: var(--bg-2); outline: none;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--ink); border: 2px solid var(--bg);
  box-shadow: 0 1px 2px oklch(0 0 0 / .2); cursor: pointer;
}
.range-val { font-family: var(--font-mono); font-size: 12px; min-width: 50px; text-align: right; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--panel); }
.stepper button { width: 28px; height: 30px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.stepper button:hover { color: var(--ink); background: var(--hover); }
.stepper input { width: 56px; height: 30px; border: 0; background: transparent; text-align: center; font-family: var(--font-mono); font-size: 12.5px; outline: none; }

.probs { display: flex; flex-direction: column; gap: 14px; margin-top: 2px; }
.prob { display: grid; grid-template-columns: 140px 1fr 60px; gap: 14px; align-items: center; }
.prob-track { display: flex; height: 24px; border-radius: 6px; overflow: hidden; background: var(--bg-2); border: 1px solid var(--line); }
.prob-track > div { display: grid; place-items: center; font-family: var(--font-mono); font-size: 10.5px; color: white; position: relative; transition: flex .2s; }
.prob-track > div:last-child { color: var(--ink); background: var(--bg-2); }

.modelpool { display: flex; flex-direction: column; gap: 8px; }
.modelpool-search { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-2); }
.modelpool-search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 13px; }
.modelpool-list { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.model-row {
  display: grid; grid-template-columns: 24px minmax(180px, 1.4fr) 110px 80px 100px 70px 90px;
  gap: 14px; padding: 9px 12px; border-bottom: 1px solid var(--line); align-items: center; font-size: 12.5px;
}
.model-row:last-child { border-bottom: 0; }
.model-row:hover { background: var(--panel-2); }
.model-row.is-on { background: var(--panel-2); }
.model-name { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.model-name b { font-weight: 500; font-size: 13px; }
.model-name .id { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }
.model-provider { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.04em; color: var(--muted); }
.check {
  width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--line);
  background: var(--panel); display: grid; place-items: center; cursor: pointer;
}
.check.is-on { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* ── Live Monitor ─────────────────────────────────────────────── */
.mon-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.mon-tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; }
.mon-tile .label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.mon-tile .v { font-family: var(--font-serif); font-size: 30px; line-height: 1.1; letter-spacing: -0.01em; margin-top: 4px; }
.mon-tile .v em { font-style: italic; color: var(--muted); font-size: 16px; }
.mon-tile .delta { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-top: 4px; }
.mon-tile .delta.up { color: var(--ok); }
.mon-tile .delta.dn { color: var(--err); }

.mon-cols { display: grid; grid-template-columns: 1fr 360px; gap: 14px; }
.mon-stream { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.mon-stream-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.mon-stream-head h3 { margin: 0; font-family: var(--font-serif); font-weight: 400; font-size: 18px; }
.mon-row {
  display: grid; grid-template-columns: 90px 1fr 1fr 70px 90px 60px; gap: 14px;
  padding: 9px 18px; border-bottom: 1px solid var(--line); align-items: center;
  font-size: 12.5px; text-decoration: none; color: inherit;
}
.mon-row:last-child { border-bottom: 0; }
.mon-row.linkable { cursor: pointer; }
.mon-row.linkable:hover { background: var(--panel-2); text-decoration: none; }
.mon-row .gid { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.mon-row.is-running { background: oklch(from var(--amber) l c h / .04); }
.mon-row.is-err { background: oklch(from var(--err) l c h / .04); }
.mon-row.header { background: var(--bg-2); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.mon-side { display: flex; flex-direction: column; gap: 14px; }
.spark { height: 50px; width: 100%; display: block; }

/* ── Data browser ─────────────────────────────────────────────── */
.db { display: grid; grid-template-columns: 260px 1fr; gap: 18px; align-items: start; }
.db-filters { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 16px 18px; position: sticky; top: 80px; }
.db-filters h3 { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.db-filter-group { border-bottom: 1px dashed var(--line); padding: 8px 0; }
.db-filter-group:last-child { border-bottom: 0; }
.db-filter-group .title { font-size: 12px; font-weight: 500; margin: 0 0 6px; display: flex; justify-content: space-between; color: var(--ink-2); }
.db-filter-group .opts { display: flex; flex-direction: column; gap: 3px; }
.db-opt { display: flex; align-items: center; gap: 8px; padding: 3px 4px; font-size: 12px; color: var(--muted); cursor: pointer; border-radius: 4px; }
.db-opt:hover { color: var(--ink); }
.db-opt.is-on { color: var(--ink); }
.db-opt .check { width: 13px; height: 13px; }
.db-opt .check svg { width: 9px; height: 9px; }
.db-opt .ct { margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); }

.db-main { display: flex; flex-direction: column; gap: 14px; }
.db-table { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.db-tr {
  display: grid; grid-template-columns: 70px minmax(180px, 1fr) minmax(180px, 1fr) 90px 80px 80px 90px 80px;
  gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); align-items: center;
  font-size: 12.5px; text-decoration: none; color: inherit;
}
.db-tr:last-child { border-bottom: 0; }
.db-tr.linkable { cursor: pointer; }
.db-tr.linkable:hover { background: var(--panel-2); text-decoration: none; }
.db-tr.header { background: var(--bg-2); padding: 8px 16px; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); cursor: default; }
.db-tr.header:hover { background: var(--bg-2); }
.db-tr .gid { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.db-tr .matchup { display: flex; align-items: center; gap: 6px; min-width: 0; }
.db-tr .matchup .vs { font-family: var(--font-mono); color: var(--faint); font-size: 10px; }
.model-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px; background: var(--bg-2); border-radius: 4px; font-size: 11.5px; white-space: nowrap; }
.provider-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; display: inline-block; }

/* ── Game replay — TRUTH GAP TIMELINE (hero) ─────────────────── */
.replay { display: grid; grid-template-columns: 1fr; gap: 18px; }
.replay-hero { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-xl); padding: 22px 26px 28px; position: relative; overflow: hidden; }
.replay-meta { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.replay-meta .gid { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.replay-conditions { display: flex; gap: 6px; flex-wrap: wrap; }

.players { display: grid; grid-template-columns: 1fr 60px 1fr; gap: 0; margin-bottom: 22px; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.player { display: flex; flex-direction: column; gap: 6px; padding: 0 16px; }
.player.right { text-align: right; align-items: flex-end; }
.player .role { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.player .name { font-family: var(--font-serif); font-size: 24px; line-height: 1.1; letter-spacing: -0.01em; }
.player .name em { font-style: italic; }
.player .id { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.player .score { font-family: var(--font-serif); font-size: 38px; line-height: 1; margin-top: 6px; letter-spacing: -0.02em; }
.player .score-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; color: var(--faint); text-transform: uppercase; }
.versus { display: grid; place-items: center; font-family: var(--font-serif); font-style: italic; font-size: 26px; color: var(--muted); }

.tg { position: relative; height: 280px; padding: 20px 20px 28px; margin: 0 -8px; }
.tg-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.tg-axis-label { font-family: var(--font-mono); font-size: 10px; fill: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.tg-grid-line { stroke: var(--line); stroke-dasharray: 2 4; }
.tg-grid-num { font-family: var(--font-mono); font-size: 10px; fill: var(--faint); }

.tg-legend { display: flex; gap: 20px; margin-top: 8px; padding-left: 8px; flex-wrap: wrap; }
.tg-legend-item { display: inline-flex; align-items: center; gap: 7px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.tg-legend-swatch { width: 16px; height: 4px; border-radius: 2px; }
.tg-legend-swatch.dashed { height: 2px; background-image: linear-gradient(to right, currentColor 50%, transparent 50%); background-size: 6px 100%; background-color: transparent !important; color: currentColor; }

.transcript { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: var(--panel); }
.round-block { border-bottom: 1px solid var(--line); padding: 16px 22px 18px; scroll-margin-top: 96px; }
.round-block:last-child { border-bottom: 0; }
.round-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; gap: 12px; }
.round-head .n { font-family: var(--font-serif); font-size: 22px; letter-spacing: -0.01em; }
.round-head .n em { color: var(--muted); font-style: italic; font-size: 14px; margin-left: 6px; }
.round-head .right { display: flex; gap: 10px; align-items: center; }

.round-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.side { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.side-head { display: flex; align-items: center; justify-content: space-between; }
.side-head .who { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.05em; color: var(--muted); text-transform: uppercase; }
.side-head .contrib { font-family: var(--font-serif); font-size: 22px; letter-spacing: -0.01em; }
.side-head .contrib em { color: var(--muted); font-style: italic; font-size: 13px; }

.msg, .rationale { font-size: 12.5px; line-height: 1.55; border-radius: 6px; padding: 8px 10px; position: relative; }
.msg { background: var(--bg); border: 1px solid var(--line); }
.msg-tag, .rationale-tag { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.msg .msg-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--coop); }
.rationale { background: oklch(from var(--ink) l c h / .04); border: 1px dashed var(--ink-2); font-style: italic; color: var(--ink-2); }
[data-theme="dark"] .rationale { background: oklch(from var(--ink) l c h / .08); }
.rationale .rationale-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-2); }

.deception-flag { display: inline-flex; align-items: center; gap: 5px; background: var(--accent-soft); color: var(--accent); padding: 2px 8px; border-radius: 4px; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.04em; text-transform: uppercase; }
.raw-bar { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; padding: 8px 22px; background: var(--bg-2); border-top: 1px solid var(--line); font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

/* ── Command Palette ─────────────────────────────────────────── */
.cmdk-backdrop { position: fixed; inset: 0; background: oklch(0 0 0 / .25); backdrop-filter: blur(4px); z-index: 100; display: grid; place-items: start center; padding-top: 12vh; }
.cmdk { width: 560px; max-width: calc(100vw - 40px); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; }
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.cmdk-input input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 15px; color: var(--ink); }
.cmdk-list { max-height: 380px; overflow-y: auto; padding: 6px; }
.cmdk-group-title { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 8px 10px 4px; }
.cmdk-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.cmdk-item:hover, .cmdk-item.is-on { background: var(--hover); color: var(--ink); }
.cmdk-item .kbd { margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; color: var(--faint); }

/* small SVG icons */
.icon { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* misc */
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.scroll-x { overflow-x: auto; }

.barpair { display: flex; flex-direction: column; gap: 3px; font-family: var(--font-mono); font-size: 10.5px; }
.barpair .lbl { color: var(--muted); display: flex; justify-content: space-between; }
.barpair .track { height: 4px; border-radius: 2px; background: var(--bg-2); position: relative; }
.barpair .track > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; }
.barpair .track > i.said { background: var(--coop); }
.barpair .track > i.did  { background: var(--accent); }

@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadein .2s ease-out; }

/* ================================================================
   App extensions — themed primitives for the real data pages
   (tables, filters, forms, raw-call details, analytics, login).
   ================================================================ */

.detail-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.detail-card > h2 { font-family: var(--font-serif); font-weight: 400; font-size: 20px; letter-spacing: -0.01em; margin: 0 0 12px; }
.detail-card > h3 { font-family: var(--font-serif); font-weight: 400; font-size: 17px; margin: 18px 0 8px; }
.detail-card p { margin: 4px 0; }
.call-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.call-card > h3 { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; font-weight: 600; }

.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th { text-align: left; padding: 8px 10px; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--bg-2); white-space: nowrap; }
.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table tbody tr:hover td { background: var(--panel-2); }
.data-table code { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-2); }
.data-table pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0 0; background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; padding: 10px; font-family: var(--font-mono); font-size: 10.5px; max-height: 320px; overflow: auto; }
.data-table details summary { cursor: pointer; color: var(--muted); font-family: var(--font-mono); font-size: 11px; }
.row-contaminated td { background: oklch(from var(--accent) l c h / .06) !important; }
.row-contaminated:hover td { background: oklch(from var(--accent) l c h / .10) !important; }
.status-chip { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 3px; font-family: var(--font-mono); font-size: 10.5px; background: var(--bg-2); border: 1px solid var(--line); color: var(--ink-2); }
.status-header { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); font-size: 12.5px; color: var(--muted); }
.status-header .status-chip { font-size: 11px; padding: 3px 10px; }

/* ── Stat tiles (study overview headline figures) ─────────── */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.stat-tile .st-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.stat-tile .st-value { font-family: var(--font-serif); font-size: 26px; line-height: 1.05; letter-spacing: -0.015em; color: var(--ink); margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-tile .st-value.small { font-size: 17px; }
.stat-tile .st-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.stat-tile.tile-coop { border-color: oklch(from var(--coop) l c h / .35); }
.stat-tile.tile-coop .st-value { color: var(--coop); }
.stat-tile.tile-accent { border-color: oklch(from var(--accent) l c h / .35); }
.stat-tile.tile-accent .st-value { color: var(--accent); }

/* ── Key-value definition grid (config groups) ────────────── */
.cfg-block { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px 28px; align-items: start; }
.cfg-group { min-width: 0; }
.cfg-group-head { display: flex; align-items: baseline; gap: 8px; margin: 4px 0 10px; padding-bottom: 7px; border-bottom: 1px solid var(--line); }
.cfg-group-head .gh-title { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-2); font-weight: 600; }
.cfg-group-head .gh-count { font-family: var(--font-mono); font-size: 10px; color: var(--faint); }
.kv-list { display: flex; flex-direction: column; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: baseline; padding: 5px 0; border-bottom: 1px dotted var(--line-2); }
.kv:last-child { border-bottom: 0; }
.kv .k { font-size: 12.5px; color: var(--muted); }
.kv .v { font-family: var(--font-mono); font-size: 12px; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kv .v.warn-note { color: var(--warn); font-family: var(--font-sans); font-style: italic; font-size: 11.5px; }
.kv .v.is-on { color: var(--ok); }
.kv .v.is-off { color: var(--muted); }
.kv-wide { grid-column: 1 / -1; }
.kv-wide .v { text-align: left; margin-top: 4px; display: block; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* ── Export builder ───────────────────────────────────────── */
.export-layout { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; }
.export-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.cfg-section-hint { color: var(--muted); font-size: 12.5px; margin: -8px 0 14px; }

.opt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.opt-card { display: flex; gap: 11px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel-2); cursor: pointer; transition: border-color .12s ease, background .12s ease; font-weight: 400; }
.opt-card:hover { border-color: var(--ink-2); }
.opt-card:has(input:checked) { border-color: var(--ink); background: var(--hover); }
.opt-card input[type=checkbox] { margin: 1px 0 0; flex: none; accent-color: var(--ink); width: 15px; height: 15px; }
.opt-card .oc-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.opt-card .oc-title { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--ink); }
.opt-card .oc-desc { font-size: 11.5px; color: var(--muted); line-height: 1.45; }

.export-side { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 14px; }
.export-summary { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-sm); }
.export-summary h3 { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; font-weight: 600; }
.sum-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dotted var(--line-2); font-size: 12.5px; color: var(--muted); }
.sum-row:last-of-type { border-bottom: 0; }
.sum-row .v { font-family: var(--font-mono); font-size: 12px; color: var(--ink); font-variant-numeric: tabular-nums; }
.sum-row .v.muted { color: var(--muted); }

.estimate-box { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-top: 12px; }
.estimate-box .big { font-family: var(--font-serif); font-size: 26px; line-height: 1; letter-spacing: -0.015em; color: var(--ink); }
.estimate-box .big em { font-style: normal; color: var(--muted); font-size: 14px; }
.estimate-grid { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin-top: 10px; font-size: 11.5px; color: var(--muted); }
.estimate-grid .v { font-family: var(--font-mono); color: var(--ink-2); text-align: right; }

.export-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.export-actions .btn { width: 100%; justify-content: center; }
.export-hint { font-size: 11.5px; color: var(--muted); margin-top: 8px; text-align: center; }

/* ── Generic UI primitives used by the export page ────────── */
.btn-secondary { background: var(--panel); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--hover); }
.info-box { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 14px; font-size: 12.5px; color: var(--ink-2); }
.info-box p { margin: 2px 0; }
.info-box.success { border-color: oklch(from var(--ok) l c h / .4); background: oklch(from var(--ok) l c h / .08); color: var(--ok); }
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.02em; border: 1px solid var(--line); background: var(--bg-2); color: var(--ink-2); }
.badge-success { color: var(--ok); border-color: oklch(from var(--ok) l c h / .4); background: oklch(from var(--ok) l c h / .1); }
.badge-error { color: var(--err); border-color: oklch(from var(--err) l c h / .4); background: oklch(from var(--err) l c h / .1); }
.badge-info { color: var(--amber); border-color: oklch(from var(--amber) l c h / .4); background: oklch(from var(--amber) l c h / .12); }
.badge-neutral { color: var(--muted); }
.text-danger { color: var(--err); font-size: 12px; }
.data-table progress { width: 100px; height: 6px; border: none; border-radius: 3px; overflow: hidden; background: var(--bg-2); }
.data-table progress::-webkit-progress-bar { background: var(--bg-2); border-radius: 3px; }
.data-table progress::-webkit-progress-value { background: var(--amber); border-radius: 3px; }
.data-table progress::-moz-progress-bar { background: var(--amber); border-radius: 3px; }

@media (max-width: 900px) {
  .export-layout { grid-template-columns: 1fr; }
  .export-side { position: static; }
}

.private-reasoning { border-color: var(--violet) !important; background: var(--violet-soft) !important; }
.badge-a4 { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.04em; color: var(--violet); margin-left: 6px; }

.filter-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; }
.filter-row label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-family: var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.filter-row select, .filter-row input { padding: 6px 9px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; color: var(--ink); font-size: 12.5px; outline: none; font-family: var(--font-sans); text-transform: none; letter-spacing: 0; }
.filter-row select:focus, .filter-row input:focus { border-color: var(--ink); }
.pagination-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }

.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); margin-bottom: 16px; }
.form-grid label, .form-field { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink); }
.form-grid input, .form-grid select, .form-grid textarea, .form-field input, .form-field select, .form-field textarea { width: 100%; padding: 7px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; color: var(--ink); font-size: 13px; outline: none; font-weight: 400; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { border-color: var(--ink); }
.form-warning { color: var(--warn); font-size: 12.5px; }
.form-error { color: var(--err); font-size: 12.5px; }
.form-ok { color: var(--ok); font-size: 12.5px; }
.form-hint { color: var(--muted); font-size: 12px; margin: -4px 0 4px; }

.btn-danger { background: var(--err); color: var(--bg); border-color: var(--err); }
.btn-danger:hover { opacity: 0.9; }

.callout {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}
.callout-warn {
  border-color: var(--warn);
  background: var(--amber-soft);
  color: var(--ink-2);
}

.login-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
  margin: 4px 0 12px;
}
.login-remember input { width: auto; margin: 0; }

.row-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }

/* ── Field help disclosures ──────────────────────────────── */
.label-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.field-help-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    padding: 0;
    border: none;
    background: none;
    color: var(--faint);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: color .12s ease;
}
.field-help-btn:hover,
.field-help-btn.is-open { color: var(--ink); }
.field-help-body {
    flex-basis: 100%;
    margin-top: 3px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-left: 2.5px solid var(--accent, var(--ink));
    border-radius: 7px;
    padding: 9px 12px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.6;
    color: var(--muted);
}

/* ── Toggle switch (boolean fields) ──────────────────────── */
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; align-self: start; }
.toggle input[type="checkbox"] {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: 0; border: 0;
    opacity: 0;
    pointer-events: none;
}
.toggle-track {
    position: relative;
    width: 40px; height: 22px;
    flex-shrink: 0;
    border-radius: 999px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    transition: background .16s ease, border-color .16s ease;
}
.toggle-track::after {
    content: "";
    position: absolute;
    top: 2px; left: 2px;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--panel);
    box-shadow: 0 1px 2px rgba(0,0,0,.22);
    transition: transform .16s ease, background .16s ease;
}
.toggle input:checked + .toggle-track { background: var(--ink); border-color: var(--ink); }
.toggle input:checked + .toggle-track::after { transform: translateX(18px); background: var(--bg); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--ink); outline-offset: 2px; }
.toggle-text { font-size: 12.5px; font-weight: 400; color: var(--muted); }
.toggle input:checked ~ .toggle-text { color: var(--ink); }

/* ── Prompt editor ───────────────────────────────────────── */
.prompt-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 12px 0;
    margin-bottom: 18px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
}
.prompt-bar-bottom { position: static; border-bottom: none; border-top: 1px solid var(--line); justify-content: flex-end; margin-top: 8px; }
.prompt-bar-meta { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.prompt-version { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 500; color: var(--ink); }
.prompt-version span { color: var(--muted); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; }
.prompt-version input { width: 120px; padding: 5px 9px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; color: var(--ink); font-size: 13px; outline: none; }
.prompt-version input:focus { border-color: var(--ink); }
.prompt-path { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-mono); font-size: 11px; color: var(--faint); max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prompt-bar-actions { display: flex; align-items: center; gap: 10px; }
.prompt-ok { color: var(--coop, var(--ink)); font-size: 12.5px; }
.prompt-field { margin-bottom: 14px; }
.prompt-field-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 5px; }
.prompt-key { font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; color: var(--ink); }
.prompt-token {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--accent, var(--muted));
    background: var(--accent-soft, var(--bg-2));
    border-radius: 4px;
    padding: 1px 6px;
}
.prompt-allowed {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 6px;
}
.prompt-allowed-label {
    font-size: 10.5px;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: var(--faint);
    margin-right: 2px;
}
.prompt-ph {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    cursor: default;
}
.prompt-ph.is-required::after {
    content: "*";
    color: var(--accent);
    margin-left: 1px;
}
.prompt-ph.is-used {
    color: var(--coop);
    border-color: color-mix(in oklch, var(--coop) 45%, transparent);
    background: color-mix(in oklch, var(--coop) 12%, transparent);
}
.prompt-allowed-hint {
    font-size: 10px;
    color: var(--faint);
}
.prompt-section { padding-top: 6px; }
.prompt-section-head {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 4px 2px 9px;
    margin: 0 0 4px;
    cursor: pointer;
    text-align: left;
    color: var(--ink);
}
.prompt-section-head:hover { color: var(--coop); }
.prompt-section-head h2 { margin: 0; font-size: 15px; }
.prompt-section-chev {
    display: inline-flex;
    color: var(--muted);
    transition: color .15s ease;
}
.prompt-section-head:hover .prompt-section-chev { color: var(--coop); }
.prompt-section-count {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--muted);
    background: var(--bg-2);
    border-radius: 999px;
    padding: 1px 8px;
}
.prompt-section-flag {
    margin-left: auto;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 12px;
    color: var(--err, var(--accent));
    background: color-mix(in oklch, var(--err, var(--accent)) 14%, transparent);
    border-radius: 999px;
    padding: 0 9px;
    line-height: 18px;
}
.prompt-section-hint { margin: -2px 0 10px; }
.prompt-area {
    width: 100%;
    padding: 10px 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.65;
    resize: vertical;
    outline: none;
    white-space: pre-wrap;
    tab-size: 2;
}
.prompt-area:focus { border-color: var(--ink); }

/* ── Prompt set list ──────────────────────────────────── */
.badge-built-in { color: var(--violet); border-color: oklch(from var(--violet) l c h / .35); background: var(--violet-soft); }
.prompt-set-list { display: flex; flex-direction: column; gap: 8px; }
.prompt-set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); transition: border-color .12s ease, background .12s ease; }
.prompt-set-row:hover { border-color: var(--ink-2); background: var(--panel-2); }
.prompt-set-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.prompt-set-name-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.prompt-set-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.prompt-set-version { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.prompt-set-desc { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.prompt-set-actions { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }

/* Analytics (Schritt 9) — themed to the design system */
.quality-box { background: var(--coop-soft); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; font-size: 12.5px; color: var(--muted); }
.quality-box strong { color: var(--ink); }
.bar-track { position: relative; background: var(--bg-2); border-radius: 4px; height: 16px; min-width: 60px; overflow: hidden; }
.bar-fill { position: absolute; inset: 0 auto 0 0; background: var(--coop); border-radius: 4px; }
.bar-label { position: relative; padding-left: 6px; font-size: 11.5px; line-height: 16px; color: var(--ink); font-family: var(--font-mono); }

/* Coding analysis — reliability pills + heatmaps */
.rel-pill { display: inline-block; font-size: 10.5px; font-family: var(--font-mono); padding: 1px 7px; border-radius: 10px; margin-right: 5px; border: 1px solid transparent; }
.rel-pill.rel-acceptable { color: var(--ok); background: oklch(from var(--ok) l c h / .12); border-color: oklch(from var(--ok) l c h / .35); }
.rel-pill.rel-tentative  { color: var(--warn); background: oklch(from var(--warn) l c h / .12); border-color: oklch(from var(--warn) l c h / .35); }
.rel-pill.rel-low        { color: var(--accent); background: var(--accent-soft); border-color: oklch(from var(--accent) l c h / .35); }
.heat-table td.heat-cell { text-align: center; font-family: var(--font-mono); font-size: 11px; font-variant-numeric: tabular-nums; padding: 7px 8px; border: 1px solid var(--bg); transition: background .15s ease; }
.heat-table th { text-align: center; }
.heat-table th:first-child, .heat-table td:first-child { text-align: left; }
.cooc-table th.cooc-head { vertical-align: bottom; height: 78px; padding: 4px; }
.cooc-table th.cooc-head > span { display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg); font-size: 10px; letter-spacing: .04em; white-space: nowrap; }

/* Login (BlankLayout) */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-card { width: min(26rem, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-xl); padding: 32px; box-shadow: var(--shadow-lg); }
.login-card h1 { font-family: var(--font-serif); font-weight: 400; font-size: 30px; letter-spacing: -0.015em; margin: 0 0 6px; }
.login-card p { color: var(--muted); margin: 0 0 20px; }
.login-card form { display: grid; gap: 14px; }
.login-card label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.login-card input { width: 100%; padding: 9px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; color: var(--ink); font-size: 14px; outline: none; }
.login-card input:focus { border-color: var(--ink); }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }

/* placeholder pages */
.placeholder { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 48px 36px; text-align: center; color: var(--muted); }
.placeholder .big { font-family: var(--font-serif); font-style: italic; font-size: 28px; color: var(--ink-2); margin-bottom: 8px; }

/* Punishment phase (Schritt P5) */
.punishment-phase { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.punishment-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.punishment-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.punishment-side { display: flex; flex-direction: column; gap: 6px; }
.punishment-chain { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.punishment-chain .serif-num { font-family: var(--font-serif); font-size: 14px; }
.chain-arrow { color: var(--faint); }

/* ── Dashboard (landing page) ─────────────────────────────────────────────── */
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.dash-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dash-controls select { padding: 6px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); font-size: 12.5px; outline: none; }
.dash-controls select:focus { border-color: var(--ink); }

.dash-kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
.dash-kpis .stat-tile { display: flex; flex-direction: column; min-width: 0; }
.dash-kpis .spark { width: 100%; height: 26px; margin-top: auto; padding-top: 6px; }
.tile-live { border-color: oklch(from var(--amber) l c h / .4); }
.tile-live .st-value { color: var(--amber); }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); margin-right: 6px; animation: pulse 1.6s ease-in-out infinite; vertical-align: 2px; }

.dash-grid-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; margin-bottom: 16px; }
.dash-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.dash-grid-2 > .detail-card, .dash-grid-3 > .detail-card { margin-bottom: 0; min-width: 0; }
.dash-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.dash-card-head .dash-link { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); text-decoration: none; white-space: nowrap; }
.dash-card-head .dash-link:hover { color: var(--ink); }
.dash-empty { color: var(--muted); font-size: 12.5px; padding: 24px 0; text-align: center; }
.dash-empty em { font-family: var(--font-serif); font-style: italic; font-size: 15px; color: var(--ink-2); display: block; margin-bottom: 4px; }

/* skeleton shimmer for progressively loaded tiles */
.skel { position: relative; overflow: hidden; background: var(--bg-2); border-radius: var(--radius); min-height: 14px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, oklch(from var(--panel) l c h / .7), transparent); animation: skel-sweep 1.4s ease-in-out infinite; }
@keyframes skel-sweep { 100% { transform: translateX(100%); } }
.skel-block { height: 160px; }
.skel-row { height: 14px; margin-bottom: 8px; }
.skel-row.short { width: 60%; }

/* sparkline */
.spark { display: block; }

/* line chart */
.lc { display: block; width: 100%; height: auto; }
.lc-grid { stroke: var(--line); stroke-width: 0.7; stroke-dasharray: 2 4; }
.lc-tick { font-family: var(--font-mono); font-size: 9.5px; fill: var(--muted); }
.lc-area { opacity: 0.10; }
.lc-line { stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 0; animation: lc-draw 0.9s ease-out; }
@keyframes lc-draw { from { stroke-dashoffset: 1; } }
.lc-dot { stroke: var(--bg); stroke-width: 1.2; }

/* gauge + donut */
.gauge, .donut { position: relative; width: 120px; height: 120px; flex-shrink: 0; }
.gauge svg, .donut svg { width: 100%; height: 100%; }
.gauge-track, .donut-track { fill: none; stroke: var(--bg-2); stroke-width: 11; }
.gauge-fill { fill: none; stroke-width: 11; stroke-linecap: round; animation: ring-in 0.9s ease-out; }
.donut-seg { fill: none; stroke-width: 13; animation: ring-in 0.9s ease-out; }
@keyframes ring-in { from { stroke-dasharray: 0 100; } }
.gauge-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.gauge-value { font-family: var(--font-serif); font-size: 22px; line-height: 1.05; letter-spacing: -0.01em; color: var(--ink); font-variant-numeric: tabular-nums; }
.gauge-sub { font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut-legend { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.donut-legend-item { display: flex; align-items: center; gap: 7px; font-size: 12px; min-width: 0; }
.donut-swatch { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.donut-legend-label { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend-pct { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-left: auto; }

/* dashboard activity feed */
.dash-feed { display: flex; flex-direction: column; }
.dash-feed-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.3fr) 70px 76px 96px; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px dashed var(--line); font-size: 12.5px; color: var(--ink-2); text-decoration: none; }
.dash-feed-row:last-of-type { border-bottom: 0; }
.dash-feed-row:hover { background: var(--hover); }
.dash-feed-row.is-running { box-shadow: inset 2px 0 0 var(--amber); }
.dash-feed-row .num { text-align: right; }

/* gauge row inside behaviour cards */
.dash-gauge-row { display: flex; align-items: center; gap: 16px; }
.dash-gauge-detail { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.dash-gauge-detail .mini-row { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); }
.dash-gauge-detail .mini-row .bar-track { flex: 1; height: 8px; min-width: 30px; }
.dash-gauge-detail .mini-row .mini-label { width: 108px; flex-shrink: 0; font-family: var(--font-mono); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-gauge-detail .mini-row .mini-val { font-family: var(--font-mono); font-size: 10.5px; width: 40px; text-align: right; flex-shrink: 0; }

/* condition heat grid */
.dash-heat { width: 100%; border-collapse: collapse; }
.dash-heat th { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); font-weight: 500; text-align: left; padding: 5px 8px; }

/* quality footer */
.dash-quality { display: flex; gap: 18px; flex-wrap: wrap; align-items: baseline; font-family: var(--font-mono); font-size: 11px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 12px 16px; }
.dash-quality b { color: var(--ink-2); font-weight: 600; }

@media (max-width: 1180px) {
  .dash-kpis { grid-template-columns: repeat(3, 1fr); }
  .dash-grid-2, .dash-grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sb { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
  .sb-spacer, .sb-status { display: none; }
  .sb-nav { flex-direction: row; flex-wrap: wrap; }
  .sb-item.is-active::before { display: none; }
  .cfg, .db, .mon-cols, .mon-grid { grid-template-columns: 1fr; }
  .view { padding: 20px 16px 60px; }
  .dash-kpis { grid-template-columns: repeat(2, 1fr); }
}

/* ===== Round-jump pills ===== */
.round-jump {
  position: sticky; top: 52px; z-index: 20;
  display: flex; gap: 4px; align-items: center;
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin;
  height: 36px; margin: 12px 0 0;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.round-pill { flex-shrink: 0; font-family: var(--font-mono); font-size: 10px; padding: 2px 7px; border-radius: 3px; background: var(--line); color: var(--muted); text-decoration: none; border: 1px solid transparent; transition: background .12s, color .12s; }
.round-pill:hover { background: var(--ink); color: var(--bg); }
.round-pill.is-flagged { border-color: var(--accent); color: var(--accent); }

/* ===== System page tabs ===== */
.tab-strip { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding-bottom: 0; }
.tab-btn { background: none; border: none; border-bottom: 2px solid transparent; padding: 8px 14px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; border-radius: 0; transition: color .15s, border-color .15s; margin-bottom: -1px; }
.tab-btn:hover { color: var(--ink); }
.tab-btn.is-active { color: var(--ink); border-bottom-color: var(--ink); }

/* System key/value rows */
.sys-kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.sys-kv:last-child { border-bottom: none; }
.sys-k { font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); flex-shrink: 0; }
.sys-v { font-size: 13px; color: var(--ink); text-align: right; }

/* Cost tables (B3, B4) */
.cost-table-wrap { overflow-x: auto; }
.cost-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.cost-table th { font-family: var(--font-mono); font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 4px 8px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.cost-table td { padding: 6px 8px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.cost-table tbody tr:hover td { background: var(--hover); }
.cost-table tr.row-exhausted td { background: oklch(from var(--err) l c h / .06); }
.cost-table tr.row-near td { background: oklch(from var(--warn) l c h / .06); }

/* ===== AI Behavior brand logo (theme-aware; replaces the placeholder CSS mark) ===== */
.sb-brand-mark{
  background: var(--ink);
  box-shadow: none;
  border-radius: 0;
  -webkit-mask: url("/logo.svg") center / contain no-repeat;
          mask: url("/logo.svg") center / contain no-repeat;
}
.sb-brand-mark::before, .sb-brand-mark::after{ content: none; }

/* ── Modal dialog ─────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: oklch(0 0 0 / .35); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 24px;
}
.modal-box {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 24px;
  width: 100%; max-width: 460px;
  box-shadow: 0 16px 48px oklch(0 0 0 / .35);
}
.modal-box h2 { margin: 0 0 10px; }

/* ── Prompt Validation Boxes ──────────────────────────────────── */
.validation-box {
  border-radius: var(--radius); padding: 10px 12px;
  margin-bottom: 6px; display: flex; flex-direction: column; gap: 6px;
  border-left: 3px solid;
}
.validation-box-error   { background: oklch(from var(--err)  l c h / .08); border-left-color: var(--err); }
.validation-box-warning { background: oklch(from var(--warn) l c h / .08); border-left-color: var(--warn); }
.validation-box-cross   { background: oklch(from var(--accent) l c h / .06); border-left-color: var(--accent); margin-bottom: 12px; }
.validation-box-title   { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

.validation-finding     { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.validation-severity    { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-right: 4px; }
.validation-critical .validation-severity { color: var(--err); }
.validation-major    .validation-severity { color: var(--warn); }
.validation-warning  .validation-severity { color: var(--warn); }
.validation-info     .validation-severity { color: var(--muted); }
.validation-evidence  { font-size: 12px; color: var(--muted); font-style: italic; }
.validation-related   { font-size: 11.5px; color: var(--muted); }

.validation-suggestion  { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line-2); }
.validation-suggestion-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.validation-suggestion-text  {
  font-family: var(--font-mono); font-size: 12px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 4px; padding: 8px;
  margin: 0; white-space: pre-wrap; word-break: break-word; max-height: 200px; overflow-y: auto;
}

/* ── Validation: collapsible header ── */
.validation-collapse-header {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; user-select: none;
  padding: 2px 0;
}
.validation-collapse-header:hover h2 { opacity: 0.75; }
.validation-collapse-icon {
  font-size: 13px; color: var(--muted); min-width: 14px; line-height: 1;
}

/* ── Validation: indeterminate progress bar ── */
@keyframes validation-slide {
  0%   { left: -40%; }
  100% { left: 110%; }
}
.validation-running        { margin-top: 10px; }
.validation-running-text   {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 13px; color: var(--muted);
}
.validation-elapsed        {
  font-family: var(--font-mono); font-size: 11px; color: var(--accent);
  min-width: 28px; white-space: nowrap;
}
.validation-progress-track {
  position: relative; height: 3px;
  background: var(--line); border-radius: 2px; overflow: hidden;
  margin-top: 6px;
}
.validation-progress-bar   {
  position: absolute; top: 0; bottom: 0;
  width: 35%; background: var(--accent); border-radius: 2px;
  animation: validation-slide 1.4s ease-in-out infinite;
}
/* Determinate n/total fill for the multi-pass validation. */
.validation-progress-fill  {
  position: absolute; top: 0; bottom: 0; left: 0;
  background: var(--accent); border-radius: 2px;
  transition: width .35s ease;
}

/* Two-model pickers */
.validation-models      { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.validation-model-pick  { flex: 1 1 240px; min-width: 220px; }
.validation-model-label {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin-bottom: 4px;
}

/* Per-pass checklist */
.validation-units       { margin-top: 10px; display: flex; flex-direction: column; gap: 3px; }
.validation-unit        { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.validation-unit-icon   {
  display: inline-grid; place-items: center; width: 16px; height: 16px;
  font-size: 11px; flex-shrink: 0; color: var(--muted);
}
.validation-unit-done   .validation-unit-icon { color: var(--ok, var(--coop)); }
.validation-unit-running .validation-unit-icon { color: var(--accent); }
.validation-unit-pending { color: var(--faint); }
.validation-unit-title  { flex: 1; }
.validation-unit-count  { font-size: 11px; font-family: var(--font-mono); }
.validation-unit-count.is-clean   { color: var(--ok, var(--coop)); }
.validation-unit-count.is-flagged { color: var(--warn); }

/* Finding type chip */
.validation-type {
  font-family: var(--font-mono); font-size: 10px; color: var(--muted);
  background: var(--bg-2); border-radius: 4px; padding: 0 5px; margin-right: 4px;
}

/* ── ModelSelect: unmistakable selection state ── */
.ms-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 8px;
  background: color-mix(in oklch, var(--accent) 14%, var(--panel));
  border: 1.5px solid var(--accent);
  font-size: 13px;
}
.ms-banner-empty {
  background: var(--panel-2);
  border: 1px dashed var(--line);
  color: var(--muted);
}
.ms-banner-check {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); color: var(--bg);
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.ms-banner-label { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; }
.ms-banner-name {
  font-family: var(--font-mono); font-size: 12.5px; font-weight: 600;
  color: var(--accent);
}
.ms-banner-hint { font-size: 12px; }
.ms-banner-clear {
  margin-left: auto; flex-shrink: 0;
  border: 1px solid var(--accent); background: transparent; color: var(--accent);
  border-radius: 5px; padding: 3px 9px; font-size: 11.5px; cursor: pointer;
}
.ms-banner-clear:hover { background: var(--accent); color: var(--bg); }

.model-row.ms-selected {
  background: color-mix(in oklch, var(--accent) 12%, var(--panel)) !important;
  box-shadow: inset 3px 0 0 0 var(--accent);
}
.model-row.ms-selected .model-name b { color: var(--accent); }
.model-row.ms-selected .model-name .id { color: var(--accent); opacity: 0.85; }

.ms-radio {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--panel);
  display: grid; place-items: center; cursor: pointer;
}
.ms-radio.is-on { background: var(--accent); border-color: var(--accent); }
.ms-radio-dot { color: var(--bg); font-size: 11px; font-weight: 700; line-height: 1; }

.ms-selected-tag {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em;
  color: var(--bg); background: var(--accent);
  padding: 2px 6px; border-radius: 4px;
}

/* ── Validation: result summary banners ── */
.validation-ok {
  display: flex; align-items: center; gap: 10px;
  margin: 14px 0; padding: 12px 16px; border-radius: 8px;
  background: color-mix(in oklch, var(--ok) 14%, var(--panel));
  border: 1.5px solid var(--ok);
  color: var(--ink); font-size: 13.5px;
}
.validation-ok-check {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ok); color: var(--bg);
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.validation-summary {
  margin: 14px 0; padding: 10px 14px; border-radius: 8px;
  background: color-mix(in oklch, var(--accent) 10%, var(--panel));
  border: 1px solid var(--accent);
  color: var(--ink); font-size: 13px;
}

/* ── Game detail redesign (Phase 2–4) ── */
.qa-banner {
  margin: 8px 0 16px; padding: 10px 16px; border-radius: 6px;
  background: color-mix(in oklch, var(--amber, #f59e0b) 12%, var(--panel));
  border: 1.5px solid var(--amber, #f59e0b); font-size: 12.5px;
}
.qa-banner ul { margin: 4px 0 0 16px; padding: 0; }

/* Protocol tab */
.proto-toolbar {
  position: sticky; top: 88px; z-index: 10;
  display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center;
  padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.proto-toggle { display: flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; }
.proto-toggle input { cursor: pointer; }

.protocol { max-width: 900px; }
.protocol.compact .proto-event { padding: 2px 0; font-size: 12px; }
.protocol.compact .proto-round-head { padding: 6px 0; }

.proto-round { border-bottom: 1px solid var(--line); padding: 12px 0; scroll-margin-top: 134px; }
.proto-round:nth-of-type(even) { background: color-mix(in oklch, var(--ink) 2%, var(--bg)); }

.proto-round-head {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 4px 0 10px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em;
  color: var(--muted); font-weight: 600;
}

.proto-event {
  display: grid; grid-template-columns: 28px 1fr; gap: 4px;
  padding: 3px 0; font-size: 13px; line-height: 1.45; align-items: baseline;
}
.proto-event.is-engine { color: var(--muted); font-size: 12px; }
.proto-event.is-a { }
.proto-event.is-b { }

.proto-event-body { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }

.proto-gutter {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  color: var(--muted); text-align: center; padding-top: 1px;
}

.proto-msg { font-style: italic; }
.proto-seq { font-size: 10px; color: var(--muted); font-family: var(--font-mono); }

.proto-reasoning {
  display: block; width: 100%; margin-top: 2px; padding-left: 8px;
  font-size: 11.5px; color: var(--muted); font-style: italic;
}
.proto-prompt {
  display: block; width: 100%; margin-top: 2px; padding-left: 8px;
  font-size: 11px; color: var(--faint); font-family: var(--font-mono);
  white-space: pre-wrap; overflow: auto; max-height: 120px;
  resize: vertical;
}
/* Once the user drags the resize handle the browser sets an inline height —
   lift the max-height cap so the box can grow beyond its initial size. */
.proto-prompt[style*="height"] { max-height: none; }
.proto-attempt {
  display: flex; align-items: baseline; gap: 6px; font-size: 11px;
  font-family: var(--font-mono); color: var(--muted); padding-left: 8px;
}
.proto-attempt.is-winning { color: var(--ink); font-weight: 600; }
.attempt-marker { font-size: 12px; }
.attempt-n { }
.attempt-fault { color: var(--accent); }
.attempt-latency { color: var(--faint); }
.attempt-cost { color: var(--faint); }
.badge-fault {
  font-size: 9px; padding: 1px 5px; border-radius: 3px;
  background: color-mix(in oklch, var(--accent) 15%, var(--panel));
  color: var(--accent); text-transform: uppercase; letter-spacing: .05em;
}
.proto-raw { font-family: var(--font-mono); font-size: 10px; line-height: 1.5; max-height: 240px; overflow: auto; white-space: pre-wrap; word-break: break-word; background: color-mix(in oklch, var(--ink) 4%, var(--bg)); border: 1px solid var(--line); border-radius: 4px; padding: 6px 9px; margin: 4px 0; resize: vertical; }
.proto-raw[style*="height"] { max-height: none; }
.proto-link {
  font-size: 11px; padding: 0 6px; color: var(--muted);
  text-decoration: underline; text-underline-offset: 2px;
}

/* Event detail panel (slide-over) */
.event-panel-backdrop {
  display: none;
}
@media (max-width: 768px) {
  .event-panel-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40;
  }
}
.event-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(560px, 92vw); overflow-y: auto;
  background: var(--bg); border-left: 1.5px solid var(--line);
  box-shadow: -4px 0 24px rgba(0,0,0,.12); padding: 0;
}
@media (max-width: 768px) {
  .event-panel {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: 70vh;
    border-left: none; border-top: 1.5px solid var(--line);
    box-shadow: 0 -4px 24px rgba(0,0,0,.12);
  }
}
.event-panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0;
  background: var(--bg); z-index: 1;
}
.event-panel-title {
  font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--ink);
}
.event-panel-outcome {
  display: block; font-size: 11px; color: var(--muted); margin-top: 2px;
}
.event-panel-close {
  background: none; border: none; font-size: 20px; line-height: 1;
  cursor: pointer; color: var(--muted); padding: 0 2px; flex-shrink: 0;
}
.event-panel-close:hover { color: var(--ink); }
.event-panel-timeline { padding: 12px 18px; display: flex; flex-direction: column; gap: 16px; }
.event-panel-meta { padding-left: 8px; }

/* link-style button */
button.link {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--muted); font-size: inherit; font-family: inherit;
  text-decoration: underline; text-underline-offset: 2px;
}
button.link:hover { color: var(--ink); }

/* Mini-chronology (Replay Tab) */
.mini-chrono { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; }
.chrono-line {
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
  font-size: 13px; line-height: 1.4; padding: 2px 0;
}
.chrono-line.is-engine { color: var(--muted); font-size: 12px; }
.chrono-line.is-a { }
.chrono-line.is-b { }
.chrono-actor {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  min-width: 22px; color: var(--muted);
}
.chrono-msg { font-style: italic; }
.chrono-seq { font-size: 10px; color: var(--muted); font-family: var(--font-mono); }
.chrono-reasoning {
  padding-left: 28px; font-size: 11.5px; color: var(--muted); font-style: italic;
}
.chrono-links {
  padding-left: 28px; font-size: 11px;
}

/* Tg-legend additions for Phase 3 */
.tg-legend-item .tg-legend-punishment {
  display: inline-block; font-size: 11px; line-height: 1;
  color: var(--accent); margin-right: 3px;
}
