/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 17.5px; }
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-canvas);
  color: #fafafa;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Utilities */
.spacer { flex: 1; }
.hidden { display: none !important; }
.mono { font-family: 'JetBrains Mono', monospace; }

/* Colors */
:root {
  /* Background hierarchy — canvas is the deepest layer, panels sit above it,
     cards on panels are tinted slightly darker so they read as inset chips
     rather than floating tiles. */
  --bg-canvas: #050507;   /* tree area, behind the timeline rows */
  --bg-panel: #111114;    /* topbar, left rail, sidebar, filter bar, histogram */
  --bg-card: #0a0a0c;     /* rail cards, info chips on panels */
  --bg: #09090b;          /* legacy alias — equals canvas-ish for any leftover use */
  --surface: #141416;
  --surface-2: #1b1b1f;
  --inset: #0c0c0e;
  --border: #262629;
  --border-subtle: #1c1c1f;
  --text-1: #fafafa;
  --text-2: #a1a1aa;
  --text-3: #71717a;
  --text-4: #71717a;
  --text-5: #52525b;
  --text-6: #3f3f46;
  --green: #22c55e;
  --blue: #3b82f6;
  --red: #ef4444;
  --amber: #f59e0b;
  --indigo: #818cf8;
  --purple: #a855f7;    /* active state, replaces blue pulse */
  --orange: #FF6A2A;    /* evo brand orange, from logo/evo-logo.svg */
  --evo-taupe: #6F6257; /* logo letter color, from logo/evo-logo.svg */

  /* Radii — terminal-console feel, sharp corners with a few softer surfaces. */
  --radius-sm: 3px;     /* pills, chips, small buttons */
  --radius-md: 4px;     /* cards, bars, code/diff blocks */
  --radius-lg: 8px;     /* drawer-summary, modal panes */
}

/* Thin scrollbars across the app. */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-6); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: var(--text-5); }
* { scrollbar-width: thin; scrollbar-color: var(--text-6) transparent; }

/* ─── Top bar ─────────────────────────────────────────── */
#topbar {
  display: flex;
  align-items: center;
  min-height: 76px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-subtle);
  gap: 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
  background: var(--bg-panel);
}
.logo {
  /* Inlined SVG from logo/evo-logo.svg, tinted via currentColor. */
  display: block;
  height: 30px;
  width: auto;
  flex: 0 0 auto;
  color: var(--text-1);
}
.divider {
  width: 1px;
  height: 16px;
  background: var(--border-subtle);
  margin: 0 14px;
}
.target {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 15px;
  color: var(--text-4);
  min-width: 0;
  cursor: pointer;
}
.target:hover strong { color: var(--purple); }
.target:empty { display: none; }
.target strong {
  color: var(--text-1);
  font-family: "JetBrains Mono", monospace;
  font-size: 16px;
  font-weight: 600;
}
.target .target-sep {
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  color: var(--text-5);
}
.target span {
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  color: var(--text-4);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 250px;
}
.pill {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.2px;
  border: 1px solid var(--border);
  background: var(--bg-canvas);
}
.pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.pill-active { color: var(--green); border-color: rgba(34,197,94,0.4); background: rgba(34,197,94,0.08); }
.pill-active .dot { background: var(--green); box-shadow: 0 0 4px var(--green); }
.pill-idle { color: var(--text-3); }
.pill-idle .dot { background: var(--text-5); }

/* Stat strip — 5 cards across the topbar: best score, experiments,
   keep rate, frontier, active. Each is a 3-line block (uppercase label,
   big value+delta, muted sub-line). Thin vertical dividers between. */
.stat-strip {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-left: 8px;
  padding: 0 2px;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.stat-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 0 22px;
  min-width: 0;
}
.stat-divider {
  width: 1px;
  background: var(--border-subtle);
  margin: 6px 0;
  flex-shrink: 0;
}
.stat-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-4);
  line-height: 1;
}
.stat-row {
  display: flex;
  align-items: baseline;
  gap: 7px;
  line-height: 1;
}
.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 28px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.8px;
  line-height: 1;
}
.stat-value.stat-active { color: var(--purple); }
.stat-delta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.1px;
}
.stat-delta:empty { display: none; }
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }
.stat-delta.neutral { color: var(--text-4); font-weight: 500; }
.stat-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-4);
  line-height: 1;
}
.stat-sub:empty { display: none; }
.exp-count { margin-right: 8px; }
.exp-count.kept { color: var(--green); }
.exp-count.skip { color: var(--text-3); }
.exp-count.err  { color: var(--red); }
.meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.meta-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 9px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface);
  min-width: 0;
}
.meta-label {
  font-size: 10px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--text-4);
  line-height: 1;
}
.meta-value {
  font-size: 12px;
  color: var(--text-1);
  line-height: 1.1;
  white-space: nowrap;
}

.run-switcher {
  margin-right: 15px;
}
.run-select {
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 4px 22px 4px 10px;
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-4) 50%), linear-gradient(135deg, var(--text-4) 50%, transparent 50%);
  background-position: calc(100% - 12px) 50%, calc(100% - 7px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.run-select:hover { border-color: var(--text-5); }
.run-select:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}
.run-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-4);
}


/* ─── Filter bar ──────────────────────────────────────── */
#filter-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-panel);
  flex-wrap: wrap;
}
.filter-bar-left { flex: 1; min-width: 0; }
.filter-bar-mid {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.filter-sep {
  width: 1px;
  height: 18px;
  background: var(--border-subtle);
  margin: 0 4px;
}

.status-filters { display: flex; gap: 4px; }
.status-chip {
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-canvas);
  color: var(--text-4);
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.status-chip .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}
/* Filter chips mirror the four-color scheme:
   * green = committed, red = failed, purple = active.
   * Everything else (evaluated / pending / discarded / pruned) is grey. */
.status-chip.committed { color: var(--green); }
.status-chip.committed.active-filter { background: rgba(34,197,94,0.10); border-color: rgba(34,197,94,0.45); }
.status-chip.failed { color: var(--red); }
.status-chip.failed.active-filter { background: rgba(239,68,68,0.10); border-color: rgba(239,68,68,0.45); }
.status-chip.active { color: var(--purple); }
.status-chip.active .status-dot { box-shadow: 0 0 4px var(--purple); }
.status-chip.active.active-filter { background: rgba(168,85,247,0.12); border-color: rgba(168,85,247,0.5); }
/* Grey bucket — distinguish by dot fill vs transparent ring so the eye can
   still tell evaluated (filled) apart from discarded/pending/pruned (rings). */
.status-chip.evaluated { color: var(--text-3); }
.status-chip.evaluated.active-filter { background: rgba(113,113,122,0.14); border-color: rgba(113,113,122,0.5); }
.status-chip.pending,
.status-chip.discarded,
.status-chip.pruned { color: var(--text-4); }
.status-chip.pending .status-dot,
.status-chip.discarded .status-dot,
.status-chip.pruned .status-dot { background: transparent; border: 1px solid currentColor; opacity: 1; }
.status-chip.pending.active-filter,
.status-chip.discarded.active-filter,
.status-chip.pruned.active-filter { background: rgba(82,82,91,0.14); border-color: rgba(82,82,91,0.5); }
.status-chip.muted { opacity: 0.45; }

