/* Same palette and type as Life Lab (the simulator site). */
:root {
  --bg: #0e110f;
  --surface: #151917;
  --surface-2: #1c211e;
  --line: #2a312d;
  --text: #e4e8e1;
  --muted: #8d978f;
  --accent: #c8f26b;
  --accent-ink: #18200a;
  --still: #7cc7ff;
  --osc: #ffb35c;
  --ship: #ff6f91;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --sans: 'IBM Plex Sans', system-ui, sans-serif;
  --r: 6px;
  --gap: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
body { display: flex; flex-direction: column; overflow: hidden; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums lining-nums; }
.muted { color: var(--muted); font-weight: 400; }
.lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }

/* ---------------------------------------------------------------- top bar: title + filters */
.topbar { flex: 0 0 auto; min-height: 52px; display: flex; align-items: center; gap: 24px; padding: 6px 16px;
  border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-weight: 600; color: var(--accent);
  letter-spacing: .02em; white-space: nowrap; }
.authors { color: var(--muted); font-family: var(--sans); font-weight: 400; font-size: 13px; margin-left: 6px; }
.filters { display: flex; align-items: center; gap: 22px; margin-left: auto; flex-wrap: wrap; }
.filter { display: flex; align-items: center; gap: 10px; }
.val { min-width: 84px; font-size: 13px; }
.runs-left { display: flex; align-items: baseline; gap: 8px; padding-left: 18px; border-left: 1px solid var(--line); }
.runs-left .num { font-size: 15px; color: var(--accent); min-width: 72px; }

/* dual-handle range slider */
.dual { position: relative; width: 170px; height: 22px; }
.dual::before { content: ''; position: absolute; left: 0; right: 0; top: 10px; height: 3px; border-radius: 2px; background: var(--line); }
.dual .fill { position: absolute; top: 10px; height: 3px; border-radius: 2px; background: var(--accent); }
.dual input { position: absolute; inset: 0; width: 100%; margin: 0; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; }
.dual input::-webkit-slider-runnable-track { background: none; height: 22px; }
.dual input::-moz-range-track { background: none; }
.dual input::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 14px; height: 14px; margin-top: 4px;
  border-radius: 50%; background: var(--text); border: 2px solid var(--bg); cursor: pointer; }
.dual input::-moz-range-thumb { pointer-events: auto; width: 12px; height: 12px; border-radius: 50%; background: var(--text);
  border: 2px solid var(--bg); cursor: pointer; }
.dual input:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 5px 10px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #46504a; }
.btn:focus-visible, .seg button:focus-visible, .x:focus-visible, .row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.small { padding: 2px 8px; font-size: 12px; }

/* ---------------------------------------------------------------- six panes */
.grid { flex: 1 1 auto; min-height: 0; display: grid; gap: var(--gap); padding: var(--gap);
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(300px, .82fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
.pane { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px;
  display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative; }
.pane-title { margin: 0 0 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.pane-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.pane-head .pane-title { margin: 0; }
.chart { flex: 1 1 auto; min-height: 0; position: relative; }
.chart canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* summary */
.kpis { flex: 1 1 auto; display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 1fr; gap: 8px; min-height: 0; }
.kpi { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px;
  display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.kpi .k { font-size: 11px; line-height: 1.3; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.kpi .v { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: clamp(16px, 1.7vw, 24px); margin-top: 2px; white-space: nowrap; }
.legend { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* object list */
.list-mode, .detail-mode { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button { background: var(--surface-2); border: 0; border-right: 1px solid var(--line); padding: 3px 9px; cursor: pointer; font-size: 12px;
  display: flex; align-items: center; gap: 5px; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; }
.t-still { background: var(--still); } .t-osc { background: var(--osc); } .t-ship { background: var(--ship); }
.list-cols { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .06em; padding: 0 8px 4px; border-bottom: 1px solid var(--line); }
.list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; position: relative; }
.list-inner { position: relative; }
.row { position: absolute; left: 0; right: 0; display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 10px;
  padding: 0 8px; border-bottom: 1px solid #202622; cursor: pointer; }
.row:hover { background: var(--surface-2); }
.row.sel { background: #222a1b; }
.row canvas { width: 44px; height: 44px; background: var(--bg); border-radius: 4px; display: block; }
.row .track { height: 4px; background: var(--bg); border-radius: 2px; overflow: hidden; }
.row .fill { height: 100%; border-radius: 2px; opacity: .55; }
.row .pct { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 13px; min-width: 64px; text-align: right; }
.empty { color: var(--muted); font-size: 13px; padding: 20px 8px; text-align: center; }

/* detail */
.x { background: none; border: 0; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.x:hover { color: var(--text); }
.chip { font-family: var(--mono); font-size: 12px; padding: 2px 9px; border-radius: 99px; border: 1px solid currentColor; text-transform: none; letter-spacing: 0; }
.apg { font-size: 12px; color: var(--muted); word-break: break-all; margin-bottom: 8px; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 13px; overflow-y: auto; min-height: 0; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }

/* viewer */
.viewer-ctl { display: flex; align-items: center; gap: 10px; font-size: 12px; }

/* tooltip */
.tooltip { position: fixed; z-index: 30; pointer-events: none; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 6px 9px; font-size: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.45); max-width: 260px; }
.tooltip b { font-weight: 600; }
.tooltip .tr { display: flex; justify-content: space-between; gap: 14px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tooltip .tr i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }

/* loading */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(14,17,15,.92); display: flex; align-items: center; justify-content: center; }
.overlay-box { text-align: center; color: var(--muted); max-width: 440px; padding: 20px; }
.overlay-box code { font-family: var(--mono); color: var(--text); background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }
.spinner { width: 28px; height: 28px; margin: 0 auto 12px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* short screens: keep panes readable and let the page scroll instead of squashing */
@media (max-height: 620px) {
  body { overflow: auto; }
  .grid { flex: none; height: 640px; }
}
/* narrow screens: stack panes */
@media (max-width: 980px) {
  body { overflow: auto; }
  .grid { flex: none; height: auto; grid-template-columns: 1fr; grid-template-rows: none; grid-auto-rows: minmax(320px, auto); }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .runs-left { border-left: 0; padding-left: 0; }
  .filters { margin-left: 0; gap: 14px; }
  .dual { width: 140px; }
}
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
