:root { font-family: system-ui, sans-serif; color: #17283c; background: #f6f8fb; }
body { position: relative; margin: 0; height: 100vh; height: 100dvh; }
#map { width: 100%; height: 100%; z-index: 0; background: #e1eaf2; }
#route, #status {
  position: absolute; z-index: 1; border: 1px solid #b0bfd4;
  background: #fff; color: #214662; box-shadow: 0 2px 8px #17283c22;
}
#route {
  top: 10px; right: 10px; width: 10.5rem; max-width: calc(100% - 4rem);
  height: 34px; padding: 0 .45rem; border-radius: .35rem; font: 600 .875rem system-ui, sans-serif;
  cursor: pointer; text-overflow: ellipsis;
}
#status {
  left: 10px; bottom: 24px; max-width: min(22rem, calc(100% - 64px));
  box-sizing: border-box; margin: 0; padding: .3rem .55rem; border-radius: .4rem;
  font: .875rem/1.3 system-ui, sans-serif; pointer-events: none;
}
#status:empty { opacity: 0; }
#later-trips-control:not([hidden]) {
  display: flex; align-items: center; gap: .4rem; position: absolute; z-index: 1;
  top: 50px; right: 10px; padding: .35rem .55rem; border: 1px solid #b0bfd4;
  border-radius: .35rem; background: #fff; color: #214662;
  box-shadow: 0 2px 8px #17283c22; font: 600 .875rem system-ui, sans-serif;
  cursor: pointer;
}
#later-trips { margin: 0; accent-color: #612bde; }
.map-loading {
  position: absolute; z-index: 2; top: 42%; left: 50%; transform: translate(-50%, -50%);
  box-sizing: border-box; width: max-content; max-width: calc(100% - 2rem);
  padding: 1rem 1.25rem; overflow: hidden; border: 1px solid #d7e0ea;
  border-radius: .8rem; background: #fff; color: #17283c;
  box-shadow: 0 8px 28px #17283c26; pointer-events: none;
  opacity: 0; transition: opacity 180ms ease;
}
.map-loading.is-visible { opacity: 1; }
.map-loading::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 4px;
  background: var(--loading-accent, #164ca2);
}
.map-loading strong, .map-loading span { display: block; }
.map-loading strong { font-size: 1rem; }
.map-loading span { margin-top: .25rem; color: #38516d; font-size: .875rem; }
@media (prefers-reduced-motion: reduce) {
  .map-loading { transition: none; }
}
.bus-marker { --bus-color: #164ca2; }
.bus-marker.off-duty { --bus-color: #596574; }
.bus-marker::before {
  content: ""; position: absolute; inset: 3px; border: 2px solid #fff;
  border-radius: 50%; background: var(--bus-color);
}
.bus-arrow {
  display: none; position: absolute; top: -10px; left: 3px; width: 18px; height: 14px;
  transform-origin: 50% 22px; transform: rotate(var(--bearing));
  filter: drop-shadow(0 1px 1px #17283c55);
}
.bus-marker.has-bearing .bus-arrow { display: block; }
.bus-arrow::before, .bus-arrow::after {
  content: ""; position: absolute; clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.bus-arrow::before { inset: 0; background: #fff; }
.bus-arrow::after { inset: 3px 4px 2px; background: #102744; }
.bus-marker.last-bearing .bus-arrow::after { background: #61768c; }
.bus-label { background: #164ca2; border: 1px solid #fff; color: #fff;
             font: 600 14px system-ui, sans-serif; border-radius: 1rem; padding: .15rem .55rem; }
.bus-label.off-duty { background: #596574; }
.bus-label::before { display: none; }
.route-stop {
  display: grid; place-items: center; background: #fff; color: #5b6877;
  border: 2px solid #8292a1; border-radius: 50%; box-sizing: border-box;
  box-shadow: 0 1px 4px #17283c40;
}
.route-stop.later-only { border-style: dashed; }
.route-stop:hover, .route-stop:focus { outline: 3px solid #7ab1ed; outline-offset: 2px; }
.stop-symbol { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.has-direction .stop-symbol, .route-chevron .chevron {
  display: block; width: 7px; height: 7px; box-sizing: border-box; background: none;
  border: solid currentColor; border-width: 2px 2px 0 0; border-radius: 0;
  transform: rotate(calc(var(--direction) + 45deg));
}
/* Center the visible chevron inside the circle before rotating it. */
.route-stop.has-direction .stop-symbol {
  transform: rotate(calc(var(--direction) + 45deg)) translate(-1px, 1px);
}
/* A ring and dot distinguish the next stop from the solid bus marker. */
.route-stop.next-stop { color: #164ca2; border: 3px solid currentColor; }
.route-stop.next-stop .stop-symbol {
  width: 5px; height: 5px; border: 0; border-radius: 50%;
  background: currentColor; transform: none;
}
.route-chevron { display: grid; place-items: center; color: #fff; pointer-events: none; }
.route-chevron .chevron { filter: drop-shadow(0 0 1px #17283c); }
.route-controls { display: flex; }
.route-fit-button, .route-reload-button {
  display: grid; place-items: center; width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: inherit; background: #fff; color: #214662; cursor: pointer;
}
.route-fit-button:hover, .route-reload-button:hover { background: #f4f4f4; }
.route-controls button:focus-visible { outline: 2px solid #164ca2; outline-offset: -3px; }
.route-controls .route-reload-button { border-right: 1px solid #d7e0ea; border-radius: 4px 0 0 4px; }
.route-controls .route-fit-button { border-radius: 0 4px 4px 0; }
.route-reload-icon {
  position: relative; width: 16px; height: 16px;
}
.route-reload-icon::before {
  content: ""; position: absolute; inset: 1px; box-sizing: border-box;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%;
}
.route-reload-icon::after {
  content: ""; position: absolute; top: 2px; right: 1px;
  width: 6px; height: 6px; box-sizing: border-box;
  border: solid currentColor; border-width: 0 2px 2px 0; border-radius: 1px;
}
.route-fit-button:disabled { color: #8292a1; cursor: default; }
.route-fit-icon {
  position: relative; width: 14px; height: 14px; box-sizing: border-box;
  border: 2px solid currentColor; border-radius: 4px;
}
.route-fit-icon::after {
  content: ""; position: absolute; inset: 3px; border-radius: 50%; background: currentColor;
}
.stop-card .leaflet-popup-content-wrapper {
  border-radius: 1rem; box-shadow: 0 8px 24px #17283c30;
}
.stop-card .leaflet-popup-content { margin: 0; }
.leaflet-container .stop-card a.leaflet-popup-close-button {
  top: .5rem; right: .5rem; width: 2rem; height: 2rem; line-height: 2rem;
  color: #38516d; border-radius: .5rem;
}
.leaflet-container .stop-card a.leaflet-popup-close-button:hover { background: #eaf0f8; }
.stop-popup {
  box-sizing: border-box; width: min(18rem, 72vw); padding: 1rem;
  color: #17283c; font: .875rem/1.4 system-ui, sans-serif;
}
.stop-popup h2 { margin: 0 1.75rem 0 0; font-size: 1.0625rem; line-height: 1.25; }
.stop-popup .stop-note { margin: .5rem 0 0; color: #38516d; }
.stop-popup .next-note { color: #164ca2; font-weight: 600; }
.stop-popup ul { list-style: none; padding: 0; margin: .7rem 0 0; }
.stop-popup li { padding: .55rem 0; border-top: 1px solid #e0e7ef; }
.stop-popup li:last-child { padding-bottom: 0; }
.pickup-main { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .65rem; }
.pickup-time { font-size: 1.125rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pickup-kind { color: #38516d; }
.pickup-kind.estimated { color: #164ca2; font-weight: 600; }
.stop-popup .pickup-note { margin: .15rem 0 0; color: #38516d; }
