* {
  box-sizing: border-box;
}

/* Theme: the app defaults to light, matching the light basemap (see MAP_STYLES/
   applyMapTheme in app.js). Toggling to the dark basemap also flips this chrome via
   the same body.dark-map class, so the panels/popups/legend always match the map.
   Semantic colors (mode badges, category/status/crowd/delay pills, marker rings) are
   deliberately NOT themed here -- they're self-contained bg+text pairs already chosen
   for contrast, independent of the surrounding page. */
:root {
  --chrome-bg: rgba(255, 255, 255, 0.92);
  --panel-bg: rgba(255, 255, 255, 0.96);
  --popup-bg: rgba(255, 255, 255, 0.94);
  --border-soft: rgba(0, 0, 0, 0.1);
  --border: rgba(0, 0, 0, 0.14);
  --text-primary: #111827;
  --text-secondary: #374151;
  --text-muted: #6b7280;
  --warning-text: #9a3412;
  --marker-neutral: #ffffff;
}

body.dark-map {
  --chrome-bg: rgba(30, 30, 46, 0.85);
  --panel-bg: rgba(20, 20, 30, 0.95);
  --popup-bg: rgba(24, 24, 36, 0.92);
  --border-soft: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.12);
  --text-primary: #f4f4f7;
  --text-secondary: #d1d5db;
  --text-muted: #9ca3af;
  --warning-text: #fdba74;
  --marker-neutral: #1f2937;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, sans-serif;
}

header {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1000;
  padding: 0.6rem 0.9rem;
  background: var(--chrome-bg);
  color: var(--text-primary);
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

#clock {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 0.6rem 0.9rem;
  background: var(--chrome-bg);
  color: var(--text-primary);
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.theme-toggle button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--chrome-bg);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle button:hover {
  filter: brightness(1.15);
}

.locate-control button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--chrome-bg);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.locate-control button:hover {
  filter: brightness(1.15);
}

.locate-control button:disabled {
  cursor: wait;
  opacity: 0.7;
}

/* Dark map mode: restyle Leaflet's own zoom control + attribution, which otherwise
   stay a bright white box regardless of the basemap. */
body.dark-map .leaflet-control-zoom a {
  background: rgba(30, 30, 46, 0.9);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.12) !important;
}

body.dark-map .leaflet-control-zoom a:hover {
  background: rgba(55, 55, 75, 0.95);
}

body.dark-map .leaflet-control-attribution {
  background: rgba(20, 20, 30, 0.75);
  color: #cbd5e1;
}

body.dark-map .leaflet-control-attribution a {
  color: #93c5fd;
}

/* Vehicle markers: colored badge with a ring, instead of a flat dot. Plain modes get
   a white ring; Intercity/Sprinter trains get a swapped-color ring (see markerColors). */
.vehicle-marker-wrapper {
  background: transparent;
  border: none;
}

.vehicle-marker-box {
  position: relative;
}

.vehicle-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--fill);
  border: 3px solid var(--ring);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  color: var(--text-primary); /* only affects the plain-text "?" fallback icon -- emoji/logo ignore this; needs to track the theme now that fill is a neutral instead of always-colored */
}

/* Route number chip, overlapping the marker's bottom-right edge like Transit
   App's route badges. Base position (centered on the marker) plus the actual
   corner offset both come from app.js's inline transform, scaled to icon size. */
.line-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111827;
  color: #fff;
  font-weight: 700;
  line-height: 1;
  border: 2px solid #fff;
  border-radius: 999px;
  padding: 0 0.35em;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

/* Heading arrow: only rendered for live-GPS trains moving above ~10km/h (see
   server.js/app.js). Points up (north/0deg) by default; rotated per-vehicle inline. */
.heading-arrow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 9px solid #fff;
  filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.7));
}

/* Station markers: small and green (the one mode color not otherwise in use). */
.station-marker-wrapper {
  background: transparent;
  border: none;
}

/* Rounded-square NS logo, like a Google Maps POI pin. !important beats Leaflet's
   own ".leaflet-marker-pane img" reset (forces width:auto otherwise). */
.station-marker {
  width: 100% !important;
  height: 100% !important;
  border-radius: 25%;
  border: 1.5px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  object-fit: cover;
  display: block;
}

/* Unlike the NS logo, this icon already has its own rounded-square shape and
   drop shadow baked in -- just needs sizing, no extra border/shadow on top. */
.bus-stop-marker {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
  display: block;
}

/* Numbered route-stop dot -- replaces a stop's usual mode logo while its route is
   focused, so "1, 2, 3..." reads as this trip's own sequence, not a generic mark. */
.route-stop-marker-wrapper {
  background: transparent;
  border: none;
}

