:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --card: #ffffff;
  --well: #f5f5f7;
  --fill: rgba(0, 0, 0, 0.05);
  --fill-strong: rgba(0, 0, 0, 0.08);
  --line: rgba(0, 0, 0, 0.08);
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-press: #006edb;
  --accent-soft: rgba(0, 113, 227, 0.14);
  --warning: #9a3412;
  --warning-bg: #fff4e8;
  --nav: rgba(251, 251, 253, 0.72);
  --hero-glow: rgba(0, 113, 227, 0.28);
  --hero-glow-2: rgba(88, 86, 214, 0.2);
  --shadow: 0 1px 1px rgba(0, 0, 0, 0.04), 0 24px 48px rgba(0, 0, 0, 0.08);
  --map-bg: #e7e7ec;
  --chip: rgba(0, 0, 0, 0.05);
  --missing: #8e8e93;
  --highlight: rgba(255, 255, 255, 0.72);
  --route-casing: #ffffff;
}

html[data-theme='dark'] {
  color-scheme: dark;
  --bg: #000000;
  --ink: #f5f5f7;
  --muted: #86868b;
  --card: #1c1c1e;
  --well: #2c2c2e;
  --fill: rgba(255, 255, 255, 0.08);
  --fill-strong: rgba(255, 255, 255, 0.14);
  --line: rgba(255, 255, 255, 0.1);
  --accent: #0a84ff;
  --accent-hover: #409cff;
  --accent-press: #0070e0;
  --accent-soft: rgba(10, 132, 255, 0.24);
  --warning: #ffd60a;
  --warning-bg: rgba(255, 159, 10, 0.16);
  --nav: rgba(0, 0, 0, 0.72);
  --hero-glow: rgba(10, 132, 255, 0.42);
  --hero-glow-2: rgba(94, 92, 230, 0.3);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04), 0 28px 60px rgba(0, 0, 0, 0.45);
  --map-bg: #1c1c1e;
  --chip: rgba(255, 255, 255, 0.08);
  --missing: #636366;
  --highlight: rgba(255, 255, 255, 0.06);
  --route-casing: #0b0b0c;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-old(root) {
  z-index: 1;
}

::view-transition-new(root) {
  z-index: 2;
}

::view-transition-group(theme-switch) {
  z-index: 10000;
  animation-duration: 450ms;
}

* {
  box-sizing: border-box;
}

html,
body {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.022em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
  letter-spacing: inherit;
}

button {
  border: 0;
  border-radius: 980px;
  cursor: pointer;
}

button:active {
  transform: scale(0.98);
}

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

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

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

.nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: 3.25rem;
  backdrop-filter: saturate(180%) blur(20px);
  background: var(--nav);
  border-bottom: 1px solid var(--line);
}

.nav-inner,
.hero,
.results,
footer {
  width: min(72rem, calc(100% - 2.5rem));
  margin-inline: auto;
}

.nav-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.wordmark:hover {
  color: var(--ink);
}

.mark {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #8ec5ff, var(--accent) 62%);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.theme-switch {
  view-transition-name: theme-switch;
  display: flex;
  align-items: center;
  gap: 0.12rem;
  padding: 0.16rem;
  border-radius: 980px;
  background: var(--fill);
}

.theme-choice {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 980px;
  background: transparent;
  color: var(--muted);
}

.theme-choice:hover {
  color: var(--ink);
  background: var(--fill-strong);
}

.theme-choice[aria-checked='true'] {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16);
}

