:root {
  color-scheme: light dark;
  --background: #ffffff;
  --surface: #f2f2f7;
  --text: #1c1c1e;
  --text-secondary: #6c6c70;
  --accent: #0a7d5a;
  --border: #d1d1d6;
  --danger: #c4262e;
  --status-on-track: #1a7a43;
  --status-over-warning: #b25000;
  --status-over-critical: #c4262e;
  --status-under: #2f6db5;
  /* Neutral device frame around screenshots (#571): no Apple bezels, their licence excludes website content */
  --frame: #1c1c1e;
  --frame-edge: transparent;
  --frame-shadow: rgb(0 0 0 / 0.18);
  /* Elevation and hero panel (#571): shadow in light mode, lighter surface + edge in dark mode */
  --card: #ffffff;
  --card-edge: transparent;
  --card-shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 8px 24px rgb(0 0 0 / 0.06);
  --hero-tint: #e8f5ef;
}

/* Dark tokens: by the device unless the visitor picked light, or picked dark (#573). Plain CSS cannot share one
   block between both cases, so they are copies; site.test.ts keeps them identical. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: #1c1c1e;
    --surface: #000000;
    --text: #f2f2f7;
    --text-secondary: #aeaeb2;
    --accent: #3cc48f;
    --border: #38383a;
    --danger: #ff6961;
    --status-on-track: #30d158;
    --status-over-warning: #ff9f0a;
    --status-over-critical: #ff6961;
    --status-under: #64a8ff;
    --frame: #3a3a3c;
    --frame-edge: #636366;
    --frame-shadow: transparent;
    --card: #2c2c2e;
    --card-edge: #3a3a3c;
    --card-shadow: none;
    --hero-tint: #17322a;
  }

  :root:not([data-theme="light"]) .badge-light {
    display: none;
  }

  :root:not([data-theme="light"]) .badge-dark {
    display: block;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #1c1c1e;
  --surface: #000000;
  --text: #f2f2f7;
  --text-secondary: #aeaeb2;
  --accent: #3cc48f;
  --border: #38383a;
  --danger: #ff6961;
  --status-on-track: #30d158;
  --status-over-warning: #ff9f0a;
  --status-over-critical: #ff6961;
  --status-under: #64a8ff;
  --frame: #3a3a3c;
  --frame-edge: #636366;
  --frame-shadow: transparent;
  --card: #2c2c2e;
  --card-edge: #3a3a3c;
  --card-shadow: none;
  --hero-tint: #17322a;
}

:root[data-theme="dark"] .badge-light {
  display: none;
}

:root[data-theme="dark"] .badge-dark {
  display: block;
}

:root[data-theme="light"] {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

header,
main,
footer {
  max-width: 44rem;
  margin: 0 auto;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 16px 8px;
}

/* Light/dark switch, added by theme.js (#573) */
.theme-switch {
  display: flex;
  padding: 2px;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.theme-switch button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--text-secondary);
  background: none;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

.theme-switch button[aria-pressed="true"] {
  color: var(--accent);
  background: var(--surface);
}

.theme-switch button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 600;
  text-decoration: none;
}

.brand img {
  border-radius: 8px;
}

main {
  margin: 16px auto;
  padding: 24px;
  background: var(--background);
  border-radius: 12px;
  overflow-wrap: anywhere;
}

@media (max-width: 46rem) {
  main {
    margin: 16px;
    padding: 20px 16px;
  }
}

h1 {
  margin: 0 0 8px;
  font-size: 1.75rem;
  line-height: 1.25;
}

h2 {
  margin: 32px 0 8px;
  font-size: 1.2rem;
  line-height: 1.3;
}

p,
ul,
ol {
  margin: 0 0 12px;
}

a {
  color: var(--accent);
}

.lead {
  font-size: 1.1rem;
}

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

/* Which language version of a legal text is binding (#535) */
.note {
  padding: 12px 16px;
  background: var(--surface);
  border-radius: 8px;
}

address {
  margin: 0 0 12px;
  font-style: normal;
}

details {
  border-bottom: 1px solid var(--border);
}

summary {
  padding: 12px 0;
  font-weight: 600;
  cursor: pointer;
}

details > :not(summary) {
  margin-top: 0;
}

footer {
  padding: 8px 16px 32px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-align: center;
}

footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  margin-bottom: 8px;
}

