* { box-sizing: border-box; margin: 0; padding: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  font-family: "Segoe UI", "Inter", system-ui, sans-serif;
  background:
    radial-gradient(circle at 18% 8%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 36%),
    radial-gradient(circle at 78% 2%, color-mix(in srgb, var(--accent-soft) 18%, transparent), transparent 32%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  background-color: var(--bg);
}

header {
  background: color-mix(in srgb, var(--bg) 82%, black 18%);
  color: var(--text);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(7px);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  min-width: 0;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent-soft) 82%, white 18%));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 22px color-mix(in srgb, var(--accent) 28%, transparent);
  overflow: hidden;
  flex-shrink: 0;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-mark--logo {
  background: none;
  box-shadow: none;
  border-radius: 0;
  overflow: visible;
  width: auto;
  height: 46px;
}

.brand-mark--logo img {
  width: auto;
  height: 100%;
  max-width: 200px;
  object-fit: contain;
}

header h1 {
  font-size: var(--fs-title);
  font-weight: 640;
  letter-spacing: 0.1px;
  line-height: 1.15;
}

header .subtitle {
  font-size: var(--fs-subtitle);
  color: var(--muted);
  letter-spacing: 0.2px;
  line-height: 1.25;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.summary-chip {
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border));
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--panel-soft) 70%, black 30%),
      color-mix(in srgb, var(--panel) 82%, black 18%));
  padding: 10px 12px;
  min-width: 150px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.summary-chip .label {
  display: block;
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.summary-chip .value {
  display: block;
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.hero-panel {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 86%, black 14%), color-mix(in srgb, var(--bg) 88%, black 12%));
}

.hero-copy {
  padding: 10px 0;
}

.hero-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero-copy h2 {
  font-size: clamp(1.35rem, 2.4vw, 2.2rem);
  line-height: 1.1;
  margin-top: 8px;
}

.hero-copy p {
  margin-top: 8px;
  max-width: 56ch;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.55;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  align-content: start;
}

.metric-card {
  border-radius: 18px;
  padding: 12px;
  background: color-mix(in srgb, var(--panel-soft) 82%, black 18%);
  border: 1px solid color-mix(in srgb, var(--accent) 14%, var(--border));
}

.metric-card .metric-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.metric-card .metric-value {
  display: block;
  margin-top: 6px;
  font-size: 1.2rem;
  font-weight: 700;
}

.service-banner {
  display: none;
  margin: 12px 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(245, 166, 35, 0.35);
  background: rgba(245, 166, 35, 0.14);
  color: #ffd089;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.4;
}

.service-banner.show { display: block; }

#top-bar {
  position: sticky;
  top: 0;
  z-index: 3000;
}

#alert-banner {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 3100;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-100%);
  font-weight: 700;
  letter-spacing: 0.2px;
  padding: 10px 14px;
  border-bottom: 2px solid rgba(0,0,0,0.15);
  background: linear-gradient(90deg, #1e6fff, #1557d0);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}

#ann-recall {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 1001;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  color: #fff;
  background: #1557d0;
}

#map {
  width: 100%;
  height: clamp(300px, 55vh, 700px);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

#map-wrap {
  position: relative;
  overflow: clip;
}

#map-empty-state {
  display: none;
  position: absolute;
  inset: 14px;
  z-index: 420;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 16%, var(--border));
  background: color-mix(in srgb, var(--panel) 70%, rgba(0, 0, 0, 0.55));
  backdrop-filter: blur(2px);
  color: var(--text);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 18px;
  pointer-events: none;
}

#map-empty-state.show {
  display: flex;
}

#map-empty-state .title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
}

#map-empty-state .sub {
  color: var(--muted);
  font-size: 0.9rem;
}

#eta-section {
  padding: 10px 14px 8px;
  background: linear-gradient(180deg, rgba(7,11,21,0.92), rgba(10,16,30,0.88));
}

#eta-section h2 {
  font-size: var(--fs-section-label);
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 12px;
  font-weight: 700;
}

#bus-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 380px));
  justify-content: center;
  align-items: start;
  gap: 12px;
}

