:root {
  --bg: #f4f7fa;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --ink: #142231;
  --ink-2: #4a5b6d;
  --ink-3: #7c8b9b;
  --line: #dbe3eb;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --accent-soft: #e3eefe;
  --good: #1a7f4b;
  --bad: #b5472b;
  --s1: #d9705a;
  --s2: #e2a24a;
  --s3: #b9c04f;
  --s4: #5bb36d;
  --s5: #2e9a5e;
  --shadow: 0 1px 2px rgba(20, 34, 49, .06), 0 4px 16px rgba(20, 34, 49, .05);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d141c;
    --surface: #151f2a;
    --surface-2: #1c2834;
    --ink: #e7eef5;
    --ink-2: #a9b8c7;
    --ink-3: #75879a;
    --line: #26354380;
    --accent: #5b9dff;
    --accent-ink: #0d141c;
    --accent-soft: #1b2d48;
    --good: #5fd398;
    --bad: #f08f74;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.2; margin: 0; }
button, select, input { font: inherit; color: inherit; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* header */
.site-header { padding: 40px 0 24px; }
.site-header h1 { font-size: clamp(28px, 5vw, 40px); letter-spacing: -.02em; }
.tagline { color: var(--ink-2); margin: 8px 0 0; max-width: 60ch; font-size: 17px; }

/* layout */
.layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.controls { display: grid; gap: 16px; }
@media (min-width: 861px) {
  .controls { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; padding-bottom: 4px; }
}

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-bottom: 12px; }
.hint { color: var(--ink-3); font-size: 13px; margin: 0 0 12px; }

/* presets */
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preset {
  text-align: left; border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 10px; padding: 9px 11px; cursor: pointer; display: grid; gap: 1px;
}
.preset:hover { border-color: var(--accent); }
.preset-label { font-weight: 600; font-size: 13.5px; }
.preset-sub { font-size: 12px; color: var(--ink-3); }

/* priorities */
.priority { display: grid; gap: 6px; padding: 9px 0; border-top: 1px solid var(--line); }
.priority:first-child { border-top: 0; padding-top: 0; }
.priority-text { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.priority-label { font-weight: 600; }
.priority-desc { color: var(--ink-3); font-size: 12px; text-align: right; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface-2); border-radius: 9px; padding: 3px; }
.seg button {
  border: 0; background: transparent; padding: 5px 0; border-radius: 7px; cursor: pointer;
  font-size: 13px; color: var(--ink-2);
}
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg button[data-weight="3"].on { background: var(--accent); color: var(--accent-ink); }

/* filters */
fieldset { border: 0; padding: 0; margin: 0 0 16px; }
legend { font-weight: 600; margin-bottom: 8px; padding: 0; display: flex; gap: 8px; align-items: baseline; width: 100%; }
legend .value { color: var(--accent); font-weight: 600; margin-left: auto; }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 12px; font-weight: 400; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; cursor: pointer; font-size: 13px; color: var(--ink-2);
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); font-weight: 600; }
.flex-row { display: grid; gap: 6px; }
.flex-row label { display: grid; grid-template-columns: 64px 1fr; align-items: center; font-size: 13px; color: var(--ink-2); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
select { width: 100%; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); }
.actions { display: flex; gap: 8px; }
.ghost {
  border: 1px solid var(--line); background: var(--surface); border-radius: 9px;
  padding: 7px 14px; cursor: pointer; font-size: 13px;
}
.ghost:hover { border-color: var(--accent); }

/* results */
.results-head { margin-bottom: 14px; }
.results-head h2 { font-size: 22px; }
.results-head .hint { margin: 4px 0 0; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.card.near { border-style: dashed; }
.card-top { display: flex; gap: 12px; align-items: flex-start; }
.rank { font-size: 13px; color: var(--ink-3); font-weight: 600; min-width: 26px; padding-top: 2px; }
.title { flex: 1; min-width: 0; }
.brand { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.title h3 { font-size: 17px; margin-top: 2px; }
.fit { display: grid; justify-items: center; background: var(--accent-soft); border-radius: 10px; padding: 5px 10px; min-width: 54px; }
.fit-num { font-size: 20px; font-weight: 700; color: var(--accent); line-height: 1.1; }
.fit-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.miss { margin: 0; font-size: 13px; color: var(--bad); }

.specs { display: flex; flex-wrap: wrap; gap: 6px; }
.spec { font-size: 12px; background: var(--surface-2); border-radius: 6px; padding: 3px 8px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.profile-spec .profile-svg { width: 34px; height: 12px; }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.bar { display: grid; grid-template-columns: 96px 1fr 14px; gap: 8px; align-items: center; font-size: 12.5px; }
.bar-label { color: var(--ink-2); }
.bar.key .bar-label { color: var(--ink); font-weight: 600; }
.bar.muted { opacity: .45; }
.bar-track { height: 7px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 99px; }
.bar-fill.s1 { background: var(--s1); }
.bar-fill.s2 { background: var(--s2); }
.bar-fill.s3 { background: var(--s3); }
.bar-fill.s4 { background: var(--s4); }
.bar-fill.s5 { background: var(--s5); }
.bar-num { color: var(--ink-3); text-align: right; font-variant-numeric: tabular-nums; }

.why { margin: 0; font-size: 13px; display: grid; gap: 2px; }
.why .good { color: var(--good); }
.why .bad { color: var(--bad); }
.notes { margin: 0; font-size: 13.5px; color: var(--ink-2); flex: 1; }
.lookup { font-size: 13px; color: var(--accent); text-decoration: none; }
.lookup:hover { text-decoration: underline; }

.more, .empty, .divider { grid-column: 1 / -1; }
.more { text-align: center; }
.empty { padding: 24px; text-align: center; color: var(--ink-2); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.divider { margin-top: 10px; }
.divider h3 { font-size: 17px; }
.divider .hint { margin: 2px 0 0; }

/* explainer */
.explainer { padding-top: 56px; padding-bottom: 24px; }
.explainer h2 { font-size: 22px; }
.explainer > p { color: var(--ink-2); max-width: 70ch; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin: 16px 0; }
.profile-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.profile-card .profile-svg { width: 100%; height: 48px; margin-bottom: 8px; }
.profile-card h3 { font-size: 16px; }
.profile-card p { font-size: 13.5px; color: var(--ink-2); margin: 6px 0 0; }
.profile-card .aka { color: var(--ink-3); font-size: 12.5px; }

.profile-svg .ground { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.profile-svg .board { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }

.site-footer { padding: 24px 0 40px; color: var(--ink-3); font-size: 13px; }
