/* Design spec: docs/design.md in the workspace (CAR-42). Road-sign colours on a
   cool grey paper, DIN-style headings from the system fonts. */

:root {
  color-scheme: light dark;
  --paper: #f3f5f4;
  --surface: #ffffff;
  --ink: #1a2228;
  --muted: #5b6670;
  --rule: #cbd3d1;
  --blue: #00518a;
  --yellow: #f2b300;
  --din: Bahnschrift, "DIN Alternate", "DIN 2014", "D-DIN", Barlow, "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --prose: 44rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #11171b;
    --surface: #172027;
    --ink: #e2e7e5;
    --muted: #98a4ac;
    --rule: #2b3740;
    --blue: #7db4e6;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 17px/1.6 var(--text);
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--blue);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}

h1,
h2,
h3,
h4,
.site-name,
.plate {
  font-family: var(--din);
  font-weight: 600;
  letter-spacing: 0.005em;
}

h1 {
  margin: 0.25rem 0 1rem;
  font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.6rem);
  line-height: 1.12;
  max-width: 48rem;
  text-wrap: balance;
}

h2 {
  margin: 2.5rem 0 0.75rem;
  font-size: 1.5rem;
  line-height: 1.2;
}

h3 {
  margin: 1.75rem 0 0.5rem;
  font-size: 1.2rem;
  line-height: 1.25;
}

h4 {
  margin: 1.25rem 0 0.4rem;
  font-size: 1rem;
  line-height: 1.3;
}

p,
ul,
ol {
  max-width: var(--prose);
}

/* Shell */

.site-header,
.site-main,
.site-footer {
  width: min(100% - 2rem, 84rem);
  margin-inline: auto;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: baseline;
  padding-block: 1.1rem;
  border-bottom: 2px solid var(--ink);
}

.site-name {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
  align-self: center;
  margin-inline-end: auto;
  color: var(--ink);
  font-size: 1.35rem;
  text-decoration: none;
}

.site-mark {
  display: block;
  flex: none;
}

.site-nav,
.lang-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  font-family: var(--din);
}

.site-nav a,
.lang-switch a {
  color: var(--ink);
  text-decoration: none;
}

.site-nav a:hover,
.lang-switch a:hover {
  color: var(--blue);
}

.lang-switch a[aria-current] {
  color: var(--muted);
}

.site-main {
  padding-block: 1.5rem 3rem;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  padding-block: 1.25rem 2rem;
  font-size: 0.9rem;
  color: var(--muted);
  border-top: 1px solid var(--rule);
}

.site-footer p {
  margin: 0;
}

.site-footer-name {
  font-family: var(--din);
}

.muted {
  color: var(--muted);
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-block-end: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.breadcrumb a {
  color: inherit;
}

/* Number plate tag: brand, model, generation. The one loud element. */

.plate {
  display: inline-flex;
  align-items: stretch;
  margin: 0 0 0.5rem;
  padding: 0;
  overflow: hidden;
  color: #111;
  background: #fff;
  border: 2px solid #111;
  border-radius: 0.35rem;
  font-size: 1.2rem;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-wrap: wrap;
  max-width: 100%;
}

.plate::before {
  content: "";
  flex: 0 0 0.9rem;
  background: #003399;
}

/* Segments never shrink or clip; a long plate wraps instead. */
.plate span {
  flex: none;
  padding: 0.4rem 0.55rem;
  white-space: nowrap;
}

.plate span + span {
  padding-inline-start: 0;
}

/* Tables */

.table-wrap {
  overflow-x: auto;
  margin-block: 1rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--rule);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 0.55rem 0.75rem;
  text-align: start;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}

tbody tr:last-child > * {
  border-bottom: 0;
}

/* On phones long names wrap instead of pushing the table sideways. */
@media (max-width: 35.99rem) {
  td:first-child {
    white-space: normal;
  }
}

@media (min-width: 36rem) {
  .finder-table td.finder-car {
    white-space: normal;
    min-width: 16rem;
  }

  /* Variant names and long headers wrap so the whole table fits beside the
     page contents instead of scrolling. */
  .variant-table td:first-child {
    white-space: normal;
    min-width: 13rem;
  }

  .variant-table thead th {
    white-space: normal;
    vertical-align: bottom;
  }
}

