/* =========================================================================
   PULSE HK — UNIFIED STYLESHEET (BUS + MTR + FERRY + PLANNER)
   Build Version: 2026.10.18
   ========================================================================= */
:root {
  --kmb-red: #e31837;
  --mtr-green: #059669;
  --ferry-teal: #0d9488;
  --theme-color: #e31837;
  --bg-light: #121212;
  --bg-white: #1c1c1e;
  --bg-surface: #1c1c1e;
  --text-main: #ffffff;
  --text-sub: #98989d;
  --border-color: #2c2c2e;
  --accent-blue: #0a84ff;
  --accent-green: #30d158;
  --accent-orange: #ff9f0a;
  --accent-red: #ff453a;
  color-scheme: dark;
}

:root.light-mode {
  --bg-light: #f3f4f6;
  --bg-white: #ffffff;
  --bg-surface: #ffffff;
  --text-main: #0f172a;
  --text-sub: #64748b;
  --border-color: #e2e8f0;
  color-scheme: light;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  transition: font-size 0.2s ease-in-out;
  width: 100%;
  height: 100%;
}
html.text-sm { font-size: 14px; }
html.text-xs { font-size: 12px; }

.leaflet-container *, .leaflet-pane img, .leaflet-tile, .leaflet-marker-icon, .leaflet-marker-shadow {
  box-sizing: content-box !important;
}
.leaflet-container { background-color: var(--bg-light) !important; }
.leaflet-tile-container, .leaflet-tile { background-color: transparent !important; }

html, body {
  background-color: var(--bg-light) !important;
  overscroll-behavior-y: contain;
}

body {
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ==========================================
   TOP BAR & BANNERS
   ========================================== */
.app-switcher {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: stretch;
  height: calc(48px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  flex-shrink: 0;
  z-index: 2000;
}

.brand-header {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  cursor: pointer;
  user-select: none;
  min-width: 0;
}
.brand-title {
  font-size: 1.08rem;
  font-weight: 900;
  letter-spacing: -0.3px;
  color: var(--text-main);
  white-space: nowrap;
}
.brand-sub-pill {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  color: var(--text-sub);
  white-space: nowrap;
}
.brand-pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-green);
  flex-shrink: 0;
  transition: transform 0.25s, background 0.25s;
}
.brand-pulse-dot.syncing {
  background: var(--accent-blue);
  transform: scale(1.35);
}

.utility-btn {
  position: relative;
  flex: 0 0 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-left: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}
.utility-btn:active { background: var(--bg-light); transform: scale(0.92); }
.utility-sub-badge {
  font-size: 0.52rem;
  font-weight: 900;
  color: var(--accent-blue);
  line-height: 1;
  margin-top: 1px;
  letter-spacing: 0.2px;
}
#backBtn {
  border-left: none;
  border-right: 1px solid var(--border-color);
  font-size: 1.95rem;
  display: none;
  line-height: 1;
}

.alert-banner {
  background: rgba(255, 69, 58, 0.18);
  border-bottom: 1px solid rgba(255, 69, 58, 0.4);
  color: #ff6961;
  padding: 7px 14px;
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
  z-index: 1999;
  flex-shrink: 0;
}
.offline-banner {
  background: rgba(255, 159, 10, 0.18);
  border-bottom: 1px solid rgba(255, 159, 10, 0.4);
  color: var(--accent-orange);
  padding: 6px 14px;
  font-size: 0.75rem;
  font-weight: 800;
  text-align: center;
  z-index: 1998;
  flex-shrink: 0;
}

/* ==========================================
   FERRY TIME PLANNER BAR
   ========================================== */
