/* Tokens moved to tokens.css */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

html, body {
  height: 100%;
  height: -webkit-fill-available;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', sans-serif;
  background: transparent !important;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: var(--font-base);
  line-height: 1.4;
  letter-spacing: var(--tracking-normal);
  overscroll-behavior: none;
}

html {
  background-color: var(--bg) !important;
}

#map {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
}

.leaflet-container {
  background: var(--bg) !important;
  font-family: inherit;
}

.leaflet-control-zoom {
  display: none !important;
}

.leaflet-control-attribution {
  font-size: 11px !important;
  background: transparent !important;
  color: var(--text-tertiary) !important;
  padding: var(--space-xs) var(--space-sm) !important;
  pointer-events: none !important;
}



/* Bottom sheet — iOS native style */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1100;
  background: var(--surface-elevated);
  backdrop-filter: blur(80px) saturate(200%);
  -webkit-backdrop-filter: blur(80px) saturate(200%);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 40px 40px 0 0;
  box-shadow: var(--glass-shadow);
  transition: transform 0.5s var(--ease-spring);
  max-height: 75vh;
  display: flex;
  flex-direction: column;
}

.sheet--dragging {
  transition: none !important;
}

.sheet--collapsed {
  transform: translateY(calc(100% - 84px - env(safe-area-inset-bottom, 0px)));
}

.sheet--half {
  transform: translateY(40%);
}

.sheet--expanded {
  transform: translateY(0);
}

.sheet__handle {
  position: relative;
  width: 40px;
  height: 5px;
  border-radius: 3px;
  background: var(--text-tertiary);
  margin: var(--space-sm) auto var(--space-sm);
  flex-shrink: 0;
  cursor: pointer;
  opacity: 0.5;
  touch-action: none;
}

.sheet__handle::before {
  content: '';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 30px;
}

.sheet__content {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 20px 20px;
  overscroll-behavior-y: contain;
}

.sheet__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px 0 8px;
  color: var(--text-secondary);
  min-height: 60px;
}

.sheet__placeholder-icon {
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.sheet__placeholder p {
  font-size: var(--font-sm);
  line-height: 1.5;
}

/* Bus card in sheet — iOS native style */
.bus-card {
  margin-bottom: 16px;
  background: var(--surface);
  border-radius: 24px;
  overflow: hidden;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  transition: opacity var(--duration-fast) ease;
}

.bus-card:active {
  opacity: 0.7;
}

.bus-card__content {
  padding: 24px 20px;
  background: var(--surface);
  border-radius: 24px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

.bus-card:last-child {
  margin-bottom: 0;
}

.bus-card--nearest {
  border: none;
  box-shadow: none;
}

.bus-card--nearest .bus-card__content {
  background-color: rgba(0, 122, 255, 0.12);
  background-image: linear-gradient(180deg, rgba(0, 122, 255, 0.2) 0%, transparent 100%);
  border: 1px solid rgba(0, 122, 255, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 8px 32px rgba(0, 122, 255, 0.15);
}

.bus-card--nearest::before {
  display: none;
}

.bus-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: 8px;
}

.bus-card__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: var(--font-base);
  font-weight: 800;
  color: var(--white);
  flex-shrink: 0;
  letter-spacing: var(--tracking-tight);
}

.bus-card__route-name {
  font-size: var(--font-base);
  font-weight: 600;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: var(--tracking-normal);
}

.bus-card__eta {
  display: flex;
  align-items: center;
  font-size: var(--font-2xl);
  font-weight: 800;
  color: var(--text);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-tight);
}

.bus-card__eta-unit {
  font-size: var(--font-base);
  font-weight: 600;
  color: var(--text-secondary);
  margin-left: var(--space-xs);
}

.bus-card__chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: var(--space-sm);
  transition: transform var(--duration-normal) var(--ease-spring);
}

.bus-card--expanded .bus-card__chevron {
  transform: rotate(180deg);
}

.bus-card__details {
  display: flex;
  gap: var(--space-md);
  font-size: var(--font-sm);
  color: var(--text-secondary);
  margin-top: 4px;
}

.bus-card__detail {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bus-card__detail svg {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.bus-card__nearest-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent);
  margin-bottom: var(--space-sm);
}

