:root {
  color-scheme: light;
  --surface-0: #f5f5f3; --surface-1: #fcfcfb; --border: #e4e3df; --grid: #ebeae6;
  --text-primary: #0b0b0b; --text-secondary: #52514e; --text-muted: #7a7974;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --avg: #8d8c87;
  --better: #2a78d6; --worse: #e34948; --mid: #f0efec;
  --better-tint: 42, 120, 214; --worse-tint: 227, 73, 72;
  --chip: #ecebe7; --accent: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-0: #121211; --surface-1: #1a1a19; --border: #2e2e2c; --grid: #262624;
    --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --avg: #8a8983;
    --better: #3987e5; --worse: #e66767; --mid: #383835;
    --better-tint: 57, 135, 229; --worse-tint: 230, 103, 103; --chip: #2a2a28; --accent: #5598e7;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211; --surface-1: #1a1a19; --border: #2e2e2c; --grid: #262624;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --avg: #8a8983;
  --better: #3987e5; --worse: #e66767; --mid: #383835;
  --better-tint: 57, 135, 229; --worse-tint: 230, 103, 103; --chip: #2a2a28; --accent: #5598e7;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--surface-0); color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 20px 60px; }
a { color: var(--accent); }
h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 2px; display: flex; align-items: center; gap: 6px; }
.lede { color: var(--text-secondary); margin: 0 0 14px; max-width: 780px; }
.sub { color: var(--text-muted); font-size: 13px; margin: 2px 0 12px; }
.muted { color: var(--text-muted); }

/* top bar */
.topbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 18px; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { text-decoration: none; color: var(--text-secondary); padding: 5px 10px; border-radius: 8px; font-size: 13px; }
.topbar nav a[aria-current="page"] { color: var(--text-primary); background: var(--chip); font-weight: 600; }
.prefs { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; background: var(--surface-1); }
.seg button { border: 0; background: transparent; color: var(--text-secondary); font: inherit; font-size: 12px;
  padding: 3px 10px; border-radius: 999px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--text-primary); color: var(--surface-1); }

/* info (i) */
.info { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; flex: none;
  border-radius: 50%; border: 1px solid var(--text-muted); color: var(--text-muted); background: transparent;
  font: italic 600 10px/1 Georgia, "Times New Roman", serif; padding: 0; margin-left: 4px; cursor: help; vertical-align: middle; }
.info:hover, .info:focus-visible { color: var(--surface-1); background: var(--accent); border-color: var(--accent); outline: none; }
#tip { position: fixed; pointer-events: none; background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; font-size: 12.5px; line-height: 1.45;
  box-shadow: 0 6px 20px rgba(0,0,0,.16); max-width: 340px; z-index: 50; font-weight: 400; text-align: left; white-space: normal; }
#tip ul { margin: 4px 0 0; padding-left: 18px; }
#tip li { margin: 2px 0; }

/* steps */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 0 0 16px; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; display: flex; gap: 10px; align-items: flex-start; color: var(--text-secondary); font-size: 13px; }
.steps li::before { content: counter(s); flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff;
  font-weight: 700; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; }

/* tabs */
.tabs-main { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs-main button { border: 0; background: transparent; font: inherit; font-size: 15px; font-weight: 600; color: var(--text-secondary);
  padding: 8px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs-main button[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--accent); }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; margin-bottom: 18px; min-width: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; position: relative; }
.tile b { display: block; font-size: 22px; font-weight: 650; letter-spacing: -.01em; padding-right: 18px; }
.tile span { color: var(--text-secondary); font-size: 13px; }
.tile .info { position: absolute; top: 12px; right: 12px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; margin-bottom: 16px;
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface-0); padding: 10px 0; }
.controls .grp { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.controls label, .lbl { color: var(--text-secondary); font-size: 13px; }
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.chip { border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary);
  border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }
select, input[type=search], input[type=number] { font: inherit; font-size: 13px; padding: 5px 8px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); max-width: 100%; }
input[type=number] { width: 60px; }
.btn { font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-1); color: var(--text-primary); cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.scroll { overflow-x: auto; }
.tablebox { max-height: 560px; overflow: auto; border-top: 1px solid var(--border); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface-1); color: var(--text-secondary); font-weight: 600; z-index: 1; vertical-align: bottom; }
th.sortable { cursor: pointer; user-select: none; }
th[aria-sort="ascending"] .lab::after { content: " ▲"; font-size: 9px; }
th[aria-sort="descending"] .lab::after { content: " ▼"; font-size: 9px; }
th .avg { display: block; color: var(--text-muted); font-weight: 400; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
#modelTable tbody tr { cursor: pointer; }
#modelTable tbody tr:hover td { background: var(--chip); }
tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--sel-color, var(--series-1)); }
td.heat { text-align: center; font-variant-numeric: tabular-nums; min-width: 58px; }
td.na { color: var(--text-muted); text-align: center; }
td.wrapcell { white-space: normal; min-width: 180px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; margin: 0; vertical-align: middle; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: 12px; color: var(--text-secondary); margin: 6px 0 6px; }
.legend i.ln { display: inline-block; width: 14px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.legend i.sq { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; margin-right: 6px; }
svg text { fill: var(--text-secondary); font-size: 12px; }
svg .ax { stroke: var(--grid); stroke-width: 1; }
svg .zero { stroke: var(--text-muted); stroke-width: 1; }
.picked { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.picked .chip { display: inline-flex; align-items: center; gap: 6px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0; }
.bar { position: relative; height: 12px; width: 160px; background: var(--chip); border-radius: 3px; }
.bar .m { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--series-1); }
.bar .c { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text-primary); }
.bar2 { position: relative; width: 160px; height: 16px; }
.bar2 .a, .bar2 .b { position: absolute; left: 0; height: 6px; border-radius: 2px; }
.bar2 .a { top: 1px; background: var(--series-1); } .bar2 .b { top: 9px; background: var(--series-2); }
.bar2 .c { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text-primary); }
.flag { font-size: 11px; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--worse); color: var(--text-primary); white-space: nowrap; }
details summary { cursor: pointer; font-weight: 600; }
details { color: var(--text-secondary); }
footer { color: var(--text-muted); font-size: 12px; margin-top: 24px; }

/* head to head */
.vs { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 12px; align-items: end; }
@media (max-width: 640px) { .vs { grid-template-columns: minmax(0, 1fr); } }
.vs .side label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.vs select { width: 100%; font-size: 15px; padding: 8px 10px; }
.verdict { font-size: 17px; line-height: 1.5; margin: 0; }
.scorebox { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-top: 14px; }
.scorebox .tile { border-left: 4px solid var(--c); }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }

/* about page */
.prose { max-width: 760px; }
.prose h2 { margin-top: 22px; }
.prose p, .prose li { color: var(--text-secondary); line-height: 1.6; }
.prose code { font-size: 12.5px; background: var(--chip); padding: 1px 5px; border-radius: 4px; }

[hidden] { display: none !important; }

/* sticky compare tray */
.tray { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface-1);
  border-top: 1px solid var(--border); box-shadow: 0 -6px 24px rgba(0,0,0,.10);
  padding: 10px 20px calc(10px + env(safe-area-inset-bottom, 0px)); }
.tray-in { max-width: 1180px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.tray .chip { display: inline-flex; align-items: center; gap: 6px; }
.tray-hint { font-size: 13px; }
.tray-actions { margin-left: auto; display: flex; gap: 8px; }
.tray .btn.primary { font-weight: 600; padding: 7px 16px; }
body.has-tray .wrap { padding-bottom: 110px; }
.btn:disabled { opacity: .45; cursor: default; }

/* best models per age */
.best { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 20px; }
.best-age h3 { font-size: 13px; margin: 0 0 4px; }
.best-age ol { list-style: none; margin: 0; padding: 0; }
.best-age .pick { width: 100%; display: grid; grid-template-columns: 12px 1fr auto 44px; gap: 8px; align-items: center;
  border: 0; border-bottom: 1px solid var(--grid); background: transparent; color: var(--text-primary);
  font: inherit; font-size: 13px; padding: 6px 2px; cursor: pointer; text-align: left; }
.best-age .pick:hover { background: var(--chip); }
.best-age .pick .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.best-age .pick .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.best-age .pick b.v { color: var(--text-primary); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