.time-travel-bar {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-shrink: 0;
  z-index: 1990;
  flex-wrap: wrap;
}
.time-travel-bar.manual-active {
  background: rgba(255, 159, 10, 0.12);
  border-bottom-color: rgba(255, 159, 10, 0.4);
}
.time-controls-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}
.time-pill-badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(48, 209, 88, 0.16);
  color: var(--accent-green);
  border: 1px solid rgba(48, 209, 88, 0.35);
  cursor: pointer;
}
.time-pill-badge.manual {
  background: rgba(255, 159, 10, 0.2);
  color: var(--accent-orange);
  border-color: rgba(255, 159, 10, 0.5);
}
.time-mode-select, .time-input-ctrl, .day-select-ctrl {
  background: var(--bg-light);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 4px 7px;
  font-size: 0.76rem;
  font-weight: 800;
  outline: none;
}
.time-action-btn {
  background: rgba(255, 159, 10, 0.18);
  color: var(--accent-orange);
  border: 1px solid rgba(255, 159, 10, 0.45);
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 0.74rem;
  font-weight: 800;
  cursor: pointer;
}

/* ==========================================
   VIEWS & 5-TAB BOTTOM BAR
   ========================================== */
.view-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  display: none;
  flex-direction: column;
  background: var(--bg-light);
  min-height: 0;
}
.view-container.active { display: flex; }

.bottom-tabs {
  background-color: var(--bg-white);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: calc(62px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  flex-shrink: 0;
  z-index: 1001;
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-sub);
  flex: 1;
  height: 100%;
  cursor: pointer;
  font-size: 0.7rem;
  gap: 2px;
  touch-action: manipulation;
}
.tab.active { color: var(--kmb-red); font-weight: 800; }
.tab-icon { font-size: 1.3rem; }

/* ==========================================
   MAIN HEADER, QUICK FILTERS & SEARCH
   ========================================== */
.location-header {
  background: var(--bg-white);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 6px;
  flex-shrink: 0;
}
.location-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.location-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
  cursor: pointer;
}
.location-text {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.location-dist-pill {
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--kmb-red);
  background: rgba(227, 24, 55, 0.12);
  padding: 2px 7px;
  border-radius: 10px;
  flex-shrink: 0;
}
.stop-dir-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-left: 22px;
}
.stop-dir-subtitle {
  font-size: 0.77rem;
  color: var(--accent-blue);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.opp-pole-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 14px;
  font-size: 0.84rem;
  font-weight: 900;
  cursor: pointer;
  border: 2px solid var(--accent-blue);
  background: rgba(10, 132, 255, 0.12);
  color: var(--accent-blue);
  flex-shrink: 0;
}
.opp-pole-btn:active { transform: scale(0.94); }

.quick-filter-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-top: 2px;
}
.quick-filter-row::-webkit-scrollbar { display: none; }
.feed-chip {
  flex: 0 0 auto;
  padding: 5px 11px;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  background: var(--bg-light);
  color: var(--text-sub);
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.feed-chip.active {
  background: var(--kmb-red);
  color: #ffffff;
  border-color: var(--kmb-red);
}

.section-bar {
  padding: 9px 14px;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  gap: 8px;
}
.section-bar.collapsible { cursor: pointer; }
.section-bar.collapsible:active { background: var(--bg-light); }

.pier-pin-btn {
  background: rgba(13, 148, 136, 0.15);
  color: #14b8a6;
  border: 1px solid rgba(13, 148, 136, 0.45);
  border-radius: 10px;
  padding: 3px 8px;
  font-size: 0.68rem;
  font-weight: 800;
  cursor: pointer;
}
.pier-pin-btn.pinned {
  background: #0d9488;
  color: #ffffff;
}

/* ==========================================
   UNIFIED ROUTE LIST CARDS & BADGES
   ========================================== */
.route-list-item {
  display: flex;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  align-items: center;
  gap: 11px;
  cursor: pointer;
  background: var(--bg-light);
  transition: background 0.15s;
  touch-action: manipulation;
}
.route-list-item.inactive-route { opacity: 0.78; }
.route-list-item:active { background: var(--bg-white); }

.route-no-col {
  min-width: 64px;
  max-width: 82px;
  flex-shrink: 0;
  font-size: 1.45rem;
  font-weight: 900;
  text-align: left;
  color: var(--text-main);
  letter-spacing: -0.5px;
  line-height: 1.1;
}
.route-no-badge {
  min-width: 62px;
  max-width: 82px;
  padding: 6px 6px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 900;
  text-align: center;
  color: #ffffff;
  flex-shrink: 0;
  line-height: 1.15;
}

.route-info-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.route-dest {
  font-size: 1.02rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}
.route-sub {
  font-size: 0.77rem;
  color: var(--text-sub);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.route-eta-col {
  text-align: right;
  min-width: 68px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
}
.eta-time {
  font-size: 1.65rem;
  font-weight: 900;
  color: var(--accent-blue);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.eta-next-sub {
  font-size: 0.7rem;
  color: var(--text-sub);
  font-weight: 700;
  margin-top: 3px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* TELEMETRY, OCCUPANCY & STATUS PILLS */
.dir-pole-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  background: rgba(10, 132, 255, 0.14);
  color: var(--accent-blue);
  border: 1px solid rgba(10, 132, 255, 0.35);
  border-radius: 5px;
  font-size: 0.7rem;
  font-weight: 800;
}
.next-stop-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  background: var(--bg-white);
  color: var(--text-sub);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
}
.special-tag, .late-bus-pill, .telemetry-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 800;
  background: rgba(255, 159, 10, 0.16);
  color: var(--accent-orange);
  border: 1px solid rgba(255, 159, 10, 0.4);
}
.event-tag, .car-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  background: rgba(10, 132, 255, 0.15);
  color: var(--accent-blue);
  border: 1px solid rgba(10, 132, 255, 0.3);
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 800;
}
.trust-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.67rem;
  font-weight: 800;
}
.trust-live { background: rgba(48, 209, 88, 0.14); color: var(--accent-green); border: 1px solid rgba(48, 209, 88, 0.35); }
.trust-sched { background: rgba(152, 152, 157, 0.15); color: var(--text-sub); border: 1px solid rgba(152, 152, 157, 0.3); }

