:root {
  --station-map-primary: var(--color-primary, #ffb800);
  --station-map-bg: var(--color-surface, #1a1a22);
  --station-map-panel: var(--color-surface-light, #252530);
  --station-map-text: var(--color-text, #fff);
  --station-map-muted: var(--color-text-secondary, #a0a0b0);
  --station-map-border: rgba(255, 255, 255, 0.12);
  --station-map-shadow: 0 20px 54px rgba(0, 0, 0, 0.26);
}

html[data-station-map-theme='light'] {
  --color-bg: #f5f6f8;
  --color-surface: #fff;
  --color-surface-light: #f2f3f6;
  --color-text: #17181c;
  --color-text-secondary: #5f6572;
  --station-map-bg: #fff;
  --station-map-panel: #f2f3f6;
  --station-map-text: #17181c;
  --station-map-muted: #5f6572;
  --station-map-border: rgba(23, 24, 28, 0.12);
  --station-map-shadow: 0 20px 54px rgba(23, 24, 28, 0.12);
}

@media (prefers-color-scheme: light) {
  html[data-station-map-theme='auto'] {
    --color-bg: #f5f6f8;
    --color-surface: #fff;
    --color-surface-light: #f2f3f6;
    --color-text: #17181c;
    --color-text-secondary: #5f6572;
    --station-map-bg: #fff;
    --station-map-panel: #f2f3f6;
    --station-map-text: #17181c;
    --station-map-muted: #5f6572;
    --station-map-border: rgba(23, 24, 28, 0.12);
    --station-map-shadow: 0 20px 54px rgba(23, 24, 28, 0.12);
  }
}

.station-map-card {
  width: min(960px, calc(100vw - 32px));
  margin-left: 50%;
  transform: translateX(-50%);
  overflow: hidden;
}

.station-map__initial {
  color: var(--station-map-muted);
  line-height: 1.5;
}

.station-map {
  color: var(--station-map-text);
}

.station-map__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.station-map__heading {
  display: grid;
  gap: 6px;
}

.station-map__title {
  margin: 0;
  color: var(--station-map-text);
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.08;
  letter-spacing: -0.025em;
}

.station-map__subtitle,
.station-map__status {
  color: var(--station-map-muted);
  font-size: 14px;
  line-height: 1.45;
}

.station-map__toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.station-map__button,
.station-map__provider,
.station-map__route {
  min-height: 42px;
  border: 1px solid var(--station-map-border);
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
}

.station-map__button,
.station-map__provider {
  background: var(--station-map-panel);
  color: var(--station-map-text);
}

.station-map__button {
  padding: 0 13px;
  font-weight: 700;
  cursor: pointer;
}

.station-map__button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.station-map__provider {
  max-width: 170px;
  padding: 0 32px 0 11px;
  cursor: pointer;
}

.station-map__layout {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(250px, 0.85fr);
  min-height: 480px;
  overflow: hidden;
  border: 1px solid var(--station-map-border);
  border-radius: 18px;
  background: var(--station-map-panel);
  box-shadow: var(--station-map-shadow);
}

.station-map__canvas-wrap {
  position: relative;
  min-height: 480px;
  background:
    radial-gradient(circle at 18% 22%, rgba(255, 184, 0, 0.15), transparent 28%),
    #dce1e7;
}

.station-map__canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.station-map__map-fallback {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  color: #39404a;
  text-align: center;
}

.station-map__rail {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  background: var(--station-map-bg);
  border-left: 1px solid var(--station-map-border);
}

.station-map__status {
  min-height: 44px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--station-map-border);
}

.station-map__list {
  min-height: 0;
  max-height: 436px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 1px;
  scroll-padding-block-end: 12px;
  scrollbar-width: thin;
}

.station-map__empty {
  padding: 24px 16px;
  color: var(--station-map-muted);
  font-size: 14px;
  line-height: 1.5;
}

.station-map__station {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--station-map-border);
  background: transparent;
  color: var(--station-map-text);
  padding: 14px 15px;
  display: grid;
  gap: 7px;
  text-align: left;
  cursor: pointer;
}

.station-map__station:hover,
.station-map__station[aria-current='true'] {
  background: color-mix(in srgb, var(--station-map-primary) 12%, transparent);
}

.station-map__station:last-child {
  border-bottom: 0;
}

.station-map__station-name {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
}

.station-map__station-address {
  color: var(--station-map-muted);
  font-size: 13px;
  line-height: 1.35;
}

.station-map__station-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}

.station-map__availability {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--station-map-muted);
}

.station-map__availability::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8b919c;
  content: '';
}

