:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --text: #14191d;
  --muted: #68737d;
  --panel: rgba(255, 255, 255, 0.93);
  --border: rgba(20, 25, 29, 0.10);
  --shadow: 0 10px 28px rgba(18, 26, 33, 0.14);
  --gmb: #159447;
  --kmb: #d92f38;
  --ctb: #f0c51e;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body,
#app,
#map {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

html,
body {
  overflow: hidden;
  background: #eef1f2;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", Arial, sans-serif;
}

button,
select {
  font: inherit;
}

#app {
  position: relative;
  isolation: isolate;
}

#map {
  position: absolute;
  inset: 0;
  background: #edf0f1;
}

/* Requirement: OpenFreeMap visual strength ~50%. Only the map canvas is faded,
   while station markers and controls remain fully opaque. */
#map .maplibregl-canvas {
  opacity: 0.5;
}

#map .maplibregl-control-container {
  display: none;
}

.topbar {
  position: absolute;
  z-index: 30;
  top: calc(var(--safe-top) + 12px);
  left: 12px;
  right: 12px;
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px 9px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  display: block;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,.14);
}


.brand-copy {
  min-width: 0;
}

.brand-name {
  font-size: 20px;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand-status {
  max-width: 190px;
  margin-top: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.language-select-wrap {
  min-width: 62px;
  display: grid;
  gap: 2px;
  padding: 7px 8px 6px 9px;
  border: 1px solid rgba(20, 25, 29, 0.09);
  border-radius: 14px;
  background: rgba(244, 246, 247, 0.95);
}

.language-select-wrap > span {
  color: #6b737a;
  font-size: 10px;
  line-height: 1;
}

.language-select-wrap select {
  min-width: 44px;
  appearance: none;
  -webkit-appearance: none;
  padding: 1px 18px 1px 0;
  border: 0;
  outline: 0;
  background:
    linear-gradient(45deg, transparent 50%, #20262b 50%) right 7px center / 5px 5px no-repeat,
    linear-gradient(135deg, #20262b 50%, transparent 50%) right 3px center / 5px 5px no-repeat;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
}

.range-select-wrap {
  min-width: 112px;
  display: grid;
  gap: 2px;
  padding: 7px 9px 6px 11px;
  border: 1px solid rgba(20, 25, 29, 0.09);
  border-radius: 14px;
  background: rgba(244, 246, 247, 0.95);
}

.range-select-wrap > span {
  color: #6b737a;
  font-size: 10px;
  line-height: 1;
}

.range-select-wrap select {
  min-width: 92px;
  appearance: none;
  -webkit-appearance: none;
  padding: 1px 20px 1px 0;
  border: 0;
  outline: 0;
  background:
    linear-gradient(45deg, transparent 50%, #20262b 50%) right 7px center / 5px 5px no-repeat,
    linear-gradient(135deg, #20262b 50%, transparent 50%) right 3px center / 5px 5px no-repeat;
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
}

.legend {
  position: absolute;
  z-index: 25;
  top: calc(var(--safe-top) + 90px);
  left: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 5px 18px rgba(20, 25, 29, 0.10);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #3c454c;
  font-size: 11px;
  font-weight: 650;
}

.legend > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend b { font: inherit; font-weight: inherit; }

.legend-dot,
.operator-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.legend-dot.gmb { background: var(--gmb); }
.legend-dot.kmb { background: var(--kmb); }
.legend-dot.ctb { background: var(--ctb); }

.map-actions {
  position: absolute;
  z-index: 30;
  right: 12px;
  bottom: calc(var(--safe-bottom) + 54px);
  display: grid;
  gap: 8px;
}

.map-action {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 8px 20px rgba(18,26,33,.14);
  color: #151a1e;
  font-size: 24px;
  font-weight: 500;
  cursor: pointer;
}

.map-action:active,
.copyright-pill:active {
  transform: scale(.96);
}

.gps-action {
  font-size: 0;
}

.gps-ring {
  position: relative;
  width: 18px;
  height: 18px;
  display: block;
  border: 2px solid #1c6ed7;
  border-radius: 50%;
}

.gps-ring::before,
.gps-ring::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  background: #1c6ed7;
}

.gps-ring::before { width: 6px; height: 6px; border-radius: 50%; }
.gps-ring::after { width: 26px; height: 2px; opacity: .22; }

.copyright-pill {
  position: absolute;
  z-index: 28;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 12px);
  transform: translateX(-50%);
  padding: 7px 12px;
  border: 1px solid rgba(20,25,29,.08);
  border-radius: 999px;
  background: rgba(255,255,255,.80);
  box-shadow: 0 4px 15px rgba(18,26,33,.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: rgba(20,25,29,.70);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}

.copyright-pill:active {
  transform: translateX(-50%) scale(.96);
}


.station-anchor-overlay-layer,
.station-overlay-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

/* Global layering rule: every pole / dot is painted underneath every stop sign. */
.station-anchor-overlay-layer { z-index: 7; }
.station-overlay-layer { z-index: 8; }

.transport-stop-anchor {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  overflow: visible;
  pointer-events: none;
  will-change: transform;
  transform-origin: 0 0;
}

.transport-stop-marker {
  /* 0 x 0 origin = exact projected station coordinate. app.js updates transform every map render frame. */
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  overflow: visible;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
  pointer-events: auto;
  will-change: transform;
  transform-origin: 0 0;
}

.transport-stop-sign {
  position: absolute;
  z-index: 3;
  left: 0;
  bottom: 20px;
  min-width: 43px;
  max-width: 108px;
  min-height: 27px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 7px;
  border: 2px solid #13181c;
  border-radius: 5px;
  box-shadow: 0 2px 6px rgba(0,0,0,.20);
  color: #11161a;
  font-size: 12px;
  line-height: 1.05;
  font-weight: 850;
  text-align: center;
  white-space: nowrap;
  transform: translateX(-50%);
  transform-origin: center bottom;
}

.transport-stop-marker.operator-gmb .transport-stop-sign { background: var(--gmb); color: #fff; }
.transport-stop-marker.operator-kmb .transport-stop-sign { background: var(--kmb); color: #fff; }
.transport-stop-marker.operator-ctb .transport-stop-sign { background: var(--ctb); color: #101418; }

/* KMB zoom-dependent marker detail ---------------------------------------- */
.kmb-pin-only {
  position: absolute;
  z-index: 5;
  left: 0;
  bottom: -2px;
  display: none;
  font-size: 25px;
  line-height: 1;
  transform: translateX(-50%);
  transform-origin: center bottom;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.24));
  pointer-events: auto;
}

.kmb-stop-sign {
  min-width: 54px;
  max-width: none;
  min-height: 35px;
  display: grid;
  grid-template-rows: auto auto;
  gap: 2px;
  padding: 4px 7px 3px;
  overflow: visible;
}

.kmb-stop-routes {
  font-size: 12px;
  line-height: 1.12;
  font-weight: 900;
  letter-spacing: 0;
  text-align: left;
  /* app.js inserts a newline after every four routes in full mode. */
  white-space: pre;
}

.kmb-stop-number {
  /* Extend the separator through the sign's horizontal padding so its
     length always matches the full station-sign width. */
  margin-left: -7px;
  margin-right: -7px;
  padding: 3px 7px 0;
  border-top: 1px solid rgba(255,255,255,.72);
  font-size: 8.5px;
  line-height: 1;
  font-weight: 750;
  letter-spacing: .02em;
  text-align: center;
  white-space: nowrap;
  opacity: .92;
}

.transport-stop-marker.operator-kmb.kmb-mode-pin .kmb-pin-only {
  display: block;
}

.transport-stop-marker.operator-kmb.kmb-mode-pin .kmb-stop-sign,
.transport-stop-marker.operator-kmb.kmb-mode-pin .transport-stop-post,
.transport-stop-marker.operator-kmb.kmb-mode-pin .transport-stop-point {
  display: none;
}

.transport-stop-marker.operator-kmb.kmb-mode-compact .kmb-pin-only,
.transport-stop-marker.operator-kmb.kmb-mode-full .kmb-pin-only {
  display: none;
}

.transport-stop-marker.operator-kmb.kmb-mode-compact .kmb-stop-sign,
.transport-stop-marker.operator-kmb.kmb-mode-full .kmb-stop-sign,
.transport-stop-marker.operator-kmb.kmb-mode-compact .transport-stop-post,
.transport-stop-marker.operator-kmb.kmb-mode-full .transport-stop-post,
.transport-stop-marker.operator-kmb.kmb-mode-compact .transport-stop-point,
.transport-stop-marker.operator-kmb.kmb-mode-full .transport-stop-point {
  display: grid;
}

.transport-stop-marker.operator-kmb.kmb-mode-compact .transport-stop-post,
.transport-stop-marker.operator-kmb.kmb-mode-full .transport-stop-post,
.transport-stop-marker.operator-kmb.kmb-mode-compact .transport-stop-point,
.transport-stop-marker.operator-kmb.kmb-mode-full .transport-stop-point {
  display: block;
}

.transport-stop-marker.operator-kmb.kmb-mode-compact .kmb-stop-sign {
  min-width: 58px;
}

.transport-stop-marker.operator-kmb.kmb-mode-full .kmb-stop-sign {
  min-width: 72px;
}


/* KMB same-location stacked stops ----------------------------------------- */
.kmb-stop-stack {
  position: absolute;
  z-index: 3;
  left: 0;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: max-content;
  min-width: 58px;
  transform: translateX(-50%);
  transform-origin: center bottom;
}

.kmb-stop-stack .kmb-stop-sign {
  position: relative;
  left: auto;
  bottom: auto;
  width: auto;
  transform: none;
  box-sizing: border-box;
}

.kmb-stop-stack .kmb-stop-card + .kmb-stop-card {
  margin-top: -2px;
}

.kmb-grouped-marker .kmb-stop-card {
  border-radius: 0;
}

.kmb-grouped-marker .kmb-stop-card:first-child {
  border-radius: 5px 5px 0 0;
}

.kmb-grouped-marker .kmb-stop-card:last-child {
  border-radius: 0 0 5px 5px;
}

.kmb-grouped-marker .kmb-stop-card:only-child {
  border-radius: 5px;
}

.transport-stop-marker.operator-kmb.kmb-mode-pin .kmb-stop-stack {
  display: none;
}

.transport-stop-marker.operator-kmb.kmb-mode-compact .kmb-stop-stack,
.transport-stop-marker.operator-kmb.kmb-mode-full .kmb-stop-stack {
  display: flex;
}

.transport-stop-marker.operator-kmb.kmb-mode-compact .kmb-stop-stack {
  min-width: 58px;
}

.transport-stop-marker.operator-kmb.kmb-mode-full .kmb-stop-stack {
  min-width: 72px;
}

.transport-stop-marker.operator-kmb.kmb-mode-compact .kmb-stop-stack .kmb-stop-sign,
.transport-stop-marker.operator-kmb.kmb-mode-full .kmb-stop-stack .kmb-stop-sign {
  display: grid;
}

.kmb-grouped-marker:hover .kmb-stop-sign,
.kmb-grouped-marker:focus-visible .kmb-stop-sign {
  transform: none;
}

.transport-stop-post {
  position: absolute;
  z-index: 0;
  left: -1px;
  bottom: 4px;
  width: 2px;
  height: 16px;
  margin: 0;
  background: #15191d;
  box-shadow: 0 1px 2px rgba(255,255,255,.7);
  pointer-events: none;
}

.transport-stop-point {
  position: absolute;
  z-index: 0;
  left: 0;
  top: 0;
  width: 8px;
  height: 8px;
  margin: 0;
  border: 1.5px solid #fff;
  border-radius: 50%;
  background: #12171b;
  box-shadow: 0 0 0 1px rgba(0,0,0,.24);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.transport-stop-marker:hover .transport-stop-sign,
.transport-stop-marker:focus-visible .transport-stop-sign {
  transform: translateX(-50%) translateY(-2px);
}

.user-location-marker {
  /* Keep the current GPS point above every station sign / pole / dot,
     while still below the app chrome (top bar and sheets). */
  z-index: 20 !important;
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #2474e8;
  box-shadow: 0 0 0 2px rgba(36,116,232,.22), 0 3px 9px rgba(0,0,0,.22);
  pointer-events: none;
}
/* MapLibre adds .maplibregl-marker to the custom GPS element.  Explicitly
   keep that transformed marker above both station overlay layers (z7/z8). */
.maplibregl-marker.user-location-marker {
  z-index: 20 !important;
}


.user-location-marker::after {
  content: "";
  position: absolute;
  inset: -10px;
  border: 1px solid rgba(36,116,232,.28);
  border-radius: 50%;
  animation: gpsPulse 2s ease-out infinite;
}

@keyframes gpsPulse {
  0% { transform: scale(.6); opacity: .75; }
  70%, 100% { transform: scale(1.25); opacity: 0; }
}

.toast {
  position: absolute;
  z-index: 55;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 58px);
  max-width: min(88vw, 420px);
  transform: translate(-50%, 12px);
  padding: 9px 13px;
  border-radius: 12px;
  background: rgba(20,25,29,.90);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  color: #fff;
  font-size: 12px;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.stop-sheet {
  position: absolute;
  z-index: 60;
  left: 10px;
  right: 10px;
  bottom: calc(var(--safe-bottom) + 10px);
  max-height: min(48vh, 390px);
  overflow: auto;
  padding: 10px 18px 18px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 18px 50px rgba(14,23,31,.23);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transform: translateY(calc(100% + 30px));
  opacity: 0;
  pointer-events: none;
  transition: transform .24s ease, opacity .2s ease;
}

.stop-sheet.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.sheet-handle {
  width: 38px;
  height: 4px;
  margin: 0 auto 13px;
  border-radius: 99px;
  background: #d5dade;
}

.sheet-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #f0f2f3;
  color: #4e575f;
  font-size: 20px;
  cursor: pointer;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding-right: 36px;
}

.operator-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  margin-top: 4px;
}

.sheet-operator {
  color: #66727b;
  font-size: 11px;
  font-weight: 700;
}

.sheet-title {
  margin: 2px 0 0;
  font-size: 19px;
  line-height: 1.25;
}

.sheet-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sheet-title-row .sheet-title {
  min-width: 0;
}

.sheet-navigate-btn {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #d7dcdf;
  border-radius: 10px;
  background: #f7f8f8;
  color: #1769d2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sheet-navigate-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sheet-navigate-btn:active {
  background: #eaf2fd;
}

.sheet-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 10px;
  color: #6b747c;
  font-size: 11px;
}

.sheet-route-title {
  margin-top: 15px;
  color: #5b646c;
  font-size: 11px;
  font-weight: 700;
}

.sheet-routes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.sheet-route-chip {
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #d7dcdf;
  border-radius: 10px;
  background: #f7f8f8;
  color: #192026;
  text-align: center;
}

.sheet-route-name {
  display: flex;
  min-height: 34px;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 7px 9px 6px;
  line-height: 1.15;
}
.sheet-route-code {
  font-size: 14px;
  font-weight: 900;
}
.sheet-route-destination {
  font-size: 10px;
  font-weight: 750;
  color: #5d676f;
}
.sheet-route-destination[hidden] { display: none; }

.sheet-route-eta {
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  gap: 0;
  min-height: 30px;
  padding: 0;
  border-top: 1px solid #d7dcdf;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.15;
  white-space: nowrap;
}

.sheet-route-eta.loading,
.sheet-route-eta.empty {
  align-items: center;
  justify-content: center;
  padding: 6px 7px;
  color: #7b858d;
  font-size: 10px;
  font-weight: 700;
}

.sheet-route-eta-item {
  display: flex;
  flex: 1 1 50%;
  min-width: 0;
  align-items: center;
  justify-content: center;
  padding: 6px 5px;
  text-align: center;
}

.sheet-route-eta-item + .sheet-route-eta-item {
  border-left: 1px solid #d7dcdf;
}

.sheet-route-eta-text {
  display: inline-block;
}

.sheet-route-eta-text.eta-soon {
  animation: stopSheetEtaBlink .78s steps(1, end) infinite;
}

@keyframes stopSheetEtaBlink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: .16; }
}

@media (max-width: 360px) {
  .sheet-routes { grid-template-columns: 1fr; }
}

.loading-overlay {
  position: absolute;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(239,242,243,.96);
  transition: opacity .25s ease, visibility .25s ease;
}

.loading-overlay.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  color: #1e252b;
}

.loading-card strong {
  font-size: 24px;
}

.loading-card span {
  color: #6e7880;
  font-size: 12px;
}

.loading-logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: center / cover no-repeat url("icons/brand-logo.png");
  box-shadow: 0 6px 18px rgba(0,0,0,.12);
}