th.num,
td.num {
  text-align: end;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

thead th {
  font-family: var(--din);
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid var(--ink);
}

tbody th {
  font-weight: 500;
}

/* Facts under the heading: ruled cells, like a form. */

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  margin: 0.5rem 0 1.25rem;
  background: var(--rule);
  border: 1px solid var(--rule);
}

.facts div {
  flex: 1 1 11rem;
  padding: 0.6rem 0.9rem;
  background: var(--paper);
}

.facts dt {
  font-size: 0.9rem;
  color: var(--muted);
}

.facts dd {
  margin: 0;
  font-family: var(--din);
  font-size: 1.3rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.verdict {
  margin: 1rem 0 0.5rem;
  padding: 0.8rem 1rem 0.8rem 1.1rem;
  font-size: 1.12rem;
  line-height: 1.5;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-inline-start: 6px solid var(--yellow);
}

.guide-updated {
  margin: 0 0 1.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Page body with the "On this page" column on wide screens. */

.page-grid {
  display: block;
}

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
  margin-block: 0 1.5rem;
  font-size: 0.92rem;
}

.toc strong {
  font-family: var(--din);
  font-weight: 600;
}

.toc a {
  color: var(--muted);
}

.toc a:hover {
  color: var(--blue);
}

@media (min-width: 64rem) {
  .page-grid {
    display: grid;
    grid-template-columns: 12rem minmax(0, 1fr);
    gap: 2.5rem;
    align-items: start;
  }

  /* Pages without the aside use the full width. */
  .page-grid > .page-content:only-child {
    grid-column: 1 / -1;
  }

  .page-aside {
    position: sticky;
    top: 1rem;
  }

  .toc {
    flex-direction: column;
    gap: 0.35rem;
    padding-block-start: 0.4rem;
    border-top: 2px solid var(--ink);
  }

  .toc a {
    text-decoration: none;
  }

  .page-content > :first-child,
  .page-content > .guide > :first-child,
  .page-content > .guide > section:first-child > :first-child {
    margin-block-start: 0;
  }
}

/* Guide markdown */

.guide table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--rule);
}

.guide th,
.guide td {
  white-space: normal;
  vertical-align: top;
}

.guide th:first-child,
.guide td:first-child {
  min-width: 9rem;
}

.guide-section h2 {
  margin-block-start: 2.5rem;
}

.guide-glance {
  max-width: var(--prose);
  padding: 0.25rem 1.25rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--rule);
}

.guide-glance h2 {
  margin-block-start: 1rem;
}

.guide-issues tbody td:first-child {
  font-weight: 600;
}

.guide-issues tbody td:first-child a::before {
  content: "";
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-inline-end: 0.45rem;
  background: var(--yellow);
  transform: rotate(45deg) translateY(-0.1rem);
}

.guide-checklist ol {
  padding-inline-start: 1.75rem;
}

.guide-checklist li {
  margin-block: 0.5rem;
}

.guide-checklist li::marker {
  font-family: var(--din);
  font-weight: 700;
  color: var(--ink);
}

details {
  margin-block: 1rem;
}

summary {
  cursor: pointer;
  font-family: var(--din);
  color: var(--blue);
}

.badge {
  display: inline-block;
  margin-inline-start: 0.4rem;
  padding: 0.05rem 0.45rem;
  font-family: var(--din);
  font-size: 0.75rem;
  line-height: 1.4;
  white-space: nowrap;
  color: var(--blue);
  border: 1px solid var(--blue);
  border-radius: 0.2rem;
  vertical-align: 0.1em;
}

.guide-list {
  display: grid;
  gap: 1rem;
  max-width: var(--prose);
  padding: 0;
  list-style: none;
}

.guide-list li {
  padding-block-end: 1rem;
  border-bottom: 1px solid var(--rule);
}

.guide-list a {
  font-family: var(--din);
  font-size: 1.15rem;
  font-weight: 600;
}

.guide-list p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

/* Market box */

.market {
  margin-block: 2.5rem;
  padding: 0.25rem 1.25rem 1rem;
  background: var(--surface);
  border: 1px solid var(--rule);
}

.market h2 {
  margin-block-start: 1rem;
}

.market-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.75rem 1.5rem;
  margin: 0;
}

.market-list dt {
  font-size: 0.85rem;
  color: var(--muted);
}

