:root {
  --bg: #E9ECEA;
  --surface: #F7F8F7;
  --ink: #23272B;
  --muted: #5E656B;
  --asphalt: #3A3F44;
  --control: #3A3F44;
  --lane: #F5C400;
  --traficom: #0A4DA2;
  --school: #E0B000;
  --ajovarma: #1E7B4F;
  --other: #8C949A;
  --fail: #C8312B;
  --fail-dark: #9E2621;
  --rule: #CDD2CF;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1B1E21;
    --surface: #24282C;
    --ink: #E8EAE9;
    --muted: #A2A9AE;
    --asphalt: #33383D;
    --control: #BFC5C9;
    --traficom: #4F8BDB;
    --school: #F0C419;
    --ajovarma: #3DAA74;
    --other: #7A8288;
    --fail: #E5534B;
    --fail-dark: #B03A33;
    --rule: #3A4045;
  }
}
:root[data-theme="dark"] {
  --bg: #1B1E21;
  --surface: #24282C;
  --ink: #E8EAE9;
  --muted: #A2A9AE;
  --asphalt: #33383D;
  --control: #BFC5C9;
  --traficom: #4F8BDB;
  --school: #F0C419;
  --ajovarma: #3DAA74;
  --other: #7A8288;
  --fail: #E5534B;
  --fail-dark: #B03A33;
  --rule: #3A4045;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Overpass", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.5;
}
main {
  max-width: 48rem;
  margin: 0 auto;
  padding: 3rem 1.25rem 4rem;
}
h1 {
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}
.topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
/* Pushed to the far side, so starting over is never next to the language
   buttons by accident. */
.topbar .reset { margin-right: auto; }
button.reset.small { padding: 0.3rem 0.7rem 0.15rem; font-size: 0.85rem; }
.toggle.small label { padding: 0.3rem 0.7rem 0.15rem; font-size: 0.85rem; }
.kicker {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.intro-answer {
  font-size: clamp(1.15rem, 3vw, 1.4rem);
  font-weight: 600;
  margin: 0 0 1rem;
  max-width: 36rem;
}
.intro-compare {
  margin: 0 0 1.5rem;
  max-width: 38rem;
  border-left: 6px solid var(--lane);
  padding-left: 1rem;
}
.lede {
  color: var(--muted);
  margin: 0 0 2.5rem;
  max-width: 38rem;
}
h2 {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0 0 1rem;
}

/* Road */
.road {
  position: relative;
  display: flex;
  height: 5.5rem;
  background: var(--asphalt);
  border-radius: 6px;
  padding: 0.9rem;
  gap: 3px;
  overflow: hidden;
}
.road::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  background: repeating-linear-gradient(90deg, var(--lane) 0 22px, transparent 22px 40px);
  pointer-events: none;
  animation: drive 1.2s ease-out 1;
}
@keyframes drive {
  from { background-position: -200px 0; }
  to { background-position: 0 0; }
}
.rseg {
  position: relative;
  min-width: 6px;
  flex-basis: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.8rem;
  padding-top: 0.15rem;
  transition: flex-grow 0.35s ease;
}
.rseg.traficom { background: var(--traficom); }
.rseg.school { background: var(--school); color: #23272B; }
.rseg.ajovarma { background: var(--ajovarma); }
.rseg.other { background: var(--other); }
.rseg.failed {
  background: repeating-linear-gradient(135deg, var(--fail) 0 6px, var(--fail-dark) 6px 12px);
  color: #fff;
}
.rseg .n { position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) {
  .road::after { animation: none; }
  .rseg { transition: none; }
}
.road-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.75rem 0 3rem;
}
.road-total .note { color: var(--muted); font-size: 0.95rem; max-width: 32rem; }
.finish {
  background: var(--traficom);
  color: #fff;
  border: 3px solid #fff;
  outline: 2px solid var(--traficom);
  border-radius: 6px;
  padding: 0.35rem 0.9rem 0.2rem;
  font-weight: 800;
  font-size: 1.6rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.finish small { display: block; font-weight: 600; font-size: 0.75rem; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3rem;
}
@media (min-width: 900px) {
  .layout { grid-template-columns: minmax(0, 25rem) minmax(0, 1fr); gap: 4rem; }
  .breakdown { position: sticky; top: 1.5rem; align-self: start; }
}

/* Controls */
fieldset {
  border: 0;
  margin: 0 0 2rem;
  padding: 0;
  min-width: 0;
}
legend {
  font-size: 1.1rem;
  font-weight: 800;
  padding: 0;
  margin-bottom: 0.75rem;
}
.field { margin-bottom: 1rem; }
.field > .label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.hint { display: block; font-size: 0.85rem; color: var(--muted); margin-top: 0.3rem; }

.toggle {
  display: inline-flex;
  flex-wrap: wrap;
  border: 2px solid var(--control);
  border-radius: 6px;
  overflow: hidden;
}
.toggle input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
}
.toggle label {
  padding: 0.45rem 0.9rem 0.3rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
}
.toggle input:checked + label {
  background: var(--control);
  color: var(--bg);
}
.toggle input:focus-visible + label {
  outline: 3px solid var(--lane);
  outline-offset: -3px;
}

