:root {
  color-scheme: light;
  --surface-1: #fdfdfc;
  --surface-2: #f2f1ec;
  --border: #dedcd2;
  --text-primary: #1a1a19;
  --text-secondary: #5c5b52;
  --text-muted: #8a8878;
  --accent: #2a78d6;
  --grid: #e8e6df;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --surface-2: #232322;
    --border: #3a3934;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #98968a;
    --accent: #3987e5;
    --grid: #2c2b28;
  }
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--surface-1);
  color: var(--text-primary);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 13px 22px; border-bottom: 1px solid var(--border);
  background: var(--surface-1);
}
.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); align-self: center; }
.topbar h1 { font-size: 17px; font-weight: 650; letter-spacing: .01em; }
.subtitle { color: var(--text-muted); font-size: 12.5px; }
.controls { display: flex; align-items: center; gap: 14px; }
.count { color: var(--text-secondary); font-size: 12.5px; white-space: nowrap; }
.toggle { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.toggle button {
  border: 0; background: transparent; color: var(--text-secondary);
  padding: 6px 14px; font: inherit; font-size: 13px; cursor: pointer;
}
.toggle button.active { background: var(--surface-2); color: var(--text-primary); font-weight: 600; }

/* Column header: its OWN row above the graph pane — can never overlap the chart. */
.col-head-clip { flex: none; overflow: hidden; border-bottom: 1px solid var(--border); background: var(--surface-1); }
.col-head { display: flex; width: max-content; will-change: transform; }
.col-head .col {
  flex: 0 0 auto; text-align: center; padding: 9px 8px 7px;
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.col-head .col a { color: inherit; text-decoration: none; }
.col-head .col a:hover { color: var(--accent); text-decoration: underline; }
.col-head .col .n { display: block; font-weight: 400; font-size: 11px; color: var(--text-muted); }

#graphPane { flex: 1 1 0; min-height: 0; overflow: auto; position: relative; }
svg#graph { display: block; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.colline { stroke: var(--grid); stroke-width: 1; }
.axis-date { fill: var(--text-secondary); font-size: 11px; font-weight: 600; }
.axis-time { fill: var(--text-muted); font-size: 10px; }
.devline { fill: none; stroke-width: 2; }
.branchline { fill: none; stroke-width: 1.5; stroke-dasharray: 4 4; opacity: .75; }
.dot { stroke: var(--surface-1); stroke-width: 2; cursor: pointer; }
.dot-hit { fill: transparent; cursor: pointer; }
.start-label { fill: var(--text-secondary); font-size: 11px; }
.tip-label { fill: var(--text-secondary); font-size: 11px; font-weight: 600; }
.dot-title { fill: var(--text-muted); font-size: 10.5px; }

.legend {
  flex: none;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 10px 22px; border-top: 1px solid var(--border);
  background: var(--surface-1);
  font-size: 12.5px; color: var(--text-secondary);
}
.legend .chip { display: inline-flex; align-items: center; gap: 7px; }
.legend .chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.tooltip {
  position: fixed; z-index: 50; max-width: 380px;
  background: var(--surface-2); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 12.5px; pointer-events: none;
  box-shadow: 0 6px 24px rgba(0,0,0,.18);
}
.tooltip .t-title { font-weight: 650; margin-bottom: 3px; }
.tooltip .t-meta { color: var(--text-secondary); margin-bottom: 5px; }
.tooltip .t-result { color: var(--text-secondary); white-space: pre-wrap; }
.tooltip .t-link { color: var(--accent); margin-top: 5px; }

#tableWrap { flex: 1 1 0; min-height: 0; padding: 0 22px; overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-secondary); font-weight: 600; position: sticky; top: 0; background: var(--surface-1); z-index: 5; }
td .devchip { display: inline-flex; align-items: center; gap: 6px; }
td .devchip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
td a { color: var(--accent); }
td .result { color: var(--text-secondary); }

.empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  text-align: center; color: var(--text-secondary);
}
.empty .hint { margin-top: 12px; font-size: 13px; color: var(--text-muted); }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; font-size: 12px; }

@media (max-width: 720px) {
  .subtitle { display: none; }
  .topbar { padding: 10px 14px; }
  .legend { padding: 8px 14px; gap: 12px; }
}