.market-list dd {
  margin: 0;
  font-family: var(--din);
  font-size: 1.2rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.market-note {
  color: var(--muted);
}

.market-offers {
  margin: 0.5rem 0 1rem;
}

.button-link {
  display: inline-block;
  min-height: 2.6rem;
  padding: 0.45rem 1.4rem;
  color: #fff;
  background: var(--blue);
  border-radius: 0.3rem;
  font: 600 1.05rem/1.2 var(--din);
  text-decoration: none;
}

.button-link:hover {
  text-decoration: none;
}

@media (prefers-color-scheme: dark) {
  .button-link {
    color: #0d1418;
  }
}

/* Home */

.home-intro {
  margin-block: 1.5rem 1.5rem;
}

.home-intro h1 {
  max-width: 18ch;
  font-size: clamp(2rem, 1.3rem + 3vw, 3.2rem);
}

.lead {
  font-size: 1.15rem;
  color: var(--muted);
}

.brand-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0;
  max-width: none;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
}

.brand-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  background: var(--surface);
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.brand-list a {
  font-family: var(--din);
  font-size: 1.1rem;
  font-weight: 600;
}

.brand-list .muted {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

/* Finder */

.finder-form {
  display: grid;
  gap: 0.9rem 1.25rem;
  margin-block: 1.5rem;
  padding: 1rem 1.25rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 4px solid var(--blue);
}

.finder-form h2 {
  margin: 0;
  font-size: 1.25rem;
}

.finder-field {
  display: grid;
  align-content: start;
  gap: 0.25rem;
}

.finder-field label,
.finder-field > span,
.finder-choices legend {
  font-size: 0.85rem;
  color: var(--muted);
}

.finder-field input,
.finder-field select {
  min-height: 2.4rem;
  padding: 0.35rem 0.55rem;
  color: inherit;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-bottom: 2px solid var(--ink);
  border-radius: 0;
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.finder-choices {
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  border: 0;
  min-inline-size: 0;
}

.finder-choices legend {
  padding: 0;
  margin-bottom: 0.25rem;
}

.finder-field .finder-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.2rem 0.55rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
}

.finder-field .finder-chip:has(input:checked) {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
  color: var(--blue);
}

.finder-field .finder-chip input {
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  accent-color: var(--blue);
}

.finder-field .finder-chip input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.finder-multi {
  color: inherit;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-bottom: 2px solid var(--ink);
  border-radius: 0;
}

.finder-multi > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 2.4rem;
  padding: 0.35rem 0.55rem;
  list-style: none;
  cursor: pointer;
}

.finder-multi > summary::-webkit-details-marker {
  display: none;
}

.finder-multi > summary::after {
  content: "";
  flex: 0 0 auto;
  border-left: 0.3rem solid transparent;
  border-right: 0.3rem solid transparent;
  border-top: 0.35rem solid var(--muted);
}

.finder-multi[open] > summary::after {
  border-top: 0;
  border-bottom: 0.35rem solid var(--muted);
}

.finder-multi-list {
  max-height: 18rem;
  overflow-y: auto;
  padding: 0.4rem 0.55rem;
  border-top: 1px solid var(--rule);
}

.finder-multi-list .finder-chip {
  display: flex;
  margin: 0.15rem 0;
  border-radius: 0;
}

.finder-multi-group {
  margin: 0.5rem 0 0.2rem;
  font-family: var(--din);
  font-size: 0.85rem;
  font-weight: 600;
}

.finder-model-empty {
  margin: 0;
  font-size: 0.85rem;
}

.finder-weights {
  margin: 0;
}

/* Chrome wraps details content in its own box, so the grid sits on a div. */
.finder-weights-grid {
  display: grid;
  gap: 0.75rem 1.25rem;
  margin-top: 0.6rem;
}

/* Weight chips are a segmented row: the radio itself is hidden. */
.finder-weight {
  flex-wrap: nowrap;
  align-self: start;
  gap: 0;
}

.finder-weight .finder-chip {
  position: relative;
  justify-content: center;
  min-width: 2.2rem;
  border-radius: 0;
  margin-inline-start: -1px;
}

.finder-weight .finder-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.finder-weight .finder-chip:has(input:checked) {
  z-index: 1;
  color: var(--paper);
  background: var(--blue);
}