.occ-pill, .load-pill {
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.67rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.occ-seating, .load-low { background: rgba(48, 209, 88, 0.16); color: var(--accent-green); }
.occ-standing, .load-med { background: rgba(255, 159, 10, 0.16); color: var(--accent-orange); }
.occ-crowded, .occ-full, .load-high { background: rgba(255, 69, 58, 0.18); color: #ff453a; }
.occ-fast { background: rgba(10, 132, 255, 0.16); color: var(--accent-blue); }
.occ-neutral { background: rgba(152, 152, 157, 0.16); color: var(--text-sub); }

.interchange-mini-pill {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.64rem;
  font-weight: 800;
  color: #ffffff;
  margin-left: 3px;
}
.bunch-tip {
  display: inline-block;
  margin-top: 3px;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 0.68rem;
  font-weight: 800;
  background: rgba(10, 132, 255, 0.14);
  color: var(--accent-blue);
}

/* MTR CAR LOAD BARS */
.car-load-strip {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-color);
}
.car-load-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-sub);
  font-weight: 700;
  margin-bottom: 4px;
}
.car-load-bars {
  display: flex;
  gap: 3px;
}
.car-load-cell {
  flex: 1;
  text-align: center;
  padding: 3px 0;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 900;
}

/* ==========================================
   DETAIL VIEW & TIMELINE
   ========================================== */
.kmb-detail-header {
  background: var(--kmb-red);
  color: #ffffff;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  z-index: 20;
  gap: 8px;
}
.kmb-detail-title {
  font-size: 1.0rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.kmb-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.kmb-reverse-btn {
  background: rgba(255,255,255,0.2);
  border: 1.5px solid rgba(255,255,255,0.75);
  color: #ffffff;
  border-radius: 18px;
  padding: 5px 10px;
  font-size: 0.76rem;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.detail-live-bar {
  background: var(--bg-white);
  padding: 7px 14px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-sub);
  font-weight: 700;
  flex-shrink: 0;
}
.live-dot-pulse { color: var(--accent-green); font-weight: 800; }

#map-container {
  height: 32vh;
  width: 100%;
  background: var(--bg-light);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-color);
}
#stop-list-container {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-light);
  padding-bottom: 80px;
}

