/* Tokens: chart chrome, categorical slots, diverging pair, delta text.
   Dark values are their own validated steps, declared under both the OS
   preference and an explicit data-theme. */
:root {
  color-scheme: light;
  --page: #f9f9f7; --surface-1: #fcfcfb;
  --text-primary: #0b0b0b; --text-secondary: #52514e; --muted: #898781;
  --hairline: #e1e0d9; --axis: #c3c2b7; --ring: rgba(11,11,11,.10);
  --wash: rgba(11,11,11,.05);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --div-neg: #2a78d6; --div-mid: #f0efec; --div-pos: #e34948;
  --better: #006300; --worse: #d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface-1: #1a1a19;
    --text-primary: #ffffff; --text-secondary: #c3c2b7; --muted: #898781;
    --hairline: #2c2c2a; --axis: #383835; --ring: rgba(255,255,255,.10);
    --wash: rgba(255,255,255,.06);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --div-neg: #3987e5; --div-mid: #383835; --div-pos: #e66767;
    --better: #0ca30c; --worse: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface-1: #1a1a19;
  --text-primary: #ffffff; --text-secondary: #c3c2b7; --muted: #898781;
  --hairline: #2c2c2a; --axis: #383835; --ring: rgba(255,255,255,.10);
  --wash: rgba(255,255,255,.06);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --div-neg: #3987e5; --div-mid: #383835; --div-pos: #e66767;
  --better: #0ca30c; --worse: #e66767;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: inherit; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

header {
  position: sticky; top: 0; z-index: 5; background: var(--page);
  border-bottom: 1px solid var(--hairline);
}
header .bar {
  max-width: 1120px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
header h1 { font-size: 15px; font-weight: 600; margin: 0; }
header nav { display: flex; gap: 4px; }
header nav a {
  text-decoration: none; padding: 4px 10px; border-radius: 6px;
  color: var(--text-secondary);
}
header nav a:hover { background: var(--wash); }
header nav a.on { color: var(--text-primary); background: var(--wash); font-weight: 600; }
header .gen { margin-left: auto; color: var(--muted); font-size: 12px; }

main { max-width: 1120px; margin: 0 auto; padding: 16px 16px 48px; }
.card {
  background: var(--surface-1); border: 1px solid var(--ring); border-radius: 10px;
  padding: 16px 18px; margin-bottom: 16px; min-width: 0;
}
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 2px; }
.card h3 { font-size: 13px; font-weight: 600; margin: 14px 0 4px; color: var(--text-secondary); }
.sub { color: var(--text-secondary); font-size: 12.5px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 860px) { .grid3, .grid2 { grid-template-columns: minmax(0, 1fr); } }

button, select {
  font: inherit; font-size: 13px; color: var(--text-primary);
  background: var(--surface-1); border: 1px solid var(--ring); border-radius: 6px;
  padding: 4px 9px; cursor: pointer; min-height: 30px;
}
button:hover:not(:disabled) { background: var(--wash); }
button:disabled { color: var(--muted); cursor: default; }
button.on { background: var(--wash); font-weight: 600; }
select { max-width: 100%; }

/* chart */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--hairline); stroke-width: 1; }
.chart .axis line { stroke: var(--axis); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart text.end { fill: var(--text-secondary); font-size: 11.5px; }
.chart text.end.note { fill: var(--muted); font-size: 11px; }
.chart .series path.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series path.band { stroke: none; opacity: .12; }
.chart .series circle { stroke: var(--surface-1); stroke-width: 2; }
.chart .env line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .env text { fill: var(--muted); font-size: 10.5px; }
.chart .xhair { stroke: var(--text-secondary); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .whisker { stroke: var(--text-secondary); stroke-width: 1.5; fill: none; }
.chart rect.hit:focus { outline: none; }
.chart rect.hit:focus-visible { stroke: var(--text-secondary); stroke-width: 1; }
.legend { display: flex; gap: 4px 14px; flex-wrap: wrap; font-size: 12.5px; margin: 4px 0 6px; }
.legend .item { display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
                color: var(--text-primary); user-select: none; padding: 2px 4px; border-radius: 4px; }
.legend .item:hover { background: var(--wash); }
.legend .item.off { color: var(--muted); }
.legend .item.off .key { opacity: .3; }
.legend .key { width: 14px; height: 2px; border-radius: 1px; flex: none; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }

#tip {
  position: fixed; pointer-events: none; display: none; z-index: 20;
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--ring); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.18);
  padding: 8px 10px; font-size: 12.5px; max-width: min(380px, calc(100vw - 24px));
}
#tip .t { color: var(--text-secondary); margin-bottom: 4px; }
#tip .r { display: flex; align-items: center; gap: 8px; }
#tip .r .key { width: 12px; height: 2px; border-radius: 1px; flex: none; }
#tip .r .v { font-weight: 600; font-variant-numeric: tabular-nums; }
#tip .r .l { color: var(--text-secondary); }

