:root {
  --bg: #0f1419;
  --surface: #1a2028;
  --surface-2: #232b35;
  --border: #2e3742;
  --text: #e6ebf0;
  --text-dim: #9aa5b1;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --live: #22c55e;
  --est: #eab308;
  --none: #9ca3af;
  --error: #ef4444;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  --radius: 8px;
  --sidebar-w: 360px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
    "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-size: 28px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.tagline {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}

.legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.badge.state-live { color: var(--live); border-color: rgba(34, 197, 94, 0.4); }
.badge.state-est  { color: var(--est);  border-color: rgba(234, 179, 8, 0.4); }
.badge.state-none { color: var(--none); border-color: rgba(156, 163, 175, 0.35); }

/* ---------- Main layout ---------- */
main {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 0;
}

#sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#map-area {
  position: relative;
  height: 100%;
  width: 100%;
}

#map {
  height: 100%;
  width: 100%;
  background: #0a0e13;
}

#directions-iframe {
  height: 100%;
  width: 100%;
  border: none;
}

/* ---------- Google Maps-style floating search bar ---------- */
.map-search {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 5;
  display: flex;
  align-items: center;
  width: 360px;
  max-width: calc(100% - 32px);
  height: 44px;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
  padding: 0 8px;
  transition: box-shadow 0.15s;
}

.map-search:focus-within {
  box-shadow: 0 2px 10px rgba(32, 33, 36, 0.38);
}

.map-search-icon {
  width: 20px;
  height: 20px;
  color: #5f6368;
  margin: 0 10px;
  flex-shrink: 0;
}

#map-search-input {
  flex: 1;
  height: 100%;
  border: none;
  background: transparent;
  font-size: 15px;
  color: #202124;
  outline: none;
  padding: 0;
  font-family: inherit;
}

#map-search-input::placeholder {
  color: #5f6368;
  opacity: 1;
}

.map-search-clear {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #5f6368;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.map-search-clear:hover {
  background: rgba(60, 64, 67, 0.08);
}

.map-search-clear[hidden] { display: none; }

/* Hide search bar when in directions mode */
.directions-mode-active .map-search {
  display: none;
}

/* Place Autocomplete dropdown — match Google Maps style.
   The .pac-container element is rendered by the legacy Places Autocomplete
   widget at <body> level, so we style it globally. */
.pac-container {
  margin-top: 4px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(32, 33, 36, 0.28);
  border: none;
  font-family: inherit;
}
.pac-item {
  padding: 10px 14px;
  font-size: 14px;
  border-top: 1px solid #ebebeb;
  cursor: pointer;
}
.pac-item:first-child { border-top: none; }
.pac-item:hover { background: #f5f5f5; }
.pac-item-query { font-size: 14px; }

/* ---------- Place info card (slides in from sidebar edge when a place is selected) ---------- */
#place-card {
  position: absolute;
  top: 76px;
  left: 16px;
  z-index: 4;
  width: 408px;
  max-width: calc(100% - 32px);
  max-height: calc(100% - 92px);
  overflow-y: auto;
  background: #ffffff;
  color: #202124;
  border-radius: 8px;
  box-shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
  font-size: 13px;
  scrollbar-width: thin;
  animation: place-card-slide 0.22s ease-out;
}

@keyframes place-card-slide {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
#place-card::-webkit-scrollbar { width: 8px; }
#place-card::-webkit-scrollbar-thumb { background: #dadce0; border-radius: 4px; }

#place-card[hidden] { display: none; }

.place-hero {
  position: relative;
  width: 100%;
  height: 180px;
  background: #f1f3f4;
  overflow: hidden;
}

.place-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.place-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  z-index: 2;
}

.place-body {
  padding: 16px 20px;
}

.place-name {
  font-size: 22px;
  font-weight: 400;
  color: #202124;
  margin: 0 0 6px;
  line-height: 1.25;
}

.place-rating {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #5f6368;
  margin-bottom: 8px;
}