/* Geolocation prompt — iOS modal */
.geo-prompt {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.geo-prompt--hidden {
  opacity: 0;
  pointer-events: none;
}

.geo-prompt__card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px 28px 24px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  opacity: 0;
  transition: transform var(--duration-normal) var(--ease-spring), opacity var(--duration-normal) ease;
}

.geo-prompt:not(.geo-prompt--hidden) .geo-prompt__card {
  transform: scale(1);
  opacity: 1;
}

.geo-prompt__icon {
  color: var(--accent);
  margin-bottom: 12px;
}

.geo-prompt__card h2 {
  font-size: var(--font-xl);
  font-weight: 800;
  margin-bottom: var(--space-sm);
  letter-spacing: -0.3px;
}

.geo-prompt__card p {
  font-size: var(--font-base);
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}

.btn {
  display: block;
  width: 100%;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--font-lg);
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity var(--duration-fast) ease, transform var(--duration-fast) var(--ease-out);
  font-family: inherit;
  letter-spacing: var(--tracking-normal);
}

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

.btn:active {
  transform: scale(0.97);
  opacity: 0.8;
}

.btn--primary {
  background: var(--accent);
  color: var(--white);
  margin-bottom: var(--space-sm);
  box-shadow: var(--shadow-sm);
}

.btn--secondary {
  background: transparent;
  color: var(--text-secondary);
}

/* Bus marker on map — iOS Maps style pill */
.bus-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--font-sm);
  font-weight: 800;
  color: var(--white);
  border: 3px solid var(--white);
  box-shadow: var(--shadow-md);
  white-space: nowrap;
  transition: transform var(--duration-normal) var(--ease-spring), box-shadow var(--duration-fast) ease;
  letter-spacing: var(--tracking-tight);
  animation: marker-enter var(--duration-normal) var(--ease-spring) forwards;
}

@keyframes marker-enter {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.bus-marker--nearest {
  transform: scale(1.2);
  border-width: 3px;
  box-shadow: var(--shadow-glow);
}

/* User location marker — iOS blue dot */
.user-marker {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue-500);
  border: 4px solid #fff;
  box-shadow: 0 0 10px rgba(0,0,0,0.4), 0 0 15px rgba(10, 132, 255, 0.5);
  position: relative;
  z-index: 2;
}

.user-marker__pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue-500);
  opacity: 0.3;
  transform: translate(-50%, -50%);
  animation: pulse 3s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
  z-index: 1;
}

@keyframes pulse {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
  100% { transform: translate(-50%, -50%) scale(4); opacity: 0; }
}

/* Stop marker */
.stop-marker {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--white);
  box-shadow: var(--shadow-sm);
}

/* Leaflet popups — iOS native style */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 0 !important;
  background: var(--surface-elevated) !important;
  backdrop-filter: blur(60px) saturate(200%);
  -webkit-backdrop-filter: blur(60px) saturate(200%);
  border: 0.5px solid var(--separator);
}

.leaflet-popup-content {
  margin: var(--space-md) !important;
  font-family: inherit !important;
  font-size: var(--font-sm) !important;
  line-height: 1.5 !important;
  color: var(--text) !important;
}

.leaflet-popup-tip {
  box-shadow: var(--shadow-sm) !important;
  background: var(--surface-elevated) !important;
}

.leaflet-popup-close-button {
  display: none !important;
}