.bus-card {
  background: linear-gradient(180deg, rgba(20, 33, 56, 0.95), rgba(12, 24, 44, 0.95));
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.28);
  border: 1px solid var(--border);
  border-left: 5px solid #ccc;
  width: 100%;
  max-width: 380px;
  justify-self: stretch;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.bus-card:hover {
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
  transform: translateY(-2px);
}

.bus-card.offline { opacity: 0.74; }

.bus-card-body {
  padding: 12px 14px;
}

.bus-card-compact {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 78%, black 22%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bus-card-compact .meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

.offline-chip {
  background: rgba(245, 166, 35, 0.17);
  color: #ffd089;
  border: 1px solid rgba(245, 166, 35, 0.35);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bus-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.bus-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
}

.bus-name {
  font-weight: 650;
  color: #f4f8ff;
  font-size: var(--fs-name);
  line-height: 1.2;
}

.bus-status {
  margin-left: auto;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 10px;
}

.bus-status.online  { background: #d4edda; color: #155724; }
.bus-status.offline { background: #f8d7da; color: #721c24; }

.bus-meta {
  font-size: var(--fs-meta);
  color: var(--muted);
  margin-bottom: 7px;
  line-height: 1.35;
}

.bus-next {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0 8px;
  padding: 10px 12px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel-soft) 72%, black 28%);
  border: 1px solid color-mix(in srgb, var(--accent) 14%, var(--border));
  transition: background-color 0.15s ease;
}

.bus-next:hover {
  background: color-mix(in srgb, var(--panel-soft) 82%, black 18%);
}

.bus-next-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.bus-next-value {
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--text);
  text-align: right;
  line-height: 1.1;
}

.bus-next-value small {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}

.bus-empty-note {
  color: var(--muted);
  font-size: 0.82rem;
  padding: 10px 0 2px;
}

.eta-list { list-style: none; }

.eta-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: var(--fs-eta);
  border-top: 1px solid rgba(139, 160, 190, 0.2);
  line-height: 1.3;
  transition: opacity 0.15s ease;
}

.eta-item:hover {
  opacity: 0.85;
}

.eta-item:first-child { border-top: none; }
.eta-value { font-weight: 650; color: #e9f1ff; }
.eta-now   { color: #66e289; font-weight: 700; }
.eta-meta { display: inline-flex; align-items: center; gap: 8px; }

.eta-conf {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.25px;
  border-radius: 999px;
  padding: 2px 6px;
  font-weight: 700;
  border: 1px solid transparent;
}

.eta-conf.conf-high { background: rgba(57,211,83,0.17); color: #95f3a5; border-color: rgba(57,211,83,0.35); }
.eta-conf.conf-medium { background: rgba(245,166,35,0.17); color: #ffd089; border-color: rgba(245,166,35,0.35); }
.eta-conf.conf-low { background: rgba(231,76,60,0.16); color: #ffb4b4; border-color: rgba(231,76,60,0.35); }

#status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--panel) 82%, black 18%);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

#status-bar {
  text-align: left;
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.25px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-dot.connected {
  background: #10b981;
  animation: pulse-dot 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.status-dot.degraded {
  background: #f59e0b;
}

.status-dot.disconnected {
  background: #ef4444;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

#mobile-view-toggle {
  display: none;
  align-items: center;
  gap: 4px;
  border: 1px solid color-mix(in srgb, var(--accent) 16%, var(--border));
  border-radius: 999px;
  padding: 4px;
  background: color-mix(in srgb, var(--panel-soft) 72%, black 28%);
  position: sticky;
  top: 0;
  z-index: 10;
  margin: 10px 14px;
  width: fit-content;
}

#mobile-view-toggle button {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

#mobile-view-toggle button.active {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--text);
}

#legal-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 8px 10px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(7, 11, 21, 0.86);
  border-top: 1px solid var(--border);
}

#legal-footer a {
  color: #c9dcff;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.15px;
}

#legal-footer a:hover {
  text-decoration: underline;
}

#audio-toggle {
  border: 1px solid rgba(139,160,190,0.32);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 40%, #0b1630), color-mix(in srgb, var(--panel) 82%, black 18%));
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
}

@media (max-width: 900px) {
  #map { height: 38vh; min-height: 220px; }
  #bus-cards { grid-template-columns: 1fr; }
  .bus-card { max-width: none; }
  .hero-panel { grid-template-columns: 1fr; }
  .hero-metrics { grid-template-columns: 1fr 1fr; }
  .header-actions { width: 100%; justify-content: flex-start; min-width: 0; }
  header { align-items: flex-start; flex-direction: column; }
  .summary-chip { flex: 1 1 calc(50% - 6px); min-width: 0; }
  #audio-toggle { width: 100%; justify-content: center; }
  .hero-copy p { max-width: none; }
  #status-strip { flex-direction: column; align-items: stretch; }
  #map-empty-state {
    inset: 8px;
    border-radius: 12px;
  }
}