.place-rating .stars { color: #fbbc04; font-weight: 500; }
.place-rating .count { color: #1a73e8; }

.place-meta {
  font-size: 13px;
  color: #5f6368;
  margin-bottom: 12px;
}

.place-actions {
  display: flex;
  gap: 8px;
  margin: 12px 0 16px;
}

.place-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid #dadce0;
  border-radius: 18px;
  color: #1a73e8;
  font-size: 12px;
  cursor: pointer;
  flex: 1;
}

.place-action:hover { background: #f1f3f4; }
.place-action-icon { font-size: 18px; line-height: 1; }

.place-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid #ebebeb;
  font-size: 14px;
  color: #202124;
}

.place-row.clickable { cursor: pointer; }
.place-row.clickable:hover { background: #f8f9fa; margin: 0 -8px; padding: 10px 8px; }

.place-row-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 24px;
  color: #5f6368;
}

.place-row-content { flex: 1; min-width: 0; }
.place-row a { color: #1a73e8; text-decoration: none; word-break: break-all; }
.place-row a:hover { text-decoration: underline; }

.place-row-toggle {
  flex-shrink: 0;
  color: #5f6368;
  font-size: 14px;
  transition: transform 0.2s;
}
.place-row.expanded .place-row-toggle { transform: rotate(180deg); }

/* ---------- Opening hours accordion ---------- */
.hours-today {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.hours-open-tag { font-weight: 500; }
.hours-open-tag.open { color: #188038; }
.hours-open-tag.closed { color: #c5221f; }
.hours-week {
  display: none;
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  font-size: 13px;
  color: #5f6368;
}
.place-row.expanded .hours-week { display: block; }
.hours-week li {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}
.hours-week li.today {
  color: #202124;
  font-weight: 500;
}

/* ---------- Photo gallery (thumbnails strip) ---------- */
.place-photos {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 12px;
}

.place-photos img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  cursor: pointer;
  border-radius: 4px;
  transition: opacity 0.15s;
}

.place-photos img:hover { opacity: 0.85; }

/* ---------- Lightbox / photo viewer ---------- */
.photo-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.photo-lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.photo-lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
}
.photo-lightbox-close:hover { background: rgba(255, 255, 255, 0.25); }

.photo-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-lightbox-nav:hover { background: rgba(255, 255, 255, 0.25); }
.photo-lightbox-prev { left: 16px; }
.photo-lightbox-next { right: 16px; }

/* ---------- Reviews section ---------- */
.place-reviews {
  border-top: 8px solid #f1f3f4;
  margin: 16px -20px 0;
  padding: 16px 20px 8px;
}

.place-reviews-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.place-reviews-heading h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  color: #202124;
}

.place-reviews-heading .total {
  font-size: 13px;
  color: #5f6368;
}

.review {
  padding: 12px 0;
  border-top: 1px solid #ebebeb;
}
.review:first-child { border-top: none; padding-top: 4px; }

.review-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.review-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #dadce0;
  object-fit: cover;
  flex-shrink: 0;
}

.review-author {
  font-size: 13px;
  font-weight: 500;
  color: #202124;
  margin: 0;
}

.review-meta {
  font-size: 12px;
  color: #5f6368;
  display: flex;
  align-items: center;
  gap: 6px;
}

.review-stars {
  color: #fbbc04;
  font-size: 13px;
  letter-spacing: 1px;
}

.review-text {
  font-size: 13px;
  color: #3c4043;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

.review-text.expanded {
  display: block;
  -webkit-line-clamp: unset;
}

.review-expand {
  color: #1a73e8;
  font-size: 12px;
  background: none;
  border: none;
  padding: 4px 0;
  cursor: pointer;
  margin-top: 2px;
}
.review-expand:hover { text-decoration: underline; }

/* ---------- Layers control (bottom-left floating) ---------- */
.layers-control {
  position: absolute;
  bottom: 24px;
  left: 16px;
  z-index: 4;
}

.directions-mode-active .layers-control { display: none; }

.layers-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #ffffff;
  border: none;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  font-size: 13px;
  color: #202124;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
}

.layers-btn:hover { background: #f8f9fa; }

.layers-btn svg {
  width: 18px;
  height: 18px;
  color: #5f6368;
}

.layers-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.24);
  padding: 16px;
  min-width: 268px;
}

.layers-panel[hidden] { display: none; }

.layers-section + .layers-section { margin-top: 16px; border-top: 1px solid #ebebeb; padding-top: 16px; }

.layers-section-title {
  font-size: 12px;
  color: #5f6368;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  font-weight: 500;
}

.layers-types {
  display: flex;
  gap: 8px;
}

.layer-type-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  padding: 6px 4px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  color: #202124;
}