.filter-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-3);
  font: inherit;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.1s, color 0.1s, background 0.1s;
}
.filter-toggle:hover { color: var(--text-1); border-color: var(--text-5); }
.filter-toggle.active-filter {
  color: var(--amber);
  border-color: rgba(245,158,11,0.55);
  background: rgba(245,158,11,0.08);
}

.view-mode-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--text-4);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.view-mode-select {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  font: inherit;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 3px 24px 3px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-transform: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-4) 50%), linear-gradient(135deg, var(--text-4) 50%, transparent 50%);
  background-position: calc(100% - 13px) 50%, calc(100% - 8px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.view-mode-select:hover { color: var(--text-1); border-color: var(--text-5); }
.view-mode-select:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
  border-color: var(--text-5);
}

.scope-breadcrumb {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--text-3);
}
.scope-breadcrumb .crumb {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-3);
}
.scope-breadcrumb .crumb:hover { background: rgba(255,255,255,0.04); color: var(--text-1); }
.scope-breadcrumb .crumb.current { color: var(--text-1); background: rgba(255,255,255,0.04); }
.scope-breadcrumb .crumb-sep { color: var(--text-5); }
.scope-reset {
  margin-left: 8px;
  font-size: 11px;
  color: var(--text-4);
  cursor: pointer;
  background: none;
  border: none;
  padding: 2px 6px;
  border-radius: 4px;
}
.scope-reset:hover { color: var(--text-1); background: rgba(255,255,255,0.04); }
.visible-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--text-5);
  margin-left: 6px;
}

/* ─── Main area (left rail + center + optional sidebar) ── */
#main-area {
  display: flex;
  min-height: 0;
  flex: 1;
  width: 100%;
  overflow: hidden;
}

/* Left rail: queues / candidates */
.left-rail {
  width: 300px;
  flex-shrink: 0;
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-panel);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.rail-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.rail-section:last-child { border-bottom: none; }
.rail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.rail-header-left {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rail-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.9px;
}
.rail-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-5);
}
/* Hover-tooltip ? icon next to the section title — quieter than the
   filled info-icon used in the settings modal. */
.rail-info {
  width: 13px;
  height: 13px;
  font-size: 9px;
  background: transparent;
  border: 1px solid var(--text-6);
  color: var(--text-4);
  cursor: help;
}
.rail-info:hover { color: var(--text-1); border-color: var(--text-4); }
.rail-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* Compact card: id on the left, status dot on the right. The drawer
   carries the full detail when clicked. */
.rail-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
}
.rail-card:hover {
  border-color: var(--text-6);
  background: var(--bg-card);
}
/* Active cards: purple outline + tint, matches the .exp-bar.active treatment.
   Failed cards: red. Both override the neutral default border. */
.rail-card.active {
  border-color: var(--purple);
  background: rgba(168,85,247,0.08);
}
.rail-card.failed {
  border-color: var(--red);
  background: rgba(239,68,68,0.06);
}
.rail-card.selected {
  border-color: var(--text-1);
  box-shadow: 0 0 0 1px var(--text-1);
  background: var(--bg-canvas);
}
.rail-card-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-1);
  letter-spacing: -0.2px;
}
.rail-card-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
/* Dot is a 3-color status indicator: green=committed, red=failed, grey=rest.
   The "currently running" signal lives on the rail-card OUTLINE instead. */
.rail-card-dot.committed { background: var(--green); }
.rail-card-dot.failed    { background: var(--red); }
.rail-card-dot.active,
.rail-card-dot.evaluated,
.rail-card-dot.pending,
.rail-card-dot.discarded,
.rail-card-dot.pruned    { background: var(--text-5); }
/* Legacy rich-card classes (rail-card-sub/hyp/meta/action) intentionally
   removed — the compact list renders id + dot only. */
.rail-empty {
  font-size: 14px;
  color: var(--text-5);
  line-height: 1.45;
  padding: 6px 0;
}

/* Center column */
#center-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* Scatter strip — docked below the timeline canvas. Top edge is a
   vertical resize handle the user can grab to grow/shrink the chart. The
   timeline above is flex:1 so it absorbs whatever space the strip frees. */
.scatter-strip {
  position: relative;
  flex-shrink: 0;
  height: 220px;          /* overridden by applyScatterRect on first render */
  background: var(--bg-panel);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  min-height: 100px;
  max-height: 600px;
}
.scatter-strip-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px 4px;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
}
.scatter-strip-head:hover .scatter-strip-title { color: var(--text-2); }
.scatter-toggle-caret {
  font-size: 10px;
  color: var(--text-4);
  display: inline-block;
  width: 10px;
  text-align: center;
  transition: transform 0.12s;
}
.scatter-strip.collapsed .scatter-toggle-caret { transform: rotate(-90deg); }
.scatter-strip.collapsed {
  height: 32px !important;       /* override the resized height when collapsed */
  min-height: 32px;
}
.scatter-strip.collapsed .scatter-plot,
.scatter-strip.collapsed .scatter-resize-top { display: none; }
/* Push best-score chip to the right edge of the header. */
.scatter-strip-head .scatter-best-label { margin-left: auto; }
.scatter-strip-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--text-4);
}
.scatter-best-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.3px;
  color: var(--amber);
}
.scatter-best-label:empty { display: none; }
.scatter-plot {
  flex: 1;
  position: relative;
  padding: 0 14px 8px;
  min-height: 0;
}
/* Top-edge resize handle: thin horizontal strip that lifts to bright on
   hover so the affordance is obvious without dominating the UI. */
.scatter-resize-top {
  position: absolute;
  top: -3px;
  left: 0;
  right: 0;
  height: 6px;
  cursor: row-resize;
  z-index: 6;
}
.scatter-resize-top::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 2px;
  border-radius: 2px;
  background: var(--text-6);
  transition: background 0.1s;
}
.scatter-resize-top:hover::after { background: var(--text-3); }
.scatter-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
.scatter-axis {
  stroke: var(--text-6);
  stroke-width: 1;
}
.scatter-grid {
  stroke: var(--border-subtle);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}
.scatter-tick {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  fill: var(--text-5);
}
.scatter-stair {
  fill: none;
  stroke: var(--amber);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.75;
  pointer-events: none;
}
/* Dots: green/red/grey + purple for active. Spine ring overlay (amber)
   sits behind the dot so it reads as a halo. */
.scatter-dot {
  cursor: pointer;
  transition: r 0.08s ease, opacity 0.08s;
}
.scatter-dot:hover { r: 6; }
.scatter-dot.committed { fill: var(--green); }
.scatter-dot.failed    { fill: var(--red); }
.scatter-dot.active    { fill: var(--purple); }
.scatter-dot.evaluated,
.scatter-dot.pending,
.scatter-dot.discarded,
.scatter-dot.pruned    { fill: var(--text-3); opacity: 0.95; }
.scatter-dot.no-score  { opacity: 0.75; }
.scatter-dot.selected  { stroke: var(--text-1); stroke-width: 1.5; }
/* Best dot — reads the brightest: white stroke ring + slight glow so the
   "current champion" jumps out before the eye chases the amber spine. */