.route-stop-marker {
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  line-height: 1;
}

header h1 {
  margin: 0;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 rgba(34, 197, 94, 0.6);
  animation: live-pulse 2s infinite;
}

@keyframes live-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

#status {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  opacity: 0.8;
}

/* Vehicle popup: dark glass card matching the header/legend, replacing Leaflet's default white box. */
.vp-popup .leaflet-popup-content-wrapper {
  background: var(--popup-bg);
  color: var(--text-primary);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
}

.vp-popup .leaflet-popup-tip {
  background: var(--popup-bg);
}

.vp-popup .leaflet-popup-content {
  margin: 0.7rem 0.9rem;
}

.vp-popup .leaflet-popup-close-button {
  color: var(--text-secondary) !important;
}

.vp {
  min-width: 160px;
  font-size: 0.85rem;
}

.vp-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
}

.vp-icon {
  font-size: 1.4rem;
  line-height: 1;
}

/* Lets the NS logo (an <img>, unlike the emoji icons) scale with whichever
   font-size is active in its context -- marker badge, popup icon, or panel header.
   !important is needed because Leaflet's own CSS (.leaflet-marker-pane img) forces
   width:auto with higher specificity than a single class selector can beat. */
.mode-icon-img {
  width: 1em !important;
  height: 1em !important;
  object-fit: contain;
  vertical-align: middle;
}

/* The logo is white-on-transparent, so it disappears against a light-mode chrome
   background (header/popup/panel -- always wrapped in .vp-icon there). Give it a small
   NS-blue badge; the marker version doesn't need this since it already sits on the
   vehicle's own colored circle. */
.vp-icon .mode-icon-img:not(.brand-logo-badge) {
  background: #003082;
  border-radius: 4px;
  padding: 2px;
  box-sizing: content-box;
}

/* Unlike NS's white-on-transparent logo, Qbuzz's is solid orange -- the same color
   as its own bus marker's fill, so it needs its own contrasting backing everywhere
   it appears (marker, card, panel), not just in light-mode chrome. */
.brand-logo-badge {
  background: var(--marker-neutral);
  border-radius: 4px;
  padding: 2px;
  box-sizing: content-box;
}

/* For a logo with dark/black text (needs a guaranteed-light backing) or white
   text (needs a guaranteed-dark one) regardless of theme -- everything else
   matches the marker's own neutral fill exactly, so the badge blends in
   rather than reading as a separate colored square inside the marker. */
.brand-logo-badge-light {
  background: #fff;
}

.brand-logo-badge-dark {
  background: #1f2937;
}

/* min-width:0 overrides flexbox's default min-width:auto, which otherwise refuses
   to shrink a text child below its own content width -- without this, a long bus
   destination fights the timestamp on the right for space, and as the timestamp's
   own width flickers with its digit count (9s -> 10s), the destination visibly
   jumps between one and two lines every refresh instead of just sitting still. */
.vp-title {
  min-width: 0;
  flex: 1 1 auto;
}

.vp-line {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Single line, truncated with an ellipsis rather than wrapped -- bus destinations
   (real headsigns like "Station Schiedam Centrum") are often longer than train
   station names and would otherwise wrap unstably (see .vp-title above). */
.vp-route {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Drawn with CSS instead of a Unicode glyph, so its size/weight stays consistent
   across fonts instead of depending on how "→" happens to render. */
.route-arrow {
  display: inline-block;
  position: relative;
  width: 14px;
  height: 8px;
  margin: 0 0.4em;
  vertical-align: middle;
}

.route-arrow::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 1.5px;
  background: currentColor;
  transform: translateY(-50%);
}

.route-arrow::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 1px;
  width: 6px;
  height: 6px;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  transform: translateY(-50%) rotate(45deg);
}

.vp-head-right {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  padding-top: 0.15rem;
}

.vp-updated {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.vp-composition-pill {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}

.vp-pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #111;
}

.vp-pill + .vp-pill {
  margin-left: 0.35rem;
}