.station-map__availability--available {
  color: #16833b;
}

.station-map__availability--available::before {
  background: #34c759;
}

.station-map__availability--maintenance {
  color: #c46a08;
}

.station-map__availability--maintenance::before {
  background: #ff9500;
}

.station-map__availability--offline {
  color: #c63830;
}

.station-map__availability--offline::before {
  background: #ff3b30;
}

.station-map__distance {
  color: var(--station-map-muted);
  white-space: nowrap;
}

.station-map__details {
  position: absolute;
  z-index: 500;
  left: 14px;
  right: 14px;
  bottom: 14px;
  max-width: 420px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 16px;
  background: rgba(20, 21, 27, 0.94);
  color: #fff;
  padding: 15px;
  display: grid;
  gap: 8px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(16px);
}

.station-map__details[hidden] {
  display: none;
}

.station-map__details-name {
  padding-right: 28px;
  font-size: 17px;
  font-weight: 800;
}

.station-map__details-address,
.station-map__details-status {
  color: rgba(255, 255, 255, 0.76);
  font-size: 13px;
  line-height: 1.4;
}

.station-map__details-close {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}

.station-map__route {
  margin-top: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  background: var(--station-map-primary);
  border-color: transparent;
  color: #17130a;
  font-weight: 800;
  text-decoration: none;
}

.station-map__button:focus-visible,
.station-map__provider:focus-visible,
.station-map__station:focus-visible,
.station-map__route:focus-visible,
.station-map__details-close:focus-visible {
  outline: 3px solid var(--station-map-primary);
  outline-offset: 2px;
}

.station-map__marker {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 12%;
  background: #8b919c;
  color: #fff;
  font: 800 12px/1 -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.3);
  transform: rotate(-45deg);
}

.station-map__marker span {
  transform: rotate(45deg);
}

.station-map__marker--available {
  background: #22a447;
}

.station-map__marker--maintenance {
  background: #e57b0c;
}

.station-map__marker--offline {
  background: #d7443c;
}

.station-map__user-marker {
  width: 18px;
  height: 18px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: #1677ff;
  box-shadow: 0 0 0 7px rgba(22, 119, 255, 0.22);
}

.station-map .leaflet-control-attribution {
  display: none !important;
}

.station-map__credits {
  margin: 7px 2px 0;
  color: var(--station-map-muted);
  font-size: 10px;
  line-height: 1.25;
  text-align: right;
}

.station-map__credits a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

body[data-page='stations-map'] {
  display: block;
  min-width: 280px;
  background: var(--color-bg);
}

.station-map-embed-shell {
  width: 100%;
  min-height: 100dvh;
  padding: 12px;
}

.station-map-embed-shell .station-map {
  min-height: calc(100dvh - 24px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.station-map-embed-shell .station-map__layout {
  min-height: 0;
}

@media (min-width: 721px) {
  .station-map-embed-shell {
    height: 100dvh;
    min-height: 0;
  }

  .station-map-embed-shell .station-map {
    height: calc(100dvh - 24px);
    min-height: 0;
    overflow: hidden;
  }

  .station-map-embed-shell .station-map__canvas-wrap,
  .station-map-embed-shell .station-map__rail {
    min-height: 0;
  }

  .station-map-embed-shell .station-map__list {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .station-map__header {
    align-items: stretch;
    flex-direction: column;
  }

  .station-map__toolbar {
    justify-content: stretch;
  }

  .station-map__button,
  .station-map__provider {
    flex: 1 1 130px;
    max-width: none;
  }

  .station-map__layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(330px, 52dvh) auto;
    min-height: 0;
  }

  .station-map__canvas-wrap {
    min-height: 330px;
  }

  .station-map__rail {
    border-top: 1px solid var(--station-map-border);
    border-left: 0;
  }

  .station-map__list {
    max-height: 290px;
  }

  .station-map__details {
    left: 10px;
    right: 10px;
    bottom: 10px;
  }
}

@media (max-width: 420px) {
  .station-map-card {
    width: calc(100vw - 20px);
  }

  .station-map__toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .station-map__provider {
    grid-column: 1 / -1;
  }

  .station-map-embed-shell {
    padding: 8px;
  }

  .station-map__title {
    font-size: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .station-map *,
  .station-map *::before,
  .station-map *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