.popup-title {
  font-weight: 800;
  font-size: var(--font-base);
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.popup-route {
  color: var(--text-secondary);
  font-size: var(--font-sm);
  margin-bottom: var(--space-sm);
}

.popup-eta {
  font-size: var(--font-sm);
  color: var(--text);
}

.popup-eta strong {
  color: var(--accent);
}



/* --- Apple Maps UI Replication --- */

/* Weather Widget (Top Left) */
.weather-widget {
  position: fixed;
  top: max(env(safe-area-inset-top, 0px) + 16px, 16px);
  left: max(env(safe-area-inset-left, 0px) + 16px, 16px);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  background: var(--surface-elevated);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-radius: 20px;
  box-shadow:
    inset 0 0 0 1px rgba(200,220,255,0.06),
    inset 1.8px 3px 0px -2px rgba(210,228,255,0.18),
    inset -2px -2px 0px -2px rgba(210,228,255,0.12),
    inset -3px -8px 1px -6px rgba(210,228,255,0.08),
    inset -0.3px -1px 4px 0px rgba(0,0,0,0.24),
    inset -1.5px 2.5px 0px -2px rgba(0,0,0,0.4),
    inset 0px 3px 4px -2px rgba(0,0,0,0.4),
    inset 2px -6.5px 1px -4px rgba(0,0,0,0.2),
    0px 1px 5px 0px rgba(0,0,0,0.2),
    0px 6px 16px 0px rgba(0,0,0,0.16);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  border: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.weather-widget[hidden] {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
}
.weather-widget__icon {
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.weather-widget__temp {
  letter-spacing: -0.3px;
}

@media (min-width: 768px) {
  .weather-widget {
    left: 420px;
    top: 20px;
  }
}

/* =========================================
   Air Raid Alert — Pill (on map)
   ========================================= */
.alert-pill {
  position: fixed;
  top: max(env(safe-area-inset-top, 0px) + 16px, 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px 8px 14px;
  background: linear-gradient(135deg, rgba(220, 30, 30, 0.92) 0%, rgba(180, 20, 20, 0.92) 100%);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-radius: 24px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
  box-shadow:
    0 4px 24px rgba(200, 30, 30, 0.45),
    0 0 0 0.5px rgba(255, 80, 80, 0.4),
    inset 0 1px 0 rgba(255,255,255,0.15);
  animation: alertSlideIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  cursor: pointer;
  white-space: nowrap;
  overflow: visible;
}
.alert-pill[hidden] {
  display: none;
}

/* Dual-ring pulse */
.alert-pill__pulse {
  position: absolute;
  inset: -3px;
  border-radius: 28px;
  border: 2px solid rgba(255, 60, 60, 0.5);
  animation: alertRingPulse 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  pointer-events: none;
  z-index: -1;
}
.alert-pill::before {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 32px;
  border: 1.5px solid rgba(255, 60, 60, 0.25);
  animation: alertRingPulse 2s cubic-bezier(0.4, 0, 0.2, 1) 0.4s infinite;
  pointer-events: none;
  z-index: -1;
}

/* Live breathing glow */
.alert-pill::after {
  content: '';
  position: absolute;
  inset: -12px;
  border-radius: 36px;
  background: radial-gradient(ellipse, rgba(255, 50, 50, 0.2) 0%, transparent 70%);
  animation: alertGlow 3s ease-in-out infinite;
  pointer-events: none;
  z-index: -2;
}

.alert-pill__icon {
  flex-shrink: 0;
  color: #ffffff;
  animation: alertBell 4s ease-in-out infinite;
}
.alert-pill__text {
  line-height: 1;
}

/* Live dot indicator */
.alert-pill__text::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffffff;
  margin-right: 6px;
  vertical-align: middle;
  animation: alertDotBlink 1.5s ease-in-out infinite;
}

@keyframes alertSlideIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-24px) scale(0.85);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}
@keyframes alertRingPulse {
  0% { opacity: 0.7; transform: scale(1); }
  70% { opacity: 0; transform: scale(1.3); }
  100% { opacity: 0; transform: scale(1.3); }
}
@keyframes alertGlow {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}
@keyframes alertBell {
  0%, 80%, 100% { transform: rotate(0deg); }
  82% { transform: rotate(-12deg); }
  84% { transform: rotate(12deg); }
  86% { transform: rotate(-8deg); }
  88% { transform: rotate(8deg); }
  90% { transform: rotate(-4deg); }
  92% { transform: rotate(0deg); }
}
@keyframes alertDotBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Alert Pill — Desktop: shift right of sidebar */
@media (min-width: 768px) {
  .alert-pill {
    left: calc(420px + ((100vw - 420px) / 2));
  }
}

/* =========================================
   Air Raid Alert — Card (inside sheet)
   ========================================= */
.alert-card {
  margin: 0 0 var(--space-md) 0;
  padding: 14px 16px;
  background: rgba(255, 59, 48, 0.12);
  border: none;
  border-radius: 24px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: alertCardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  position: relative;
  overflow: hidden;
}
/* Subtle shimmer on alert card */
.alert-card::before {
  content: '';
  position: absolute;
  top: 0; left: -100%; right: 0; bottom: 0;
  width: 200%;
  background: linear-gradient(90deg, transparent 0%, rgba(255,59,48,0.06) 50%, transparent 100%);
  animation: alertShimmer 4s ease-in-out infinite;
}
.alert-card[hidden] {
  display: none;
}
.alert-card__header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ff453a;
  margin-bottom: 6px;
  position: relative;
}
.alert-card__header strong {
  font-size: var(--font-base);
  font-weight: 700;
  color: #ff453a;
}
/* Live dot in card header */
.alert-card__header strong::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ff453a;
  margin-right: 6px;
  vertical-align: middle;
  animation: alertDotBlink 1.5s ease-in-out infinite;
}
.alert-card__header svg {
  color: #ff453a;
  flex-shrink: 0;
}
.alert-card__body {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  margin: 0 0 6px 0;
  line-height: 1.45;
  position: relative;
}
.alert-card__time {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
  position: relative;
}

