/* nfltr-comp — tokens follow the dataviz reference palette; dark values are selected, not auto-flipped. */
:root {
  color-scheme: light;
  --bg: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --warn-bg: #fff4d6;
  --warn-ink: #6b4b00;
  --err-bg: #fde3e3;
  --err-ink: #7a1f1f;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 1px rgba(0,0,0,.03);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #262625;
    --text: #ffffff; --text-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.10);
    --accent: #3987e5; --accent-ink: #ffffff;
    --warn-bg: #3a2e0b; --warn-ink: #f5d58a; --err-bg: #4a1a1a; --err-ink: #ffb4b4;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #262625;
  --text: #ffffff; --text-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.10);
  --accent: #3987e5; --accent-ink: #ffffff;
  --warn-bg: #3a2e0b; --warn-ink: #f5d58a; --err-bg: #4a1a1a; --err-ink: #ffb4b4;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --shadow: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
a { color: var(--accent); }
h1 { font-size: 1.35rem; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0; }
h3 { font-size: 0.95rem; margin: 1rem 0 0.4rem; color: var(--text-2); }
p { margin: 0.35rem 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-weight: 400; }
.wrap { max-width: 1180px; margin: 0 auto; padding-inline: 16px; }

.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-block: 14px; flex-wrap: wrap; }
.tagline { color: var(--text-2); margin: 2px 0 0; font-size: 0.9rem; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-block: 14px; box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.note { color: var(--text-2); font-size: 0.88rem; margin: 6px 0 10px; }
.warn-text { color: var(--warn-ink); background: var(--warn-bg); padding: 6px 10px; border-radius: 8px; }

/* controls */
.controls { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.control { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.control.grow { flex: 1 1 260px; }
.control.full { flex-basis: 100%; }
.control label { font-size: 0.8rem; color: var(--text-2); font-weight: 600; }
select, input[type="number"], input[type="search"] {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--axis);
  border-radius: 8px; padding: 8px 10px; min-height: 40px; width: 100%;
}
select:focus, input:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn {
  font: inherit; border-radius: 8px; padding: 8px 12px; min-height: 40px; cursor: pointer;
  border: 1px solid var(--axis); background: var(--surface); color: var(--text);
}
.btn.ghost { background: transparent; }
.btn:hover { background: var(--surface-2); }

.picker { position: relative; }
.pick-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); max-height: 320px; overflow: auto;
  margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--axis);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.pick-list li { margin: 0; }
.pick-list button {
  width: 100%; text-align: left; font: inherit; color: var(--text); background: none; border: 0;
  padding: 8px 10px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px;
}
.pick-list button:hover, .pick-list button:focus-visible { background: var(--surface-2); }
.pick-list button:disabled { opacity: .45; cursor: default; }
.pick-list .sub { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.pick-list .none { padding: 8px 10px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; min-height: 36px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px 6px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); font-size: 0.9rem;
}
.chip .x { border: 0; background: none; color: var(--text-2); cursor: pointer; font-size: 1rem; line-height: 1; padding: 2px 4px; border-radius: 50%; }
.chip .x:hover { background: var(--border); color: var(--text); }
.swatch { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }

.banner { padding: 10px 14px; border-radius: 10px; margin-block: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: 0.92rem; }
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); }
.banner.error { background: var(--err-bg); color: var(--err-ink); }
.banner p { margin: 2px 0; }

.notes ul { margin: 6px 0 0; padding-left: 20px; }
.notes li { margin: 4px 0; font-size: 0.92rem; }

/* player cards */
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.pcard { margin: 0; padding: 14px; }
.pcard header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.pcard .name { font-weight: 700; font-size: 1.05rem; line-height: 1.2; }
.pcard .sub { color: var(--text-2); font-size: 0.85rem; }
.pcard .swatch { width: 14px; height: 14px; }
.bigstats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0; }
.bigstats div { background: var(--surface-2); border-radius: 8px; padding: 8px 6px; text-align: center; }
.bigstats .v { font-size: 1.3rem; font-weight: 700; line-height: 1.1; }
.bigstats .l { font-size: 0.72rem; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.group { margin-top: 10px; }
.group h4 { margin: 0 0 4px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
dl.stats { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 0.9rem; }
dl.stats dt { color: var(--text-2); }
dl.stats dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
dl.stats dd .n { color: var(--muted); font-size: 0.8rem; }
dl.stats .na { color: var(--muted); }
dl.stats dt[title] { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }

/* charts */
.chart-wrap { position: relative; width: 100%; height: 320px; margin-top: 6px; }
.seg { display: inline-flex; border: 1px solid var(--axis); border-radius: 8px; overflow: hidden; }
.seg-btn { font: inherit; font-size: 0.85rem; border: 0; background: transparent; color: var(--text-2); padding: 6px 10px; cursor: pointer; }
.seg-btn.is-on { background: var(--accent); color: var(--accent-ink); }
.part-missing { padding: 10px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-ink); font-size: 0.9rem; margin: 6px 0; }

details > summary { cursor: pointer; color: var(--text-2); font-size: 0.9rem; margin-top: 8px; user-select: none; }
details > summary h2 { display: inline; }
.tbl { overflow-x: auto; margin-top: 6px; }
.tbl-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
table { border-collapse: collapse; width: 100%; font-size: 0.86rem; font-variant-numeric: tabular-nums; }
th, td { padding: 5px 8px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--text-2); font-weight: 600; }
th:first-child, td:first-child { text-align: left; }
thead th { position: sticky; top: 0; background: var(--surface); }
td.low { color: var(--muted); }
td.low::after { content: " ⚠"; font-size: 0.75em; }
td .n { color: var(--muted); font-size: 0.85em; }
tr.low td { color: var(--muted); }
tr.foot td { font-weight: 600; border-top: 1px solid var(--axis); }
.legend-note { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }

.gloss { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 10px 0 0; font-size: 0.9rem; }
.gloss dt { font-weight: 600; }
.gloss dd { margin: 0; color: var(--text-2); }

.site-footer { border-top: 1px solid var(--border); margin-top: 24px; padding-block: 18px; font-size: 0.85rem; color: var(--text-2); }

@media (max-width: 640px) {
  body { font-size: 14px; }
  .bigstats { grid-template-columns: repeat(4, 1fr); }
  .gloss { grid-template-columns: 1fr; gap: 2px; }
  .gloss dd { margin-bottom: 8px; }
  .chart-wrap { height: 280px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* field visuals (target map, route tree) */
.field-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-top: 8px; }
.field-cell h3 { margin: 0; display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 0.95rem; }
.field-cell .sub { color: var(--text-2); font-size: 0.82rem; margin: 2px 0 6px; }
svg.field { width: 100%; height: auto; display: block; font-family: inherit; }
svg.field [tabindex]:focus { outline: none; }
svg.field [tabindex]:focus-visible circle:last-child, svg.field path[tabindex]:focus-visible { stroke: var(--accent); stroke-opacity: .6; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.8rem; color: var(--text-2); margin: 4px 0 6px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.tip { position: absolute; z-index: 60; max-width: 280px; background: var(--surface); color: var(--text); border: 1px solid var(--axis); border-radius: 8px; padding: 8px 10px; font-size: 0.82rem; line-height: 1.4; box-shadow: 0 8px 24px rgba(0,0,0,.22); pointer-events: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.popular ol { margin: 8px 0 0; padding-left: 22px; }
.popular li { margin: 4px 0; }
.pop-btn { font: inherit; background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