.vp-detail {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.vp-detail:empty {
  display: none;
}

.vp-meta {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.vp-sep {
  margin: 0 0.35rem;
}

#map {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.legend {
  background: var(--chrome-bg);
  color: var(--text-primary);
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 165px;
  border: 1px solid var(--border-soft);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.legend-title {
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.legend-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  margin: -4px -4px -4px 0;
  border-radius: 4px;
  flex-shrink: 0;
}

.legend-toggle:hover {
  color: var(--text-primary);
}

/* An SVG chevron instead of a Unicode triangle or a border-corner hack -- the polyline's
   own bounding box (x:2-8, y:3.5-6.5) is exactly centered on the 10x10 viewBox, so
   rotating it around its own center stays truly centered in both states, unlike a
   font glyph's bearing or a border-corner shape (whose "ink" sits off in one corner). */
.legend-toggle-icon {
  transition: transform 0.15s ease;
}

.legend-toggle[aria-expanded='false'] .legend-toggle-icon {
  transform: rotate(-90deg); /* points right: collapsed */
}

.legend-body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* Beats .legend-body's own display:flex, which otherwise outranks the "hidden"
   attribute's UA-stylesheet display:none by specificity and keeps it visible. */
.legend-body[hidden] {
  display: none;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  box-sizing: border-box;
  background: var(--marker-neutral);
  border: 2px solid transparent; /* mode color set inline via border-color -- matches the marker's ring/fill split */
}

.legend-label {
  flex: 1;
}

/* Red/green toggle switch for showing or hiding a vehicle type. */
.switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: #dc2626;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s ease;
}

.switch input:checked + .slider {
  background: #16a34a;
}

.switch input:checked + .slider::before {
  transform: translateX(14px);
}

.vp-timetable-btn {
  display: block;
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.4rem 0.6rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text, #111);
  font-weight: 600;
  font-size: 0.78rem;
  cursor: pointer;
}

.vp-timetable-btn:hover {
  filter: brightness(1.1);
}

/* Timetable slide-in panel */
.timetable-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 500px;
  max-width: 90vw;
  z-index: 1100;
  background: var(--panel-bg);
  color: var(--text-primary);
  border-left: 1px solid var(--border-soft);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(6px);
}

.timetable-panel[hidden] {
  display: none;
}

.timetable-header {
  display: flex;
  flex-direction: column;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.timetable-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1rem;
}

/* Fills the gap between the title and the action buttons in the top row (pinned there,
   not in the scrollable body, so it stays visible while scrolling a long stop list). */
.timetable-header-route {
  flex: 1;
  min-width: 0;
  margin: 0 0.6rem;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timetable-header-route:empty {
  display: none;
}

#timetable-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.timetable-date {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.timetable-header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.timetable-close,
.timetable-refresh {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}

.timetable-refresh {
  font-size: 1.15rem;
}

.timetable-close:hover,
.timetable-refresh:hover {
  color: var(--text-primary);
}

.timetable-body {
  padding: 0.9rem 1rem;
  overflow-y: auto;
}

.timetable-loading {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.timetable-updated {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.timetable-freshness-sep {
  opacity: 0.5;
}

.timetable-route {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.timetable-summary {
  margin-bottom: 0.8rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border);
}

.timetable-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.timetable-composition {
  margin-bottom: 0.6rem;
}

.composition-pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.crowd-pill,
.category-pill-compact {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 700;
}

.timetable-notice {
  font-size: 0.78rem;
  color: var(--warning-text);
  background: rgba(249, 115, 22, 0.12);
  border: 1px solid rgba(249, 115, 22, 0.3);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.6rem;
}

/* Per-stop rows: name on the left, arrival/departure stacked compactly on the right.
   Replaces a wide 4/5-column table, which didn't fit both arrival and departure
   cleanly in a narrow sidebar. */
.stop-list {
  display: flex;
  flex-direction: column;
}

/* Fixed 5-column grid (Stop / Crowd / Plat. / Arr / Dep) so every row lines up
   vertically, instead of arrival/departure shifting around per-row like a flex
   layout would. */
.stop-row {
  display: grid;
  grid-template-columns: 1fr 64px 46px 82px 82px;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border-soft);
}

.stop-row-header {
  position: sticky;
  top: 0;
  background: var(--panel-bg);
  font-size: 0.65rem;
  line-height: 1;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 0.3rem 0;
  z-index: 1;
}

.stop-row-header div:nth-child(n + 2) {
  text-align: center;
}

/* Bus/tram/metro/ferry trips have no crowd forecast (NS-only data) -- same "drop
   the least essential column, give the name more room" treatment as the mobile
   layout below, just applied at any width instead of only on narrow screens. */
.stop-list-no-crowd .stop-row {
  grid-template-columns: 1fr 46px 82px 82px;
}
.stop-list-no-crowd .stop-row > :nth-child(2),
.stop-list-no-crowd .stop-row-header > :nth-child(2) {
  display: none;
}

/* Station departure board: same visual language as the train stop-list (row grid,
   time/delay chip styling) but its own 4-column layout (To / Cat. / Plat. / Dep.). */
.departure-row {
  display: grid;
  grid-template-columns: 1fr 64px 60px 46px 84px;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border-soft);
}

.departure-row-header {
  position: sticky;
  top: 0;
  background: var(--panel-bg);
  font-size: 0.65rem;
  line-height: 1;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 0.3rem 0;
  z-index: 1;
}

.departure-row-header div:nth-child(n + 2) {
  text-align: center;
}

.stop-row-name {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  min-width: 0;
}

/* Truncate rather than wrap -- a long station/destination name (e.g. "Den Haag
   Hollands Spoor") would otherwise wrap across several lines and blow out the
   row's height, breaking the grid's row-to-row alignment. */
.stop-row-name span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stop-row-crowd,
.stop-row-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  font-size: 0.74rem;
  line-height: 1.3;
}

