:root {
  color-scheme: light;
  --surface-0: #f4f3f0;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --border: #dddbd5;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77756f;
  --accent: #2a78d6;
  --series-typing: #2a78d6;
  --series-paste: #eb6834;
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-critical: #d03b3b;
  --status-good-text: #006300;
  --status-warning-text: #7a5200;
  --status-critical-text: #a32020;
  --band-away: rgba(82, 81, 78, 0.16);
  --band-idle: rgba(82, 81, 78, 0.08);
  --code-bg: #f6f5f2;
  --highlight: rgba(250, 178, 25, 0.35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --surface-2: #242422;
    --border: #383835;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #9a9890;
    --accent: #3987e5;
    --series-typing: #3987e5;
    --series-paste: #d95926;
    --status-good-text: #6fd16f;
    --status-warning-text: #fab219;
    --status-critical-text: #f08a8a;
    --band-away: rgba(195, 194, 183, 0.18);
    --band-idle: rgba(195, 194, 183, 0.08);
    --code-bg: #20201e;
    --highlight: rgba(250, 178, 25, 0.28);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --surface-2: #242422;
  --border: #383835;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #9a9890;
  --accent: #3987e5;
  --series-typing: #3987e5;
  --series-paste: #d95926;
  --status-good-text: #6fd16f;
  --status-warning-text: #fab219;
  --status-critical-text: #f08a8a;
  --band-away: rgba(195, 194, 183, 0.18);
  --band-idle: rgba(195, 194, 183, 0.08);
  --code-bg: #20201e;
  --highlight: rgba(250, 178, 25, 0.28);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
button, select, input { font: inherit; color: inherit; }
button {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover { border-color: var(--text-muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
select, input[type="text"], input[type="password"], input[type="search"], input[type="url"] {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }

.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--surface-1); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; color: var(--text-primary); text-decoration: none; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
main { max-width: 1280px; margin: 0 auto; padding: 16px; }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 16px; }
.signin { max-width: 440px; margin: 48px auto; }
.signin label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-weight: 600; }
.signin .error { color: var(--status-critical-text); min-height: 1.2em; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.tile .label { color: var(--text-secondary); font-size: 12px; }
.tile .value { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--text-secondary); font-weight: 600; font-size: 12px; position: sticky; top: 0; background: var(--surface-1); }
th button { all: unset; cursor: pointer; }
th button:focus-visible { outline: 2px solid var(--accent); }
td.num, th.num { text-align: right; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
td.reasons { white-space: normal; min-width: 260px; color: var(--text-secondary); font-size: 12px; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12px; }
.badge .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.badge.strong { color: var(--status-critical-text); }
.badge.strong .dot { background: var(--status-critical); border-radius: 2px; transform: rotate(45deg); }
.badge.review { color: var(--status-warning-text); }
.badge.review .dot { background: var(--status-warning); }
.badge.none { color: var(--text-muted); }
.badge.none .dot { background: transparent; border: 1.5px solid var(--text-muted); }
.badge.note { color: var(--text-secondary); }
.badge.note .dot { background: var(--text-muted); width: 6px; height: 6px; }

.reason-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.reason-list li { display: flex; gap: 10px; align-items: baseline; }
.reason-list .badge { min-width: 70px; }

.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 16px; margin: 0; }
.metrics div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dashed var(--border); padding: 4px 0; }
.metrics dt { color: var(--text-secondary); }
.metrics dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.timeline svg { width: 100%; display: block; overflow: visible; }
.timeline .lane-label { fill: var(--text-secondary); font-size: 11px; }
.timeline .axis { fill: var(--text-muted); font-size: 10px; }
.timeline .grid { stroke: var(--border); stroke-width: 1; }
.timeline .cursor { stroke: var(--text-primary); stroke-width: 1.5; }
.timeline .hit { fill: transparent; cursor: pointer; }

.tooltip {
  position: fixed; z-index: 10; pointer-events: none; max-width: 320px;
  background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px; font-size: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.15);
}

.player-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.player-controls input[type="range"] { flex: 1; min-width: 160px; }
.player-caption { color: var(--text-secondary); font-size: 12px; min-height: 1.4em; margin-bottom: 8px; }
.cells { display: grid; gap: 8px; }
.cell { border: 1px solid var(--border); border-radius: 6px; background: var(--code-bg); }
.cell .cell-head { font-size: 11px; color: var(--text-muted); padding: 4px 8px; border-bottom: 1px solid var(--border); }
.cell pre { margin: 0; padding: 8px; overflow-x: auto; font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.cell.markdown pre { font-family: inherit; color: var(--text-secondary); }
.cell mark { background: var(--highlight); color: inherit; border-radius: 2px; }
.cell.active { border-color: var(--accent); }

@media (max-width: 640px) {
  main { padding: 12px 16px; }
  .tile .value { font-size: 22px; }
}
@media (forced-colors: active) {
  .badge .dot { border: 1px solid CanvasText; }
}