@keyframes alertCardIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes alertShimmer {
  0% { transform: translateX(-50%); }
  50% { transform: translateX(0%); }
  100% { transform: translateX(-50%); }
}

/* Red vignette on map during alert */
body.air-raid-active #map::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(200, 30, 30, 0.08) 100%);
  pointer-events: none;
  z-index: 400;
  animation: alertVignetteIn 1s ease forwards;
}
@keyframes alertVignetteIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Map Controls Right — Apple Maps Grouped Stack */
.map-controls-right {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  right: 12px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Grouped button stack (buttons inside share a container) */
.map-btn-group {
  display: flex;
  flex-direction: column;
  background: var(--surface-elevated);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-radius: 14px;
  border: none;
  box-shadow:
    inset 0 0 0 1px rgba(200,220,255,0.06),
    inset 1.8px 3px 0px -2px rgba(210,228,255,0.18),
    inset -2px -2px 0px -2px rgba(210,228,255,0.12),
    inset -3px -8px 1px -6px rgba(210,228,255,0.08),
    inset -0.3px -1px 4px 0px rgba(0,0,0,0.24),
    inset -1.5px 2.5px 0px -2px rgba(0,0,0,0.4),
    inset 0px 3px 4px -2px rgba(0,0,0,0.4),
    inset 2px -6.5px 1px -4px rgba(0,0,0,0.2);
  overflow: hidden;
}

.map-btn {
  width: 44px;
  height: 44px;
  border-radius: 0;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: none;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  box-shadow: none;
  position: relative;
}
/* Separator between grouped buttons */
.map-btn-group .map-btn + .map-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 8px;
  right: 8px;
  height: 0.5px;
  background: var(--separator);
}

.map-btn:active {
  background: var(--separator);
}

/* Standalone button (not in a group) */
.map-btn--standalone {
  background: var(--surface-elevated);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-radius: 14px;
  border: none;
  box-shadow:
    inset 0 0 0 1px rgba(200,220,255,0.06),
    inset 1.8px 3px 0px -2px rgba(210,228,255,0.18),
    inset -2px -2px 0px -2px rgba(210,228,255,0.12),
    inset -3px -8px 1px -6px rgba(210,228,255,0.08),
    inset -0.3px -1px 4px 0px rgba(0,0,0,0.24),
    inset -1.5px 2.5px 0px -2px rgba(0,0,0,0.4),
    inset 0px 3px 4px -2px rgba(0,0,0,0.4),
    inset 2px -6.5px 1px -4px rgba(0,0,0,0.2);
}

/* Active/toggled state for 3D and Globe */
.map-btn--active {
  background: var(--accent) !important;
  color: #ffffff;
}
.map-btn--active span {
  color: #ffffff !important;
}
.map-btn--active svg {
  stroke: #ffffff;
}

/* Bottom Sheet Apple Maps style */
.sheet {
  background: var(--surface-elevated) !important;
  backdrop-filter: blur(35px) saturate(200%) !important;
  -webkit-backdrop-filter: blur(35px) saturate(200%) !important;
  border-radius: 20px 20px 0 0 !important;
  border: none !important;
  color: var(--text);
  overflow: hidden !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  box-shadow:
    inset 0 0 0 1px rgba(200,220,255,0.06),
    inset 1.8px 3px 0px -2px rgba(210,228,255,0.18),
    inset -2px -2px 0px -2px rgba(210,228,255,0.12),
    inset -3px -8px 1px -6px rgba(210,228,255,0.08),
    inset -0.3px -1px 4px 0px rgba(0,0,0,0.24),
    inset -1.5px 2.5px 0px -2px rgba(0,0,0,0.4),
    inset 0px 3px 4px -2px rgba(0,0,0,0.4),
    inset 2px -6.5px 1px -4px rgba(0,0,0,0.2),
    0px 1px 5px 0px rgba(0,0,0,0.2),
    0px -8px 40px rgba(0,0,0,0.15) !important;
}

