/* PKSB GPS — Live Bus Tracker styles */

:root {
  /* Route palette - keep in sync with ROUTE_COLORS in app.js. */
  --route-main: #0d9488;
  --route-patong: #ef8a17;
  --route-dragon: #dc2626;

  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --line: rgba(15, 23, 42, 0.08);
  --live: #16a34a;
  --danger: #dc2626;
  --focus: #2563eb;

  --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.08), 0 2px 8px rgba(15, 23, 42, 0.10);
  --shadow-2: 0 2px 6px rgba(15, 23, 42, 0.08), 0 10px 30px rgba(15, 23, 42, 0.16);

  --gutter: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  --font: "Inter", "Noto Sans Thai", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background: #e8eef0;
  -webkit-tap-highlight-color: transparent;
}

/* The map is the whole screen; every control floats over it. */
#map {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #e8eef0;
}

.leaflet-container {
  font-family: var(--font);
}

/* Mute the busy default OSM palette into a calm backdrop. */
.leaflet-tile-pane {
  filter: saturate(0.45) brightness(1.04) contrast(0.92);
}

/* ---------- Floating top UI: search + line button ---------- */

#top-ui {
  position: fixed;
  top: calc(var(--safe-top) + var(--gutter));
  left: calc(var(--safe-left) + var(--gutter));
  right: calc(var(--safe-right) + var(--gutter));
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* Gaps between the floating pieces stay draggable map. */
  pointer-events: none;
}

#top-ui > * {
  pointer-events: auto;
}

.search-wrap {
  position: relative;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 6px;
  background: var(--surface);
  border-radius: 26px;
  box-shadow: var(--shadow-2);
  transition: box-shadow 0.15s ease;
}

.search-bar:focus-within {
  box-shadow: var(--shadow-2), 0 0 0 2px var(--focus);
}

.brand-mark {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--route-main);
  display: grid;
  place-items: center;
}

.brand-mark svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

#stop-search {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  border: none;
  background: transparent;
  outline: none;
  /* 16px keeps iOS Safari from zooming the page on focus. */
  font: 500 16px/1 var(--font);
  color: var(--ink);
}

#stop-search::placeholder {
  color: var(--ink-3);
  font-weight: 400;
}

.icon-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}

.icon-btn[aria-expanded="true"] {
  background: var(--ink);
  color: #fff;
}

.icon-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Layers menu: the less-used toggles (buses, stops). */
.layers-menu {
  position: absolute;
  top: 60px;
  right: 0;
  z-index: 1003;
  width: 230px;
  padding: 8px;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-2);
}

.layers-menu.hidden {
  display: none;
}

.layers-title {
  padding: 6px 10px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.switch-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 0 10px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
}

.switch-row:hover {
  background: var(--surface-2);
}

.switch-row input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 24px;
  border-radius: 12px;
  background: #cbd5e1;
  transition: background 0.15s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.3);
  transition: transform 0.15s ease;
}

.switch-row input:checked + .switch {
  background: var(--route-main);
}

.switch-row input:checked + .switch::after {
  transform: translateX(16px);
}

.switch-row input:focus-visible + .switch {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.search-results {
  position: absolute;
  top: 60px;
  left: 0;
  right: 0;
  z-index: 1002;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-2);
  max-height: min(60vh, 420px);
  overflow-y: auto;
}

.search-results.hidden {
  display: none;
}

.search-result-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
}

.search-result-item:hover,
.search-result-item.active {
  background: var(--surface-2);
}

.search-result-dot {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  margin-top: 3px;
  border-radius: 50%;
  background: #fff;
  border: 3.5px solid var(--ink-3);
}

.search-result-name {
  font-weight: 600;
  font-size: 14.5px;
}

.search-result-sub {
  color: var(--ink-2);
  font-size: 12.5px;
  margin-top: 2px;
}

.search-result-empty {
  padding: 14px;
  font-size: 14px;
  color: var(--ink-2);
}

