:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6b6a66;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --link: #1c5cab;
  --accent: #2a78d6;
  --accent-wash: rgba(42, 120, 214, 0.14);
  --base-line: #898781;
  --row-hover: rgba(11, 11, 11, 0.03);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #9c9a93;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --link: #86b6ef;
    --accent: #3987e5;
    --accent-wash: rgba(57, 135, 229, 0.2);
    --base-line: #9c9a93;
    --row-hover: rgba(255, 255, 255, 0.04);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #9c9a93;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --link: #86b6ef;
  --accent: #3987e5;
  --accent-wash: rgba(57, 135, 229, 0.2);
  --base-line: #9c9a93;
  --row-hover: rgba(255, 255, 255, 0.04);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 1rem/1.55 var(--font);
}

a { color: var(--link); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }

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

.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Header and footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; padding-top: 12px; padding-bottom: 12px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.2rem; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.site-header nav a { color: var(--ink-2); text-decoration: none; }
.site-header nav a:hover { color: var(--ink); text-decoration: underline; }

.site-footer { margin-top: 64px; border-top: 1px solid var(--border); background: var(--surface); color: var(--ink-2); font-size: 0.875rem; padding: 24px 0 32px; }
.site-footer p { margin: 0 0 8px; }

main { padding-bottom: 16px; }
.preview-note { background: var(--accent-wash); color: var(--ink); font-size: 0.875rem; padding: 8px 0; }
section { margin-top: 40px; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.2; margin: 32px 0 12px; letter-spacing: -0.015em; }
h2 { font-size: 1.3rem; line-height: 1.3; margin: 0 0 12px; }
p { margin: 0 0 12px; max-width: 46rem; }
.lead { font-size: 1.1rem; color: var(--ink-2); }
.small { font-size: 0.875rem; color: var(--ink-2); }

.crumbs { margin-top: 20px; font-size: 0.875rem; color: var(--ink-2); }
.crumbs a { color: var(--ink-2); }
.page-head h1 { margin-top: 12px; }

.verdict { display: flex; gap: 14px; align-items: flex-start; font-size: 1.1rem; max-width: 50rem; }
.verdict > span:last-child { padding-top: 4px; }

/* Grade chips: fixed colors with their own text color in both themes */
.grade {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.6em; height: 1.6em; padding: 0 0.35em; border-radius: 6px;
  font-weight: 700; font-size: 0.85rem; line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(11, 11, 11, 0.12);
}
.grade-large { font-size: 1.5rem; border-radius: 10px; flex: none; }
.grade-a { background: #1c5cab; color: #ffffff; }
.grade-b { background: #b7d3f6; color: #0b0b0b; }
.grade-c { background: #e1e0d9; color: #0b0b0b; }
.grade-d { background: #f7c4b8; color: #0b0b0b; }
.grade-e { background: #c23b3b; color: #ffffff; }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 24px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.tile-label { font-size: 0.875rem; color: var(--ink-2); }
.tile-value { font-size: 1.7rem; font-weight: 650; letter-spacing: -0.01em; }
.tile-note { font-size: 0.8rem; color: var(--muted); }

/* Tables */
.table-wrap { position: relative; overflow-x: auto; margin: 0 0 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.925rem; }
caption { text-align: left; font-weight: 650; padding: 12px 14px 4px; }
th, td { padding: 8px 14px; text-align: left; border-top: 1px solid var(--grid); vertical-align: middle; }
thead th { border-top: 0; font-size: 0.8rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
tbody th { font-weight: 500; }
tbody tr:hover { background: var(--row-hover); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total th, tr.total td { font-weight: 700; }

.two-col { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 760px) { .two-col { grid-template-columns: 1fr 1fr; } }

/* Lists */
.make-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.make-grid a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: var(--ink); }
.make-grid a:hover { border-color: var(--link); }
.link-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 16px; }
.link-list li { display: flex; gap: 8px; align-items: center; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pills a { padding: 4px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); text-decoration: none; }

.callout, .note { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.note { margin-top: 40px; }
.note h2 { font-size: 1.05rem; }
.note p:last-child, .callout p:last-child { margin-bottom: 0; }

/* Search */
.hero { padding-top: 8px; }
.search { position: relative; max-width: 34rem; margin-top: 16px; }
.search input {
  width: 100%; font: inherit; font-size: 1.05rem; padding: 12px 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--axis); border-radius: 10px;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.search-results {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.search-results a { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 8px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; }
.search-results a .hint { color: var(--muted); font-size: 0.8rem; margin-left: auto; }
.search-results [aria-selected="true"] a, .search-results a:hover { background: var(--row-hover); outline: 1px solid var(--border); }
.search-results .empty { padding: 8px 10px; color: var(--ink-2); }

/* Chart */
.chart { margin: 0 0 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 14px 8px; position: relative; }
.chart figcaption { font-size: 0.9rem; color: var(--ink-2); margin-bottom: 8px; }
.chart-legend { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.8rem; color: var(--ink-2); }
.chart-legend li { display: flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 16px; }
.key-line { height: 2px; border-radius: 1px; }
.key-model { background: var(--accent); }
.key-base { background: var(--base-line); }
.key-band { height: 10px; background: var(--accent-wash); border-radius: 2px; }
.chart-plot { position: relative; min-height: 240px; }
.chart-plot:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.chart-plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-plot .tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart-plot .axis-title { fill: var(--muted); font-size: 12px; }
.chart-plot .end-label { fill: var(--ink-2); font-size: 12px; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 4; min-width: 170px; padding: 8px 10px; font-size: 0.8rem;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
}
.chart-tip .tip-title { color: var(--ink-2); margin-bottom: 4px; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 8px; }
.chart-tip .tip-row strong { font-variant-numeric: tabular-nums; }
.chart-tip .tip-row span:last-child { color: var(--ink-2); }
.chart-tip .tip-key { width: 12px; height: 2px; border-radius: 1px; flex: none; }

@media (forced-colors: active) {
  .grade { border: 1px solid CanvasText; }
}

@media (max-width: 480px) {
  table { font-size: 0.85rem; }
  th, td { padding: 7px 8px; }
  caption { padding: 10px 8px 4px; }
  .tile-value { font-size: 1.45rem; }
  .verdict { font-size: 1rem; }
}