.scatter-dot.best {
  stroke: var(--text-1);
  stroke-width: 1.6;
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.55));
}
.scatter-dot.best.committed { fill: #4ade80; }   /* lifted green */
.scatter-dot.best.active    { fill: #c084fc; }   /* lifted purple */
.scatter-spine {
  fill: none;
  stroke: var(--amber);
  stroke-width: 1.5;
  opacity: 0.7;
  pointer-events: none;
}
.scatter-empty {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-5);
  padding: 30px 4px;
  text-align: center;
  line-height: 1.5;
}

/* ─── Timeline ────────────────────────────────────────── */
#timeline-section {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#timeline-axis {
  display: flex;
  align-items: center;
  height: 33px;
  padding: 0 var(--timeline-pad-x, 16px);
  border-bottom: 1px solid var(--border-subtle);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-5);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  background: var(--bg-panel);
  flex-shrink: 0;
  overflow: hidden;
}
.axis-tick {
  position: relative;
  flex-shrink: 0;
  border-left: 1px dashed var(--border);
  padding-left: 8px;
  display: flex;
  align-items: center;
  color: var(--text-4);
}
.axis-tick:first-child { border-left: none; padding-left: 0; }

.timeline-rows {
  flex: 1;
  overflow: auto;
  padding: 10px 0 20px;
  position: relative;
  cursor: grab;
  background-color: var(--bg-canvas);
  background-image:
    radial-gradient(rgba(63,63,70,0.55) 1px, transparent 1px),
    linear-gradient(to right, transparent 0, transparent calc(100% - 1px), rgba(63,63,70,0.4) calc(100% - 1px), rgba(63,63,70,0.4) 100%);
  background-size: 16px 16px, 100% 100%;
  background-position: 0 0, 0 0;
  background-repeat: repeat, no-repeat;
}

.timeline-rows-inner {
  position: relative;
  min-width: 100%;
}

/* Soft amber lane behind the best-path (spine) row in the timeline. */
.timeline-spine-lane {
  position: absolute;
  left: 0;
  right: 0;
  background: rgba(245,158,11,0.035);
  border-top: 1px dashed rgba(245,158,11,0.22);
  border-bottom: 1px dashed rgba(245,158,11,0.22);
  pointer-events: none;
  z-index: 0;
}

/* Connectors layer (SVG) drawn under bars */
.timeline-connectors {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}
/* Tree connectors carry structure, not status — the destination node's
   dot, fill, and border already encode status. Only the spine is colored,
   so the best-path reads as a continuous amber thread. */
.timeline-connector {
  fill: none;
  stroke: var(--text-2);
  stroke-width: 1.5px;
  opacity: 0.7;
}
.timeline-connector.lineage { stroke: var(--amber); stroke-width: 2.5px; opacity: 1; }
.timeline-connector.muted { stroke: var(--text-4); opacity: 0.35; }

.exp-caret {
  position: absolute;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  color: var(--text-2);
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  border-radius: 2px;
  z-index: 2;
}
.exp-caret:hover {
  color: var(--text-1);
  border-color: var(--text-3);
}
/* When the owning node is on the best path, the toggle picks up amber so
   the spine reads as one continuous chain through the tree, including its
   branch handles. */
.exp-caret.lineage {
  color: var(--amber);
  border-color: rgba(245,158,11,0.7);
}
.exp-caret.lineage:hover {
  color: var(--amber);
  border-color: var(--amber);
}
.exp-caret.empty { opacity: 0; pointer-events: none; }

/* Hover-revealed action chips (retry / spawn) that sit just below a node.
   Hidden by default; appear when the cursor is over the owning bar or the
   chips themselves (the bridge prevents flicker on the small gap). */
.exp-bar-actions {
  position: absolute;
  display: flex;
  gap: 4px;
  /* The inline `left` is the bar's horizontal center; translateX(-50%)
     here centers the chip group around that anchor regardless of width.
     padding-top creates the visible gap while keeping the hover area
     contiguous with the bar's bottom edge — no flicker on cursor cross. */
  transform: translateX(-50%);
  padding-top: 6px;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}
/* Adjacent-sibling combinator scopes hover to THIS bar's actions only.
   The render order is: bar → actions → caret → summary, so `+` matches
   exactly one .exp-bar-actions per hovered bar. */
.exp-bar:hover + .exp-bar-actions,
.exp-bar-actions:hover {
  opacity: 1;
  pointer-events: auto;
}
.exp-action {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1;
  padding: 4px 9px;
  color: var(--text-2);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.exp-action.exp-action-icon {
  padding: 4px 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.exp-action:hover {
  color: var(--purple);
  border-color: rgba(168,85,247,0.55);
  background: rgba(168,85,247,0.08);
}

.exp-bar {
  position: absolute;
  display: flex;
  align-items: center;
  height: 52px;
  border-radius: var(--radius-md);
  padding: 0 14px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: var(--text-1);
  background: rgba(82,82,91,0.32);
  border: 1px solid rgba(113,113,122,0.4);
  overflow: hidden;
  white-space: nowrap;
  min-width: 22px;
  cursor: pointer;
  z-index: 1;
  transition: filter 0.08s, box-shadow 0.1s;
}
.exp-bar:hover { filter: brightness(1.18); }
.exp-bar.muted { opacity: 0.32; }
.exp-bar.selected { box-shadow: 0 0 0 1.5px var(--text-1); }
/* Status dot inside the bar (matches reference .node-status). Color
   stays semantic even on amber lineage bars — the dot tells you status,
   the bar fill tells you whether it's on the best path. */
.exp-bar .exp-status {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-right: 9px;
}
/* Three dot colors only. "Running" is signaled by the bar's blue outline,
   not by the dot. */
.exp-bar .exp-status.committed { background: var(--green); }
.exp-bar .exp-status.failed    { background: var(--red); }
.exp-bar .exp-status.active,
.exp-bar .exp-status.evaluated,
.exp-bar .exp-status.pending,
.exp-bar .exp-status.discarded,
.exp-bar .exp-status.pruned    { background: var(--text-5); }

.exp-bar .exp-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-5);
  margin-right: 10px;
  flex-shrink: 0;
  letter-spacing: -0.2px;
}
.exp-bar .exp-hyp {
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
  line-height: 1.18;
  color: var(--text-1);
}
.exp-bar .exp-score {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  margin-left: 10px;
  flex-shrink: 0;
  color: var(--text-1);
}
/* Compact (off-spine) bars: hide hypothesis + delta, expand the id so it
   leads, push score to the right edge. The hover tooltip carries the
   hypothesis + delta on demand; the .exp-expand chip promotes the card
   inline (state.expandedCards). */
.exp-bar.compact { padding: 0 11px; }
.exp-bar.compact .exp-hyp,
.exp-bar.compact .exp-delta { display: none; }
.exp-bar.compact .exp-id {
  flex: 1;
  margin-right: 0;
  color: var(--text-2);
  font-size: 12px;
}
.exp-bar.compact .exp-score {
  margin-left: 6px;
  font-size: 12px;
}

