/* Minimal, data-first layout: one accent color, dense numbers, no decoration. */

:root {
  --bg: #fbfbfa;
  --bg-soft: #f3f3f1;
  --card: #ffffff;
  --fg: #17181a;
  --muted: #6b7076;
  --line: #e4e4e0;
  --accent: #2f6feb;
  --accent-2: #d97706;
  --accent-3: #059669;
  --accent-4: #9333ea;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #111214;
  --bg-soft: #17191c;
  --card: #17191c;
  --fg: #e8e9ea;
  --muted: #8b9198;
  --line: #262a2f;
  --accent: #4d8bf5;
  --accent-2: #f59e0b;
  --accent-3: #34d399;
  --accent-4: #c084fc;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111214;
    --bg-soft: #17191c;
    --card: #17191c;
    --fg: #e8e9ea;
    --muted: #8b9198;
    --line: #262a2f;
    --accent: #4d8bf5;
    --accent-2: #f59e0b;
    --accent-3: #34d399;
    --accent-4: #c084fc;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: min(1240px, 100% - 32px); margin: 0 auto; }

/* ---------------------------------------------------------------- nav */
.nav {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; gap: 20px; height: 52px; }
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-name { font-weight: 600; letter-spacing: -0.01em; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.live { background: var(--ok); box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); animation: pulse 2.4s infinite; }
.dot.stale { background: var(--warn); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.run-select {
  appearance: none;
  background: var(--bg-soft);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 3px 8px;
  font: inherit;
  font-size: 13px;
  max-width: 260px;
}

.tabs { display: flex; gap: 2px; margin-left: auto; }
.tabs a {
  padding: 6px 10px; border-radius: 7px; cursor: pointer;
  color: var(--muted); text-decoration: none; font-size: 13px;
}
.tabs a:hover { color: var(--fg); background: var(--bg-soft); }
.tabs a.active { color: var(--fg); background: var(--bg-soft); }

.nav-right { display: flex; align-items: center; gap: 10px; }
.nav-status { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.icon-btn {
  background: none; border: 1px solid var(--line); border-radius: 7px;
  color: var(--fg); cursor: pointer; width: 28px; height: 28px; line-height: 1;
}

/* --------------------------------------------------------------- hero */
.hero {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; padding: 28px 0 18px;
}
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.02em; }
.hero-sub { margin: 0; color: var(--muted); font-size: 13px; }
.hero-right { min-width: 300px; text-align: right; }
.hero-step { font-family: var(--mono); font-size: 24px; font-weight: 600; }
.hero-step small { color: var(--muted); font-size: 13px; font-weight: 400; margin-left: 6px; }
.hero-eta { color: var(--muted); font-size: 12px; font-family: var(--mono); margin-top: 6px; }
.progress { height: 4px; background: var(--bg-soft); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .6s ease; }

/* -------------------------------------------------------------- tiles */
.tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 10px; margin-bottom: 14px;
}

.grid-mini {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 14px; margin-top: 4px;
}
.mini { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.mini h3 {
  font-size: 11px; font-weight: 500; margin: 0 0 4px;
  font-family: var(--mono); color: var(--muted);
  display: flex; align-items: center; gap: 6px;
}
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px;
}
.tile-label { color: var(--muted); font-size: 11px; text-transform: lowercase; letter-spacing: .02em; }
.tile-value { font-family: var(--mono); font-size: 20px; font-weight: 600; margin-top: 3px; white-space: nowrap; }
.tile-value small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.tile-delta { font-size: 11px; font-family: var(--mono); color: var(--muted); }
.tile-delta.good { color: var(--ok); }
.tile-delta.bad { color: var(--err); }

/* ------------------------------------------------------- experiment setup */
/* Dense key/value grid: the shape and the recipe of one run, on one screen. */
.spec-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 18px;
}
.spec-item {
  display: flex; flex-direction: column; gap: 1px; min-width: 0;
  border-left: 2px solid var(--line); padding-left: 10px;
}
.spec-label { color: var(--muted); font-size: 11px; letter-spacing: .02em; }
.spec-value { font-family: var(--mono); font-size: 15px; font-weight: 600; }
.spec-hint {
  color: var(--muted); font-size: 10px; font-family: var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* --------------------------------------------------------------- runs */
.table-wrap { overflow-x: auto; }
table.runs { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12px; }
table.runs th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 11px;
  padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.runs td {
  padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.runs tbody tr { cursor: pointer; }
table.runs tbody tr:hover { background: var(--bg-soft); }
table.runs tbody tr.active { background: color-mix(in srgb, var(--accent) 10%, transparent); }
table.runs td.status { color: var(--muted); }
table.runs td.status .pct { color: var(--fg); margin-right: 6px; }
table.runs td.status.running { color: var(--accent); }
table.runs td.status.done { color: var(--ok); }
table.runs td.status.failed, table.runs td.status.error { color: var(--err); }

/* A shared legend under the compare charts: 20 runs, one color each. */
.compare-legend { grid-column: 1 / -1; margin-top: 2px; }
.compare-legend span { font-size: 10px; }

/* --------------------------------------------------------------- grid */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 14px; }
.span2 { grid-column: span 2; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 14px; min-width: 0;
}
.grid .card { margin-bottom: 0; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.card-head h2 { font-size: 13px; font-weight: 600; margin: 0; letter-spacing: .01em; }
.controls { margin-left: auto; display: flex; gap: 14px; align-items: center; }
.ctl { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; cursor: pointer; }
.ctl input[type="range"] { width: 110px; accent-color: var(--accent); }

.chart { width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text { fill: var(--muted); font-size: 10px; font-family: var(--mono); }
.chart .axis line, .chart .axis path { stroke: var(--line); }
.chart .grid-line { stroke: var(--line); stroke-dasharray: 2 3; opacity: .7; }
.chart .series-line { fill: none; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hover-dot { stroke: var(--card); stroke-width: 1.5; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); font-family: var(--mono); }
.swatch { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* -------------------------------------------------------------- feeds */
.feed { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.feed.compact { max-height: 200px; gap: 6px; }
.sample { border-left: 2px solid var(--line); padding-left: 10px; }
.sample-step { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.sample-text { font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.event { display: flex; gap: 10px; font-size: 12px; align-items: baseline; }
.event time { font-family: var(--mono); color: var(--muted); font-size: 11px; flex: none; }
.event.warn .msg { color: var(--warn); }
.event.error .msg { color: var(--err); }

.muted { color: var(--muted); }
.small { font-size: 11px; }

/* ------------------------------------------------------------ picker */
.picker { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.pill {
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--muted);
  border-radius: 20px; padding: 3px 10px; font-size: 12px; cursor: pointer;
  font-family: var(--mono);
}
.pill.on { color: var(--fg); border-color: var(--fg); background: var(--card); }
.pill .swatch { margin-right: 5px; }

/* --------------------------------------------------------------- misc */
.json {
  font-family: var(--mono); font-size: 12px; line-height: 1.5; margin: 0;
  white-space: pre-wrap; overflow-wrap: anywhere; color: var(--fg);
  background: var(--bg-soft); border-radius: 8px; padding: 12px;
  max-height: 420px; overflow: auto;
}
.hidden { display: none !important; }
.foot {
  display: flex; justify-content: space-between; color: var(--muted);
  font-size: 11px; font-family: var(--mono); padding: 20px 0 28px;
}
.tip {
  position: fixed; pointer-events: none; z-index: 50;
  background: var(--card); border: 1px solid var(--line); border-radius: 7px;
  padding: 6px 8px; font-family: var(--mono); font-size: 11px;
  box-shadow: 0 6px 24px rgba(0,0,0,.12); white-space: nowrap;
}

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .span2 { grid-column: span 1; }
  .hero { flex-direction: column; align-items: stretch; }
  .hero-right { min-width: 0; text-align: left; }
  .nav-inner { gap: 10px; }
  .run-select { max-width: 140px; }
  .nav-status { display: none; }
}

/* On a phone the brand, the run picker and four tabs cannot share one row:
   stack the picker full width and let the tabs scroll on their own. */
@media (max-width: 640px) {
  .nav-inner { flex-wrap: wrap; height: auto; padding: 8px 0; gap: 8px 10px; }
  .brand { flex: 1 1 100%; }
  .brand-name { white-space: nowrap; }
  .run-select { max-width: none; flex: 1 1 auto; min-width: 0; }
  .nav-right { margin-left: auto; }
  .tabs { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
}