.theme-choice svg {
  width: 1.05rem;
  height: 1.05rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.hero {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2.6rem 0 2rem;
  text-align: center;
}

body:has(#result-summary) .hero,
body:has(.message) .hero {
  flex: none;
  display: block;
  padding: clamp(1.6rem, 4vh, 2.4rem) 0 0.2rem;
}

body:has(#result-summary) h1 {
  font-size: clamp(2rem, 4vw, 2.7rem);
}

body:has(#result-summary) .lede,
body:has(#result-summary) .data-status {
  font-size: 1rem;
}

body:has(#result-summary) .search {
  margin-top: 1.15rem;
}

.hero::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 50%;
  width: min(62rem, 100%);
  height: min(40rem, 90%);
  translate: -50% -58%;
  background:
    radial-gradient(ellipse 46% 42% at 50% 46%, var(--hero-glow), transparent 68%),
    radial-gradient(ellipse 30% 28% at 64% 36%, var(--hero-glow-2), transparent 70%);
  pointer-events: none;
}

.hero-copy,
.search {
  position: relative;
  z-index: 1;
}

.hero-copy {
  width: min(44rem, 100%);
  margin-inline: auto;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h1 {
  margin: 0.35rem 0 0;
  font-size: clamp(2.7rem, 6.4vw, 4.6rem);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1.05;
  text-wrap: balance;
}

.lede {
  margin: 0.9rem auto 0;
  max-width: 34rem;
  color: var(--muted);
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: -0.018em;
  line-height: 1.35;
}

.data-status,
.hint,
.location-status,
footer {
  color: var(--muted);
}

.data-status {
  margin: 0.85rem 0 0;
  font-size: calc(0.92rem * 0.6);
}

.data-status.warning {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.55rem 0.8rem;
  border-radius: 0.8rem;
  background: var(--warning-bg);
  color: var(--warning);
}

.search {
  width: min(34rem, 100%);
  margin: 1.8rem auto 0;
}

.search-panel {
  padding: 1.15rem 1.15rem 1rem;
  text-align: left;
  background:
    linear-gradient(180deg, var(--highlight), transparent 2.4rem),
    var(--card);
  border: 1px solid var(--line);
  border-radius: 1.7rem;
  box-shadow: var(--shadow);
}

.location {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
  align-items: center;
  min-height: 2.4rem;
}

.location[hidden] {
  display: none;
}

.locate {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.48rem 0.9rem 0.48rem 0.7rem;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 600;
}

.locate svg {
  width: 1.05rem;
  height: 1.05rem;
  flex: none;
}

.locate:hover {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}

.location-status {
  margin: 0;
  font-size: 0.88rem;
}

.query {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.25rem;
  align-items: stretch;
  margin-top: 0.9rem;
  padding: 0.35rem;
  background: var(--well);
  border-radius: 1.15rem;
}

.query:focus-within {
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.field {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-weight: 600;
}

.field > span:first-child {
  padding: 0.28rem 0.75rem 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

input,
select {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
}

input {
  padding: 0 0.75rem;
  font-size: 1.08rem;
  font-weight: 500;
}

.postcode-field input,
.radius-control select {
  height: 2.6rem;
  padding-top: 0;
  padding-bottom: 0;
  line-height: 2.6rem;
}

input::placeholder {
  color: color-mix(in srgb, var(--ink) 20%, transparent);
  opacity: 1;
}

input:focus,
select:focus {
  outline: none;
}

input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--ink);
  transition: background-color 9999s ease-out;
}

.radius-field {
  border-left: 1px solid var(--line);
}

.radius-control {
  position: relative;
  display: flex;
  align-items: flex-start;
  height: 2.6rem;
  min-width: 0;
}

.radius-control select {
  width: max-content;
  min-width: 7.4rem;
  field-sizing: content;
  padding-right: 1.85rem;
  padding-left: 0.75rem;
  font-size: 1.08rem;
  font-weight: 500;
  appearance: none;
  cursor: pointer;
}

.radius-control::after {
  content: "";
  position: absolute;
  right: 0.78rem;
  top: 50%;
  width: 0.4rem;
  height: 0.4rem;
  border-right: 1.6px solid var(--muted);
  border-bottom: 1.6px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.submit {
  align-self: stretch;
  min-width: 8.6rem;
  padding: 0 1.15rem;
  background: var(--accent);
  color: white;
  font-weight: 600;
  border-radius: 0.9rem;
}

.submit:hover {
  background: var(--accent-hover);
}

.submit:active {
  background: var(--accent-press);
}

.hint {
  margin: 0.75rem 0.2rem 0.1rem;
  font-size: 0.84rem;
  line-height: 1.4;
}

.results {
  margin: 1.6rem auto 2.4rem;
}

.results h2 {
  margin: 0 0 0.9rem;
  font-size: clamp(1.45rem, 2.4vw, 1.85rem);
  font-weight: 600;
  letter-spacing: -0.035em;
}

.results > p,
.message {
  margin: 0 0 1rem;
  color: var(--muted);
}

.message {
  padding: 0.9rem 1rem;
  border-radius: 1rem;
  background: var(--warning-bg);
  color: var(--warning);
}

.sort-bar {
  margin: 0 0 0.8rem;
  padding: 0.55rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1.15rem;
}

.sort-row {
  --control-height: 2rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.sort-field {
  position: relative;
  width: max-content;
  flex: none;
  margin-left: auto;
}

.sort-field::after {
  content: "";
  position: absolute;
  right: 0.75rem;
  top: 50%;
  width: 0.38rem;
  height: 0.38rem;
  border-right: 1.6px solid var(--muted);
  border-bottom: 1.6px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.sort-field select {
  width: max-content;
  height: var(--control-height);
  field-sizing: content;
  padding: 0 1.7rem 0 0.8rem;
  border-radius: 980px;
  background: var(--fill);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: var(--control-height);
  appearance: none;
}

.fuel-switch {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  flex: none;
  gap: 0.15rem;
  width: max-content;
  max-width: 100%;
  padding: 0.16rem;
  border-radius: 1.15rem;
  background: var(--fill);
}

.fuel-button {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: max-content;
  height: var(--control-height);
  padding: 0 0.7rem;
  border-radius: 980px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
}

.fuel-button:hover {
  color: var(--ink);
}

.fuel-button[aria-pressed='true'] {
  background: var(--fuel);
  color: white;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

.fuel-e10 { --fuel: #1a7f37; }
.fuel-e5 { --fuel: #0e5c28; }
.fuel-b7_standard { --fuel: #1d1d1f; }
.fuel-b7_premium { --fuel: #3a3a3c; }
.fuel-b10 { --fuel: #4d7c0f; }
.fuel-hvo { --fuel: #6d28d9; }

html[data-theme='dark'] .fuel-e10 { --fuel: #30d158; }
html[data-theme='dark'] .fuel-e5 { --fuel: #1f8f45; }
html[data-theme='dark'] .fuel-b7_standard { --fuel: #000000; }
html[data-theme='dark'] .fuel-b7_premium { --fuel: #2c2c2e; }

html[data-theme='dark'] .fuel-e10[aria-pressed='true'] {
  color: #1d1d1f;
}

html[data-theme='dark'] .fuel-b7_standard[aria-pressed='true'],
html[data-theme='dark'] .fuel-b7_premium[aria-pressed='true'] {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 17.5rem;
  align-items: stretch;
  min-height: min(36rem, 70vh);
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1.4rem;
  box-shadow: var(--shadow);
}

#station-map {
  height: 100%;
  min-height: min(36rem, 70vh);
  background: var(--map-bg);
  border-top-left-radius: 1.35rem;
  border-bottom-left-radius: 1.35rem;
  overflow: hidden;
}

.leaflet-container {
  font-family: inherit;
  background: var(--map-bg);
}

.leaflet-tile-pane {
  filter: saturate(0.72) contrast(0.97) brightness(1.03);
}

html[data-theme='dark'] .leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) saturate(0.32) brightness(0.9) contrast(0.96);
}

.leaflet-bar {
  border: 0 !important;
  overflow: hidden;
  border-radius: 0.8rem !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16) !important;
}

.leaflet-bar a {
  width: 2rem !important;
  height: 2rem !important;
  line-height: 2rem !important;
  background: var(--card) !important;
  color: var(--ink) !important;
  border-bottom: 1px solid var(--line) !important;
}

.leaflet-bar a:hover {
  background: var(--well) !important;
}

.leaflet-control-attribution {
  background: color-mix(in srgb, var(--card) 86%, transparent) !important;
  color: var(--muted) !important;
}

.leaflet-control-attribution a {
  color: var(--accent) !important;
}

.station-rail {
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  overflow: auto;
  max-height: min(36rem, 70vh);
  background: var(--card);
  border-left: 1px solid var(--line);
  border-top-right-radius: 1.35rem;
  border-bottom-right-radius: 1.35rem;
  scrollbar-width: thin;
  scrollbar-color: var(--fill-strong) transparent;
}

.station-rail::-webkit-scrollbar {
  width: 10px;
}

.station-rail::-webkit-scrollbar-button,
.station-rail::-webkit-scrollbar-button:single-button,
.station-rail::-webkit-scrollbar-button:vertical:start:decrement,
.station-rail::-webkit-scrollbar-button:vertical:end:increment,
.station-rail::-webkit-scrollbar-button:vertical:start:increment,
.station-rail::-webkit-scrollbar-button:vertical:end:decrement {
  display: none;
  width: 0;
  height: 0;
}

.station-rail::-webkit-scrollbar-track {
  background: transparent;
  margin-block: 0.85rem;
}

.station-rail::-webkit-scrollbar-thumb {
  background: var(--fill-strong);
  border: 2px solid transparent;
  border-radius: 980px;
  background-clip: padding-box;
}

.rail-empty {
  padding: 0.8rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.rail-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "price name"
    "price distance"
    "bar bar";
  column-gap: 0.55rem;
  row-gap: 0.1rem;
  width: 100%;
  margin: 0;
  padding: 0.5rem 0.5rem 0.42rem;
  border: 0;
  border-radius: 0.75rem;
  background: transparent;
  color: inherit;
  text-align: left;
  line-height: 1.2;
}

.rail-item:hover,
.rail-item.is-hovered {
  background: var(--fill);
}

.rail-item[aria-current='true'] {
  background: var(--accent-soft);
}

.rail-price {
  grid-area: price;
  align-self: center;
  min-width: 3.15rem;
  padding: 0.28rem 0.35rem;
  border-radius: 0.5rem;
  background: var(--missing);
  color: white;
  font-size: 0.92rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  text-align: center;
}

.rail-name {
  grid-area: name;
  overflow: hidden;
  font-size: 0.84rem;
  font-weight: 620;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-distance {
  grid-area: distance;
  color: var(--muted);
  font-size: 0.74rem;
}

.rail-distance-track {
  grid-area: bar;
  display: block;
  height: 0.22rem;
  margin-top: 0.18rem;
  border-radius: 980px;
  background: var(--fill);
  overflow: hidden;
}

.rail-distance-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--bar);
}

html[data-theme='light'] .rail-distance-fill {
  background: hsl(from var(--bar) h 70% 46%);
}

.price-marker,
.you-marker {
  background: transparent;
  border: 0;
}

.price-marker span {
  display: block;
  height: 100%;
  background: var(--missing);
  color: white;
  border: 2px solid white;
  border-radius: 980px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 20px;
  text-align: center;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.price-marker.is-hovered span {
  transform: scale(1.14);
  box-shadow: 0 0 0 2px var(--card), 0 8px 18px rgba(0, 0, 0, 0.38);
}

.you-marker span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 45%, transparent);
}

.leaflet-tooltip.station-tip {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: inherit;
  white-space: normal;
  max-width: 16.5rem;
}

.leaflet-tooltip.station-tip.is-preview {
  opacity: 0.92 !important;
}

.leaflet-tooltip.station-tip::before {
  display: none;
}

.station-tip .tip {
  width: 16rem;
  max-width: 100%;
  padding: 0.7rem 0.75rem 0.65rem;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  box-shadow: var(--shadow);
  white-space: normal;
  overflow-wrap: anywhere;
}

.station-tip .tip p,
.station-tip .tip li {
  overflow-wrap: anywhere;
}

.station-tip .tip p {
  margin: 0.15rem 0 0;
}

.tip-prices,
.tip-services {
  margin: 0.4rem 0 0;
  padding: 0;
  list-style: none;
}

.tip-price {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: baseline;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.tip-price span:first-child {
  min-width: 0;
}

.tip-price span:last-child {
  flex: none;
}

.tip-price.is-current {
  font-weight: 700;
  color: var(--accent);
}

.tip-kicker,
.tip-services-empty,
.tip-brand {
  color: var(--muted);
}

.tip-kicker,
.tip-services-empty {
  font-size: 0.72rem;
  font-weight: 650;
}

.tip-services {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
}

.tip-services li {
  max-width: 100%;
  padding: 0.12rem 0.45rem;
  border-radius: 980px;
  background: var(--chip);
  font-size: 0.72rem;
}

.tip-name {
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tip-closed {
  color: var(--warning);
  font-weight: 700;
}

.tip-logo {
  display: block;
  height: 1.6rem;
  width: auto;
  max-width: 5rem;
  object-fit: contain;
  margin-bottom: 0.35rem;
  padding: 0.15rem 0.3rem;
  background: white;
  border-radius: 0.4rem;
}

footer {
  padding: 1.1rem 0 1.35rem;
  font-size: 0.78rem;
  line-height: 1.45;
  text-align: center;
}

footer p {
  width: min(40rem, 100%);
  margin: 0 auto;
}

@media (max-width: 52rem) {
  .query {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .submit {
    grid-column: 1 / -1;
    min-height: 2.8rem;
  }
}

@media (max-width: 40rem) {
  .nav-inner,
  .hero,
  .results,
  footer {
    width: min(72rem, calc(100% - 1.4rem));
  }

  .query {
    grid-template-columns: 1fr;
  }

  .radius-field {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .map-layout {
    grid-template-columns: 1fr;
  }

  #station-map {
    border-radius: 1.35rem 1.35rem 0 0;
  }

  .station-rail {
    max-height: 16rem;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 0 0 1.35rem 1.35rem;
  }

  h1 {
    font-size: 2.55rem;
  }

  .lede {
    font-size: 1.08rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  button:active {
    transform: none;
  }

  .price-marker span {
    transition: none;
  }
}