.exp-bar .exp-delta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  margin-left: 6px;
  color: var(--text-4);
  flex-shrink: 0;
  letter-spacing: -0.1px;
}

/* Bar OUTLINES carry state. Three meaningful colors:
   * red    — errored (failed)
   * purple — currently running (active)
   * gold   — on the best-path spine (lineage)
   Everything else uses the neutral default border. Subtypes (discarded /
   pruned / pending) get a dashed border so you can still tell "not live"
   from "live but neutral" at a glance. */
.exp-bar.committed .exp-id { color: var(--text-5); }
.exp-bar.committed .exp-hyp { color: var(--text-1); }

.exp-bar.evaluated .exp-id { color: var(--text-5); }
.exp-bar.evaluated .exp-hyp { color: var(--text-1); }

.exp-bar.discarded {
  border-style: dashed;
}
.exp-bar.discarded .exp-id { color: var(--text-5); }
.exp-bar.discarded .exp-hyp { color: var(--text-3); }

.exp-bar.pruned {
  border-style: dashed;
  opacity: 0.75;
}
.exp-bar.pruned .exp-id,
.exp-bar.pruned .exp-hyp { color: var(--text-5); }

.exp-bar.pending {
  border-style: dashed;
}
.exp-bar.pending .exp-id,
.exp-bar.pending .exp-hyp { color: var(--text-4); }

.exp-bar.failed {
  background: rgba(239,68,68,0.06);
  border-color: var(--red);
}
.exp-bar.failed .exp-id { color: var(--text-5); }
.exp-bar.failed .exp-hyp { color: var(--text-2); }
.exp-bar.failed .exp-score { color: var(--red); }

/* Spine override — placed AFTER the static statuses so gold wins over the
   neutral / dashed defaults. .active comes after this so a (theoretical)
   active spine node still pulses blue. */
.exp-bar.lineage {
  background: rgba(245,158,11,0.10);
  border-color: var(--amber);
  border-style: solid;
}
.exp-bar.lineage .exp-id  { color: rgba(245,158,11,0.55); }
.exp-bar.lineage .exp-hyp { color: var(--text-1); }
.exp-bar.lineage .exp-score { color: var(--amber); }

.exp-bar.active {
  background: rgba(168,85,247,0.08);
  border-color: var(--purple);
  border-style: solid;
  animation: pulse-active 2s ease-in-out infinite;
}
.exp-bar.active .exp-id { color: var(--text-5); }
@keyframes pulse-active {
  0%, 100% { box-shadow: 0 0 0 0 rgba(168,85,247,0); }
  50%      { box-shadow: 0 0 0 3px rgba(168,85,247,0.24); }
}

.exp-bar.root-bar {
  background: rgba(255,255,255,0.02);
  border-color: var(--border-subtle);
  border-style: dashed;
}
.exp-bar.root-bar .exp-id { color: var(--text-3); }
.exp-bar.root-bar .exp-hyp { color: var(--text-4); font-style: italic; }

/* Collapsed-children summary row */
.exp-collapsed-summary {
  position: absolute;
  display: flex;
  align-items: center;
  height: 22px;
  padding: 0 13px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-5);
  background: rgba(82,82,91,0.06);
  border-radius: 3px;
  border: 1px dashed var(--border);
  cursor: pointer;
}
.exp-collapsed-summary:hover { color: var(--text-2); border-color: var(--text-5); }

.timeline-empty {
  padding: 75px;
  text-align: center;
  color: var(--text-4);
  font-size: 16px;
}
.timeline-empty code {
  font-family: 'JetBrains Mono', monospace;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 2px 6px;
  margin: 0 2px;
  color: var(--text-2);
}

/* ─── Docked sidebar (opens on node selection) ──────────── */
.sidebar {
  width: var(--evo-sidebar-w, 575px);
  flex-shrink: 0;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
/* The content area is the scroll container; .sidebar itself stays put so the
   resize handle (its absolute child) doesn't scroll away. */
#sidebar-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.sidebar.hidden { display: none; }

/* Drag-to-resize handle on the panel's left edge (side mode only). */
.sidebar-resize {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 7px;
  cursor: ew-resize;
  z-index: 5;
}
.sidebar-resize::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: transparent;
  transition: background 0.12s;
}
.sidebar-resize:hover::before,
.sidebar-resize.dragging::before { background: var(--accent, #e8843c); }
/* No edge-resize in center peek — width is fixed there. */
.sidebar.peek-center .sidebar-resize { display: none; }

/* Diff tab: let the diff block fill the panel instead of capping at a fixed
   height with empty space below it. */
.sidebar[data-tab="diff"] #sidebar-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar[data-tab="diff"] .drawer-header,
.sidebar[data-tab="diff"] .drawer-tabs { flex-shrink: 0; }
.sidebar[data-tab="diff"] .drawer-section {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.sidebar[data-tab="diff"] .diff-toolbar { flex-shrink: 0; }
.sidebar[data-tab="diff"] .diff-files,
.sidebar[data-tab="diff"] .diff-block {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

/* Center-peek (Notion-style): lift the panel out of the right rail into a
   centered modal over a dimmed backdrop. The tree fills the width behind it. */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 50;
}
.sidebar-backdrop.hidden { display: none; }
.sidebar.peek-center {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(960px, 94vw);
  height: min(82vh, 880px);
  border: 1px solid var(--border);
  border-left: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  z-index: 60;
}
.drawer-peek-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  margin-right: 4px;
  background: none;
  border: none;
  border-radius: 5px;
  color: var(--text-3);
  cursor: pointer;
}
.drawer-peek-toggle:hover {
  background: var(--bg-hover, rgba(255, 255, 255, 0.06));
  color: var(--text-1);
}
.sidebar-prune-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-3);
  background: transparent;
  border: 1px solid var(--border);
  padding: 4px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
}
.sidebar-prune-btn:hover {
  color: var(--red);
  border-color: rgba(239,68,68,0.55);
  background: rgba(239,68,68,0.06);
}
.sidebar-spawn-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-3);
  background: transparent;
  border: 1px solid var(--border);
  padding: 4px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
}
.sidebar-spawn-btn:hover {
  color: var(--purple);
  border-color: rgba(168,85,247,0.55);
  background: rgba(168,85,247,0.06);
}
.drawer-header {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  min-height: 52px;
  border-bottom: 1px solid var(--border-subtle);
  gap: 8px;
  position: sticky;
  top: 0;
  background: var(--bg-panel);
  z-index: 2;
}
/* Browser-style back / forward chips for navigating between nodes opened
   in the drawer. Sized + colored to match the filter-toggle / settings
   button vocabulary; SVG chevrons inside. */