/* Fallback for Android devices without backdrop-filter support */
@supports not (backdrop-filter: blur(1px)) {
  .sheet {
    background: var(--surface-elevated-solid) !important;
  }
}

/* Real HTML element that ALWAYS fills iOS home indicator area */
#safeAreaFill {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: env(safe-area-inset-bottom, 0px);
  background: var(--surface-elevated);
  backdrop-filter: blur(35px) saturate(200%);
  -webkit-backdrop-filter: blur(35px) saturate(200%);
  /* Fallback for Android devices without backdrop-filter support */
  z-index: 1200;
  pointer-events: none;
}

@supports not (backdrop-filter: blur(1px)) {
  #safeAreaFill {
    background: var(--surface-elevated-solid);
  }
}

.sheet__handle {
  width: 38px !important;
  height: 5px !important;
  border-radius: 2.5px !important;
  background: var(--text-tertiary) !important;
  margin: var(--space-md) auto !important;
  opacity: 1 !important;
}

.sheet__content {
  padding: 4px 20px 20px !important;
}

/* Search Bar inside sheet */
.search-container {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 4px 20px 16px 20px;
  flex-shrink: 0;
}

.search-input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  background: rgba(120, 120, 128, 0.16);
  border-radius: 99px;
  padding: var(--space-sm) var(--space-md);
  gap: var(--space-sm);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.05);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.search-icon {
  color: var(--text-tertiary);
}

.search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: var(--font-lg);
  font-weight: 500;
  outline: none;
  width: 100%;
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

.search-profile {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #a99ee4;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  font-weight: 700;
  font-size: var(--font-base);
  flex-shrink: 0;
}

/* Places Section */
.places-section {
  margin-bottom: 24px;
}

.places-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--font-xl);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  padding: 0 4px;
}

.places-title svg {
  color: var(--text-tertiary);
}

.places-list {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  padding: 0 var(--space-xs) var(--space-sm);
  -webkit-overflow-scrolling: touch;
}

.places-list::-webkit-scrollbar {
  display: none;
}

.place-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  opacity: 1;
  transition: transform 0.2s, background-color 0.2s, color 0.2s;
  background: rgba(120, 120, 128, 0.16);
  padding: 4px 16px 4px 4px;
  border-radius: 99px;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.place-item:active {
  transform: scale(0.95);
}

.place-item--active {
  background: var(--blue-500);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.place-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: var(--font-sm);
}

.place-name {
  font-size: var(--font-base);
  font-weight: 500;
}

.place-name {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text);
  text-align: center;
}



/* --- Formatting & Timeline Updates --- */

/* Status Arriving */
.status-arriving {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-base);
  font-weight: 700;
  color: var(--success); /* Apple Green */
  background: rgba(52, 199, 89, 0.15);
  padding: var(--space-xs) var(--space-sm);
  border-radius: 12px;
  letter-spacing: -0.2px;
  line-height: 1;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse-dot 1s infinite alternate;
}

@keyframes pulse-dot {
  0% { transform: scale(0.8); opacity: 0.5; }
  100% { transform: scale(1.4); opacity: 1; }
}

/* Bus Timeline */
.bus-timeline {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 0.5px solid var(--separator);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.bus-card .bus-timeline {
  display: none;
}

.bus-card--expanded .bus-timeline {
  display: flex;
}

.timeline-node {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  position: relative;
}

/* Vertical line connecting dots */
.timeline-node:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 64px; /* time width (48) + gap (12) + dot center (5) - line half width (1) = 64 */
  top: 16px;
  bottom: -14px;
  width: 2px;
  background: var(--separator);
  z-index: 1;
}

.timeline-node__time {
  width: 56px;
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-align: right;
  flex-shrink: 0;
  line-height: 1.3;
}

.timeline-node__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--separator);
  border: 2px solid var(--surface);
  margin-top: var(--space-xs);
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}