.stop-row-passed {
  opacity: 0.45;
}

.stop-row-skipped .stop-row-name {
  text-decoration: line-through;
  opacity: 0.5;
}

.stop-row-next {
  background: rgba(59, 130, 246, 0.12);
  margin: 0 -0.3rem;
  padding: 0.45rem 0.3rem;
  border-radius: 6px;
}

.stop-row-next .stop-row-name {
  font-weight: 700;
}

.stop-event-empty {
  color: #4b5563;
}

.stop-event-time {
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.stop-event-was {
  display: block;
  color: #6b7280;
  font-size: 0.65rem;
  text-decoration: line-through;
}

.stop-event-delay {
  color: #f59e0b;
  font-weight: 700;
  font-size: 0.68rem;
  margin-left: 0.15rem;
}

.stop-event-delay-major {
  color: #ef4444;
}

.stop-event-cancelled {
  color: #ef4444;
  font-size: 0.72rem;
  text-decoration: line-through;
}

.timetable-next-badge {
  display: inline-block;
  flex-shrink: 0;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: #3b82f6;
  color: #fff;
  font-size: 0.62rem;
  line-height: 1.4;
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* Inline delay coloring for the "Speed • Delay • ..." meta line (vehicle popup and
   timetable panel header) -- same thresholds/palette as .stop-event-delay's per-stop
   orange/red, plus a green "on time" state since this one's always shown. */
.delay-text {
  font-weight: 700;
}

.delay-text-ontime {
  color: #16a34a;
}

.delay-text-minor {
  color: #f59e0b;
}

.delay-text-major {
  color: #ef4444;
}

.delay-chip {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}

.delay-ontime {
  background: #16a34a;
  color: #fff;
}

.delay-minor {
  background: #f87171;
  color: #fff;
}

.delay-major {
  background: #dc2626;
  color: #fff;
}

.delay-unknown {
  background: #4b5563;
  color: #e5e7eb;
}

.delay-skip {
  background: #f97316;
  color: #fff;
}

/* Traffic-light coloring for every "last updated"/"fetched" timestamp -- same
   palette as the delay chips above, just applied as text color instead of a
   filled pill (these sit inline in otherwise-plain status text). */
.freshness-good {
  color: #16a34a;
}

.freshness-warn {
  color: #f97316;
}

.freshness-bad {
  color: #dc2626;
}

/* Mobile overrides -- kept at the end of the file so they win the cascade
   against the desktop rules above at equal selector specificity. */
@media (max-width: 600px) {
  /* On a phone-width screen, 90vw still leaves a sliver of the map/header
     exposed on the left edge behind the panel -- go fully edge-to-edge instead. */
  .timetable-panel {
    left: 0;
    width: 100%;
    max-width: 100%;
    border-left: none;
  }

  /* Both grids' fixed column widths were sized for a 500px desktop panel -- at
     full-width-on-a-phone (~360px of actual content after padding) they only
     left ~50px for the name/destination column, wrapping most Dutch station
     names across 3-4 lines and breaking row alignment entirely. Dropping the
     per-stop crowd column (the least essential field) and trimming the rest
     gives that column roughly 3x the room. */
  .stop-row {
    grid-template-columns: 1fr 38px 64px 64px;
    gap: 0.3rem;
  }
  .stop-row > :nth-child(2),
  .stop-row-header > :nth-child(2) {
    display: none;
  }

  .departure-row {
    grid-template-columns: 1fr 52px 38px 64px;
    gap: 0.3rem;
  }
  .departure-row > :nth-child(2),
  .departure-row-header > :nth-child(2) {
    display: none;
  }

  /* Split view: with a vehicle/station panel open, give the map the bottom half
     instead of letting the panel cover it entirely -- the map stays live underneath
     so a train/bus can still be tracked while its stop list is open (see
     setTimetablePanelOpen in app.js, which toggles this class and re-measures the
     map). Desktop keeps the panel as a full-height sidebar with the map behind it,
     so this only applies below the phone-width breakpoint above. */
  body.timetable-open #map {
    top: 50%;
  }

  body.timetable-open .timetable-panel {
    bottom: auto;
    height: 50%;
    border-bottom: 1px solid var(--border-soft);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  }
}