.stop-item {
  position: relative;
  padding: 14px 14px 14px 44px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  background: var(--bg-light);
}
.stop-item.active-stop { background: var(--bg-white); }
.stop-line {
  position: absolute;
  left: 22px;
  top: 0;
  bottom: 0;
  width: 3px;
  background-color: var(--kmb-red);
  z-index: 1;
}
.stop-item:first-child .stop-line { top: 22px; }
.stop-item:last-child .stop-line { bottom: auto; height: 22px; }
.stop-dot {
  position: absolute;
  left: 15px;
  top: 19px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #98989d;
  border: 3px solid var(--bg-light);
  z-index: 2;
}
.stop-item.active-stop .stop-dot {
  background: var(--kmb-red);
  border-color: #ffffff;
  transform: scale(1.12);
}
.stop-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.stop-name { font-size: 1.0rem; font-weight: 700; color: var(--text-main); }
.stop-meta-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.stop-dist-badge { font-size: 0.74rem; font-weight: 800; color: var(--kmb-red); }
.nearest-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.66rem;
  font-weight: 800;
  background: rgba(10,132,255,0.18);
  color: var(--accent-blue);
}

.stop-bm-btn {
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  color: var(--text-sub);
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.05rem;
  flex-shrink: 0;
}
.stop-bm-btn.saved {
  background: rgba(255, 159, 10, 0.16);
  border-color: rgba(255, 159, 10, 0.5);
  color: var(--accent-orange);
}

.eta-expanded-container {
  display: none;
  flex-direction: column;
  background: var(--bg-white);
  margin-top: 10px;
  border-top: 1px solid var(--border-color);
  padding-top: 8px;
}
.eta-expanded-container.active { display: flex; }