@media (max-width: 440px) {
  .topbar {
    gap: 7px;
    min-height: 62px;
    border-radius: 18px;
  }

  .brand-logo {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
    border-radius: 10px;
  }

  .brand-name { font-size: 18px; }
  .brand-status { max-width: 132px; font-size: 10px; }
  .language-select-wrap { min-width: 56px; padding-left: 7px; padding-right: 6px; }
  .language-select-wrap select { min-width: 40px; font-size: 12px; }
  .range-select-wrap { min-width: 100px; }
  .range-select-wrap select { min-width: 80px; font-size: 13px; }
  .legend { top: calc(var(--safe-top) + 86px); }
}

@media (max-width: 350px) {
  .brand-status { display: none; }
  .brand-logo { display: none; }
  .language-select-wrap > span, .range-select-wrap > span { display: none; }
  .language-select-wrap, .range-select-wrap { align-content: center; padding-top: 8px; padding-bottom: 8px; }
  .legend { gap: 6px; font-size: 10px; }
}

/* Keep stacked KMB cards aligned when hovering/focusing. This rule is placed
   after the generic marker hover rule so the stack never receives translateX. */
.transport-stop-marker.kmb-grouped-marker:hover .kmb-stop-stack .kmb-stop-sign,
.transport-stop-marker.kmb-grouped-marker:focus-visible .kmb-stop-stack .kmb-stop-sign,
.transport-stop-marker.kmb-grouped-marker .kmb-stop-stack .kmb-stop-sign:hover,
.transport-stop-marker.kmb-grouped-marker .kmb-stop-stack .kmb-stop-sign:focus-visible {
  transform: none;
}