/* Line button on the left, language switch on the right; the gap between
   them stays draggable map. */
.top-row {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.top-row > * {
  pointer-events: auto;
}

/* Language switch: both options always visible, the current one filled. */
.lang-switch {
  flex: 0 0 auto;
  display: inline-flex;
  gap: 2px;
  height: 42px;
  margin-left: auto;
  padding: 3px;
  border-radius: 21px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

.lang-opt {
  min-width: 42px;
  margin: 0;
  padding: 0 10px;
  border: none;
  border-radius: 18px;
  background: none;
  font: 600 13px/1 var(--font);
  color: var(--ink-2);
  cursor: pointer;
}

.lang-opt[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
}

.lang-opt:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

/* Line button: opens the line chooser, and says which line is showing. */
.line-btn {
  flex: 0 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: 100%;
  height: 42px;
  margin: 0;
  padding: 0 12px 0 13px;
  border: none;
  border-radius: 21px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  font: 600 14px/1 var(--font);
  color: var(--ink);
  cursor: pointer;
  --chip-color: var(--ink);
}

.line-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

#line-btn-label {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Home page: three stripes in the line colours; a line's view: its colour. */
.line-btn-swatch {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: conic-gradient(var(--route-main) 0 120deg, var(--route-patong) 120deg 240deg, var(--route-dragon) 240deg 360deg);
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--line);
}

.line-view .line-btn-swatch {
  width: 10px;
  height: 10px;
  margin: 0 4px;
  background: #fff;
  box-shadow: none;
}

.line-view .line-btn {
  background: var(--chip-color);
  color: #fff;
}

.line-btn-caret {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.7;
}

/* Live bus count per line, in the line chooser. */
.chip-count {
  display: none;
  flex: 0 0 auto;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--chip-color) 14%, #fff);
  color: var(--chip-color);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

.chip-count:not(:empty) {
  display: inline-block;
}

.chip-count-all {
  --chip-color: var(--ink-2);
}

/* ---------- Line chooser modal ---------- */

.line-dialog {
  width: min(440px, calc(100vw - 32px));
  max-height: min(80vh, 640px);
  padding: 0 8px 10px;
  border: none;
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
  font-family: var(--font);
}

.line-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.line-dialog[open] {
  animation: dialog-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
}

/* Grabber only makes sense for the phone bottom-sheet layout. */
.ld-grabber {
  display: none;
}

.ld-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 10px 10px 12px;
}

.ld-head h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.ld-live {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
}

.is-offline .ld-live {
  color: #b91c1c;
}

.ld-close {
  position: static;
  flex: 0 0 auto;
}

.ld-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lp-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  margin: 0;
  padding: 8px 10px;
  border: none;
  border-radius: 14px;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.lp-row:hover {
  background: var(--surface-2);
}

.lp-row:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.lp-badge {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--chip-color);
  display: grid;
  place-items: center;
}

.lp-badge svg {
  width: 21px;
  height: 21px;
  fill: #fff;
}

.lp-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.lp-name {
  font-size: 15px;
  font-weight: 600;
}

.lp-sub {
  overflow: hidden;
  font-size: 12.5px;
  color: var(--ink-2);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.lp-badge-all {
  background: conic-gradient(var(--route-main) 0 120deg, var(--route-patong) 120deg 240deg, var(--route-dragon) 240deg 360deg);
}

.lp-badge-all svg {
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}

/* Tick on the view that's currently showing. */
.lp-check {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--chip-color, var(--ink));
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  visibility: hidden;
}

.lp-row[aria-current="true"] {
  background: var(--surface-2);
}

.lp-row[aria-current="true"] .lp-check {
  visibility: visible;
}

/* ---------- Connection-lost toast ---------- */

/* Announced to screen readers (role="alert") but not shown: the status pill
   at the bottom already says "Connection lost", in one place instead of two. */
#status-banner {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

#status-banner.hidden {
  display: none;
}