.drawer-nav {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  background: var(--bg-canvas);
  color: var(--text-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.1s, border-color 0.1s, background 0.1s;
}
.drawer-nav svg { width: 12px; height: 12px; display: block; }
.drawer-nav:hover:not(:disabled) {
  color: var(--text-1);
  border-color: var(--text-5);
}
.drawer-nav:disabled {
  color: var(--text-6);
  cursor: default;
  opacity: 0.45;
}
.drawer-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-panel);
  position: sticky;
  top: 52px;
  z-index: 1;
}
.drawer-tab {
  border: none;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text-4);
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 10px 6px;
  margin-bottom: -1px;
  text-align: center;
  transition: color 0.1s, border-color 0.1s;
}
.drawer-tab:hover {
  color: var(--text-1);
}
.drawer-tab.active {
  color: var(--text-1);
  border-bottom-color: var(--text-1);
}
.drawer-tab:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: -2px;
}
.drawer-back {
  font-size: 16px;
  color: var(--text-4);
  cursor: pointer;
}
.drawer-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-1);
}
.drawer-close {
  font-size: 20px;
  color: var(--text-4);
  cursor: pointer;
}
.drawer-section {
  padding: 20px 25px;
  border-bottom: 1px solid var(--border-subtle);
}
.drawer-section:last-child { border-bottom: none; }
/* Children list — a flat, sortable view of immediate children. Replaces
   the cramped mini-timeline sub-view. Each row is dot · id · score ·
   delta · hypothesis (truncated). Sorted by score desc by default. */
.drawer-children {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}
.drawer-child {
  display: grid;
  grid-template-columns: 8px 70px 44px 56px 1fr;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
}
.drawer-child:hover {
  border-color: var(--text-6);
  background: var(--bg-card);
}
.drawer-child-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-5);
}
.drawer-child-dot.committed { background: var(--green); }
.drawer-child-dot.failed    { background: var(--red); }
.drawer-child-dot.active,
.drawer-child-dot.evaluated,
.drawer-child-dot.pending,
.drawer-child-dot.discarded,
.drawer-child-dot.pruned    { background: var(--text-5); }
.drawer-child-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-1);
  letter-spacing: -0.2px;
}
.drawer-child-score {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  text-align: right;
}
.drawer-child-delta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-4);
  text-align: right;
}
.drawer-child-hyp {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.drawer-summary {
  padding: 22px 24px 22px;
  background:
    radial-gradient(circle at 0% 0%, rgba(245,158,11,0.10), transparent 38%),
    var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
}
.drawer-section-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 1.1px;
  margin-bottom: 12px;
  display: block;
}
/* Score row: big mono number + a subtle delta pill. No text-shadow glow
   — relies on size + amber for visual weight. */
.drawer-score-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.drawer-score {
  font-family: 'JetBrains Mono', monospace;
  font-size: 52px;
  font-weight: 700;
  color: var(--amber);
  line-height: 1;
  letter-spacing: -1.5px;
}
.drawer-score-delta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.drawer-score-delta.up      { color: var(--green); }
.drawer-score-delta.down    { color: var(--red); }
.drawer-score-delta.neutral { color: var(--text-4); }

/* Parent-link line under the score. Status is shown by the header pill,
   so the meta is just "from <parent_id>" with a navigable link. */
.drawer-score-meta {
  margin-top: 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-4);
}
.drawer-parent-link {
  color: var(--text-2);
  text-decoration: none;
  cursor: pointer;
  margin-left: 4px;
}
.drawer-parent-link:hover {
  color: var(--text-1);
  text-decoration: underline;
}

/* Detail line — small explanatory text for failures, prune reasons,
   or the frontier-candidate hint. Sits below the meta row, subtler. */
.drawer-summary-detail {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-3);
}
.drawer-summary-detail.error  { color: var(--red); }
.drawer-summary-detail.accent {
  color: var(--amber);
  padding: 8px 11px;
  background: rgba(245,158,11,0.05);
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: var(--radius-md);
}
.sidebar-empty {
  font-size: 14px;
  color: var(--text-4);
  line-height: 1.45;
}
.drawer-meta-row {
  display: flex;
  padding: 5px 0;
}
.drawer-meta-key {
  width: 100px;
  font-size: 14px;
  color: var(--text-4);
}
.drawer-meta-val {
  font-size: 14px;
  color: var(--text-3);
}
.drawer-meta-val.mono {
  font-family: 'JetBrains Mono', monospace;
}
.drawer-hyp {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-1);
  line-height: 1.5;
  margin-top: 4px;
}

/* Execution Backend — vendor logo sits inline with the backend label in
   a regular meta-row (no separate pill). */
.drawer-backend-inline-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-right: 8px;
  vertical-align: -4px;
}
.drawer-backend-inline-logo svg,
.drawer-backend-inline-logo img { width: 100%; height: 100%; display: block; }
/* Raw config fold-out at the bottom of the backend section — power-user
   escape hatch for fields the specialized renderer doesn't surface. */
.drawer-raw-config {
  margin-top: 12px;
  border-top: 1px dashed var(--border-subtle);
  padding-top: 10px;
}
.drawer-raw-config > summary {
  list-style: none;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-4);
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.drawer-raw-config > summary::-webkit-details-marker { display: none; }
.drawer-raw-config > summary::before {
  content: '▸';
  font-size: 9px;
  color: var(--text-5);
  transition: transform 0.12s;
  display: inline-block;
}
.drawer-raw-config[open] > summary::before { transform: rotate(90deg); }
.drawer-raw-config > summary:hover { color: var(--text-2); }
.drawer-raw-config .config-pre { margin-top: 8px; }
.diff-block {
  background: var(--bg-canvas);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  padding: 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  max-height: 375px;
  overflow-y: auto;
  white-space: pre;
}
.diff-add { color: var(--green); background: rgba(34,197,94,0.06); display: block; }
.diff-del { color: var(--red); background: rgba(239,68,68,0.06); display: block; }
.diff-hunk { color: var(--text-4); display: block; }
.diff-ctx { color: var(--text-3); display: block; }

/* GitHub-style per-file diff (split / unified) */
.diff-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.diff-view-toggle { display: flex; gap: 4px; }
.diff-view-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 5px;
  border: 1px solid var(--border-subtle);
  background: none;
  color: var(--text-3);
  cursor: pointer;
}
.diff-view-btn.active {
  background: var(--bg-hover, rgba(255,255,255,0.08));
  color: var(--text-1);
  border-color: var(--border);
}
.diff-files { overflow: auto; }
.diff-file {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  overflow: hidden;
  background: var(--bg-canvas);
}
.diff-file:last-child { margin-bottom: 0; }
.diff-file-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-2);
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 1;
}
.diff-file-name { overflow-wrap: anywhere; }
.diff-stat { font-size: 11px; margin-left: auto; flex-shrink: 0; }
.diff-stat-add { color: var(--green); }
.diff-stat-del { color: var(--red); }
.diff-hunk-head {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-4);
  background: rgba(255,255,255,0.02);
  padding: 3px 12px;
}
.diff-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  line-height: 1.5;
}
.diff-gutter {
  width: 40px;
  min-width: 40px;
  text-align: right;
  padding: 0 8px;
  color: var(--text-4);
  background: rgba(255,255,255,0.02);
  user-select: none;
  vertical-align: top;
}
.diff-table.split .diff-gutter-r { border-left: 1px solid var(--border-subtle); }
.diff-cell {
  padding: 0 8px;
  white-space: pre-wrap;
  word-break: break-word;
  vertical-align: top;
  color: var(--text-3);
}
.diff-cell.add { background: rgba(34,197,94,0.12); color: var(--text-1); }
.diff-cell.del { background: rgba(239,68,68,0.12); color: var(--text-1); }
.diff-cell.empty { background: rgba(255,255,255,0.015); }
.diff-sign {
  display: inline-block;
  width: 1ch;
  margin-right: 4px;
  color: var(--text-4);
  user-select: none;
}
/* Highlight.js tokens set their own foreground; keep their background clear
   so the line-level add/del tint shows through. */