.finder-weight .finder-chip:has(input:focus-visible) {
  z-index: 2;
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.finder-note {
  font-size: 0.85rem;
}

/* The score hint gets its own row so it does not stretch the chip groups. */
.finder-score-hint {
  grid-column: 1 / -1;
  margin: 0;
}

.finder-more-filters {
  margin: 0;
}

/* Same columns as .finder-form at each width, so the filters line up with the
   main ones. */
.finder-more-grid {
  display: grid;
  gap: 0.9rem 1.25rem;
  margin-top: 0.6rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Result count, above the table. */
.finder-count {
  margin-block: 1.5rem 0.5rem;
  font-family: var(--din);
  font-weight: 600;
  font-size: 1.05rem;
}

/* One link per finder row: the car in bold, the variant spec under it. */
.finder-table td {
  vertical-align: top;
}

.finder-link {
  display: block;
  text-decoration: none;
}

.finder-name {
  display: block;
  font-family: var(--din);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
}

.finder-link:hover .finder-name {
  text-decoration: underline;
}

.finder-spec {
  display: block;
  font-size: 0.88rem;
  color: var(--muted);
}

.finder-verdict,
.finder-guide {
  max-width: 40rem;
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--muted);
}

.finder-verdict .badge,
.finder-guide .badge {
  margin: 0 0.35rem 0 0;
  text-decoration: none;
}

.finder-scores {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  max-width: 40rem;
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--muted);
}

/* Score meter: five squares, a yellow fill for scores of 2 or less. */
.score {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.score-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.score-pips {
  display: inline-flex;
  gap: 2px;
}

.score-pips i {
  display: block;
  inline-size: 0.55rem;
  block-size: 0.55rem;
  border: 1px solid var(--ink);
}

.score-pips i.on {
  background: var(--ink);
}

.score-low .score-pips i.on {
  background: var(--yellow);
  border-color: var(--yellow);
}

.score-value {
  font-family: var(--din);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

/* In a fact card the meter is the value, so it takes the value's size. */
.facts .score {
  gap: 0.5rem;
}

.facts .score-pips {
  gap: 3px;
}

.facts .score-pips i {
  inline-size: 0.8rem;
  block-size: 0.8rem;
}

.facts .score-value {
  font-size: inherit;
}

.finder-cost {
  font-weight: 600;
}

.finder-compare {
  text-align: end;
}

.finder-more {
  display: block;
  margin-top: 0.75rem;
}

/* Clearing is a plain link back to the empty finder: the form only swaps
   the results, so a fresh page resets every field at once. */
.finder-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
}

.finder-form button {
  justify-self: start;
  min-height: 2.6rem;
  padding: 0.45rem 1.4rem;
  color: #fff;
  background: var(--blue);
  border: 0;
  font-family: var(--din);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}

@media (prefers-color-scheme: dark) {
  .finder-form button {
    color: #0d1418;
  }
}

/* On phones the number fields go two per row so the results come sooner. */
@media (max-width: 35.99rem) {
  .finder-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .finder-form > * {
    grid-column: 1 / -1;
  }

  .finder-form > .finder-field:has(> input[type="number"]) {
    grid-column: auto;
    min-inline-size: 0;
  }

  .finder-field input[type="number"] {
    inline-size: 100%;
    min-inline-size: 0;
  }

  .finder-more-grid > * {
    grid-column: 1 / -1;
  }

  .finder-more-grid > .finder-field:has(> input[type="number"]) {
    grid-column: auto;
    min-inline-size: 0;
  }
}

@media (min-width: 36rem) {
  .finder-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .finder-form h2,
  .finder-more-filters,
  .finder-weights,
  .finder-actions {
    grid-column: 1 / -1;
  }

  .finder-weights-grid {
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  }

  /* The open make and model lists float over the fields below. */
  #finder-make-field,
  #finder-model-field {
    position: relative;
  }

  .finder-multi[open] > .finder-multi-list {
    position: absolute;
    z-index: 10;
    inset-inline: 0;
    top: 100%;
    background: var(--paper);
    border: 1px solid var(--rule);
    box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 0.25);
  }
}