.kmb-eta-line, .eta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-color);
  gap: 8px;
}
.kmb-eta-line:last-child, .eta-row:last-child { border-bottom: none; }
.kmb-eta-left { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.kmb-eta-mins { font-size: 1.35rem; font-weight: 900; color: var(--accent-blue); font-variant-numeric: tabular-nums; }
.kmb-eta-remark { font-size: 0.8rem; color: var(--text-sub); font-weight: 600; }

.eta-dep-clock { font-size: 1.15rem; font-weight: 900; min-width: 52px; font-variant-numeric: tabular-nums; }
.eta-via-chain { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.via-stop-chip {
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 0.74rem;
  font-weight: 800;
}
.eta-row-time { font-size: 1.3rem; font-weight: 900; font-variant-numeric: tabular-nums; }

.more-actions-bar { display: flex; gap: 8px; padding: 8px 0 4px 0; flex-wrap: wrap; }
.more-pill-btn {
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
}
.more-pill-btn.active { border-color: var(--ferry-teal); color: #14b8a6; }

.schedule-12h-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 6px;
  max-height: 210px;
  overflow-y: auto;
  padding-top: 8px;
}
.sailing-chip {
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 5px 7px;
}
.sailing-chip.fast-chip { border-left: 3px solid var(--accent-blue); }
.sailing-chip.ord-chip { border-left: 3px solid var(--accent-orange); }
.sailing-chip-time { font-size: 0.86rem; font-weight: 900; display: flex; justify-content: space-between; }
.sailing-chip-sub { font-size: 0.66rem; color: var(--text-sub); font-weight: 700; }

/* ==========================================
   BROWSE, BOOKMARKS & PLANNER TAB (REQ 1)
   ========================================== */
.search-box-container, .planner-header {
  padding: 10px 14px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.search-input, .planner-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: 11px;
  font-size: 0.96rem;
  outline: none;
  background: var(--bg-light);
  color: var(--text-main);
  font-weight: 700;
}
.search-input:focus, .planner-select:focus { border-color: var(--kmb-red); }
.region-filters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.region-filters::-webkit-scrollbar { display: none; }
.region-btn {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 9px;
  border: 1px solid var(--border-color);
  background: var(--bg-light);
  color: var(--text-sub);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}
.region-btn.active { background: var(--kmb-red); color: #fff; border-color: var(--kmb-red); }

.planner-row { display: flex; align-items: center; gap: 8px; }
.planner-label { font-size: 0.78rem; font-weight: 900; color: var(--text-sub); min-width: 38px; text-transform: uppercase; }
.planner-walk-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  background: rgba(48, 209, 88, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(48, 209, 88, 0.35);
}

.del-fav-btn {
  background: rgba(227, 24, 55, 0.14);
  border: 1px solid rgba(227, 24, 55, 0.32);
  color: var(--kmb-red);
  border-radius: 9px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ==========================================
   MAP VIEW & LAYER SWITCHER FIX
   ========================================== */
#global-map-container { flex: 1; width: 100%; background: var(--bg-light); z-index: 1; }
.map-filter-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1002;
  display: flex;
  gap: 6px;
  max-width: calc(100% - 70px);
}
.map-layer-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: 18px;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
  background: var(--bg-white);
  color: var(--text-sub);
  border: 1.5px solid var(--border-color);
  box-shadow: 0 2px 8px rgba(0,0,0,0.45);
}
.map-layer-pill.active-bus { background: var(--kmb-red); color: #fff; border-color: #fff; }
.map-layer-pill.active-mtr { background: var(--mtr-green); color: #fff; border-color: #fff; }
.map-layer-pill.active-ferry { background: var(--ferry-teal); color: #fff; border-color: #fff; }

.map-bottom-sheet {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-white);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  max-height: 64vh;
  overflow-y: auto;
  z-index: 1005;
  transform: translateY(100%);
  transition: transform 0.26s cubic-bezier(0.1, 0.8, 0.2, 1);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
}
.map-bottom-sheet.active { transform: translateY(0); }
.sheet-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: sticky;
  top: 0;
  background: var(--bg-white);
  z-index: 2;
}
.sheet-title { font-size: 1.1rem; font-weight: 800; }
.sheet-close {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
}

/* FIX TOP-RIGHT MAP LAYER BUTTON (NO EMPTY BLACK SQUARE) */
.leaflet-control-zoom a {
  background-color: var(--bg-surface) !important;
  color: var(--text-main) !important;
  border-bottom: 1px solid var(--border-color) !important;
}
.leaflet-control-layers {
  background-color: var(--bg-surface) !important;
  color: var(--text-main) !important;
  border: 1.5px solid var(--border-color) !important;
  border-radius: 8px !important;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5) !important;
}
.leaflet-control-layers-toggle {
  width: 36px !important;
  height: 36px !important;
  background-image: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-decoration: none !important;
}
.leaflet-control-layers-toggle::after {
  content: "🗺️";
  font-size: 1.15rem;
}
.leaflet-control-layers-expanded { padding: 8px 12px !important; font-weight: 700 !important; }

.leaflet-gps-lock-btn {
  background-color: var(--bg-white) !important;
  width: 34px !important;
  height: 34px !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin-bottom: 10px !important;
  border-radius: 6px !important;
  box-shadow: 0 1px 5px rgba(0,0,0,0.65) !important;
  border: 1.5px solid var(--border-color) !important;
}
.leaflet-gps-lock-btn.locked {
  border-color: var(--accent-blue) !important;
  box-shadow: 0 0 10px rgba(10, 132, 255, 0.65) !important;
}

.kmb-map-stop-label {
  background: #ffffff !important;
  color: #111111 !important;
  border: 1.5px solid #222222 !important;
  border-radius: 6px !important;
  padding: 2px 8px !important;
  font-weight: 800 !important;
  font-size: 0.78rem !important;
  white-space: nowrap !important;
}

html:not(.light-mode) .dark-tiles {
  filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}
.custom-user-icon div {
  width: 100% !important;
  height: 100% !important;
  background: #0a84ff !important;
  border-radius: 50% !important;
  border: 3px solid #ffffff !important;
  box-shadow: 0 0 12px rgba(0,0,0,0.85) !important;
}

.text-center { text-align: center; padding: 36px 20px; color: var(--text-sub); font-size: 0.96rem; }
.toast-msg {
  position: fixed;
  bottom: 78px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(28, 28, 30, 0.95);
  color: #ffffff;
  border: 1px solid var(--border-color);
  padding: 9px 16px;
  border-radius: 18px;
  font-size: 0.84rem;
  font-weight: 800;
  z-index: 4000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
}
.toast-msg.show { opacity: 1; transform: translateX(-50%) translateY(0); }