.check {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  cursor: pointer;
  font-weight: 600;
}
.check input {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0.15rem 0 0;
  accent-color: var(--traficom);
  flex-shrink: 0;
}

.money {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding-right: 0.7rem;
}
.money input, .fee input {
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 0;
  width: 6.5rem;
  padding: 0.45rem 0.6rem 0.3rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.money input:focus { outline: none; }
.money:focus-within { outline: 3px solid var(--lane); outline-offset: 1px; }
.money span { color: var(--muted); }

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
}
.stepper button {
  font: inherit;
  font-weight: 800;
  font-size: 1.2rem;
  width: 2.5rem;
  height: 2.4rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.stepper button:disabled { color: var(--rule); cursor: default; }
.stepper output {
  min-width: 2.2rem;
  text-align: center;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

details.fees {
  border-top: 1px solid var(--rule);
  padding-top: 1rem;
  margin-bottom: 1.5rem;
}
details.fees summary {
  cursor: pointer;
  font-weight: 800;
}
.fee-grid {
  display: grid;
  gap: 0.5rem;
  margin-top: 1rem;
}
.fee {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.4rem;
  font-size: 0.95rem;
}
.fee .money input { width: 4.5rem; padding: 0.3rem 0.4rem 0.2rem; }

button.reset {
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
  border: 2px solid var(--control);
  border-radius: 6px;
  padding: 0.45rem 1rem 0.3rem;
  cursor: pointer;
}
:focus-visible { outline: 3px solid var(--lane); outline-offset: 2px; }

/* Breakdown list */
ol.steps {
  list-style: none;
  margin: 0 0 2.5rem;
  padding: 0;
  counter-reset: step;
}
ol.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  gap: 0 0.9rem;
  align-items: baseline;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}
ol.steps li::before {
  content: counter(step);
  display: inline-grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.85rem;
  color: #fff;
  background: var(--dot, var(--asphalt));
  align-self: start;
}
li.traficom { --dot: var(--traficom); }
li.school { --dot: var(--school); }
li.school::before { color: #23272B; }
li.ajovarma { --dot: var(--ajovarma); }
li.other { --dot: var(--other); }
li.failed { --dot: var(--fail); }
li.failed.school::before { color: #fff; }
.what { font-weight: 600; }
.what .fi { font-weight: 400; color: var(--muted); }
.detail { grid-column: 2; font-size: 0.9rem; color: var(--muted); }
.price {
  grid-column: 3;
  grid-row: 1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tag {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0 0.45rem;
  border-radius: 3px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  vertical-align: 0.1em;
}
.tag.fail { background: var(--fail); }
.tag.pass { background: var(--ajovarma); }
ol.steps li.total { border-bottom: none; padding-top: 1rem; }
ol.steps li.total::before { content: none; }
ol.steps li.total .what { grid-column: 2; font-size: 1.15rem; font-weight: 800; }
ol.steps li.total .price { font-size: 1.15rem; }

.payees {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1rem;
}
.payee {
  background: var(--surface);
  border-left: 6px solid var(--c);
  border-radius: 4px;
  padding: 0.8rem 1rem 0.7rem;
}
.payee strong {
  display: block;
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.payee p { margin: 0.1rem 0 0; font-size: 0.9rem; color: var(--muted); }


@media (max-width: 520px) {
  main { padding-top: 2rem; }
  .road { height: 4.5rem; padding: 0.7rem; }
  .rseg .n { display: none; }
  ol.steps li { grid-template-columns: 1.9rem 1fr auto; gap: 0 0.6rem; }
}

input.school {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.45rem 0.7rem 0.3rem;
  width: 100%;
  max-width: 24rem;
}
input.school:focus { outline: 3px solid var(--lane); outline-offset: 1px; }
input.school[aria-invalid="true"] { border-color: var(--fail); }
.hint a, table.fees a { color: var(--traficom); }
.warn {
  border-left: 6px solid var(--fail);
  background: var(--surface);
  border-radius: 4px;
  padding: 0.6rem 0.9rem 0.5rem;
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
}
table.fees {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin: 0 0 0.5rem;
}
table.fees td {
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: baseline;
}
table.fees td.amt {
  text-align: right;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-left: 1rem;
}
table.fees td.src {
  text-align: right;
  white-space: nowrap;
  padding-left: 1rem;
  font-size: 0.85rem;
}
.fees-wrap { margin-top: 2.5rem; }
ul.sources {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0;
  font-size: 0.95rem;
}
ul.sources li {
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--rule);
}
ul.sources li.s-head {
  border-bottom: none;
  padding: 1rem 0 0.15rem;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
ul.sources li.s-head:first-child { padding-top: 0; }
.s-what { display: block; font-weight: 600; }
.s-src { display: block; color: var(--muted); font-size: 0.9rem; }
ul.sources a { color: var(--traficom); }

/* Journey */
.stops {
  list-style: none;
  display: flex;
  align-items: center;
  margin: 0 0 1.75rem;
  padding: 0;
  position: relative;
}
.stops::before {
  content: "";
  position: absolute;
  left: 0.85rem; right: 0.85rem;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  background: var(--rule);
}
.stops li { flex: 1; display: flex; justify-content: center; position: relative; }
.stops li:first-child { justify-content: flex-start; }
.stops li:last-child { justify-content: flex-end; }
.stops button {
  /* Grid centring rather than the button default: with padding:0 the font's
     own metrics decide where the digit sits, which leaves it high in the
     circle — and the € on the last stop worst of all. Same approach as the
     numbered circles in the result list. */
  display: grid;
  place-items: center;
  line-height: 1;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  border: 2px solid var(--rule);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}
.stops button.done { background: var(--asphalt); border-color: var(--asphalt); color: #fff; }
.stops button.current { background: var(--lane); border-color: var(--lane); color: #23272B; }
.stops button:disabled { cursor: default; }
.stepcount { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.3rem; }
.step h2 {
  font-size: clamp(1.5rem, 4.5vw, 2rem);
  line-height: 1.15;
  margin: 0 0 1.25rem;
}
.step h2:focus { outline: none; }
.step .q {
  font-weight: 800;
  font-size: 1.1rem;
  margin: 1.75rem 0 0.75rem;
}
.choices { display: grid; gap: 0.6rem; margin: 0 0 1rem; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice label {
  display: block;
  border: 2px solid var(--rule);
  border-radius: 8px;
  padding: 0.8rem 1rem 0.65rem;
  cursor: pointer;
  background: var(--surface);
}
.choice label strong { display: block; font-weight: 800; }
.choice label span { display: block; color: var(--muted); font-size: 0.9rem; margin-top: 0.15rem; }
.choice input:checked + label { border-color: var(--control); box-shadow: inset 6px 0 0 var(--lane); }
.choice input:focus-visible + label { outline: 3px solid var(--lane); outline-offset: 2px; }
input.text {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.45rem 0.7rem 0.3rem;
  width: 100%;
  max-width: 20rem;
}
input.text:focus { outline: 3px solid var(--lane); outline-offset: 1px; }
.nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 2rem 0 0;
}
.btn {
  font: inherit;
  font-weight: 800;
  border-radius: 6px;
  padding: 0.6rem 1.2rem 0.45rem;
  cursor: pointer;
  border: 2px solid var(--control);
}
.btn.primary { background: var(--traficom); border-color: var(--traficom); color: #fff; margin-left: auto; }
.btn.secondary { background: transparent; color: var(--ink); }
.answers { list-style: none; margin: 0 0 2.5rem; padding: 0; }
.answers li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 1rem;
  align-items: baseline;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--rule);
}
.answers .a-q { font-size: 0.85rem; color: var(--muted); grid-column: 1; }
.answers .a-v { font-weight: 600; grid-column: 1; }
.answers button {
  grid-column: 2; grid-row: 1 / span 2;
  font: inherit; font-size: 0.9rem; font-weight: 600;
  color: var(--traficom);
  background: none; border: 0; cursor: pointer; padding: 0.3rem 0;
  text-decoration: underline;
}