footer a {
  color: var(--text-secondary);
}

/* Apple's badge: unaltered, at least 40 px high, a quarter of its height clear around it */
.store-badge {
  margin: 1.5rem 0;
}

.store-badge a {
  display: inline-block;
  padding: 10px 0;
  line-height: 0;
}

.store-badge img {
  display: block;
  height: 40px;
  width: auto;
}

.store-badge .badge-dark {
  display: none;
}

/* Excess-km calculator (#239) */
.calculator {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  border: 0;
}

.field > label,
.field > legend {
  font-weight: 600;
  padding: 0;
}

.field input[type="text"],
.field input[type="date"] {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.field input[aria-invalid="true"] {
  border-color: var(--danger);
}

.field-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.choice {
  display: flex;
  gap: 8px;
  align-items: baseline;
  min-height: 44px;
  padding: 8px 0;
}

.calculator details.more {
  display: grid;
  gap: 16px;
}

.calculator details.more[open] > .field {
  margin-bottom: 16px;
}

.status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-weight: 600;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status[data-status="on-track"] { color: var(--status-on-track); }
.status[data-status="over-warning"] { color: var(--status-over-warning); }
.status[data-status="over-critical"] { color: var(--status-over-critical); }
.status[data-status="under"] { color: var(--status-under); }

.headline {
  margin: 4px 0 12px;
  font-size: 1.4rem;
  font-weight: 600;
}

/* The cost leads the result (#575), in the traffic light's colour */
.cost {
  margin-top: 14px;
}

.cost-label {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.cost-value {
  margin: 0;
  font-size: 2.4rem;
  line-height: 1.15;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.cost[data-status="on-track"] .cost-value { color: var(--status-on-track); }
.cost[data-status="over-warning"] .cost-value { color: var(--status-over-warning); }
.cost[data-status="over-critical"] .cost-value { color: var(--status-over-critical); }
.cost[data-status="under"] .cost-value { color: var(--status-under); }

.cost:not([hidden]) + .headline {
  margin-top: 4px;
  font-size: 1.1rem;
}

/* Driven km against the contract; positions come from rechner.js (CSP: no style attributes) */
.bar {
  position: relative;
  height: 12px;
  border-radius: 6px;
  background: var(--border);
  color: var(--text-secondary);
}

.bar-block[data-status="on-track"] .bar { color: var(--status-on-track); }
.bar-block[data-status="over-warning"] .bar { color: var(--status-over-warning); }
.bar-block[data-status="over-critical"] .bar { color: var(--status-over-critical); }
.bar-block[data-status="under"] .bar { color: var(--status-under); }

.bar-actual,
.bar-projected {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 6px;
}

.bar-actual {
  background: currentColor;
}

.bar-projected {
  background: repeating-linear-gradient(90deg, currentColor 0 6px, transparent 6px 10px);
  opacity: 0.3;
}

.bar-expected,
.bar-contract {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  margin-left: -1px;
}

.bar-expected {
  background: var(--text);
}

.bar-contract {
  background: var(--text-secondary);
}

.bar-caption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 16px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

/* The app right at the result */
.result-app {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  margin: 16px 0 0;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.result-app p {
  margin: 0;
  flex: 1 1 14rem;
}

.values {
  display: grid;
  /* Labels keep their width; a very long value wraps instead of squeezing them letter by letter */
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 16px;
  margin: 0 0 12px;
}

.values dt {
  color: var(--text-secondary);
  overflow-wrap: normal;
}

.values dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 500;
  text-align: right;
}

@media (max-width: 30rem) {
  .values {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .values dd {
    margin-bottom: 8px;
    text-align: left;
  }
}

.hint {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

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

table { width: 100%; border-collapse: collapse; font-size: 0.95em; }
th, td { text-align: left; padding: 0.4em 0.5em 0.4em 0; border-bottom: 1px solid currentColor; vertical-align: top; }
/* The factor column ("2.320 g/l") never breaks inside the number; main allows breaks anywhere */
td:nth-child(2) { white-space: nowrap; }

/* Press kit (#233) */
.facts dt {
  font-weight: 600;
  margin-top: 12px;
}

.facts dd {
  margin: 0;
}

.shots {
  display: grid;
  gap: 16px;
  list-style: none;
  margin: 16px 0;
  padding: 0;
}

.shots img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.copy {
  max-width: 100%;
  width: 100%;
  margin-top: 4px;
  padding: 6px 8px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* Two screenshots side by side, stacked on phones (switching guide, #241) */
.figures {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 16px 0;
}

.figures figure {
  flex: 1 1 12rem;
  max-width: 16rem;
  margin: 0;
}

.figures img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.figures figcaption {
  margin-top: 6px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Wide pages (#571): every page; every rule starts with .wide */
.wide header,
.wide main,
.wide footer {
  max-width: 72rem;
}

.wide main {
  padding: 0;
  background: transparent;
  border-radius: 0;
}

.wide .card {
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  overflow-wrap: anywhere;
}

.wide .card > :first-child,
.wide .card > section > :first-child {
  margin-top: 0;
}

.wide .card > :last-child,
.wide .card > section > :last-child {
  margin-bottom: 0;
}

.wide .narrow {
  max-width: 44rem;
}

.wide main > * + * {
  margin-top: 24px;
}

@media (max-width: 46rem) {
  .wide main {
    margin: 16px;
    padding: 0;
  }

  .wide .card {
    padding: 20px 16px;
  }
}

/* Start page (#571) */
.wide .hero {
  display: grid;
  gap: 24px;
  align-items: center;
  margin: 8px 0 24px;
  padding: 24px 16px;
  background: var(--hero-tint);
  border-radius: 24px;
}

.wide .hero-text > * {
  max-width: 44rem;
}

.wide .hero h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.wide .lead {
  color: var(--text-secondary);
}

.wide .hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  margin: 1.5rem 0 0;
}

.wide .hero-actions .store-badge {
  margin: 0;
}

/* inline-block left a line-box gap under the badge and pushed it off the button's centre */
.wide .hero-actions .store-badge a {
  display: block;
}

.wide .btn-secondary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 20px;
  border: 2px solid var(--accent);
  border-radius: 12px;
  font-weight: 600;
  text-decoration: none;
}

.wide .btn-secondary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.wide .hero-shots {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: center;
}

.wide .hero-shots img,
.wide .strip img,
.wide .lead-shot,
.wide .app-shot {
  display: block;
  height: auto;
  border: 6px solid var(--frame);
  border-radius: 22px;
  box-shadow: 0 0 0 1px var(--frame-edge);
}

.wide .app-shot {
  border-width: 4px;
  border-radius: 14px;
}

.wide .strip img {
  width: 100%;
}

.wide .hero-shots img {
  border-width: 10px;
  border-radius: 30px;
  box-shadow: 0 0 0 1px var(--frame-edge), 0 8px 24px var(--frame-shadow);
}

.wide .hero-iphone {
  width: 40%;
  max-width: 15rem;
}

.wide .hero-ipad {
  width: 55%;
  max-width: 21rem;
}

.wide .tiles {
  display: grid;
  gap: 16px;
}

.wide .tiles h2 {
  margin-top: 0;
  font-size: 1.3rem;
}

.wide .lead-shot {
  width: 100%;
  max-width: 12rem;
}

.wide .tile-accent {
  background: var(--accent);
  color: var(--background);
}

.wide .tile-accent a {
  color: var(--background);
  font-weight: 600;
}

.wide .strip {
  display: grid;
  gap: 16px;
  margin: 24px 0;
}

@media (min-width: 46rem) {
  .wide .tiles,
  .wide .strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .wide .hero {
    padding: 32px;
  }

  .wide .hero h1 {
    font-size: 2.4rem;
  }

  .wide .lead-tile {
    grid-column: span 2;
    display: grid;
    grid-template-columns: 1fr 12rem;
    gap: 24px;
    align-items: start;
  }

  .wide .tile-accent {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 24px;
    align-items: center;
  }

  .wide .tile-accent > :last-child {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
}

@media (min-width: 64.01rem) {
  .wide .hero {
    grid-template-columns: 1.1fr 0.9fr;
    gap: 48px;
    margin: 24px 0 6rem;
    padding: 40px 48px;
  }

  .wide .hero-shots {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1.1;
    align-self: end;
    margin-bottom: -5rem;
  }

  .wide .hero-ipad,
  .wide .hero-iphone {
    position: absolute;
    max-width: none;
  }

  .wide .hero-ipad {
    top: 0;
    right: 0;
    width: 68%;
  }

  .wide .hero-iphone {
    bottom: 0;
    left: 4%;
    width: 38%;
  }

  .wide .tiles {
    grid-template-columns: repeat(3, 1fr);
  }

  .wide .strip {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Phones: only the iPhone shot below the badge, no iPad, no strip */
@media (max-width: 46rem) {
  /* .hero-shots img sets display: block, so the iPad needs the same specificity */
  .wide .hero-shots .hero-ipad,
  .wide .lead-shot,
  .wide .strip {
    display: none;
  }

  .wide .hero-shots {
    justify-content: flex-start;
  }

  .wide .hero-iphone {
    width: 15rem;
  }
}

/* Calculator (#571) */
.wide .intro {
  padding: 0 16px;
}

.wide .calc-layout,
.wide .calc-more {
  display: grid;
  gap: 16px;
}

.wide .calculator {
  /* The form card stretches to the result's height; the fields stay at the top instead of spreading out */
  align-content: start;
}

.wide .calc-side {
  display: grid;
  gap: 16px;
}

/* Only the calculator's app call holds a screenshot; the guides' app calls are plain text */
.wide .app-call:has(.app-shot) {
  display: grid;
  grid-template-columns: 1fr 7rem;
  gap: 16px;
  align-items: start;
}

.wide .app-call h2 {
  margin-top: 0;
}

.wide .app-shot {
  width: 100%;
}

/* The app call is a tinted band like the start page's hero, not a card */
.wide .app-band {
  border-color: transparent;
  background: var(--hero-tint);
  box-shadow: none;
}

.wide .app-band > div {
  max-width: 44rem;
}

/* Shown beside the form until the first result; only the side-by-side layout needs it */
.wide .result-placeholder {
  display: none;
  margin: 0;
  color: var(--text-secondary);
}

@media (min-width: 64.01rem) {
  .wide .calc-layout {
    grid-template-columns: 1.1fr 0.9fr;
  }

  .wide .calc-more {
    grid-template-columns: 1fr 1fr;
  }

  .wide #ergebnis[hidden] + .result-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 48px;
    text-align: center;
  }

  .wide .app-band {
    grid-template-columns: 1fr 9rem;
    align-items: center;
  }

  .wide .calculator,
  .wide .calculator details.more {
    grid-template-columns: 1fr 1fr;
  }

  .wide .calculator details.more,
  .wide .calculator details.more > summary,
  .wide .calculator details.more > fieldset {
    grid-column: 1 / -1;
  }

  .wide .calculator details.more[open] > .field {
    margin-bottom: 0;
  }
}

@media (max-width: 46rem) {
  .wide .intro {
    padding: 0;
  }

  .wide .app-call:has(.app-shot) {
    grid-template-columns: 1fr;
  }

  .wide .app-shot {
    display: none;
  }
}

.wide .values {
  font-variant-numeric: tabular-nums;
}

.wide .card h2:first-child {
  margin-top: 0;
}

/* Press kit (#571) */
.wide .press-top,
.wide .press-more {
  display: grid;
  gap: 16px;
}

.wide .press-top p {
  max-width: 44rem;
}

.wide .press-top .facts dt:first-of-type {
  margin-top: 0;
}

.wide .shots {
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 46rem) {
  .wide .shots {
    grid-template-columns: repeat(4, 1fr);
  }

  .wide .shots-ipad {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 64.01rem) {
  .wide .press-top {
    grid-template-columns: 1.4fr 1fr;
  }

  .wide .press-more {
    grid-template-columns: repeat(3, 1fr);
  }

  .wide .shots {
    grid-template-columns: repeat(5, 1fr);
  }

  .wide .shots-ipad {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Phones get a 1 px placeholder through <picture>, so hidden screenshots are never downloaded */
.wide picture {
  display: contents;
}

.wide picture source {
  display: none;
}

.checklist {
  padding: 0;
  list-style: none;
}

.checklist li + li {
  margin-top: 8px;
}

.checklist label {
  display: flex;
  gap: 10px;
  align-items: baseline;
}

.checklist input {
  flex: none;
  accent-color: var(--accent);
}

.checklist input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Tables break between words and hyphenate long ones instead of splitting at any letter */
td,
th {
  overflow-wrap: normal;
  hyphens: auto;
}

/* Primary button of the invitation page (#745) */
.btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--background);
  font-weight: 600;
  text-decoration: none;
}