@media (min-width: 60rem) {
  .finder-form {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .finder-more-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 35.99rem) {
  .site-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .site-name {
    margin-inline-end: 0;
  }

  .site-nav {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .lang-switch {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .facts div {
    flex: none;
  }

  .facts div:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .stack-table {
    overflow-x: visible;
  }

  .stack-table thead {
    display: none;
  }

  .stack-table table,
  .stack-table tbody,
  .stack-table tr,
  .stack-table td {
    display: block;
    width: 100%;
  }

  /* Each row becomes a card: the name across the top, then the figures in
     two columns with their label above them. */
  .stack-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 0.75rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--rule);
  }

  .stack-table tr.row-more {
    display: none;
  }

  .variant-table:has(.rows-toggle[open]) tr.row-more {
    display: grid;
  }

  .stack-table tr:last-child {
    border-bottom: 0;
  }

  .stack-table td {
    padding: 0;
    border-bottom: 0;
    white-space: normal;
  }

  .stack-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 400;
  }

  .stack-table td:first-child {
    grid-column: 1 / -1;
    font-family: var(--din);
    font-size: 1.05rem;
    font-weight: 600;
  }

  .stack-table td:first-child::before {
    content: none;
  }

  .stack-table td.num {
    text-align: start;
  }

  .finder-table td.finder-car {
    font-family: var(--text);
    font-size: inherit;
    font-weight: 400;
  }

  /* A result card: the car across the top, then the figures in three
     columns. The order puts the most useful figures first. */
  .finder-table tr {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem 0.75rem;
  }

  .finder-table td[data-label]::before {
    font-size: 0.75rem;
  }

  .finder-table td.finder-car {
    grid-column: 1 / -1;
    order: 0;
  }

  .finder-table td.finder-cost {
    order: 1;
  }

  .finder-table td.finder-price {
    order: 2;
  }

  .finder-table td.finder-mileage {
    order: 3;
  }

  .finder-table td.finder-years {
    order: 4;
  }

  .finder-table td.finder-trip {
    order: 5;
  }

  .finder-table td.finder-listings {
    order: 6;
  }

  .finder-table td.finder-compare {
    order: 7;
    align-self: end;
    justify-self: end;
    text-align: end;
  }
}