.is-offline .live-pill {
  background: #fef2f2;
  color: #b91c1c;
  box-shadow: var(--shadow-1), inset 0 0 0 1px rgba(220, 38, 38, 0.25);
}

.is-offline .live-pill .sep,
.is-offline #last-refreshed {
  color: #b91c1c;
}

/* ---------- Floating bottom UI: live status + locate ---------- */

#bottom-ui {
  position: fixed;
  left: calc(var(--safe-left) + var(--gutter));
  right: calc(var(--safe-right) + var(--gutter));
  bottom: calc(var(--safe-bottom) + 26px);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

#bottom-ui > * {
  pointer-events: auto;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  height: 38px;
  padding: 0 15px 0 13px;
  background: var(--surface);
  border-radius: 19px;
  box-shadow: var(--shadow-1);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}

.live-pill .sep,
#last-refreshed {
  color: var(--ink-2);
  font-weight: 500;
}

.live-dot {
  position: relative;
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-right: 2px;
  border-radius: 50%;
  background: var(--live);
}

.live-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--live);
  animation: live-pulse 2s ease-out infinite;
}

@keyframes live-pulse {
  from {
    transform: scale(1);
    opacity: 0.6;
  }
  to {
    transform: scale(3);
    opacity: 0;
  }
}

.is-offline .live-dot,
.is-offline .live-dot::after {
  background: var(--danger);
}

.is-offline .live-dot::after {
  animation: none;
}

/* Positions are no longer live - say so visually, not just in text. Muted
   but still solid (no transparency, which turned overlaps into mud) and
   still hinting at route colours. */
.is-offline .bus-pin {
  filter: saturate(0.3) brightness(1.08);
}

/* The sheet takes over the bottom of the screen while it's open. */
#bottom-ui {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.sheet-open #bottom-ui {
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
}

.sheet-open #bottom-ui > * {
  pointer-events: none;
}

.fab {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.1s ease, color 0.15s ease;
}

.fab svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.fab:active {
  transform: scale(0.94);
}

/* Only as wide as the locate button: the "All routes" pill floats above it
   without taking width from the status pill on the same flex row. */
.fab-stack {
  position: relative;
  flex: 0 0 auto;
  margin-left: auto;
}

/* Labelled secondary button - a bare corner-brackets icon is ambiguous. */
.fab-pill {
  position: absolute;
  right: 0;
  bottom: 62px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  height: 40px;
  padding: 0 14px 0 12px;
  border-radius: 20px;
  font: 600 13px/1 var(--font);
  box-shadow: var(--shadow-1);
}

.fab-pill svg {
  width: 18px;
  height: 18px;
}

.fab:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

#locate-btn.located {
  color: var(--focus);
}

#locate-btn.locating svg {
  animation: locating 1s ease-in-out infinite alternate;
}

@keyframes locating {
  to {
    opacity: 0.3;
  }
}

.user-location-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--focus);
  border: 3px solid #fff;
  box-shadow: 0 0 0 7px rgba(37, 99, 235, 0.18), 0 1px 4px rgba(0, 0, 0, 0.35);
}

/* ---------- Leaflet chrome ---------- */

/* Zoom buttons stack right above the fit/locate buttons (hidden on
   touch-size screens, where pinch-zoom is the norm and space is tight). */
.leaflet-bottom.leaflet-right .leaflet-control-zoom {
  margin: 0 calc(var(--safe-right) + var(--gutter)) 132px 0;
  border: none;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-2);
}

.leaflet-touch .leaflet-bar a,
.leaflet-bar a {
  width: 52px;
  height: 46px;
  line-height: 46px;
  font: 400 24px/46px var(--font);
  color: var(--ink);
  border-bottom-color: var(--line);
}

.leaflet-bar a:hover {
  background: var(--surface-2);
}

.leaflet-control-attribution {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.7) !important;
  border-top-left-radius: 6px;
}

.bus-icon-wrapper {
  background: transparent;
  border: none;
}

/* ---------- Vehicle markers ---------- */