.diff-cell .hljs,
.diff-cell code { background: transparent; }

.task-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
}
.task-row:last-child { border-bottom: none; }
/* Title line: dot + task id on the left, duration/score pushed right. */
.task-head {
  display: flex;
  align-items: center;
  gap: 9px;
}
.task-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.task-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--text-3);
  margin-right: auto;
  overflow-wrap: anywhere;
}
/* Description text — its own line below the title, full width. */
.task-summary {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-4);
  /* indent to align under the id, past the dot + gap */
  padding-left: 17px;
}
.task-score {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  flex-shrink: 0;
}
.task-duration {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-4);
  flex-shrink: 0;
}

/* Trace detail (expanded task) */
.trace-detail {
  padding: 13px 0 13px 20px;
  border-left: 3px solid var(--border);
  margin: 5px 0 10px 3px;
}
.trace-timestamps {
  display: flex;
  gap: 20px;
  font-size: 14px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-4);
  margin-bottom: 13px;
  padding: 5px 0;
}
.trace-msg {
  margin-bottom: 13px;
}
.trace-role {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}
.trace-role.user { color: var(--blue); }
.trace-role.agent { color: var(--indigo); }
.trace-role.tool { color: var(--amber); }
.trace-content {
  background: var(--bg-canvas);
  border-radius: var(--radius-md);
  padding: 10px 13px;
  border: 1px solid var(--border-subtle);
  font-size: 14px;
  color: var(--text-1);
  line-height: 1.5;
}
.trace-error {
  font-size: 14px;
  color: var(--red);
  margin-top: 2px;
}
.failure-box {
  background: rgba(239,68,68,0.04);
  border: 1px solid rgba(239,68,68,0.18);
  border-radius: var(--radius-md);
  padding: 13px;
  margin-top: 10px;
}
.failure-box-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.failure-box-text {
  font-size: 15px;
  color: var(--text-1);
  line-height: 1.5;
  margin-top: 5px;
}

/* ─── Modal (scratchpad) ──────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(9,9,11,0.85);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  width: 720px;
  max-height: 840px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
/* Confirmation modals (e.g., prune) are narrower than the settings modal. */
.modal-confirm { width: 440px; max-width: 92vw; max-height: none; }
.modal-confirm .modal-title .mono {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-1);
  margin-left: 4px;
}
.modal-blurb {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-3);
}
.modal-field {
  display: block;
}
.modal-field-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-4);
  margin-bottom: 6px;
}
.modal-field-req {
  font-size: 9px;
  color: var(--red);
  letter-spacing: 0.6px;
}
.modal-field textarea {
  width: 100%;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  color: var(--text-1);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font: inherit;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  resize: vertical;
}
.modal-field textarea:focus {
  outline: 1px solid var(--text-5);
  outline-offset: 0;
  border-color: var(--text-5);
}
.modal-error {
  margin-top: 10px;
  padding: 8px 11px;
  background: rgba(239,68,68,0.06);
  border: 1px solid rgba(239,68,68,0.45);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-size: 12px;
}
.modal-status {
  margin-top: 10px;
  padding: 8px 11px;
  background: rgba(168,85,247,0.06);
  border: 1px solid rgba(168,85,247,0.45);
  border-radius: var(--radius-sm);
  color: var(--purple);
  font-size: 12px;
}
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
/* Destructive primary button — red-tinted so the action reads as
   consequential without screaming. */
.btn-prune {
  background: rgba(239,68,68,0.10);
  border: 1px solid rgba(239,68,68,0.55);
  color: var(--red);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 5px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.btn-prune:hover:not(:disabled) {
  background: rgba(239,68,68,0.16);
  border-color: var(--red);
  color: #fecaca;
}
.btn-prune:disabled { opacity: 0.45; cursor: default; }
.btn-spawn {
  background: rgba(168,85,247,0.12);
  border: 1px solid rgba(168,85,247,0.50);
  color: var(--purple);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 5px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.btn-spawn:hover:not(:disabled) {
  background: rgba(168,85,247,0.18);
  border-color: var(--purple);
  color: #ddd6fe;
}
.btn-spawn:disabled { opacity: 0.45; cursor: default; }
.modal-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.modal-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
}
.modal-sub {
  font-size: 11px;
  color: var(--text-5);
  margin-left: 10px;
}
.close-btn {
  font-size: 18px;
  color: var(--text-4);
  cursor: pointer;
  line-height: 1;
}
.modal-body {
  padding: 24px;
  overflow-y: auto;
  font-size: 13px;
  color: var(--text-3);
  line-height: 1.6;
}
.modal-body.settings-body {
  padding: 18px 20px 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
/* Settings modal owns a footer in addition to header + body, so it
   needs to behave like a dedicated grid: header / scrollable body /
   sticky footer. Height is fixed (not capped) so switching tabs
   doesn't resize the modal — content scrolls inside the panel. */
.modal.settings-modal {
  display: flex;
  flex-direction: column;
  height: min(840px, 88vh);
  min-height: 0;
}
/* Workspace popover: read-only summary anchored beneath the project name
   in the topbar. Positioning is set inline by JS. */
.workspace-popover {
  position: fixed;
  z-index: 200;
  width: 360px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  font-size: 11px;
  color: var(--text-2);
}
.workspace-popover.hidden { display: none; }
.ws-pop-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.ws-pop-title {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}
.ws-pop-sub {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-5);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ws-pop-body {
  display: flex;
  flex-direction: column;
  padding: 8px 14px;
}
.ws-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border-subtle);
}
.ws-row:last-child { border-bottom: none; }
.ws-label {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-4);
}
.ws-value {
  color: var(--text-1);
  text-align: right;
  word-break: break-all;
}
.ws-value.mono { font-family: 'JetBrains Mono', monospace; }
.ws-pop-section {
  padding: 10px 14px;
  border-top: 1px solid var(--border-subtle);
}
.ws-pop-section-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-4);
  margin-bottom: 6px;
}
.ws-pre {
  margin: 0;
  background: var(--inset);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 8px 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-1);
  white-space: pre-wrap;
  overflow-x: auto;
}

/* Rich select: closed-state trigger with current label + sub, expands
   to a popover with full label + description per option. Replaces the
   nested left-rail pattern inside the settings panels — frees the full
   panel width for the option's config form. */
