:root {
  color-scheme: light;
  --plane: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11,11,11,.10);
  --s1:#2a78d6; --s2:#eb6834; --s3:#1baf7a; --s4:#eda100;
  --s5:#e87ba4; --s6:#008300; --s7:#4a3aa7; --s8:#e34948;
  --wash: rgba(42,120,214,.10);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane:#0d0d0d; --surface:#1a1a19; --ink:#fff; --ink-2:#c3c2b7;
    --muted:#898781; --grid:#2c2c2a; --axis:#383835; --border:rgba(255,255,255,.10);
    --s1:#3987e5; --s2:#d95926; --s3:#199e70; --s4:#c98500;
    --s5:#d55181; --s6:#008300; --s7:#9085e9; --s8:#e66767;
    --wash: rgba(57,135,229,.16);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane:#0d0d0d; --surface:#1a1a19; --ink:#fff; --ink-2:#c3c2b7;
  --muted:#898781; --grid:#2c2c2a; --axis:#383835; --border:rgba(255,255,255,.10);
  --s1:#3987e5; --s2:#d95926; --s3:#199e70; --s4:#c98500;
  --s5:#d55181; --s6:#008300; --s7:#9085e9; --s8:#e66767;
  --wash: rgba(57,135,229,.16);
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--plane); color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
a { color: inherit; text-decoration-color: var(--axis); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }
.wrap { max-width: 1140px; margin: 0 auto; padding: 0 16px; }

.top {
  position: sticky; top: 0; z-index: 8;
  border-bottom: 1px solid var(--border); background: var(--surface);
  padding-top: env(safe-area-inset-top, 0px);
}
.top-inner { display: flex; align-items: center; gap: 16px; justify-content: space-between; padding-block: 12px; }
h1 { font-size: 18px; }
.sub { font-size: 12.5px; }
@media (max-width: 560px) {
  .top-inner { flex-wrap: wrap; padding-block: 10px; }
  .sub { display: none; }
}
h1 { font-size: 21px; margin: 0; font-weight: 640; letter-spacing: -.01em; }
h1 span { color: var(--ink-2); font-weight: 400; }
.sub { margin: 4px 0 0; color: var(--ink-2); }
h2 { font-size: 15px; margin: 0; font-weight: 620; }
.hint { margin: 3px 0 0; color: var(--muted); max-width: 62ch; font-size: 12.5px; }

.top-controls { display: flex; gap: 10px; align-items: center; flex: none; }
@media (max-width: 560px) { .top-inner { flex-wrap: wrap; } .seg#listPick button { padding: 6px 9px; } }

.ghost {
  background: none; border: 1px solid var(--border); color: var(--ink-2);
  border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 15px; flex: none;
}
.ghost:hover { background: var(--plane); color: var(--ink); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; margin: 16px 0;
}
.card-head { display: flex; gap: 14px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; margin-bottom: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > .card { margin: 0; min-width: 0; }
.grid-2.three { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 1000px) { .grid-2.three { grid-template-columns: 1fr 1fr; } }
@media (max-width: 820px) { .grid-2, .grid-2.three { grid-template-columns: 1fr; } }

.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 16px 0; }
@media (max-width: 820px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.tile .v { font-size: 25px; font-weight: 640; letter-spacing: -.02em; }
.tile .k { color: var(--muted); font-size: 12px; margin-top: 2px; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; flex: none; }
.seg button {
  background: none; border: 0; border-right: 1px solid var(--border); color: var(--ink-2);
  padding: 6px 11px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--wash); color: var(--ink); font-weight: 560; }

.filterbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); color: var(--ink-2); font-size: 12.5px; }
.filterbar select, #search, #aiMinNum {
  font: inherit; background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 7px; padding: 5px 8px;
}
#search { min-width: 220px; }
#aiMinNum { width: 10ch; field-sizing: content; min-width: 7ch; padding: 3px 6px; }
#prState { font: inherit; font-size: 12.5px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 8px; }
.presets { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.presets button {
  font: inherit; font-size: 12px; background: none; color: var(--ink-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; cursor: pointer;
}
.presets button:hover { background: var(--wash); color: var(--ink); }
.range-note { color: var(--muted); margin-left: auto; }

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; color: var(--ink-2); font-size: 12px; }
.legend.scale { gap: 4px; align-items: center; }
.legend.scale i { margin: 0; width: 13px; height: 10px; }
.legend.scale span:last-child { margin-left: 2px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 5px; vertical-align: -1px; }

.graph-ctl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ghost.wide { width: auto; padding: 0 12px; height: 30px; font-size: 12.5px; }
#graph svg { touch-action: none; }

input[type="range"] { width: 130px; accent-color: var(--s1); }
.dual { position: relative; width: 220px; height: 20px; }
.dual::before {
  content: ""; position: absolute; left: 7px; right: 7px; top: 8px; height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--grid) var(--a), var(--s1) var(--a) var(--b), var(--grid) var(--b));
}
.dual input { position: absolute; inset: 0; width: 100%; margin: 0; pointer-events: none; background: none; appearance: none; -webkit-appearance: none; }
.dual input::-webkit-slider-runnable-track { background: none; height: 20px; }
.dual input::-moz-range-track, .dual input::-moz-range-progress { background: none; }
.dual input::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto; cursor: pointer; margin-top: 3px; box-sizing: border-box;
  width: 14px; height: 14px; border-radius: 50%; background: var(--s1); border: 2px solid var(--surface);
}
.dual input::-moz-range-thumb {
  pointer-events: auto; cursor: pointer;
  width: 10px; height: 10px; border-radius: 50%; background: var(--s1); border: 2px solid var(--surface);
}

.note { margin: 10px 0 0; color: var(--ink-2); font-size: 12.5px; }
.note b { font-weight: 620; color: var(--ink); }
#aiNote { margin: 0 0 10px; }

.scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { text-align: right; padding: 7px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
table.data th:first-child, table.data td:first-child,
table.data th.l, table.data td.l { text-align: left; }
table.data thead th { color: var(--muted); font-weight: 560; font-size: 12px; cursor: pointer; position: sticky; top: 0; background: var(--surface); }
table.data thead th:hover { color: var(--ink); }
table.data tbody tr:hover { background: var(--wash); }
table.data td.num { font-variant-numeric: tabular-nums; }
table.data td.dim { color: var(--muted); }
td.subj { max-width: 46ch; overflow: hidden; text-overflow: ellipsis; }

.tip {
  position: fixed; z-index: 9; pointer-events: none;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font-size: 12.5px; line-height: 1.45;
  box-shadow: 0 6px 20px rgba(0,0,0,.14); max-width: 280px;
}
.tip b { font-weight: 620; }
.tip .k { color: var(--muted); }

.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.more {
  margin-top: 10px; font: inherit; font-size: 12.5px; background: none; color: var(--ink-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; cursor: pointer; width: 100%;
}
.more:hover { background: var(--wash); color: var(--ink); }

.foot { color: var(--muted); font-size: 12.5px; padding: 8px 0 40px; }
.foot p { margin: 4px 0; }

.pill { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11.5px; background: var(--grid); color: var(--ink-2); }
.pill.merged { background: color-mix(in srgb, var(--s7) 18%, transparent); color: var(--s7); }
.pill.open { background: color-mix(in srgb, var(--s3) 18%, transparent); color: var(--s3); }
.pill.closed { background: color-mix(in srgb, var(--s8) 16%, transparent); color: var(--s8); }
.ai { color: var(--s4); font-size: 11px; cursor: help; }
a.star { font-weight: 620; color: var(--s7); }