/* --route-color is set per marker (see busIcon/updateMarkerRotation in
   app.js); --bus-scale on the map container shrinks markers as you zoom out
   (see busScaleForZoom). */
.bus-pin {
  position: relative;
  width: 48px;
  height: 48px;
  --route-color: #334155;
  transform: scale(var(--bus-scale, 1));
  transition: transform 0.2s ease;
}

/* Disc + arrowhead drawn pointing "up" (north); rotated around the box
   center to the bus's heading, so the arrow shows the direction of travel. */
.bus-arrow {
  position: absolute;
  top: 0;
  left: 0;
  width: 48px;
  height: 48px;
  overflow: visible;
  transform-origin: 50% 50%;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.bus-shape-outline {
  fill: #fff;
  stroke: #fff;
  stroke-width: 5;
  stroke-linejoin: round;
}

.bus-shape-fill {
  fill: var(--route-color);
}

/* Upright bus pictogram centred on the disc; never rotates. */
.bus-glyph {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 16px;
  height: 16px;
  fill: #fff;
  pointer-events: none;
}

/* On a line other than the one whose view is open (see
   filterVehiclesToLine in app.js). */
.leaflet-marker-icon.is-filtered {
  opacity: 0;
  pointer-events: none;
}

/* Halo on the bus whose details sheet is open. */
.leaflet-marker-icon.is-selected .bus-pin::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--route-color) 22%, transparent);
  border: 2px solid var(--route-color);
  animation: selected-halo 1.8s ease-in-out infinite alternate;
}

@keyframes selected-halo {
  to {
    transform: scale(1.18);
  }
}

.bus-stale .bus-shape-fill {
  fill: #8a8a8a;
}

/* ---------- Popups ---------- */

.leaflet-popup-content-wrapper {
  padding: 0;
  border-radius: 18px;
  box-shadow: var(--shadow-2);
}

.leaflet-popup-content {
  margin: 16px 18px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
}

.leaflet-popup-tip {
  box-shadow: none;
}

.leaflet-container a.leaflet-popup-close-button {
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font: 400 22px/28px var(--font);
  color: var(--ink-3);
}

.leaflet-container a.leaflet-popup-close-button:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.ico {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ico-fill {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.popup-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.popup-subtitle {
  font-size: 12.5px;
  color: var(--ink-2);
  margin-top: 1px;
}

/* Vehicle popup */

.popup-vehicle {
  min-width: 220px;
}

.pv-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding-right: 24px;
}

.pv-badge {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: var(--route-color);
  display: grid;
  place-items: center;
}

.pv-badge svg {
  width: 23px;
  height: 23px;
  fill: #fff;
}

.pv-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 6px;
}

.pv-row-strong {
  color: var(--ink);
  font-weight: 600;
}

.pv-row-strong .ico {
  color: var(--route-color);
}

.pv-foot {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-3);
}

/* Stop popup */

.popup-stop {
  width: 244px;
}

.stop-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
  padding-right: 24px;
}

.stop-route-dot {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  margin-top: 3px;
  border-radius: 50%;
  background: #fff;
  border: 3.5px solid;
}

.stop-direction {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--ink-2);
  margin: 0 0 10px;
}

.stop-schedule-freq {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 8px;
}

.stop-next {
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 6px;
}

.stop-next-time {
  font-weight: 700;
}

.stop-next-ended {
  color: var(--ink-2);
  font-weight: 500;
}

.stop-eta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #ecfdf3;
  color: #166534;
}

.stop-eta-plate {
  display: inline-block;
  font-weight: 700;
  background: rgba(22, 101, 52, 0.12);
  border-radius: 5px;
  padding: 1px 6px;
}

.stop-eta .stop-eta-note {
  flex-basis: 100%;
  font-size: 11px;
  font-weight: 500;
  opacity: 0.75;
}

.time-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.time-chip {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
}

.time-chip.next {
  background: var(--surface);
  border-width: 1.5px;
  color: var(--ink);
  font-weight: 700;
}

