:root {
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, sans-serif;
  --background: #101312;
  --surface: #181c19;
  --raised: #202722;
  --border: #343e36;
  --text: #f3f7f1;
  --muted: #b2bdb4;
  --accent: #8dff54;
  --accent-ink: #14210f;
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 1.5rem; }
body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.55;
}

a { color: inherit; text-underline-offset: .24em; }
a:hover { color: var(--accent); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { line-height: 1.12; letter-spacing: -.035em; }
h2 { font-size: clamp(1.55rem, 3vw, 2.15rem); }
h3 { font-size: 1.24rem; }
em { font-style: normal; }

.shell {
  width: min(calc(100% - 4rem), 72rem);
  margin-inline: auto;
}

.visually-hidden, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link:focus {
  position: absolute;
  z-index: 3;
  top: .75rem;
  left: .75rem;
  padding: .65rem 1rem;
  background: var(--surface);
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: #141815;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.75rem;
  min-height: 4.7rem;
}

.brand {
  display: flex;
  width: clamp(9.5rem, 19vw, 13rem);
  flex-shrink: 0;
}

.brand img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 2rem);
}

.site-header nav a, .header-link {
  color: var(--text);
  font-size: .93rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.site-header a:hover { color: var(--accent); }
.header-link {
  padding: .52rem .85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.hero {
  padding-block: clamp(2.65rem, 6vw, 5rem) clamp(1.85rem, 4vw, 3.05rem);
}

.hero-inner { max-width: 52rem; }
.hero h1 {
  margin-block: .45rem .6rem;
  font-size: clamp(2.35rem, 7vw, 4.85rem);
  line-height: 1.03;
  letter-spacing: -.065em;
  font-weight: 780;
  text-wrap: balance;
}

.hero h1 em { color: var(--accent); }
.hero-inner > p {
  max-width: 42rem;
  font-size: clamp(1rem, 2vw, 1.16rem);
  color: var(--muted);
  text-wrap: pretty;
}

.tool-links {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem 1rem;
  margin-top: .9rem;
}
.tool-links a { font-size: .92rem; font-weight: 650; }
.vehicle-basis { margin-top: .45rem; }
.site-header nav a[aria-current] { color: var(--accent); }

.calculator, .charging-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(0, .82fr);
  gap: 1rem;
  align-items: start;
}

.panel {
  min-width: 0;
  padding: clamp(1rem, 2.65vw, 1.85rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.form-heading, .dialog-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: .8rem;
  margin-bottom: 1.2rem;
}

.muted, .hint { color: var(--muted); }
.form-heading p, .section-heading p, .result-panel > p, .charging-panel h3 + p { margin-top: .35rem; }
.hint { font-size: .875rem; }
.form-heading .muted { font-size: .94rem; }

.text-button {
  padding: .1rem 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: .875rem;
  font-weight: 700;
  text-align: start;
  text-decoration: underline;
  text-underline-offset: .24em;
}

.form-heading .text-button {
  margin-top: .32rem;
  flex-shrink: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: .8rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: .32rem;
  min-width: 0;
  color: var(--text);
  font-size: .9rem;
  font-weight: 600;
}

.field select, .number-field, textarea {
  min-width: 0;
  min-height: 2.92rem;
  border: 1px solid #455248;
  border-radius: 8px;
  background: #111612;
  color: var(--text);
}

.field select {
  width: 100%;
  appearance: none;
  padding: .56rem 2.2rem .56rem .7rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 1rem) 52%, calc(100% - .7rem) 52%;
  background-size: .3rem .3rem;
  background-repeat: no-repeat;
  font-size: 1rem;
}

.number-field {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding-inline: .7rem;
}

.number-field:focus-within, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.number-field input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 2.8rem;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.number-field input::-webkit-inner-spin-button,
.number-field input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.number-field input { appearance: textfield; }
.number-field input::placeholder { color: #9ca79e; font-weight: 400; }
.number-field:has(input:disabled) { opacity: .55; }
.unit { color: var(--muted); white-space: nowrap; font-size: .78rem; font-weight: 500; }

.form-group {
  min-width: 0;
  margin: 1.2rem 0 0;
  padding: 0;
  border: 0;
}

.form-group legend {
  padding: 0;
  margin-bottom: .5rem;
  color: var(--text);
  font-size: .98rem;
  font-weight: 700;
}

.segments {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .3rem;
  padding: .26rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #111612;
}

.segments label {
  position: relative;
  min-width: 0;
  cursor: pointer;
  text-align: center;
}

.segments input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segments span {
  display: grid;
  align-content: center;
  min-height: 2.35rem;
  padding: .25rem .2rem;
  border-radius: 7px;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 700;
}

.segments input:checked + span { background: var(--accent); color: var(--accent-ink); }
.segments input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }
.segments + .hint, .split-field { margin-block: .45rem .7rem; }
.split-field .number-field { max-width: 10rem; }

.options {
  margin-top: 1.25rem;
  padding-top: .85rem;
  border-top: 1px solid var(--border);
}

.options summary {
  cursor: pointer;
  color: var(--text);
  font-size: .95rem;
  font-weight: 650;
}

.options summary::marker { color: var(--accent); }
.details-inner > .hint { margin-block: .7rem; }
.details-inner > .hint:last-child { margin-bottom: 0; }

.result-panel {
  border-color: #405642;
  background: linear-gradient(155deg, #253726 0, #1a221c 48%, #1a1f1b 100%);
}

.result-panel > .muted { font-size: .92rem; }
.result-error { margin-block: .7rem; color: #ffce91; }
.difference {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  margin: 1.15rem 0;
  padding-block: .9rem 1.1rem;
  border-block: 1px solid #405642;
}

.difference-value {
  color: var(--accent);
  font-size: clamp(2.85rem, 6vw, 4.5rem);
  line-height: 1;
  letter-spacing: -.06em;
  font-weight: 780;
  overflow-wrap: anywhere;
}

.difference[data-direction="more"] .difference-value { color: #ffce91; }
.difference-caption { color: var(--text); font-size: .96rem; font-weight: 600; }
.comparison { display: grid; gap: 1rem; }
.comparison-label {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .15rem 1rem;
  font-size: .96rem;
}

.comparison-label strong { font-variant-numeric: tabular-nums; font-size: 1.07rem; }
.meter {
  height: .42rem;
  margin-block: .3rem .24rem;
  border-radius: 1rem;
  background: #354639;
  overflow: hidden;
}

.meter span { display: block; height: 100%; border-radius: inherit; }
.meter-petrol { background: #b3c3b5; }
.meter-ev { background: var(--accent); }
.estimate-note {
  margin-block: 1rem .85rem;
  font-size: .83rem;
  color: var(--muted);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: .51rem .91rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: .92rem;
  font-weight: 720;
  line-height: 1.35;
  text-decoration: none;
  text-align: center;
}

.button.primary { background: var(--accent); color: var(--accent-ink); }
.button.primary:hover { background: #b3ff8b; color: var(--accent-ink); }
.button.secondary { border-color: #48574b; background: #242d26; color: var(--text); }
.button.secondary:hover { border-color: var(--accent); color: var(--accent); }
.result-panel .button { width: 100%; }
.button[aria-disabled="true"] { pointer-events: none; opacity: .55; }

.extra-result {
  margin-top: 1rem;
  padding: .83rem .9rem;
  background: #151b16;
  border: 1px solid #405642;
  border-radius: 9px;
}

.extra-result h3 { font-size: 1rem; }
.extra-result h3 + p { margin-top: .25rem; }
.budget-breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-block: .65rem .38rem; }
.budget-breakdown dt { font-size: .84rem; color: var(--muted); }
.budget-breakdown dd { font-weight: 700; }
#budget-difference { font-size: .88rem; font-weight: 650; }

.section-block { margin-top: clamp(2.75rem, 6vw, 5rem); }
.section-heading { max-width: 48rem; margin-bottom: 1.05rem; }
.charging-grid { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); align-items: stretch; }
.parking-options { display: grid; align-content: start; gap: .47rem; margin-inline: 0; padding: .72rem; }
.parking-options label {
  display: flex;
  align-items: flex-start;
  min-width: 0;
  gap: .6rem;
  cursor: pointer;
  padding: .55rem .67rem;
  border: 1px solid transparent;
  border-radius: 9px;
}

.parking-options label:has(input:checked) { border-color: #53734a; background: #263b25; }
.parking-options label:hover { background: var(--raised); }
.parking-options input { flex: 0 0 auto; accent-color: var(--accent); margin: .32rem 0 0; width: 1rem; height: 1rem; }
.parking-options small { display: block; color: var(--muted); font-size: .875rem; }
.charging-panel ul { margin-block: .7rem; padding-left: 1.3rem; }
.charging-panel li { margin-block: .24rem; }
.charging-panel li::marker { color: var(--accent); }
.charging-usage { color: var(--accent); font-size: .92rem; font-weight: 650; }
.charging-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem .9rem; margin-block: .9rem .55rem; }
.quiet-link { color: var(--muted); font-size: .9rem; }

.routes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.route { display: grid; grid-template-rows: auto auto 1fr auto; }
.route-road { color: var(--accent); font-size: .9rem; font-weight: 650; }
.route h3 { margin-block: .28rem .45rem; font-size: 1.4rem; }
.route dl { display: grid; gap: .45rem; border-top: 1px solid var(--border); margin-top: .85rem; padding-top: .65rem; }
.route dt { color: var(--muted); font-size: .85rem; }
.route dd { font-weight: 650; }
.network-links { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; margin-top: .85rem; }
.network-links span { color: var(--muted); margin-right: .25rem; }

.site-footer { border-top: 1px solid var(--border); margin-top: 3rem; }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .65rem; padding-block: 1rem 1.4rem; }
.footer-inner .muted { font-size: .9rem; }

dialog {
  width: min(34rem, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  padding: 0;
  border: 1px solid #587051;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

dialog::backdrop { background: rgb(0 0 0 / .76); }
.dialog-inner { display: grid; gap: .8rem; padding: clamp(1rem, 4vw, 1.5rem); }
.dialog-heading { margin: 0; }
.dialog-heading h2 { font-size: 1.42rem; }
.dialog-inner textarea { display: block; width: 100%; padding: .8rem; resize: vertical; }
.dialog-inner .button { justify-self: start; }

@media (min-width: 900px) and (min-height: 760px) {
  .result-panel { position: sticky; top: 1rem; }
}

@media (max-width: 800px) {
  .shell { width: calc(100% - 2.5rem); }
  .calculator, .charging-grid { grid-template-columns: minmax(0, 1fr); }
  .header-inner { flex-wrap: wrap; min-height: 0; gap: .3rem 1rem; padding-block: .58rem .65rem; }
  .site-header nav { order: 3; width: 100%; justify-content: space-between; flex-wrap: wrap; gap: .45rem .85rem; border-top: 1px solid var(--border); padding-top: .58rem; }
  .routes { grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
}

@media (max-width: 425px) {
  .shell { width: calc(100% - 1.5rem); }
  .form-heading { flex-wrap: wrap; gap: .3rem; }
  .field-grid { gap: .55rem; }
  .field, .segments span { font-size: .85rem; }
  .number-field { padding-inline: .45rem; gap: .18rem; }
  .unit { font-size: .72rem; }
  .number-field input::placeholder { font-size: .83rem; }
}