/* tables */
.tw { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { text-align: left; padding: 5px 10px 5px 0; border-bottom: 1px solid var(--hairline);
         vertical-align: top; }
th { color: var(--muted); font-weight: 500; white-space: nowrap; }
th.num { text-align: right; }
tr.sep td { border-bottom-color: var(--axis); }
details { margin-top: 10px; }
summary { cursor: pointer; color: var(--text-secondary); font-size: 12.5px; }

/* deltas: icon + sign + text, never color alone */
.d { font-variant-numeric: tabular-nums; white-space: nowrap; }
.d.better { color: var(--better); }
.d.worse { color: var(--worse); }
.d.same { color: var(--muted); }

/* checks: history (one row per commit) and failure logs */
.ckhist { width: auto; }
.ckhist th, .ckhist td { padding: 3px 6px 3px 0; }
.ckhist thead th { vertical-align: bottom; }
.ckhist th.grp { text-align: center; color: var(--text-secondary); font-weight: 600; border-bottom: 0; padding-bottom: 0; }
.ckhist th.set { font-size: 11px; font-weight: 400; padding: 4px 2px; vertical-align: bottom; text-align: center; }
.ckhist th.set .v { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; display: inline-block; }
.ckhist td.c { text-align: center; padding: 3px 2px; min-width: 16px; }
.ckhist .gs { border-left: 1px solid var(--hairline); padding-left: 6px; }
.ckhist .fs { padding-left: 8px; }
.ckhist td.subj { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ckhist tbody tr { cursor: pointer; }
.ckhist tbody tr:hover td { background: var(--wash); }
.ckhist tbody tr.cur td { background: var(--wash); }
.ckhist tbody tr.cur td:first-child a { font-weight: 600; }
.ckhist .st { font-size: 12px; line-height: 1; }
.ckhist .st.ok { color: var(--better); }
.ckhist .st.ko { color: var(--worse); font-weight: 700; }
.ckhist .st.none { color: var(--muted); }
.pf td { vertical-align: top; }
.pf .op { white-space: nowrap; margin-right: 12px; }
.pf .lemma { white-space: nowrap; }
.nw { white-space: nowrap; }
.pf .st { font-size: 12px; }
.pf .st.ok { color: var(--better); }
.pf .st.ko { color: var(--worse); font-weight: 700; }
.pf .st.none { color: var(--muted); }
pre.log { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--wash);
          border-radius: 6px; padding: 8px 10px; overflow-x: auto; margin: 6px 0 0; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.tile { border: 1px solid var(--ring); border-radius: 8px; padding: 10px 12px; }
.tile .k { color: var(--text-secondary); font-size: 12px; }
.tile .v { font-size: 22px; font-weight: 600; margin-top: 2px; }
.tile .s { font-size: 12.5px; margin-top: 2px; }

/* compare selectors */
.pick { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 6px;
        align-items: center; }
.pick .lab { color: var(--text-secondary); font-size: 12.5px; width: 22px; }
.pick select { width: 100%; }
.notice { border-left: 3px solid var(--s4); padding: 6px 10px; background: var(--wash);
          border-radius: 4px; font-size: 12.5px; margin: 10px 0 0; }
.notice ul { margin: 4px 0 0; padding-left: 18px; }

/* sunburst */
.sb { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.sb .plot { flex: 1 1 420px; max-width: 560px; min-width: 0; }
.sb .side { flex: 1 1 220px; min-width: 0; }
.sb path.arc { cursor: pointer; }
.sb path.arc:hover { filter: brightness(1.08); }
.sb text.albl { pointer-events: none; font-size: 11px; dominant-baseline: central; }
.sb text.ct { fill: var(--text-primary); font-weight: 600; pointer-events: none; }
.sb text.cs { fill: var(--text-secondary); font-size: 12px; pointer-events: none; }
.crumbs { font-size: 13px; color: var(--muted); margin: 6px 0; }
.crumbs a { color: var(--text-primary); cursor: pointer; text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .here { color: var(--text-secondary); font-weight: 600; }
.ramp { height: 8px; border-radius: 4px; margin: 6px 0 2px;
        background: linear-gradient(90deg, var(--div-neg), var(--div-mid), var(--div-pos)); }
.ramp-l { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }

/* commit picker */
.cpick { position: relative; min-width: 0; }
.cpick .cur { width: 100%; text-align: left; overflow: hidden; text-overflow: ellipsis;
              white-space: nowrap; padding-right: 26px; position: relative; }
.cpick .cur::after { content: "▾"; position: absolute; right: 9px; color: var(--muted); }
.cpick .panel { position: absolute; z-index: 15; left: 0; right: 0; top: calc(100% + 4px);
                background: var(--surface-1); border: 1px solid var(--ring); border-radius: 8px;
                box-shadow: 0 6px 20px rgba(0,0,0,.18); padding: 6px; }
.cpick input { width: 100%; font: inherit; font-size: 13px; color: var(--text-primary);
               background: var(--page); border: 1px solid var(--ring); border-radius: 6px;
               padding: 6px 8px; margin-bottom: 4px; }
.cpick .list { max-height: 300px; overflow-y: auto; }
.cpick .it { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 10px;
             padding: 5px 8px; border-radius: 5px; cursor: pointer; font-size: 13px; }
.cpick .it .subj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cpick .it.on { background: var(--wash); }
.cpick .it.sel { font-weight: 600; }
.cpick .more { color: var(--muted); font-size: 12px; padding: 4px 8px 2px; }
.cpick .more:empty { display: none; }

.sw.hatch { background: repeating-linear-gradient(45deg, var(--div-mid) 0 2px, var(--muted) 2px 4px); }
ul.removed { list-style: none; padding: 0; margin: 0; font-size: 12px; }
ul.removed li { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
ul.removed li .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }

/* bench bars: operations side by side, separated */
.grid3.ops { gap: 0; }
.grid3.ops .opname { font-size: 12px; color: var(--text-secondary); font-weight: 600; margin: 2px 0; }
@media (min-width: 861px) {
  .grid3.ops .op + .op { border-left: 1px solid var(--hairline); padding-left: 16px; margin-left: 16px; }
}
@media (max-width: 860px) { .grid3.ops .op + .op { margin-top: 10px; } }