.timeline-node--active .timeline-node__dot {
  background: var(--accent);
  border-color: var(--surface);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.timeline-node__name {
  font-size: var(--font-base);
  font-weight: 500;
  color: var(--text);
  flex: 1;
  line-height: 1.3;
}


/* Skeleton Loading */
.skeleton-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding-top: var(--space-md);
}
.skeleton-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.skeleton-header {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}
.skeleton-badge {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--separator);
  animation: skeleton-shimmer 1.5s infinite ease-in-out;
}
.skeleton-text {
  flex: 1;
  height: 18px;
  border-radius: 4px;
  background: var(--separator);
  animation: skeleton-shimmer 1.5s infinite ease-in-out;
}
.skeleton-text.short {
  flex: 0 0 60px;
}
@keyframes skeleton-shimmer {
  0% { opacity: 0.3; }
  50% { opacity: 0.8; }
  100% { opacity: 0.3; }
}

/* Search Clear Button — Fix: effective touch target 44x44px via padding */
.search-clear-btn {
  position: absolute;
  right: var(--space-sm);
  top: 50%;
  transform: translateY(-50%);
  background: var(--separator);
  border: none;
  border-radius: var(--radius-full);
  /* Visual size stays 20x20, but padding expands tap area to 44x44 */
  width: 20px;
  height: 20px;
  padding: 12px;
  margin: -12px;
  box-sizing: content-box;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
}
.search-clear-btn[hidden] {
  display: none;
}
.search-clear-btn:active {
  transform: translateY(-50%) scale(0.9);
  background: var(--separator-opaque);
}

/* Menu Button */
.menu-btn {
  background: rgba(120, 120, 128, 0.16);
  border: none;
  border-radius: 99px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: transform var(--duration-fast) ease;
  flex-shrink: 0;
}
.menu-btn:active {
  transform: scale(0.95);
  background: rgba(120, 120, 128, 0.25);
}


/* Menu Popup */
.search-container {
  position: relative;
}
.menu-popup {
  position: fixed;
  top: max(env(safe-area-inset-top, 0px) + 60px, 70px);
  right: 16px;
  background: var(--surface-elevated);
  border-radius: var(--radius-md);
  box-shadow:
    inset 0 0 0 1px rgba(200,220,255,0.06),
    inset 1.8px 3px 0px -2px rgba(210,228,255,0.18),
    inset -2px -2px 0px -2px rgba(210,228,255,0.12),
    inset -3px -8px 1px -6px rgba(210,228,255,0.08),
    inset -0.3px -1px 4px 0px rgba(0,0,0,0.24),
    inset -1.5px 2.5px 0px -2px rgba(0,0,0,0.4),
    inset 0px 3px 4px -2px rgba(0,0,0,0.4),
    inset 2px -6.5px 1px -4px rgba(0,0,0,0.2),
    0px 1px 5px 0px rgba(0,0,0,0.2),
    0px 6px 16px 0px rgba(0,0,0,0.16);
  display: flex;
  flex-direction: column;
  padding: var(--space-xs) 0;
  min-width: 220px;
  z-index: 3000;
  backdrop-filter: blur(30px) saturate(200%);
  -webkit-backdrop-filter: blur(30px) saturate(200%);
  border: none;
  animation: scaleIn var(--duration-fast) var(--ease-out);
  transform-origin: top right;
}
.menu-popup[hidden] {
  display: none;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--text);
  font-size: var(--font-base);
  font-family: inherit;
  cursor: pointer;
  transition: background var(--duration-fast) ease;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
}
.menu-item:active {
  background: var(--separator);
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}


/* =========================================
   Desktop Sidebar View (Task 68)
   ========================================= */
@media (min-width: 768px) {
  .sheet {
    top: 20px !important;
    bottom: 20px !important;
    left: 20px !important;
    right: auto !important;
    width: 380px !important;
    max-height: calc(100vh - 40px) !important;
    border-radius: 32px !important;
    border: 1px solid var(--separator) !important;
    overflow: hidden !important;
    box-shadow: var(--shadow-lg);
    /* Disable drag transforms on desktop */
    transform: none !important;
  }
  .sheet--collapsed, .sheet--expanded {
    transform: none !important;
  }
  .sheet__handle {
    display: none;
  }
  .search-container {
    padding-top: var(--space-md);
  }
}

/* =========================================
   Toast Notification & Offline Banner (Task 55, 56)
   ========================================= */