.rich-select { position: relative; width: 100%; }
.rich-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--inset);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 9px 12px;
  font: inherit;
  color: var(--text-1);
  cursor: pointer;
  text-align: left;
  transition: border-color 120ms ease;
}
.rich-select-trigger:hover { border-color: var(--text-5); }
.rich-select.open .rich-select-trigger {
  border-color: rgba(168,85,247,0.55);
}
.rich-select-current {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}
.rich-select-current-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
}
.rich-select-current-sub {
  font-size: 10px;
  color: var(--text-4);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rich-select-caret {
  flex-shrink: 0;
  color: var(--text-4);
  transition: transform 120ms ease;
}
.rich-select.open .rich-select-caret { transform: rotate(180deg); }
.rich-select-pop {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  box-shadow: 0 14px 36px rgba(0,0,0,0.55);
  max-height: 340px;
  overflow-y: auto;
}
.rich-select-pop.hidden { display: none; }
.rich-select-group-label {
  padding: 8px 12px 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-5);
}
.rich-select-option {
  padding: 9px 12px;
  cursor: pointer;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.rich-select-option-icon,
.rich-select-current-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
}
.rich-select-option-icon img,
.rich-select-option-icon svg,
.rich-select-current-icon img,
.rich-select-current-icon svg { width: 100%; height: 100%; object-fit: contain; }
.rich-select-option:first-of-type { border-top: none; }
.rich-select-group-label + .rich-select-option { border-top: none; }
.rich-select-option:hover { background: var(--inset); }
.rich-select-option.current { background: rgba(168,85,247,0.06); }
.rich-select-option-text { min-width: 0; flex: 1; }
.rich-select-option-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
}
.rich-select-option-desc {
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.45;
}
.rich-select-option-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--purple);
  border: 1px solid rgba(168,85,247,0.4);
  background: rgba(168,85,247,0.08);
  padding: 2px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

.modal-footer.settings-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-panel, var(--inset));
}
.settings-footer-status {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-3);
  letter-spacing: 0.02em;
  transition: color 120ms ease;
}
.settings-footer-status[data-tone="ok"]      { color: var(--green); }
.settings-footer-status[data-tone="error"]   { color: var(--red); }
.settings-footer-status[data-tone="pending"] { color: var(--purple); }
.modal-body pre {
  background: var(--inset);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  color: var(--text-3);
}
.config-pre {
  background: var(--inset);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  color: var(--text-2);
  margin: 10px 0 0;
}

/* Strategy picker */
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-3);
  font: inherit;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-right: 10px;
  transition: color 0.1s, background 0.1s;
}
.btn-ghost:hover {
  color: var(--text-1);
  border-color: rgba(255,106,42,0.65);
  background: rgba(255,106,42,0.08);
}

/* Topbar settings button — filled chip with icon. Heavier than the
   compact .btn-ghost variants used inside the settings modal so it reads
   as a clear, clickable control on the panel-colored topbar. */
#settings-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  color: var(--text-1);
  margin-right: 0;
}
#settings-btn svg {
  flex-shrink: 0;
  color: var(--text-2);
}
#settings-btn:hover {
  background: var(--bg-card);
  border-color: var(--text-5);
  color: var(--text-1);
}
#settings-btn:hover svg { color: var(--text-1); }
.btn-primary {
  background: var(--orange);
  color: #fff;
  border: none;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.1s, filter 0.1s;
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
}
.btn-primary:disabled {
  opacity: 0.35;
  cursor: default;
}
.btn-link {
  background: transparent;
  border: none;
  color: var(--text-4);
  font: inherit;
  font-size: 12px;
  padding: 6px 0;
  cursor: pointer;
  text-decoration: none;
}
.btn-link:hover {
  color: var(--text-2);
  text-decoration: underline;
}
.strategy-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.strategy-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-3);
  padding: 4px 0;
}
.strategy-row > span { flex: 1; }
.strategy-row small {
  color: var(--text-5);
  font-weight: normal;
}
.strategy-row select,
.strategy-row input {
  background: var(--inset);
  border: 1px solid var(--border-subtle);
  color: var(--text-1);
  padding: 6px 9px;
  border-radius: 4px;
  font: inherit;
  font-size: 12px;
  width: 140px;
}
.strategy-desc {
  font-size: 12px;
  color: var(--text-5);
  padding: 10px 12px;
  background: var(--inset);
  border-radius: 6px;
  line-height: 1.5;
}
.strategy-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-subtle);
  flex-shrink: 0;
}
.strategy-status {
  font-size: 12px;
  color: var(--text-5);
}
.strategy-empty {
  font-size: 12px;
  color: var(--text-5);
  font-style: italic;
}

/* Info-icon popover */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-2);
  font-size: 10px;
  font-weight: 600;
  cursor: help;
  user-select: none;
  line-height: 1;
  vertical-align: middle;
  transition: background 0.1s, color 0.1s;
}
.info-icon:hover {
  background: var(--text-6);
  color: var(--text-1);
}
.tip-popover {
  position: fixed;
  z-index: 300;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--text-6);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-2);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.tip-popover p {
  margin: 0;
}
.tip-popover p + p {
  margin-top: 8px;
}

.strategy-detail {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.strategy-detail-desc {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.55;
}
.strategy-detail-params {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

/* Workspace config modal */
.config-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
}
.config-backends {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.config-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 16px;
}
.config-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.config-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}
.config-card-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-3);
}
.config-card-section {
  margin-top: 14px;
}
.config-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-4);
}
.config-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
.config-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
}
.config-row span {
  color: var(--text-3);
}
.config-row strong {
  color: var(--text-1);
  font-size: 12px;
  text-align: right;
}
.config-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.config-badge {
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--text-3);
  background: var(--inset);
}
.config-badge.active {
  border-color: rgba(59,130,246,0.4);
  color: var(--blue);
}
.config-kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.config-kv {
  background: var(--inset);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px;
}
.config-kv span {
  display: block;
  font-size: 11px;
  color: var(--text-4);
}
.config-kv strong {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-1);
}
.config-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.config-list-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--inset);
  font-size: 12px;
  color: var(--text-3);
}
.config-list-main {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.config-runtime-empty {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-4);
}

