:root {
  --bg: #f4f2ec;
  --surface: #fff;
  --text: #16191f;
  --muted: #646b77;
  --border: #e3dfd5;
  --accent: #0b4fa3;
  --accent-text: #fff;
  --star: #f2a900;
  --star-empty: #d8d3c6;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1a1d23;
    --text: #ecebe6;
    --muted: #9ba2ae;
    --border: #2b2f37;
    --accent: #6aa5f2;
    --accent-text: #0b1220;
    --star-empty: #3b404a;
    --danger: #ff8f84;
    --danger-bg: #3a1815;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
h1, h2 { line-height: 1.15; letter-spacing: -0.015em; text-wrap: balance; }
h2 { font-size: 1.3rem; margin: 0 0 1rem; }

.wrap { max-width: 720px; margin: 0 auto; padding-inline: 20px; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .9rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.topbar { padding-block: 1.25rem; }
.brand { color: var(--text); font-weight: 800; text-decoration: none; font-size: 1.1rem; }
.brand-star { color: var(--star); }

.footer { padding-block: 3rem 2rem; font-size: .85rem; color: var(--muted); }

/* Swedish licence plate */
.plate {
  display: inline-flex;
  align-items: stretch;
  font-size: 1.7rem;
  background: #fff;
  color: #111;
  border: .1em solid #111;
  border-radius: .3em;
  overflow: hidden;
  box-shadow: 0 10px 24px -14px rgba(0, 0, 0, .5);
  font-family: "DIN Condensed", "DIN Alternate", Bahnschrift, "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
}
.plate-lg { font-size: clamp(2.3rem, 10vw, 3.4rem); }
.plate-eu {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: .15em;
  padding: .3em .28em .25em;
  background: #039;
  color: #fff;
  font: 700 .4em/1 system-ui, sans-serif;
}
.plate-eu svg { width: 1.6em; height: 1.6em; }
.plate-text, .plate input, .plate-sizer {
  padding: .1em .4em;
  font: inherit;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}
/* The input sits on top of a hidden "ABC 123" in the same grid cell, so it is
   exactly as wide as a standard plate in whatever font the plate gets. */
.plate-field { display: inline-grid; }
.plate-field > * { grid-area: 1 / 1; }
.plate-sizer { visibility: hidden; }
.plate input {
  width: 100%;
  min-width: 0;
  text-align: center;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
}
.plate input::placeholder { color: #c5c5c5; }
.plate:focus-within { outline: 3px solid var(--accent); outline-offset: 3px; }

.btn {
  padding: .75em 1.4em;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.btn-lg { font-size: 1.15rem; padding-inline: 1.8em; }
.btn-quiet { background: var(--surface); color: var(--text); border: 1px solid var(--border); font-weight: 600; }

/* Swish button in the footer. The QR code is for visitors on computers. */
.swish {
  display: flex;
  align-items: center;
  gap: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
}
.swish-qr { margin: 0; text-align: center; font-size: .8rem; color: var(--muted); }
.swish-qr img { display: block; margin-bottom: .35rem; border-radius: 6px; }
.swish-text p { margin: 0 0 .9rem; }
.swish-text .btn { display: inline-block; text-decoration: none; }
@media (max-width: 600px) { .swish-qr { display: none; } }

.error {
  margin: 0 0 1rem;
  padding: .65rem .9rem;
  border-radius: 10px;
  background: var(--danger-bg);
  color: var(--danger);
}

/* Front page */
.hero { padding-block: clamp(2rem, 12vh, 7rem) 2rem; text-align: center; }
.hero h1 { font-size: clamp(2rem, 7vw, 3.3rem); margin: 0 0 .75rem; font-weight: 800; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 32em; margin: 0 auto 2.25rem; }
/* The plate sits in the middle column, centred under the heading, with the
   button beside it. On narrow screens the button goes underneath instead. */
.search {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.search .plate { grid-column: 2; }
.search .btn { justify-self: start; }
@media (max-width: 40rem) {
  .search { grid-template-columns: auto; justify-content: center; }
  .search .plate { grid-column: auto; }
  .search .btn { justify-self: stretch; }
}
.hero .error { display: inline-block; }

/* Car page */
.card {
  margin-bottom: 1.5rem;
  padding: clamp(1.1rem, 4vw, 1.75rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.car { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.5rem; }
.car-info { flex: 1 1 14rem; }
.car-info h1 { margin: 0 0 .2rem; font-size: clamp(1.5rem, 5vw, 2rem); }
.car-info p { margin: 0; }
.score {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.score-num { font-size: 1.25rem; }

.stars {
  --pct: calc(var(--rating, 0) / 5 * 100%);
  display: inline-block;
  line-height: 1;
  letter-spacing: .08em;
  background: linear-gradient(90deg, var(--star) var(--pct), var(--star-empty) var(--pct));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stars-lg { font-size: 1.5rem; }

.rate { margin: 0 0 1rem; padding: 0; border: 0; }
.rate legend, .field-label { display: block; margin-bottom: .35rem; padding: 0; font-weight: 600; }
.rate-stars { display: inline-flex; gap: .1rem; }
.rate-stars input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.rate-stars label {
  font-size: 2.1rem;
  line-height: 1;
  color: var(--star-empty);
  cursor: pointer;
  transition: transform .1s;
}
.rate-stars label:hover { transform: scale(1.12); }
/* Fill up to the checked star, or up to the hovered one while hovering. */
.rate-stars:has(input:checked) label { color: var(--star); }
.rate-stars input:checked + label ~ label { color: var(--star-empty); }
.rate-stars:has(label:hover) input + label { color: var(--star); }
.rate-stars input + label:hover ~ label { color: var(--star-empty); }
.rate-stars input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

textarea {
  display: block;
  width: 100%;
  padding: .7rem .8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: inherit;
  font: inherit;
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.cf-turnstile { margin: 1rem 0; }

.reviews { padding-inline: .25rem; }
.review { padding-block: 1rem; border-top: 1px solid var(--border); }
.review .stars { font-size: 1.05rem; }
.review header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.review-meta { font-size: .85rem; color: var(--muted); }
.review p { margin: .5rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.vote { display: flex; gap: .5rem; margin-top: .6rem; }
.vote button {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .25rem .65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .85rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.vote button:hover { color: var(--text); border-color: var(--muted); }
.vote button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.vote svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.vote button[aria-pressed="true"] { color: var(--accent); border-color: currentColor; }
.vote button[aria-pressed="true"] svg { fill: currentColor; fill-opacity: .2; }

.edit { margin-top: .6rem; }
.edit summary { display: inline-block; cursor: pointer; font-size: .85rem; color: var(--accent); }
.edit form { margin-top: .75rem; }
.edit-actions { display: flex; gap: .5rem; margin-top: .75rem; }
