:root, :root[data-theme="dark"] {
  --bg: #14180f; --panel: #1c2216; --line: #2f3826; --text: #e7e9dc; --muted: #8e9680;
  --hover: #1a2013; --detail: #10140b; --pick: #262e1e; --on-accent: #14180f;
  --c0: #ff8a3d; --c1: #5ec8e5; --c2: #b6e35a; --c3: #f26ba5; --c4: #c39bff;
  --good: #7fd36b; --bad: #ff6b6b; color-scheme: dark;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
:root[data-theme="light"] {
  --bg: #f4f5ef; --panel: #ffffff; --line: #d5d9c8; --text: #1d2216; --muted: #5e664f;
  --hover: #eef0e4; --detail: #ecefdf; --pick: #e7ebd9; --on-accent: #ffffff;
  --c0: #d4580a; --c1: #0a82a6; --c2: #5a8a08; --c3: #c0226a; --c4: #7243d4;
  --good: #2f8a1f; --bad: #c62828; color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 22px; margin: 0; font-weight: 650; }
h2 { font-size: 18px; margin: 22px 0 10px; font-weight: 650; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.top .spacer { flex: 1; }
.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; margin-bottom: 14px; }
.picker { position: relative; flex: 1 1 260px; }
input, select, button {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 10px;
}
input[type=checkbox] { width: auto; padding: 0; }
input { width: 100%; }
button { cursor: pointer; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--c0); color: var(--on-accent); border-color: var(--c0); font-weight: 600; }
button.link { border: 0; background: none; color: var(--c1); padding: 2px 0; }
button.danger { color: var(--bad); }
:focus-visible { outline: 2px solid var(--c1); outline-offset: 1px; }
.results { position: absolute; z-index: 5; left: 0; right: 0; top: 100%; background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; max-height: 280px; overflow: auto; }
.results button { display: flex; width: 100%; justify-content: space-between; border: 0; border-radius: 0; text-align: left; }
.results button:hover { background: var(--pick); }
.muted { color: var(--muted); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; min-height: 34px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 5px 6px 5px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); }
.chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chip button { border: 0; padding: 0 6px; background: none; color: var(--muted); }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button.on, .chips button.on { border-color: var(--c0); color: var(--c0); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
th { color: var(--muted); font-weight: 500; font-size: 13px; position: relative; }
tr.ev, tr.rr { cursor: pointer; }
tr.ev:hover td, tr.rr:hover td { background: var(--hover); }
td.best { font-weight: 650; }
.scroll { overflow-x: auto; }
.detail td { background: var(--detail); }
.empty { padding: 28px 0; color: var(--muted); }
small { color: var(--muted); }
.live { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px; background: var(--c0); color: var(--on-accent); font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.head h2 { margin: 0; }
.good { color: var(--good); } .bad { color: var(--bad); }

/* resizable columns */
.grip { position: absolute; right: 0; top: 0; bottom: 0; width: 9px; cursor: col-resize; user-select: none; touch-action: none; }
.grip::after { content: ""; position: absolute; right: 3px; top: 25%; bottom: 25%; width: 2px; background: var(--line); border-radius: 1px; }
.grip:hover::after, .grip.on::after { background: var(--c1); }

/* account menu */
.acct { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 290px; padding: 12px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.35); display: grid; gap: 10px; }
.menu label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.menu label.inline { display: flex; align-items: center; gap: 8px; }
.menu form { display: grid; gap: 8px; margin-top: 8px; }
.menu hr { border: 0; border-top: 1px solid var(--line); width: 100%; margin: 0; }

/* sign-in screen */
.authbox { max-width: 380px; margin: 9vh auto 0; padding: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.authbox h1 { margin-bottom: 14px; }
.authbox form { display: grid; gap: 10px; }
.authbox .links { display: flex; justify-content: space-between; margin-top: 12px; }
.note { padding: 8px 10px; border-radius: 6px; font-size: 14px; border: 1px solid var(--line); margin-bottom: 10px; }
.note.err { border-color: var(--bad); color: var(--bad); }
.note.ok { border-color: var(--good); color: var(--good); }

/* stats and admin */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart text { fill: var(--muted); font-size: 11px; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.form-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.form-row input { width: auto; flex: 1 1 140px; }
td.act { white-space: nowrap; }
td.act button { padding: 3px 8px; font-size: 13px; margin: 0 2px 2px 0; }
code { background: var(--detail); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