@media (min-width: 1000px) {
  header {
    padding: 12px 20px;
  }
  .brand-mark {
    width: 52px;
    height: 52px;
  }
  header h1 {
    font-size: 1.9rem;
  }
  header .subtitle {
    font-size: 0.95rem;
  }
  .header-actions {
    gap: 8px;
  }
  .summary-chip {
    min-width: 118px;
    padding: 8px 10px;
  }
  .summary-chip .value {
    font-size: 0.9rem;
  }
  #audio-toggle {
    padding: 9px 12px;
    font-size: 0.78rem;
  }
  .hero-panel {
    grid-template-columns: 1.35fr 0.65fr;
  }
  #bus-cards.offline-grid {
    grid-template-columns: repeat(3, minmax(280px, 1fr));
    gap: 14px;
  }
}

@media (max-width: 640px) {
  header {
    padding: 12px 14px;
    gap: 12px;
  }
  .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }
  .header-actions {
    gap: 8px;
  }
  .summary-chip {
    padding: 8px 10px;
  }
  .summary-chip .value {
    font-size: 0.92rem;
  }
  .hero-panel {
    padding: 12px 14px;
    gap: 12px;
  }
  .hero-copy h2 {
    font-size: 1.2rem;
  }
  .hero-copy p {
    display: none;
  }
  .hero-metrics {
    display: none;
  }
  .metric-card {
    padding: 11px 12px;
  }
  .metric-card .metric-value {
    font-size: 0.95rem;
  }
  #eta-section {
    padding: 10px 12px 8px;
  }
  .bus-next {
    padding: 9px 10px;
  }
  .bus-next-value {
    font-size: 1rem;
  }
  .eta-item {
    font-size: 0.82rem;
    gap: 8px;
  }
  #legal-footer {
    font-size: 0.78rem;
    padding-bottom: 18px;
  }
  #mobile-view-toggle {
    display: inline-flex;
    margin: 10px 14px;
  }
  body.mobile-view-map #eta-section,
  body.mobile-view-map #legal-footer {
    display: none;
  }
  body.mobile-view-map #map {
    height: calc(100vh - 290px);
    height: calc(100dvh - 290px);
    min-height: 280px;
  }
  body.mobile-view-arrivals #map {
    display: none;
  }
  body.mobile-view-arrivals #map-wrap {
    display: none;
  }
  body.mobile-view-arrivals #map-empty-state {
    display: none !important;
  }
  body.mobile-view-arrivals #eta-section {
    display: block;
    min-height: 58vh;
  }
}

body.a11y-high-contrast header { background: #000; color: #fff; }
body.a11y-high-contrast .bus-card { border: 2px solid #000; box-shadow: none; }
body.a11y-large-text .bus-meta { font-size: 0.88rem; }

.shimmer-bar {
  height: 16px;
  border-radius: 8px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--panel) 88%, black 12%), color-mix(in srgb, var(--panel) 78%, black 22%), color-mix(in srgb, var(--panel) 88%, black 12%));
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  margin-bottom: 8px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  background: linear-gradient(90deg, color-mix(in srgb, var(--panel) 88%, black 12%), color-mix(in srgb, var(--panel) 78%, black 22%), color-mix(in srgb, var(--panel) 88%, black 12%));
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 12px;
  border: 1px solid var(--border);
  height: 200px;
  width: 100%;
  max-width: 380px;
}