.toast-container {
  position: fixed;
  /* Fix: account for iOS home indicator safe area */
  bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 12px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-full);
  font-size: var(--font-sm);
  font-weight: 500;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  animation: slideUpToast var(--duration-normal) var(--ease-spring);
  pointer-events: auto;
}
.toast--offline {
  background: var(--warning);
  color: var(--black);
}
@keyframes slideUpToast {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Task 21: Anticipation animation */
.bus-card {
  cursor: pointer;
}
.bus-card:active {
  opacity: 0.75;
  transition: opacity 0.1s ease;
}

/* Task 63: Wave pulsing for skeletons */
.skeleton-card:nth-child(2) .skeleton-badge,
.skeleton-card:nth-child(2) .skeleton-text {
  animation-delay: 0.15s;
}
.skeleton-card:nth-child(3) .skeleton-badge,
.skeleton-card:nth-child(3) .skeleton-text {
  animation-delay: 0.3s;
}

/* Task 28: Route Chip (Law of Common Region) */
.bus-card__route-chip {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--surface-elevated);
  padding: 4px;
  padding-right: var(--space-md);
  border-radius: var(--radius-full);
  border: 1px solid var(--separator);
}
.bus-card__header {
  gap: var(--space-sm) !important;
}

/* Task 67: Onboarding Tooltip */
.onboarding-tooltip {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--font-xs);
  font-weight: 600;
  pointer-events: none;
  animation: pulseTooltip 2s infinite ease-in-out;
  transition: opacity 0.3s ease;
  white-space: nowrap;
}
.onboarding-tooltip::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--primary);
}
@keyframes pulseTooltip {
  0%, 100% { transform: translateX(-50%) translateY(0); opacity: 0.8; }
  50% { transform: translateX(-50%) translateY(-4px); opacity: 1; }
}

/* Task 71: Recent Searches */
.recent-searches {
  position: absolute;
  top: 100%;
  left: 20px;
  right: 20px;
  background: var(--surface-elevated-solid);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-sm) 0;
  margin-top: var(--space-xs);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(20px);
  border: 1px solid var(--separator);
  animation: scaleIn var(--duration-fast) var(--ease-out);
  transform-origin: top left;
}
.recent-searches[hidden] { display: none; }
.recent-search-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--text);
  font-size: var(--font-sm);
  cursor: pointer;
  transition: background var(--duration-fast) ease;
}
.recent-search-item:active {
  background: var(--separator);
}
.recent-search-title {
  padding: 0 var(--space-md) var(--space-xs);
  font-size: var(--font-xs);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Task 56: Pull to refresh */
.ptr-indicator {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 60px;
  opacity: 0;
  transform: translateY(0);
  pointer-events: none;
  z-index: 10;
}
.ptr-refreshing svg {
  animation: spin 1s linear infinite;
}
@keyframes spin {
  100% { transform: rotate(360deg); }
}



/* Fix for cut-off green icons (Task 105 followup) */
.bus-card__header {
  flex-wrap: nowrap;
}
.bus-card__route-chip {
  flex: 1;
  min-width: 0;
}
.bus-card__eta, .status-arriving {
  flex-shrink: 0;
}

/* 3D Map Toggle */
#map {
  transition: transform 0.5s ease;
}
.map-3d {
  transform: perspective(1000px) rotateX(45deg) scale(1.2);
  transform-origin: center center;
}

/* =========================================
   Accessibility: Reduced Motion
   Respects system preference to disable animations
   ========================================= */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .user-marker__pulse {
    display: none;
  }
  .bus-marker {
    animation: none;
  }
  .skeleton-badge,
  .skeleton-text {
    animation: none;
    opacity: 0.5;
  }
}

/* iPad & Desktop Layout (responsive-design) */
@media (min-width: 768px) {
  .sheet {
    top: 24px;
    bottom: 24px;
    left: 24px;
    right: auto;
    width: 380px;
    border-radius: 24px;
    transform: none !important;
    max-height: calc(100vh - 48px);
  }
  
  .sheet__handle {
    display: none;
  }
  
  .sheet--collapsed, .sheet--expanded {
    transform: none !important;
  }
  
  /* Make controls stick to right, not bottom-center on iPad */
  .map-controls-right {
    bottom: 40px;
    right: 24px;
  }
}