.settings-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.settings-section {
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}
.settings-section:first-child {
  padding-top: 0;
  border-top: none;
}
.settings-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.settings-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-1);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border-subtle);
}
.settings-section-sub {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
}
.settings-summary-grid {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: 16px;
}
.settings-detail-block {
  min-width: 0;
}
.settings-section-body {
  margin-top: 4px;
}
.settings-provider-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}
.settings-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-3);
}
.settings-field.checkbox {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.settings-field.checkbox > span { flex: 1; }
.settings-field.checkbox input {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.settings-field small {
  color: var(--text-4);
}
.settings-field input,
.settings-field select,
.settings-field textarea {
  background: var(--inset);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 6px 9px;
  color: var(--text-1);
  font: inherit;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  width: 100%;
  transition: border-color 120ms ease;
}
.settings-field input:focus,
.settings-field select:focus,
.settings-field textarea:focus {
  outline: none;
  border-color: rgba(168,85,247,0.55);
}
.settings-select {
  background: var(--inset);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 6px 9px;
  color: var(--text-1);
  font: inherit;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  width: 100%;
}
/* Inline row variant: short inputs (numbers, selects) sit to the right
   of their label instead of below, matching the example density. */
.settings-field.inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.settings-field.inline > span { flex: 1; }
.settings-field.inline input,
.settings-field.inline select { width: 160px; }
.settings-field textarea {
  min-height: 88px;
  resize: vertical;
}
.settings-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}
.provider-status {
  margin-top: 16px;
}
.provider-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.provider-status-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--inset);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 10px;
}
.provider-status-item span {
  font-size: 11px;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.provider-status-item strong {
  font-size: 12px;
  color: var(--text-1);
  font-weight: 600;
}
.settings-advanced {
  margin-top: 16px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface);
}
.settings-advanced summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
.settings-advanced summary::-webkit-details-marker {
  display: none;
}
.settings-advanced-body {
  padding: 0 14px 14px;
}
.segmented-choice {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.segmented-choice-item {
  text-align: left;
  background: var(--inset);
  border: 1px solid var(--border-subtle);
  color: var(--text-3);
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.segmented-choice-item:hover {
  color: var(--text-2);
  border-color: var(--text-6);
}
.segmented-choice-item.selected {
  color: var(--text-1);
  background: var(--surface-2);
  border-color: rgba(242,139,57,0.45);
}
.settings-group {
  margin-top: 12px;
}
.override-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.override-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--inset);
  padding: 10px 12px;
}
.override-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-1);
}
.override-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-3);
}
.override-detail {
  margin-top: -2px;
}
.override-toggle {
  white-space: nowrap;
}
@media (max-width: 980px) {
  .config-layout {
    grid-template-columns: 1fr;
  }
  .settings-shell {
    gap: 14px;
  }
  .settings-summary-grid,
  .settings-provider-fields {
    grid-template-columns: 1fr;
  }
  .segmented-choice {
    grid-template-columns: 1fr;
  }
}

/* Settings modal layout */
.settings-shell {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
  flex: 1;
  height: 100%;
}
.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 12px;
  border-right: 1px solid var(--border-subtle);
  min-width: 0;
}
.settings-nav-item {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 8px 10px;
  text-align: left;
  color: var(--text-3);
  cursor: pointer;
  transition: color 120ms ease, background 120ms ease;
}
.settings-nav-item:hover {
  color: var(--text-1);
  background: var(--inset);
}
.settings-nav-item.selected {
  color: var(--text-1);
  background: var(--inset);
  border-left: 2px solid var(--purple);
  padding-left: 8px;
}
.settings-nav-title {
  display: block;
  font-size: 12px;
  font-weight: 600;
}
.settings-nav-sub {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  color: var(--text-5);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
}
.settings-panel {
  min-width: 0;
  overflow-y: auto;
  padding-right: 4px;
  min-height: 0;
}
.settings-block {
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px dashed var(--border-subtle);
}
.settings-block:first-child { padding-top: 0; margin-top: 0; border-top: none; }
.settings-block-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-4);
  margin-bottom: 10px;
  font-family: 'JetBrains Mono', monospace;
}
.settings-help { margin-top: 6px; font-size: 11px; color: var(--text-4); }
.runtime-source-row,
.runtime-check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--inset);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 8px;
}
.runtime-check-row {
  cursor: pointer;
}
.runtime-check-row:hover {
  border-color: var(--text-6);
  background: var(--surface-2);
}
.runtime-toggle-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border-subtle);
  background: var(--inset);
  border-radius: 8px;
  padding: 10px 12px;
}
.runtime-toggle-row strong {
  display: block;
  color: var(--text-1);
  font-size: 12px;
}
.runtime-toggle-row small {
  display: block;
  margin-top: 3px;
  max-width: 520px;
}
.runtime-source-editor {
  border: 1px solid var(--border-subtle);
  background: var(--inset);
  border-radius: 8px;
  padding: 10px;
  margin-top: 8px;
}
.runtime-source-editor-main {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(120px, 0.8fr) auto;
  gap: 8px;
  align-items: center;
}
.runtime-action-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.runtime-source-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-3);
}
.runtime-source-path {
  font-size: 12px;
  color: var(--text-1);
}
.runtime-source-meta,
.runtime-check-row span {
  font-size: 11px;
  color: var(--text-3);
}
.runtime-key-list {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
}
.runtime-key-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--inset);
  border-top: 1px solid var(--border-subtle);
  padding: 9px 11px;
  font-size: 11px;
}
.runtime-key-row:first-child {
  border-top: none;
}
.runtime-key-row span {
  color: var(--text-1);
  font-weight: 600;
}
.runtime-key-row code {
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
}
.runtime-source-status {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.35px;
}
.runtime-source-status.ok { color: var(--green); }
.runtime-source-status.bad { color: var(--red); }
.runtime-source-status:not(.ok):not(.bad) { color: var(--text-3); }
.runtime-key-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mini-modal-overlay {
  position: fixed;
  inset: 0;
  /* Sits ABOVE the settings modal (z-index 200) since it opens as a
     sub-modal from within it. */
  z-index: 240;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.mini-modal {
  width: min(560px, 100%);
  max-height: min(720px, 90vh);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 80px rgba(0,0,0,0.45);
}
.mini-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-subtle);
}
.mini-modal-body {
  padding: 18px;
}
.settings-input {
  background: var(--inset);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 9px 11px;
  color: var(--text-1);
  width: 100%;
}
.settings-field input,
.settings-field select,
.settings-field textarea {
  background: var(--inset);
  border: 1px solid var(--border-subtle);
  color: var(--text-1);
}
.settings-select {
  background: var(--inset);
  border: 1px solid var(--border-subtle);
  color: var(--text-1);
}
.provider-status-item {
  background: var(--inset);
  border: 1px solid var(--border-subtle);
}
.provider-status-item span { color: var(--text-4); }
.provider-status-item strong { color: var(--text-1); }
.settings-advanced {
  background: var(--surface);
  border-color: var(--border-subtle);
}
.segmented-choice-item {
  background: var(--inset);
  border-color: var(--border-subtle);
  color: var(--text-3);
}
.segmented-choice-item:hover {
  color: var(--text-1);
  border-color: var(--text-6);
}
.segmented-choice-item.selected {
  background: var(--surface);
  color: var(--text-1);
  border-color: rgba(255,106,42,0.45);
}
.override-row {
  background: var(--inset);
  border-color: var(--border-subtle);
}
.override-title { color: var(--text-1); }
.override-sub { color: var(--text-3); }
@media (max-width: 980px) {
  .settings-shell {
    grid-template-columns: 1fr;
  }
  .settings-nav {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 12px;
    flex-direction: row;
    overflow-x: auto;
  }
  .settings-nav-item {
    min-width: 160px;
  }
  .settings-panel {
    overflow-y: auto;
  }
}

/* Dashboard responsive fallbacks — shrink the rails as the viewport
   narrows but never hide the sidebar; the user has no other way to see
   detail content. The left rail is the first to shrink. */
@media (max-width: 1280px) {
  .sidebar { width: 420px; }
  .left-rail { width: 220px; }
}
@media (max-width: 1000px) {
  .left-rail { width: 190px; }
  .sidebar { width: 360px; }
}