/* v1.7.0: station tap, ETA blink, route detail -------------------------- */
.transport-stop-marker,
.transport-stop-marker * {
  -webkit-tap-highlight-color: transparent;
}

/* Tapping/focusing a stop must not move the sign. */
.transport-stop-marker:hover .transport-stop-sign,
.transport-stop-marker:focus-visible .transport-stop-sign {
  transform: translateX(-50%);
}

.transport-stop-marker.kmb-grouped-marker:hover .kmb-stop-stack .kmb-stop-sign,
.transport-stop-marker.kmb-grouped-marker:focus-visible .kmb-stop-stack .kmb-stop-sign,
.transport-stop-marker.kmb-grouped-marker .kmb-stop-stack .kmb-stop-sign:hover,
.transport-stop-marker.kmb-grouped-marker .kmb-stop-stack .kmb-stop-sign:focus-visible,
.kmb-stop-sign:focus {
  transform: none;
  outline: none;
}

.kmb-route-line {
  display: block;
  white-space: nowrap;
}

.kmb-route-token {
  display: inline-block;
}

.kmb-route-token.eta-soon,
.ctb-route-token.eta-soon,
.gmb-route-token.eta-soon,
.sheet-route-chip.eta-soon {
  animation: kmbEtaBlink .78s steps(1, end) infinite;
}