.layer-type-card:hover { background: #f1f3f4; }
.layer-type-card.active .layer-type-thumb { border-color: #1a73e8; box-shadow: 0 0 0 2px #1a73e8; }
.layer-type-card.active { color: #1a73e8; font-weight: 500; }

.layer-type-thumb {
  width: 64px;
  height: 48px;
  border-radius: 4px;
  border: 2px solid transparent;
  background-size: cover;
  background-position: center;
}

.thumb-roadmap {
  background-image: linear-gradient(135deg, #e8eef5 0%, #d4dfeb 100%);
  background-image: linear-gradient(135deg, #e8eef5 0%, #d4dfeb 50%, #f5e8e0 100%),
    repeating-linear-gradient(0deg, transparent 0 8px, rgba(180, 180, 180, 0.3) 8px 9px),
    repeating-linear-gradient(90deg, transparent 0 8px, rgba(180, 180, 180, 0.3) 8px 9px);
}

.thumb-satellite {
  background-image:
    radial-gradient(circle at 30% 40%, rgba(60, 100, 60, 0.7), transparent 40%),
    radial-gradient(circle at 70% 60%, rgba(80, 60, 40, 0.7), transparent 35%),
    linear-gradient(135deg, #1a3a5c, #2d4f7a);
}

.thumb-terrain {
  background-image:
    radial-gradient(ellipse at 30% 60%, #c4a47a 0%, transparent 50%),
    radial-gradient(ellipse at 70% 40%, #8a9d6b 0%, transparent 50%),
    linear-gradient(135deg, #d8d4c2 0%, #b8b09a 100%);
}

.layer-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  font-size: 14px;
  color: #202124;
  cursor: pointer;
}

.layer-toggle:hover { background: #f8f9fa; border-radius: 4px; }

.layer-toggle input[type="checkbox"] {
  margin: 0;
  width: 16px;
  height: 16px;
  accent-color: #1a73e8;
}

.layer-toggle-icon { font-size: 16px; }

/* ---------- Street View overlay ---------- */
.streetview-container {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: #000;
}
.streetview-container[hidden] { display: none; }

#streetview-panorama {
  width: 100%;
  height: 100%;
}

.streetview-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  z-index: 11;
}

.streetview-close:hover { background: #ffffff; }

/* ---------- Mode tabs ---------- */
.mode-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 3px;
  border-radius: var(--radius);
}

.mode-tab {
  flex: 1;
  padding: 8px 4px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  border-radius: 5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.mode-tab.active {
  background: var(--accent);
  color: white;
}

.mode-tab:hover:not(.active) {
  color: var(--text);
}

.mode-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mode-panel[hidden] {
  display: none;
}

/* ---------- Directions integration panel ---------- */
.dir-bus-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.dir-bus {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.dir-bus-num {
  display: inline-block;
  min-width: 36px;
  padding: 2px 8px;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  margin-right: 6px;
  font-variant-numeric: tabular-nums;
}

.dir-bus-stop {
  font-size: 13px;
  color: var(--text);
  margin-top: 4px;
}

.dir-bus-eta {
  font-size: 12px;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.dir-bus-eta.state-live { color: var(--live); }
.dir-bus-eta.state-est  { color: var(--est); }
.dir-bus-eta.state-none { color: var(--none); }

.dir-bus-note {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ---------- Travel mode tabs ---------- */
/* G2: bottom-sheet style mode tabs */
.travel-mode-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: var(--surface-2);
  padding: 8px;
  border-radius: 12px;
  margin: 12px 0;
}

.travel-mode-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px 8px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.travel-mode-tab .tmt-icon {
  font-size: 20px;
  line-height: 1;
}

.travel-mode-tab .tmt-time {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.travel-mode-tab .tmt-label {
  font-size: 10px;
  color: var(--text-dim);
}

.travel-mode-tab.active {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--text);
}
.travel-mode-tab.active .tmt-label { color: var(--accent); }

.travel-mode-tab:hover:not(.active) {
  background: var(--surface);
}

/* ---------- Route alternatives list ---------- */
.dir-routes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.dir-route-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dir-route-card:hover { border-color: var(--accent); }
.dir-route-card.active { border-color: var(--accent); background: rgba(59, 130, 246, 0.08); }

/* G3: route card head — duration + time range */
.dir-route-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.dir-route-duration-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dir-route-duration {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.dir-route-time-range {
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.dir-route-fare {
  font-size: 14px;
  font-weight: 600;
  color: var(--live);
  background: rgba(34, 197, 94, 0.12);
  padding: 4px 10px;
  border-radius: 999px;
}

.dir-route-distance {
  font-size: 12px;
  color: var(--text-dim);
}

/* G3: segment chips row — 🚶 → bus# → 🚶 */
.dir-route-segments {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.dir-route-segments .seg {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.dir-route-segments .seg-walk { background: transparent; border: none; padding: 4px; font-size: 14px; }
.dir-route-segments .seg-bus   { background: rgba(59, 130, 246, 0.12); border-color: var(--accent); color: var(--accent); }
.dir-route-segments .seg-metro { background: rgba(168, 85, 247, 0.12); border-color: #a855f7; color: #c084fc; }
.dir-route-segments .seg-train { background: rgba(20, 184, 166, 0.12); border-color: #14b8a6; color: #5eead4; }
.dir-route-segments .seg-tram  { background: rgba(244, 114, 182, 0.12); border-color: #f472b6; color: #f9a8d4; }
.dir-route-segments .seg-arrow { color: var(--text-dim); font-size: 14px; }
.dir-route-segments .seg-icon  { font-size: 12px; }
.dir-route-segments .seg-num   { font-variant-numeric: tabular-nums; }

/* G3: departure note */
.dir-route-departure-note {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
  padding: 6px 8px;
  background: var(--surface);
  border-radius: 4px;
}
.dir-route-departure-note .dn-emph {
  color: var(--accent);
  font-weight: 600;
}

.dir-route-detail-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 4px 0 0;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.dir-route-detail-btn:hover { text-decoration: underline; }

.dir-route-steps {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.dir-route-card.active .dir-route-steps { display: block; }

.dir-step {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px dashed var(--border);
  font-size: 13px;
}
.dir-step:first-child { border-top: none; }

.dir-step-icon {
  width: 28px;
  flex-shrink: 0;
  font-size: 18px;
  text-align: center;
}

.dir-step-body { flex: 1; min-width: 0; }
.dir-step-instruction { color: var(--text); line-height: 1.45; }
.dir-step-instruction b { font-weight: 600; }
.dir-step-meta { font-size: 11px; color: var(--text-dim); margin-top: 3px; }

.dir-step-transit {
  margin-top: 6px;
  padding: 6px 8px;
  background: var(--bg);
  border-radius: 4px;
  font-size: 12px;
}

.dir-step-transit-line {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 11px;
  margin-right: 4px;
}

.dir-step-tdx {
  margin-top: 4px;
  font-size: 11px;
  color: var(--est);
}
.dir-step-tdx.state-live { color: var(--live); }
.dir-step-tdx.state-none { color: var(--none); }

/* ---------- Saved & Explore lists ---------- */
.saved-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.saved-item {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.saved-item:hover { border-color: var(--accent); background: rgba(59, 130, 246, 0.06); }

.saved-item-thumb {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 6px;
  background: var(--bg) center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--text-dim);
}

.saved-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.saved-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-item-meta {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-item-meta .stars { color: #fbbc04; }

.saved-item-remove {
  align-self: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  border-radius: 50%;
}

.saved-item-remove:hover { background: var(--bg); color: var(--error); }

.saved-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.6;
}

/* ---------- Explore categories ---------- */
.explore-categories {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.explore-cat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
}

.explore-cat:hover { border-color: var(--accent); background: rgba(59, 130, 246, 0.06); }
.explore-cat.active { border-color: var(--accent); background: var(--accent); color: white; }
.explore-cat span:first-child { font-size: 22px; }

/* ---------- Controls ---------- */
.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field > span {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}

select, input[type="text"], input:not([type]) {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

select:focus, input:focus {
  border-color: var(--accent);
}

select:disabled, input:disabled, button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button {
  padding: 10px 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
}

/* ---------- Route meta ---------- */
.route-meta {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.route-meta h2 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
}

.route-meta p {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

.direction-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 3px;
  border-radius: var(--radius);
}

.dir-btn {
  flex: 1;
  padding: 6px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  border-radius: 5px;
}

.dir-btn.active {
  background: var(--accent);
  color: white;
}

.dir-btn:hover:not(.active) {
  color: var(--text);
}

/* ---------- Status banner ---------- */
.status-banner {
  padding: 12px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.status-banner.error {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
}

.status-banner.warn {
  border-color: rgba(234, 179, 8, 0.5);
  background: rgba(234, 179, 8, 0.08);
  color: #fde68a;
}

.status-banner.info {
  border-color: rgba(59, 130, 246, 0.5);
  background: rgba(59, 130, 246, 0.08);
  color: #93c5fd;
}

/* ---------- Stop list ---------- */
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.last-updated {
  font-size: 11px;
  font-weight: normal;
  color: var(--text-dim);
  text-transform: none;
  letter-spacing: 0;
}

.stop-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}

/* G5: 站列 — 左側 rail 線串起所有站，右側 ETA badge */
.stop-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  padding: 10px 8px 10px 0;
  background: transparent;
  align-items: center;
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}

.stop-row:hover {
  background: rgba(59, 130, 246, 0.08);
  border-radius: 6px;
}

/* The vertical rail line that connects all stops */
.stop-rail {
  position: relative;
  width: 28px;
  height: 100%;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stop-rail::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--border);
  transform: translateX(-50%);
}

.stop-row.stop-first .stop-rail::before { top: 50%; }
.stop-row.stop-last .stop-rail::before  { bottom: 50%; }

.stop-rail-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--none);
  border: 2px solid var(--surface);
  position: relative;
  z-index: 1;
}
.stop-rail-dot.state-live { background: var(--live); }
.stop-rail-dot.state-est  { background: var(--est); }
.stop-rail-dot.state-none { background: var(--none); }
.stop-rail-dot.has-bus {
  width: 14px;
  height: 14px;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18);
}

.stop-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

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

.stop-name {
  font-size: 14px;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stop-edge-tag {
  font-size: 10px;
  color: var(--text-dim);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.stop-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
}

.stop-seq-mini {
  font-variant-numeric: tabular-nums;
}

.transfer-icons {
  display: inline-flex;
  gap: 3px;
}
.transfer-icon {
  font-size: 12px;
  line-height: 1;
}

.bus-plate-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  background: rgba(34, 197, 94, 0.18);
  color: var(--live);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bus-plate-chip.inline {
  margin-left: auto;
}

/* G5: 站與站之間的車牌標籤（橋接列）— 模擬「公車在這兩站中間」 */
.stop-bridge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 2px 0;
  margin-left: 13px;
  position: relative;
}
.stop-bridge::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.stop-bridge-plates {
  display: flex;
  gap: 4px;
  padding-left: 16px;
  flex-wrap: wrap;
}

/* G5: ETA badge — Google-Maps-style large number on right */
.stop-badge {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
  text-align: center;
  min-width: 50px;
}
.stop-badge.badge-live {
  background: rgba(34, 197, 94, 0.18);
  color: var(--live);
}
.stop-badge.badge-arriving {
  background: var(--live);
  color: #06241a;
  animation: pulse-arrive 1.4s ease-in-out infinite;
}
@keyframes pulse-arrive {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
  50%      { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
}
.stop-badge.badge-est {
  background: rgba(234, 179, 8, 0.15);
  color: var(--est);
}
.stop-badge.badge-none {
  background: rgba(156, 163, 175, 0.15);
  color: var(--none);
  font-weight: 500;
}

.stop-row.highlighted {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.stop-row.near-bus {
  background: rgba(34, 197, 94, 0.06);
  border-radius: 6px;
}

/* ---------- Footer ---------- */
.footer {
  padding: 8px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.footer a {
  color: var(--text-dim);
  text-decoration: underline;
}

.footer a:hover {
  color: var(--text);
}

.footer-sep {
  color: var(--border);
}

/* ---------- Google Maps markers ----------
   AdvancedMarkerElement anchors at the bottom-center of its content. We use a
   1x1 wrapper + absolutely-positioned child translated to the wrapper center,
   so visually the marker is centered on the LatLng. */
.gmap-marker-wrap {
  position: relative;
  width: 1px;
  height: 1px;
}
.gmap-marker-child {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

/* Stop dots */
.stop-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  cursor: pointer;
}
.stop-dot.state-live { background: #22c55e; width: 14px; height: 14px; }
.stop-dot.state-est  { background: #eab308; }
.stop-dot.state-none { background: #9ca3af; }

/* Bus pill markers */
.bus-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 26px;
  padding: 0 10px;
  background: #2563eb;
  color: white;
  font-size: 12px;
  font-weight: 700;
  border-radius: 13px;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
}
.bus-icon.dir-0 { background: #2563eb; } /* 去程：藍 */
.bus-icon.dir-1 { background: #dc2626; } /* 返程：紅 */
.bus-icon.stale {
  opacity: 0.55;
  border-color: rgba(255, 255, 255, 0.5);
}

/* Google Maps InfoWindow — content theming
   (We leave Google's default light bubble chrome alone, just style the inner
   content for consistency.) */
.iw {
  font-family: inherit;
  font-size: 13px;
  line-height: 1.55;
  color: #111;
  min-width: 160px;
}
.iw h4 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  color: #111;
}
.iw .popup-sub {
  font-size: 11px;
  color: #666;
  margin-top: 2px;
}
.iw .popup-state {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
}
.popup-state.state-live { background: rgba(34, 197, 94, 0.18);  color: #15803d; }
.popup-state.state-est  { background: rgba(234, 179, 8, 0.2);   color: #a16207; }
.popup-state.state-none { background: rgba(156, 163, 175, 0.2); color: #4b5563; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  :root { --sidebar-w: 100%; }
  /* On mobile: map on top, sidebar slides up from bottom (Google Maps style). */
  main { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  #sidebar {
    border-right: none;
    border-top: 1px solid var(--border);
    max-height: 50vh;
  }
  .topbar { padding: 10px 14px; }
  .brand h1 { font-size: 16px; }
  .tagline { display: none; }
  .footer { padding: 6px 14px; font-size: 10px; }
  .legend { gap: 4px; }
  .badge { font-size: 10px; padding: 2px 6px; }

  /* Place card: full-width sheet from bottom */
  #place-card {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    max-height: 70vh;
    border-radius: 12px 12px 0 0;
  }

  /* Mode tabs: only emoji on tight viewports */
  .mode-tab { font-size: 16px; padding: 6px 2px; }
  .mode-tab .label-text { display: none; }

  /* Compact layers panel */
  .layers-panel { min-width: 220px; }

  /* Explore grid: 3 cols on mobile */
  .explore-categories { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Loading spinner ---------- */
.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Toast notification ----------
   Attached to #toast-host (a position:fixed container) so individual toasts
   use plain absolute positioning. position:fixed on the toast element itself
   is unreliable in some rendering pipelines. */
#toast-host {
  position: absolute;
  bottom: 24px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 10px;
  z-index: 200;
  pointer-events: none;
}
.app-toast {
  background: #f8fafc;
  color: #0f172a;
  border-radius: 8px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: translateY(20px);
  max-width: calc(100% - 48px);
  transition: transform 0.28s cubic-bezier(.2,.7,.3,1), opacity 0.28s;
  font-size: 14px;
  font-weight: 500;
  pointer-events: auto;
}
.app-toast.visible { transform: translateY(0); opacity: 1; }
.toast-msg { line-height: 1.4; }
.toast-action {
  background: transparent;
  border: none;
  color: #1a73e8;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: inherit;
}
.toast-action:hover { background: rgba(26, 115, 232, 0.12); }

/* (toast stacking now handled by #toast-host flex container) */

/* ---------- Welcome modal (first-visit onboarding) ---------- */
.welcome-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 25, 0.65);
  backdrop-filter: blur(4px);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: welcome-fade 0.2s ease-out;
}
@keyframes welcome-fade { from { opacity: 0; } to { opacity: 1; } }

.welcome-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 28px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  animation: welcome-pop 0.28s cubic-bezier(.2,.8,.2,1.05);
}
@keyframes welcome-pop {
  from { transform: scale(0.92) translateY(8px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
.welcome-card h2 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}
.welcome-card .sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 20px;
}
.welcome-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.welcome-mode {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}
.welcome-mode-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.welcome-mode-desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}
.welcome-cta {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.welcome-btn {
  padding: 10px 18px;
  border-radius: 6px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.welcome-btn-primary { background: var(--accent); color: white; }
.welcome-btn-primary:hover { background: var(--accent-hover); }
.welcome-btn-secondary { background: transparent; color: var(--text-dim); }
.welcome-btn-secondary:hover { color: var(--text); }

/* ---------- Empty state improvements ---------- */
.empty-state {
  padding: 28px 18px;
  text-align: center;
  color: var(--text-dim);
}
.empty-state-emoji { font-size: 36px; margin-bottom: 12px; }
.empty-state-title {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 6px;
}
.empty-state-hint {
  font-size: 12px;
  line-height: 1.6;
}
.empty-state-cta {
  margin-top: 16px;
  padding: 8px 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.empty-state-cta:hover { background: var(--accent-hover); }

/* Live-mode controls hint label */
.controls-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin: 0 0 -4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

/* ---------- Bus arrival alerts (F1) ---------- */
.alert-row {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #d0d0d0;
}
.alert-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid #dadce0;
  color: #1a73e8;
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.alert-btn:hover { background: rgba(26, 115, 232, 0.08); }
.alert-btn.active {
  background: #1a73e8;
  color: #fff;
  border-color: #1a73e8;
}
.alert-threshold-picker {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.alert-threshold-pick {
  flex: 1;
  padding: 4px 8px;
  background: #f8f9fa;
  border: 1px solid #dadce0;
  color: #202124;
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.alert-threshold-pick:hover { background: #e8f0fe; }

.alerts-section {
  margin-top: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.alerts-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.alert-item {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface);
  border-radius: 6px;
  align-items: center;
  font-size: 12px;
}
.alert-item-body { flex: 1; min-width: 0; }
.alert-item-route { font-weight: 600; color: var(--text); }
.alert-item-stop {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.alert-item-threshold {
  font-size: 11px;
  padding: 2px 6px;
  background: rgba(59, 130, 246, 0.18);
  color: var(--accent);
  border-radius: 999px;
}
.alert-item-remove {
  width: 22px;
  height: 22px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  border-radius: 50%;
}
.alert-item-remove:hover { background: var(--bg); color: var(--error); }

/* ---------- Stop sequence progress (F2) ---------- */
.stop-progress {
  margin-top: 12px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--text-dim);
}
.stop-progress-title {
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 12px;
}
.stop-progress-track {
  position: relative;
  height: 24px;
  border-radius: 12px;
  background: linear-gradient(to right, rgba(59, 130, 246, 0.18), rgba(34, 197, 94, 0.18));
  overflow: visible;
}
.stop-progress-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 18px;
  background: var(--accent);
  color: white;
  border-radius: 9px;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border: 2px solid var(--surface-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: left 0.4s ease-out;
}
.stop-progress-dot.at-stop {
  background: var(--live);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}
.stop-progress-dot.moving {
  background: var(--accent);
}
.stop-progress-tick {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 4px;
  height: 4px;
  background: var(--text-dim);
  border-radius: 50%;
  opacity: 0.5;
}
.stop-progress-edge {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  pointer-events: none;
}
.stop-progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 10px;
}

/* ---------- G1: Departure schedule panel ---------- */
.departure-panel {
  position: absolute;
  left: var(--sidebar-w);
  top: 0;
  width: 380px;
  max-width: calc(100vw - var(--sidebar-w) - 20px);
  height: 100%;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 25;
  transform: translateX(-12px);
  opacity: 0;
  transition: transform 0.25s ease-out, opacity 0.25s ease-out;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.departure-panel.visible {
  transform: translateX(0);
  opacity: 1;
}
.departure-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.departure-back {
  background: transparent;
  border: 1px solid var(--border);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.departure-back:hover {
  background: var(--surface);
}
.departure-head-body {
  flex: 1;
  min-width: 0;
}
.departure-head-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.departure-head-sub {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}
.departure-route-tag {
  background: var(--accent);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 11px;
}
.departure-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: 11px;
  color: var(--text-dim);
}
.departure-meta .freshness {
  font-variant-numeric: tabular-nums;
}
.departure-meta .problem-link {
  cursor: pointer;
  color: var(--accent);
}
.departure-meta .problem-link:hover {
  text-decoration: underline;
}
.departure-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 8px;
}
.departure-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 8px;
  border-bottom: 1px solid var(--border);
}
.departure-item:last-child {
  border-bottom: none;
}
.dep-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 80px;
}
.dep-tag {
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  width: fit-content;
}
.dep-tag-live      { background: rgba(34, 197, 94, 0.18); color: var(--live); }
.dep-tag-est       { background: rgba(234, 179, 8, 0.15); color: var(--est); }
.dep-tag-scheduled { background: rgba(156, 163, 175, 0.15); color: var(--text-dim); }
.dep-time {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.dep-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: right;
  align-items: flex-end;
}
.dep-plate {
  font-weight: 600;
  color: var(--live);
  font-variant-numeric: tabular-nums;
}
.dep-arrive {
  font-variant-numeric: tabular-nums;
}
.dep-crowd {
  opacity: 0.7;
}
.departure-actions {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.departure-actions .alert-btn {
  width: 100%;
}
.iw-open-departures {
  margin-top: 6px;
  width: 100%;
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.iw-open-departures:hover {
  background: var(--accent-hover);
}

/* ---------- G4: Vertical step-by-step timeline overlay ---------- */
.step-timeline {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 50;
  overflow-y: auto;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.25s ease-out, transform 0.25s ease-out;
}
.step-timeline.visible {
  opacity: 1;
  transform: translateY(0);
}
.step-timeline-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 1;
}
.step-timeline-close {
  background: transparent;
  border: 1px solid var(--border);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.step-timeline-close:hover {
  background: var(--surface-2);
}
.step-timeline-head-body { flex: 1; min-width: 0; }
.step-timeline-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.step-timeline-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.step-timeline-body {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}

/* Timeline row — rail (left) + body (right) */
.tl-row {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  position: relative;
  min-height: 60px;
}
.tl-row + .tl-row { margin-top: 0; }

.tl-rail {
  position: relative;
  width: 36px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 4px;
}
.tl-rail::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: -2px;
  left: 50%;
  width: 2px;
  background: var(--border);
  transform: translateX(-50%);
}
.tl-row-origin .tl-rail::before { top: 50%; }
.tl-row-dest .tl-rail::before { bottom: 50%; }
.tl-rail-walk::before {
  background: repeating-linear-gradient(to bottom, var(--text-dim) 0 4px, transparent 4px 8px);
}
.tl-rail-transit::before {
  background: var(--accent);
  width: 3px;
}
.tl-rail-origin::before { background: var(--accent); width: 3px; }
.tl-rail-dest::before { background: var(--accent); width: 3px; }

.tl-bullet {
  position: relative;
  z-index: 1;
  width: 16px;
  height: 16px;
  background: var(--surface);
  border: 3px solid var(--accent);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 10px;
}
.tl-bullet-transit {
  background: var(--accent);
  color: white;
  font-size: 11px;
  width: 28px;
  height: 28px;
}

.tl-body {
  flex: 1;
  padding-bottom: 18px;
  min-width: 0;
}

.tl-place {
  font-size: 15px;
  color: var(--text);
  line-height: 1.4;
}
.tl-place b { font-weight: 600; }
.tl-place-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Walking segment */
.tl-walk-head {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 13px;
  padding: 6px 0;
}
.tl-walk-icon { font-size: 16px; }
.tl-streetview-btn {
  margin-top: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.tl-streetview-btn:hover {
  background: var(--surface);
  border-color: var(--accent);
}

/* Transit segment card */
.tl-transit-card {
  margin-top: 8px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  border-left: 4px solid var(--accent);
}
.tl-transit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tl-transit-line {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.tl-transit-time {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.tl-live-tag {
  background: rgba(34, 197, 94, 0.18);
  color: var(--live);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}
.tl-transit-headsign {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}
.tl-transit-comfort {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.85;
}

.tl-expand-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 6px 0 0;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  display: block;
}
.tl-expand-btn:hover { text-decoration: underline; }
.tl-expand-btn.expanded::before { content: "▴"; margin-right: 4px; }

.tl-other-departures {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 12px;
}
.tl-other-departure-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.tl-other-departure-note {
  margin-top: 6px;
  color: var(--text-dim);
  font-size: 10px;
}

.tl-intermediate-stops {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 12px;
}
.tl-intermediate-note {
  color: var(--text-dim);
  padding: 2px 0;
}