.stop-next-note {
  display: block;
  margin-top: 1px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
}

.time-chip-more {
  background: transparent;
  color: var(--ink-3);
}

.stop-near {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ink-2);
  border-top: 1px solid var(--line);
  padding-top: 8px;
  margin-top: 4px;
}

/* ---------- Bottom sheet (phones) ---------- */

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1100;
  max-height: 62vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 20px calc(var(--safe-bottom) + 22px);
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -4px 30px rgba(15, 23, 42, 0.18);
  font-size: 14px;
  line-height: 1.45;
  transform: translateY(105%);
  visibility: hidden;
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0.28s;
}

.sheet.open {
  transform: translateY(0);
  visibility: visible;
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sheet-grabber {
  width: 40px;
  height: 5px;
  margin: 0 auto 14px;
  border-radius: 3px;
  background: #cbd5e1;
}

.sheet-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.sheet-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

/* Popup content reused in the sheet: full width and a touch larger. */
.sheet .popup-stop {
  width: auto;
}

.sheet .popup-title {
  font-size: 17px;
}

.sheet .popup-subtitle,
.sheet .pv-row,
.sheet .stop-direction,
.sheet .stop-next,
.sheet .stop-schedule-freq,
.sheet .stop-eta {
  font-size: 13.5px;
}

.sheet .time-chip {
  font-size: 12.5px;
  padding: 4px 9px;
}

.sheet .pv-head,
.sheet .stop-header {
  padding-right: 44px;
}

/* ---------- Responsive ---------- */

/* Phones: pinch to zoom, no zoom buttons, and slimmer controls so the map
   keeps as much of the screen as possible. */
@media (max-width: 767px) {
  .leaflet-control-zoom {
    display: none;
  }

  #top-ui {
    gap: 8px;
  }

  .search-bar {
    height: 48px;
    border-radius: 24px;
  }

  .brand-mark,
  .icon-btn {
    width: 36px;
    height: 36px;
  }

  .brand-mark svg {
    width: 20px;
    height: 20px;
  }

  .search-results,
  .layers-menu {
    top: 56px;
  }

  .line-btn {
    height: 38px;
    border-radius: 19px;
    font-size: 13.5px;
  }

  .lang-switch {
    height: 38px;
    border-radius: 19px;
  }

  .lang-opt {
    min-width: 40px;
    border-radius: 16px;
  }

  .live-pill {
    height: 34px;
    padding: 0 13px 0 11px;
    font-size: 12.5px;
  }

  /* The line chooser opens as a bottom sheet, in thumb reach. */
  .line-dialog {
    width: 100%;
    max-width: none;
    max-height: 85vh;
    margin: auto 0 0;
    padding-bottom: calc(var(--safe-bottom) + 14px);
    border-radius: 22px 22px 0 0;
  }

  .line-dialog[open] {
    animation: sheet-in 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  @keyframes sheet-in {
    from {
      transform: translateY(100%);
    }
  }

  .ld-grabber {
    display: block;
    width: 40px;
    height: 5px;
    margin: 10px auto 0;
    border-radius: 3px;
    background: #cbd5e1;
  }

  .ld-head {
    padding-top: 10px;
  }
}

/* Tablets/desktop: search + line button become a left-hand column. */
@media (min-width: 768px) {
  :root {
    --gutter: 16px;
  }

  #top-ui {
    right: auto;
    width: 440px;
  }

  /* The language switch leaves the column for the top-right corner, level
     with the search bar. */
  .lang-switch {
    position: fixed;
    top: calc(var(--safe-top) + var(--gutter) + 5px);
    right: calc(var(--safe-right) + var(--gutter));
  }

  .sheet {
    display: none;
  }

  #bottom-ui {
    bottom: calc(var(--safe-bottom) + 28px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot::after,
  #locate-btn.locating svg,
  .leaflet-marker-icon.is-selected .bus-pin::before {
    animation: none;
  }
}