@keyframes kmbEtaBlink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: .18; }
}

.sheet-route-chip:is(button) {
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sheet-route-chip:is(button):focus {
  outline: none;
}

.stop-sheet.route-detail-open {
  max-height: min(72vh, 620px);
}

.sheet-main[hidden],
.route-detail[hidden] {
  display: none !important;
}

.route-detail {
  padding-top: 2px;
}

.route-back {
  margin: 0 0 6px;
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: #34424d;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.route-detail-title {
  margin: 0;
  padding-right: 36px;
  font-size: 20px;
  line-height: 1.2;
}

.route-detail-status {
  margin-top: 4px;
  color: #6b747c;
  font-size: 11px;
}

.route-directions {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.route-direction-card {
  overflow: hidden;
  border: 1px solid #dfe4e7;
  border-radius: 14px;
  background: #fff;
}

.route-direction-heading {
  position: sticky;
  top: -10px;
  z-index: 2;
  padding: 9px 11px;
  border-bottom: 1px solid #e6e9eb;
  background: rgba(247,248,248,.97);
  color: #20282e;
  font-size: 12px;
  font-weight: 850;
}

.route-stop-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.route-stop-item {
  display: grid;
  grid-template-columns: 26px minmax(0,1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 35px;
  padding: 5px 10px;
  border-bottom: 1px solid #eef0f1;
  font-size: 12px;
}

.route-stop-item:last-child {
  border-bottom: 0;
}

.route-stop-item.current {
  background: #fff3f4;
  font-weight: 850;
}

.route-stop-seq {
  color: #8a949b;
  font-size: 10px;
  font-weight: 750;
  text-align: right;
}

.route-stop-name {
  min-width: 0;
  color: #1d252b;
  line-height: 1.25;
}

.route-current-badge {
  padding: 3px 6px;
  border-radius: 99px;
  background: #d92f38;
  color: #fff;
  font-size: 9px;
  font-weight: 850;
  white-space: nowrap;
}

/* All KMB cards live inside .kmb-stop-stack, including a single stop. Keep
   them perfectly stationary after tap/hover/focus. */
.transport-stop-marker.operator-kmb:hover .kmb-stop-stack .kmb-stop-sign,
.transport-stop-marker.operator-kmb:focus-visible .kmb-stop-stack .kmb-stop-sign,
.transport-stop-marker.operator-kmb .kmb-stop-stack .kmb-stop-sign:hover,
.transport-stop-marker.operator-kmb .kmb-stop-stack .kmb-stop-sign:focus-visible,
.transport-stop-marker.operator-kmb .kmb-stop-stack .kmb-stop-sign:active {
  transform: none;
  outline: none;
}


.top-controls {
  display: flex;
  align-items: stretch;
  gap: 7px;
  flex: 0 0 auto;
}

.top-search-btn,
.top-settings-btn {
  width: 44px;
  min-width: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(20,25,29,.09);
  border-radius: 14px;
  background: rgba(244,246,247,.95);
  color: #1d2429;
  cursor: pointer;
}
.top-search-btn svg,
.top-settings-btn svg,
.route-search-input-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
}
.top-search-btn:active,
.top-settings-btn:active { transform: scale(.96); }
.top-settings-btn svg { stroke-width: 1.8; }


.settings-panel {
  position: absolute;
  z-index: 43;
  top: calc(var(--safe-top) + 88px);
  right: 12px;
  width: min(320px, calc(100vw - 24px));
  display: none;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 14px 38px rgba(17,25,31,.2);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
}
.settings-panel.open { display: block; }
.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 9px 14px;
  border-bottom: 1px solid #e7eaec;
}
.settings-head strong { font-size: 15px; font-weight: 850; }
.settings-close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: #f1f3f4;
  color: #3a4349;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}
.settings-fields {
  display: grid;
  gap: 10px;
  padding: 12px;
}
.settings-field {
  display: grid;
  grid-template-columns: minmax(88px, 1fr) minmax(120px, 1.25fr);
  align-items: center;
  gap: 12px;
}
.settings-field > span {
  color: #59636b;
  font-size: 13px;
  font-weight: 750;
}
.settings-field select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  padding: 10px 34px 10px 12px;
  border: 1px solid #d9dee1;
  border-radius: 12px;
  outline: 0;
  background:
    linear-gradient(45deg, transparent 50%, #20262b 50%) right 16px center / 5px 5px no-repeat,
    linear-gradient(135deg, #20262b 50%, transparent 50%) right 12px center / 5px 5px no-repeat,
    #f7f8f8;
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
}

.route-search-panel {
  position: absolute;
  z-index: 42;
  top: calc(var(--safe-top) + 88px);
  right: 12px;
  width: min(640px, calc(100vw - 24px));
  max-height: min(64vh, 560px);
  display: none;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 14px 38px rgba(17,25,31,.2);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
}
.route-search-panel.open { display: block; }

.route-search-input-row {
  display: grid;
  grid-template-columns: 28px minmax(0,1fr) 36px;
  align-items: center;
  gap: 7px;
  padding: 10px 10px 8px 12px;
  border-bottom: 1px solid #e7eaec;
}
.route-search-input-icon {
  display: grid;
  place-items: center;
  color: #657079;
}
.route-search-input-row input {
  width: 100%;
  min-width: 0;
  padding: 8px 4px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #14191d;
  font: inherit;
  font-size: 16px;
  font-weight: 650;
}
.route-search-input-row input::placeholder { color: #929aa0; font-weight: 500; }
.route-search-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #f0f2f3;
  color: #505960;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}
.route-search-status {
  padding: 8px 12px;
  color: #69737b;
  font-size: 11px;
  border-bottom: 1px solid #eef0f1;
}
.route-search-table-head,
.route-search-result {
  display: grid;
  grid-template-columns: 78px 74px 90px minmax(120px,1fr);
  align-items: center;
  gap: 8px;
}
.route-search-table-head {
  padding: 8px 12px 7px;
  background: #f7f8f8;
  color: #7a838a;
  font-size: 10px;
  font-weight: 750;
}
.route-search-results {
  max-height: calc(min(64vh, 560px) - 126px);
  overflow: auto;
  overscroll-behavior: contain;
}
.route-search-result {
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-bottom: 1px solid #eceeef;
  background: #fff;
  color: #171c20;
  text-align: left;
  cursor: pointer;
}
.route-search-result:last-child { border-bottom: 0; }
.route-search-result:active { background: #f4f6f6; }
.route-search-result .op { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 750; }
.route-search-result .op::before { content: ''; width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: var(--op-color, #777); }
.route-search-result .route { font-size: 16px; font-weight: 850; }
.route-search-result .stop-no { color: #59636b; font-size: 12px; font-weight: 700; }
.route-search-result .destination { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 650; }
.route-search-empty { padding: 22px 14px 24px; color: #7a838a; text-align: center; font-size: 13px; }

@media (max-width: 520px) {
  .route-search-table-head,
  .route-search-result { grid-template-columns: 62px 56px 74px minmax(96px,1fr); gap: 5px; }
  .route-search-result { padding-left: 10px; padding-right: 10px; }
  .route-search-table-head { padding-left: 10px; padding-right: 10px; }
}

@media (max-width: 440px) {
  .top-controls { gap: 4px; }
  .language-select-wrap { min-width: 52px; }
  .range-select-wrap { min-width: 94px; }
  .top-search-btn, .top-settings-btn { width: 38px; min-width: 38px; border-radius: 12px; }
  .route-search-panel, .settings-panel { top: calc(var(--safe-top) + 84px); }
}

@media (max-width: 350px) {
  .top-search-btn, .top-settings-btn { width: 36px; min-width: 36px; }
  .route-search-table-head,
  .route-search-result { grid-template-columns: 58px 48px 64px minmax(88px,1fr); }
}


/* Citybus zoom-dependent route display ----------------------------------- */
.ctb-stop-sign {
  min-width: 58px;
  max-width: none;
  min-height: 31px;
  padding: 5px 8px;
}

.ctb-stop-routes {
  display: grid;
  gap: 1px;
  font-size: 12px;
  line-height: 1.12;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

.ctb-route-line {
  display: block;
  white-space: nowrap;
}

.ctb-route-token {
  display: inline;
}

.transport-stop-marker.operator-ctb.ctb-mode-compact .ctb-stop-sign {
  min-width: 58px;
}

.transport-stop-marker.operator-ctb.ctb-mode-full .ctb-stop-sign {
  min-width: 72px;
}


/* v1.9.7 operator visibility settings */
.settings-divider {
  height: 1px;
  margin: 2px 0 0;
  background: #e7eaec;
}
.settings-section-title {
  margin-top: 1px;
  color: #3d474e;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .02em;
}
.operator-toggle-row {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}
.operator-toggle-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #404a51;
  font-size: 13px;
  font-weight: 750;
}
.operator-toggle-name b { font: inherit; }
.switch-control {
  position: relative;
  width: 46px;
  height: 28px;
  flex: 0 0 46px;
}
.switch-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.switch-track {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: 999px;
  background: #c8ced2;
  transition: background .18s ease;
}
.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,.22);
  transition: transform .18s ease;
}
.switch-control input:checked + .switch-track {
  background: #1d7a47;
}
.switch-control input:checked + .switch-track .switch-thumb {
  transform: translateX(18px);
}
.switch-control input:focus-visible + .switch-track {
  outline: 3px solid rgba(28,110,215,.2);
  outline-offset: 2px;
}
.legend [data-operator].operator-disabled {
  opacity: .32;
  filter: grayscale(1);
}


/* v1.10.2 — map gestures always win over dense station signs.
   Station taps are resolved in app.js by post-click hit testing, so every pixel
   of every sign can still be used to drag, pinch-zoom or double-tap the map. */
.station-overlay-layer,
.transport-stop-marker,
.transport-stop-marker *,
.kmb-pin-only,
.kmb-stop-sign,
.ctb-stop-sign {
  pointer-events: none !important;
  touch-action: none;
}

/* v1.10.5: ETA urgency on map stop route numbers for all operators */
.gmb-stop-routes { white-space: nowrap; }
.gmb-route-token { display: inline-block; }
.ctb-route-token { display: inline-block; }


/* v1.10.5.1: optional map label settings */
.map-label-toggle-row .operator-toggle-name { gap: 9px; }
.map-label-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 4px;
  color: #69737a;
  font-size: 17px;
  line-height: 1;
  font-weight: 800;
}
.map-label-number-icon { font-size: 14px; }