[id] {
  scroll-margin-top: 1rem;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* Running costs: a narrow label and amount table, amounts aligned. */
.cost-table {
  max-width: 34rem;
}

.cost-table td {
  text-align: end;
}

/* Sum row of the running costs and the km form under it. */
.cost-total th,
.cost-total td {
  font-weight: 700;
}

.cost-km {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.cost-km input {
  width: 7rem;
}

/* Price check form on the variant page. */
.price-check {
  margin-top: 1rem;
  padding: 1rem 1.25rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 4px solid var(--blue);
}

.price-check h3 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

.price-check form {
  display: grid;
  gap: 0.5rem;
}

.price-check-field {
  display: grid;
  gap: 0.25rem;
}

.price-check-field label {
  font-size: 0.85rem;
  color: var(--muted);
}

.cost-km input,
.price-check-field input {
  min-height: 2.4rem;
  padding: 0.35rem 0.55rem;
  color: inherit;
  background: var(--paper);
  border: 1px solid var(--rule);
  font: inherit;
}

.cost-km button,
.price-check button {
  justify-self: start;
  min-height: 2.6rem;
  margin-top: 0.25rem;
  padding: 0.45rem 1.4rem;
  color: #fff;
  background: var(--blue);
  border: 0;
  font-family: var(--din);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}

@media (prefers-color-scheme: dark) {
  .cost-km button,
  .price-check button {
    color: #0d1418;
  }
}

.price-verdict {
  padding-left: 0.75rem;
  border-left: 4px solid var(--blue);
}

.price-verdict-below,
.price-verdict-above {
  border-left-color: var(--yellow);
}

@media (min-width: 36rem) {
  /* Long condition and cause cells wrap so the table fits without sideways scroll. */
  .issue-table td {
    white-space: normal;
  }

  .issue-table td:first-child {
    min-width: 11rem;
  }

  .issue-table td:nth-child(2) {
    min-width: 14rem;
  }
}

@media (min-width: 36rem) {
  .price-check form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .price-check button {
    grid-column: 1 / -1;
  }
}

/* Comparison controls and table. */
.compare-action {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 0.25rem 0 1.25rem;
  font-size: 0.9rem;
}

.compare-form {
  display: inline;
  margin: 0;
}

/* The compare control is a toggle: an empty box to add, a ticked box once in. */
.compare-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.2rem;
  padding: 0.3rem 0.8rem 0.3rem 0.6rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 0.3rem;
  font: 600 0.95rem/1.2 var(--din);
  white-space: nowrap;
  cursor: pointer;
}

.compare-toggle::before {
  content: "";
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 1rem;
  height: 1rem;
  font-size: 0.8rem;
  line-height: 1;
  border: 1.5px solid var(--muted);
  border-radius: 0.15rem;
}

.compare-toggle:hover {
  border-color: var(--blue);
}

.compare-toggle:hover::before {
  border-color: var(--blue);
}

.compare-toggle[aria-pressed="true"] {
  color: var(--blue);
  border-color: var(--blue);
}

.compare-toggle[aria-pressed="true"]::before {
  content: "✓";
  color: var(--paper);
  background: var(--blue);
  border-color: var(--blue);
}

.compare-form-short .compare-toggle {
  min-width: 7.6rem;
  min-height: 1.9rem;
  padding: 0.15rem 0.55rem 0.15rem 0.45rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.compare-form-short .compare-toggle::before {
  width: 0.85rem;
  height: 0.85rem;
  font-size: 0.7rem;
}

.compare-form-short .compare-toggle[aria-pressed="true"] {
  color: var(--blue);
}

.compare-form button.compare-remove {
  min-height: 0;
  padding: 0;
  color: var(--blue);
  background: none;
  border: 0;
  font-family: var(--text);
  font-size: inherit;
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.compare-form-short {
  display: inline-block;
}

/* The label column stays visible while the value columns scroll sideways. */
.compare-table th,
.compare-table td {
  min-width: 9rem;
}

.compare-table th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 10rem;
  background: var(--surface);
}

.compare-table thead th {
  vertical-align: top;
  white-space: normal;
}

.compare-table thead th:first-child {
  z-index: 2;
}

.compare-generation {
  display: block;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--muted);
}

.compare-variant {
  display: block;
  font: 600 1.02rem/1.3 var(--din);
}

.compare-table .compare-form {
  display: block;
  margin-top: 0.2rem;
}

/* The lowest cost or price in a row: blue, since yellow means a warning. */
.compare-best {
  font-weight: 700;
  color: var(--blue);
  box-shadow: inset 3px 0 0 var(--blue);
}

/* The table is as wide as its columns need, not the whole page. */
.compare-wrap {
  width: fit-content;
  max-width: 100%;
}

.compare-table {
  width: auto;
}

.compare-table td {
  min-width: 12rem;
}

.compare-sub th,
.compare-sub td {
  padding-block: 0.3rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.compare-sub th {
  padding-inline-start: 1.5rem;
  font-weight: 400;
}

.compare-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.compare-links form {
  margin: 0;
}

.compare-links button.compare-remove {
  padding: 0;
  color: var(--blue);
  background: none;
  border: 0;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* The finder's comparison count stays in reach while the buyer scrolls the results. */
#compare-bar:not(:empty) {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.9rem;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--blue);
  font-size: 0.95rem;
}

#compare-bar a {
  font-weight: 600;
}

@media (max-width: 40rem) {
  .compare-table th,
  .compare-table td {
    min-width: 8rem;
  }

  .compare-table th:first-child {
    min-width: 6.5rem;
    max-width: 7.5rem;
    font-size: 0.85rem;
    white-space: normal;
  }
}

/* Long variant tables show the most listed rows; the toggle reveals the rest
   and then gets out of the way. */
.variant-table:not(:has(.rows-toggle[open])) tr.row-more {
  display: none;
}

.rows-toggle {
  margin-block: 0;
  padding: 0.6rem 0.75rem;
  border-top: 1px solid var(--rule);
}

.rows-toggle[open] {
  display: none;
}

/* Info tip: a small round "i" that shows its text on hover, focus or tap. */
.info-tip {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 1.1em;
  height: 1.1em;
  margin-inline-start: 0.3em;
  border: 1px solid var(--muted);
  border-radius: 50%;
  color: var(--muted);
  font: 600 0.7rem/1 var(--din);
  text-transform: none;
  vertical-align: middle;
  cursor: help;
}

.info-tip:hover,
.info-tip:focus {
  color: var(--blue);
  border-color: var(--blue);
  outline: none;
}

.info-tip:hover::after,
.info-tip:focus::after {
  content: attr(data-tip);
  /* tip.js sets the position; fixed keeps scrolling tables from clipping it. */
  position: fixed;
  top: var(--tip-y, auto);
  left: var(--tip-x, auto);
  z-index: 20;
  width: var(--tip-w, 18rem);
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font: 400 0.85rem/1.4 var(--text);
  white-space: normal;
  text-align: start;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.15);
}
