/* ============================================================
   RailGap — dark theme, mobile-first, optimised for driving
   Design system v2 — Space Mono + DM Sans
   ============================================================ */

:root {
  --bg:          #0d0f14;
  --surface:     #161922;
  --surface2:    #1e2230;
  --border:      rgba(255,255,255,0.08);
  --text:        #f0f2f7;
  --muted:       #6b7280;
  --accent:      #f59e0b;
  --danger:      #ef4444;
  --safe:        #22c55e;
  --mono:        'Space Mono', monospace;
  --sans:        'DM Sans', sans-serif;
  --panel-h:     70vh;
  --panel-peek:  116px;  /* handle 38 + peek-row content (prefix/name/road/dist) ~74 + buffer */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top:    env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
}

/* ── Map ─────────────────────────────────────────────────── */

#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* Zoom controls — centrati in basso, sopra il pannello peek */
.leaflet-bottom.leaflet-right {
  bottom: calc(var(--panel-peek) + var(--safe-bottom) + 12px);
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}
.leaflet-control-zoom {
  border: none !important;
  display: flex;
  flex-direction: row;
  gap: 8px;
}
.leaflet-control-zoom a {
  width: 48px !important;
  height: 48px !important;
  line-height: 48px !important;
  font-size: 20px !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
}
.leaflet-control-zoom a:hover {
  background: var(--surface2) !important;
}

/* Override Leaflet attribution */
.leaflet-control-attribution {
  background: rgba(0,0,0,0.5) !important;
  color: rgba(255,255,255,0.4) !important;
  font-size: 9px !important;
}
.leaflet-control-attribution a { color: rgba(255,255,255,0.4) !important; }

/* ── Top bar ─────────────────────────────────────────────── */

#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-top));
  background: linear-gradient(to bottom, rgba(13,15,20,0.95) 60%, transparent);
  backdrop-filter: blur(8px);
}

.logo {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text);
}
.logo span { color: var(--accent); }

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 15px;
  color: var(--text);
  transition: background 0.15s;
}
.icon-btn:active { background: var(--surface2); opacity: 0.8; }

/* GPS pill */
.gps-pill {
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  background: rgba(34,197,94,0.15);
  border: 1px solid rgba(34,197,94,0.3);
  display: flex; align-items: center; gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--safe);
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.3s;
}
.gps-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--safe);
  animation: gpsPulse 1.5s ease-in-out infinite;
}

.gps-pill.gps-warn {
  background: rgba(245,158,11,0.15);
  border-color: rgba(245,158,11,0.3);
  color: var(--accent);
}
.gps-pill.gps-warn .gps-dot  { background: var(--accent); }

.gps-pill.gps-off {
  background: rgba(255,255,255,0.05);
  border-color: var(--border);
  color: var(--muted);
}
.gps-pill.gps-off .gps-dot   { background: var(--muted); animation: none; }

@keyframes gpsPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.7); }
}

/* Search */
.search-box {
  position: absolute;
  left: 12px; right: 12px;
  top: calc(10px + var(--safe-top));
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(22,25,34,0.97);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  backdrop-filter: blur(12px);
  z-index: 110;
}
.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  font-family: var(--sans);
}
.search-input::placeholder { color: var(--muted); }
.search-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
}

/* ── Alert toast ─────────────────────────────────────────── */

.alert-toast {
  position: fixed;
  top: calc(68px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 102;
  background: rgba(239,68,68,0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(239,68,68,0.5);
  border-radius: 12px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 8px 32px rgba(239,68,68,0.4);
  cursor: pointer;
}

.alert-close {
  margin-left: 4px;
  opacity: 0.7;
  font-size: 14px;
  cursor: pointer;
}
.alert-close:hover { opacity: 1; }


/* ── L1 popup teaser ─────────────────────────────────────── */
.l1-popup-teaser {
  padding: 8px 4px 4px;
  min-width: 180px;
  text-align: center;
}
.l1-pt-name {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 2px;
  font-family: var(--sans);
}
.l1-pt-road {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 2px;
}
.l1-pt-dist {
  font-size: 12px;
  color: rgba(255,255,255,0.75);
  margin-bottom: 8px;
}
.l1-pt-fav-btn {
  display: block;
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: #f59e0b;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  width: 100%;
  cursor: pointer;
  font-family: var(--sans);
}
.l1-pt-fav-btn:active { background: rgba(255,255,255,0.1); }
.l1-pt-disused {
  margin-top: 6px;
  padding: 5px 8px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 6px;
  color: #f87171;
  font-size: 12px;
  font-family: var(--sans);
  text-align: center;
}



/* ── Header auth elements ────────────────────────────────── */
.login-btn {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #0d0f14;
  background: #f59e0b;
  padding: 8px 14px;
  border-radius: 10px;
  text-decoration: none;
  display: flex;
  align-items: center;
  white-space: nowrap;
  transition: transform 0.1s, opacity 0.15s;
}
.login-btn:active { transform: scale(0.96); opacity: 0.85; }

/* ── L1 CTA ───────────────────────────────────────────────── */
.l1-cta { padding: 4px 18px 20px; font-family: var(--sans); }
.l1-cta-head {
  display: flex; gap: 10px; align-items: center;
  margin: 14px 0 6px;
}
.l1-cta-lock { font-size: 20px; }
.l1-cta-title {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}
.l1-cta-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
  line-height: 1.45;
}
.l1-cta-feats {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.l1-cta-feats li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.l1-cta-ico {
  font-size: 18px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.l1-cta-feats li div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.l1-cta-feats b {
  font-size: 13.5px;
  color: var(--text);
  font-weight: 600;
}
.l1-cta-feats span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.l1-cta-btn {
  display: block;
  text-align: center;
  background: #f59e0b;
  color: #0d0f14;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  padding: 14px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(245,158,11,0.25);
  transition: transform 0.1s, box-shadow 0.15s;
}
.l1-cta-btn:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(245,158,11,0.2);
}
.l1-cta-privacy {
  margin-top: 12px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  font-family: var(--sans);
}

/* L1 countdown chip: lock affordance instead of --:-- */
.countdown-chip.l1-locked { cursor: pointer; }
.countdown-chip.l1-locked .countdown {
  color: #f59e0b;
  font-size: 14px;
  letter-spacing: 0.05em;
}
.countdown-chip.l1-locked .countdown-label { color: var(--muted); }

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f59e0b;
  color: #000;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Explore invite (utente fermo, non invasivo) ─────────── */
.explore-invite {
  position: fixed;
  bottom: calc(100px + var(--safe-bottom));
  left: 12px;
  right: 12px;
  z-index: 102;
  background: rgba(20, 22, 30, 0.94);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.1);
  border-left: 3px solid #f59e0b;
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: invite-slide-up 0.3s ease;
}
@keyframes invite-slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.explore-invite-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.explore-invite-text {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: #e5e7eb;
  font-family: var(--sans);
}
.explore-invite-btn {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 8px;
  border: none;
  background: #f59e0b;
  color: #000;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--sans);
  cursor: pointer;
}
.explore-invite-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #6b7280;
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

/* Banner crossing selezionato manualmente (non il più vicino) */
.nearest-banner {
  flex: 0 0 auto;
  margin: 4px 12px 12px;
  background: rgba(59,130,246,0.1);
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.nearest-banner-icon { font-size: 18px; flex-shrink: 0; }
.nearest-banner-text {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: #e5e7eb;
  font-family: var(--sans);
}
.nearest-banner-btn {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 8px;
  border: none;
  background: #3b82f6;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--sans);
  cursor: pointer;
}

/* Simulated position badge */
.sim-badge {
  position: fixed;
  top: calc(68px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 101;
  background: rgba(245,158,11,0.92);
  color: #000;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  cursor: pointer;
}

/* ── Bottom sheet (panel) ────────────────────────────────── */

#sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  border-top: 1px solid var(--border);
  height: auto;
  max-height: calc(var(--panel-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* Default: peeking — shows only handle + peek-row */
  transform: translateY(calc(100% - var(--panel-peek) - var(--safe-bottom)));
  transition: transform 0.4s cubic-bezier(0.32,0.72,0,1), border-color 0.3s;
  /* Only the visible peek portion should receive touch events */
  pointer-events: none;
}
#sheet .panel-handle-area,
#sheet .peek-row,
#sheet .crossing-dots {
  pointer-events: auto;
}

/* Expanded states */
#sheet.info,
#sheet.warning,
#sheet.alert,
#sheet.l1-expanded {
  transform: translateY(0);
  pointer-events: none;
}
#sheet.info > *,
#sheet.warning > *,
#sheet.alert > *,
#sheet.l1-expanded > * {
  pointer-events: auto;
}

/* Border accent per urgency */
#sheet.warning { border-top-color: var(--accent); }
#sheet.alert   { border-top-color: var(--danger); }

/* ── Handle ────────────────────────────────────────────── */

.panel-handle-area {
  height: 38px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  gap: 4px;
}
.panel-handle {
  width: 40px; height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  transition: background 0.2s;
}
.panel-handle-area:hover  .panel-handle { background: rgba(255,255,255,0.35); }
.panel-handle-area:active .panel-handle { background: rgba(255,255,255,0.5); }

.panel-hint {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.04em;
  font-weight: 500;
}

/* ── Peek row ──────────────────────────────────────────── */

.peek-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0 20px 12px;
}

.peek-left {
  flex: 1;
  min-width: 0;
  padding-right: 16px;
}


.peek-name {
  font-weight: 500;
  font-size: 13px;
  color: var(--muted);
  word-break: break-word;
}

.peek-road {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  margin-top: 1px;
  word-break: break-word;
}

.peek-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Countdown chip ────────────────────────────────────── */

.countdown-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  text-align: center;
}

.countdown-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
}

.countdown {
  font-family: var(--mono);
  font-size: 42px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  transition: color 0.3s;
}

#sheet.warning .countdown { color: var(--accent); }
#sheet.alert   .countdown { color: var(--danger); }

.reopen-time {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  font-family: var(--mono);
}
.reopen-time span { color: var(--safe); font-weight: 700; }

/* ── Passaggi ravvicinati (cluster) — colore giallo: è avvertimento, non allarme ─── */
.cluster-info {
  margin: 0 20px 10px;
  padding: 10px 12px;
  background: rgba(234, 179, 8, 0.08);
  border: 1px solid rgba(234, 179, 8, 0.35);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  font-family: var(--sans);
}
.cluster-badge {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent);
  text-transform: uppercase;
}
.cluster-badge-icon { font-size: 13px; }
.cluster-badge-text b { color: var(--text); }
.cluster-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}
.cluster-sub b { color: var(--text); font-weight: 700; }
.cluster-warn {
  margin-top: 8px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
  font-family: var(--sans);
  background: rgba(234,179,8,0.08);
  border-left: 2px solid var(--accent);
  border-radius: 4px;
  opacity: 0.9;
}
.cluster-list {
  margin-top: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.cluster-list-item {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px;
  background: rgba(255,255,255,0.03);
  border-left: 2px solid transparent;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.cluster-list-item.current {
  border-left-color: var(--accent);
  color: var(--text);
  background: rgba(245, 158, 11, 0.08);
}
.cluster-list-item.past {
  opacity: 0.45;
}
.cluster-list-item .cli-num {
  color: var(--muted);
  font-size: 10px;
  min-width: 16px;
}
.cluster-list-item .cli-times { flex: 1; }
.cluster-list-item .cli-trains { color: var(--muted); font-size: 11px; }

/* ── Train card states (raffica context) ─────────────────── */
.train-card.closing {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 1px var(--danger);
}
.train-card.during-closure {
  border-color: var(--accent) !important;
  background: rgba(245, 158, 11, 0.06);
}

/* ── Data source badge ──────────────────────────────────── */
.source-badge {
  display: inline-block;
  font-size: 9px;
  font-family: var(--mono);
  letter-spacing: 0.03em;
  padding: 1px 5px;
  border-radius: 3px;
  margin-top: 3px;
  text-transform: uppercase;
  font-weight: 600;
}
.source-badge.src-live    { background: #1a3d1a; color: #4cdb6a; }
.source-badge.src-blend   { background: #2d2d00; color: #d4c44a; }
.source-badge.src-hist    { background: #1a2540; color: #7ab3f5; }
.source-badge.src-fallback{ background: #2a1a1a; color: #c47a7a; }

/* ── Expanded panel content ─────────────────────────────── */

.panel-content {
  flex: 0 0 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Sheet tab bar ───────────────────────────────────────── */
.sheet-tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px 12px;
}
.sheet-tab {
  flex: 1;
  padding: 7px 0;
  border: none;
  border-radius: 8px;
  background: var(--surface2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--sans);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.sheet-tab.active {
  background: var(--text);
  color: var(--bg);
}
.sheet-tab-panel {
  flex: 0 0 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 16px;
  max-height: 45vh;
}

.sep {
  height: 1px;
  background: var(--border);
  margin: 0 20px 12px;
}

.trains-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px 8px;
}
.trains-label-text {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.swipe-hint {
  font-size: 10px;
  color: var(--muted);
  opacity: 0.6;
}

/* Crossing navigation dots (between peek-row and panel-content) */
.crossing-dots {
  display: flex;
  gap: 5px;
  justify-content: center;
  align-items: center;
  padding: 6px 0 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
#sheet.info .crossing-dots,
#sheet.warning .crossing-dots,
#sheet.alert .crossing-dots {
  opacity: 1;
  pointer-events: auto;
}
.crossing-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
}
.crossing-dot.active {
  width: 16px;
  border-radius: 3px;
  background: var(--text);
}
.crossing-dot:active { opacity: 0.6; }

/* Horizontal train scroll */
.trains-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0 calc(50% - 58px) 4px;
}
.trains-scroll::-webkit-scrollbar { display: none; }

.train-card {
  flex: 0 0 116px;
  scroll-snap-align: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.2s;
}
.train-card.active {
  border-color: var(--danger);
  background: rgba(239,68,68,0.08);
}
.train-card-empty {
  font-size: 12px;
  color: var(--muted);
  padding: 20px;
  text-align: center;
}

.train-time {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.train-dest {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.train-closure {
  font-size: 10px;
  color: var(--muted);
  font-family: var(--mono);
}
.train-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 4px;
  width: fit-content;
  margin-top: 2px;
}
.train-badge.on-time { background: rgba(34,197,94,0.15);   color: var(--safe);   }
.train-badge.delayed { background: rgba(245,158,11,0.15);  color: var(--accent); }
.train-badge.past    { background: rgba(107,114,128,0.15); color: var(--muted);  }

.train-src-badge {
  font-size: 8px;
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 1px 4px;
  border-radius: 3px;
  width: fit-content;
}
.train-src-badge.src-live     { background: #1a3d1a; color: #4cdb6a; }
.train-src-badge.src-blend    { background: #2d2d00; color: #d4c44a; }
.train-src-badge.src-hist     { background: #1a2540; color: #7ab3f5; }
.train-src-badge.src-fallback { background: #2a1a1a; color: #c47a7a; }

/* Scroll dots */
.scroll-dots {
  display: flex;
  gap: 4px;
  justify-content: center;
  padding: 8px 0 4px;
}
.dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--muted);
  transition: all 0.2s;
}
.dot.active {
  width: 14px;
  border-radius: 3px;
  background: var(--accent);
}

/* Sheet footer */
.sheet-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px 4px;
}

.collapse-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  padding: 2px 4px;
  cursor: pointer;
}
.collapse-btn:active { opacity: 0.5; }

.deselect-btn {
  background: rgba(255,255,255,0.07);
  border: none;
  color: var(--muted);
  font-size: 13px;
  width: 26px; height: 26px;
  border-radius: 50%;
  cursor: pointer;
}
.deselect-btn:active { background: rgba(255,255,255,0.18); }

.precision-note {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
}

/* ── Favourite button ────────────────────────────────────── */

.fav-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 8px;
  transition: color 0.2s, transform 0.15s;
  line-height: 1;
}
.fav-btn:active { transform: scale(0.85); }
.fav-btn.active { color: #f4c542; }

/* ── Tracked crossing marker (🚧 + state-colored pulsing halo) ───────────── */

.tcm-wrap { background: transparent; border: 0; }

.tcm {
  position: relative;
  width: 48px; height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}
.tcm-emoji {
  position: relative;
  font-size: 22px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.7));
  z-index: 3;
}
.tcm-halo {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  z-index: 1;
  pointer-events: none;
  will-change: transform, opacity;
}
.tcm-ring {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  z-index: 2;
  pointer-events: none;
  box-sizing: border-box;
  will-change: transform, opacity;
}

/* State: open/tracked — green (traffic-light semantic: go), breathing pulse (2.4s) */
.tcm-open .tcm-halo {
  background: radial-gradient(circle, rgba(34,197,94,0.55) 0%, rgba(34,197,94,0) 70%);
  animation: halo-breath 2.4s ease-in-out infinite;
}
.tcm-open .tcm-ring {
  border: 2px solid rgba(34,197,94,0.9);
  box-shadow: 0 0 8px rgba(34,197,94,0.55);
  animation: ring-breath 2.4s ease-in-out infinite;
}

/* State: warn — yellow halo + pulsing yellow ring (1.6s) */
.tcm-warn .tcm-halo {
  background: radial-gradient(circle, rgba(245,158,11,0.65) 0%, rgba(245,158,11,0) 70%);
  animation: halo-pulse 1.6s ease-in-out infinite;
}
.tcm-warn .tcm-ring {
  border: 2px solid rgba(245,158,11,0.95);
  box-shadow: 0 0 10px rgba(245,158,11,0.7);
  animation: ring-pulse 1.6s ease-in-out infinite;
}

/* State: closed — red halo + pulsing red ring (0.8s) */
.tcm-closed .tcm-halo {
  background: radial-gradient(circle, rgba(239,68,68,0.8) 0%, rgba(239,68,68,0) 70%);
  animation: halo-pulse 0.8s ease-in-out infinite;
}
.tcm-closed .tcm-ring {
  border: 2px solid rgba(239,68,68,1);
  box-shadow: 0 0 14px rgba(239,68,68,0.85);
  animation: ring-pulse 0.8s ease-in-out infinite;
}

/* Favourite — gold glow around the emoji (coexists with state halo/ring) */
.tcm-fav .tcm-emoji {
  text-shadow: 0 0 4px #f5c400, 0 0 10px #f5c400;
}

@keyframes halo-pulse {
  0%, 100% { transform: scale(0.55); opacity: 0.35; }
  50%      { transform: scale(1.55); opacity: 1.0;  }
}
@keyframes ring-pulse {
  0%, 100% { transform: scale(0.7);  opacity: 0.55; }
  50%      { transform: scale(1.35); opacity: 1.0;  }
}
@keyframes halo-breath {
  0%, 100% { transform: scale(0.75); opacity: 0.4; }
  50%      { transform: scale(1.4);  opacity: 1.0; }
}
@keyframes ring-breath {
  0%, 100% { transform: scale(0.85); opacity: 0.65; }
  50%      { transform: scale(1.25); opacity: 1.0;  }
}

/* Zoom-gate: freeze animations below zoom 13 (set by JS on #map) */
#map.tcm-static .tcm-halo,
#map.tcm-static .tcm-ring { animation: none !important; transform: none !important; }

/* ── Leaflet scale control — dark theme + push below topbar ──────────────── */
.leaflet-top.leaflet-left { top: calc(64px + var(--safe-top)); }
.leaflet-control-scale-line {
  background: rgba(13,15,20,0.75) !important;
  border: 1px solid rgba(255,255,255,0.25) !important;
  border-top: none !important;
  color: #e5e7eb !important;
  font-family: var(--mono) !important;
  font-size: 11px !important;
  padding: 2px 6px !important;
  text-shadow: none !important;
}

/* ── Leaflet popup — dark theme ─────────────────────────── */

.railgap-popup .leaflet-popup-content-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  padding: 0;
  overflow: hidden;
}
.railgap-popup .leaflet-popup-content {
  margin: 0;
  line-height: 1;
}
.railgap-popup .leaflet-popup-tip-container { display: none; }

.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
  gap: 10px;
}
.popup-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  flex: 1;
  min-width: 0;
  word-break: break-word;
  line-height: 1.3;
}
.popup-fav {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.2s, transform 0.15s;
}
.popup-fav:active { transform: scale(0.85); }
.popup-fav.is-fav { color: #f4c542; }

.popup-road {
  padding: 0 14px 2px;
  font-size: 12px;
  color: var(--muted);
}
.popup-sub {
  padding: 0 14px 6px;
  font-size: 12px;
  color: var(--muted);
}

.popup-state {
  display: block;
  padding: 8px 14px 12px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--sans);
  letter-spacing: 0.01em;
}
.popup-state.state-open    { color: #22c55e; }
.popup-state.state-warn    { color: #f59e0b; }
.popup-state.state-closed  { color: #ef4444; }
.popup-state.state-disused { color: #6b7280; }

/* ── Map legend ─────────────────────────────────────────────────────────── */
/* Toggle "i" è nell'header (.header-actions). Pannello dropdown ancorato
   sotto la topbar, top-right, così non copre sheet/popup. */
.map-legend {
  position: fixed;
  top: calc(var(--topbar-h, 56px) + 6px);
  right: 12px;
  z-index: 1100;   /* sopra mappa, sotto modali account/feedback */
}
.legend-toggle {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  font-style: italic;
  font-family: var(--serif, Georgia, serif);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.legend-toggle:active { opacity: 0.8; }
.legend-panel {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 12px 14px 10px;
  margin-top: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  min-width: 220px;
  max-width: 260px;
}
.legend-intro {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.legend-intro-title {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}
.legend-intro-sub {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.4;
  font-family: var(--sans);
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-family: var(--sans);
  color: var(--text);
  padding: 4px 0;
}
.legend-tcm {
  width: 22px; height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
}
.legend-tcm-open   { background: rgba(34,197,94,0.20);  box-shadow: 0 0 0 2px rgba(34,197,94,0.55); }
.legend-tcm-warn   { background: rgba(245,158,11,0.22); box-shadow: 0 0 0 2px rgba(245,158,11,0.65); }
.legend-tcm-closed { background: rgba(239,68,68,0.24);  box-shadow: 0 0 0 2px rgba(239,68,68,0.7); }
.legend-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  margin: 0 4px;
}
.legend-dot.grey {
  background: #444;
  border: 1.5px solid #888;
}
.legend-dot.disused {
  background: rgba(239,68,68,0.3);
  border: 1.5px solid #ef4444;
}

.user-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #4a9eff;
  border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(74,158,255,0.2);
}

/* ── Onboarding screens ──────────────────────────────────── */

.onboarding-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: calc(24px + var(--safe-top));
  padding-bottom: calc(24px + var(--safe-bottom));
}

.onboarding-content {
  max-width: 380px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

/* ── Welcome screen ─────────────────────────────────────── */

.welcome-logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
}

.welcome-train {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 12px;
  animation: gentle-bounce 3s ease-in-out infinite;
}

@keyframes gentle-bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

.welcome-brand {
  font-family: var(--mono);
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.welcome-brand span {
  color: var(--accent);
}

.welcome-tagline {
  font-size: 17px;
  line-height: 1.5;
  color: rgba(255,255,255,0.7);
  text-align: center;
  margin-bottom: 36px;
}

.welcome-features {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 40px;
}

.welcome-feat {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
  color: rgba(255,255,255,0.65);
  line-height: 1.45;
}

.feat-icon {
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1.2;
}

.btn-start {
  width: 100%;
  padding: 16px;
  border-radius: 14px;
  background: var(--accent);
  border: none;
  color: #0d0f14;
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: -0.01em;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-start:active { opacity: 0.85; transform: scale(0.98); }

.welcome-version {
  margin-top: 20px;
  font-size: 11px;
  color: rgba(255,255,255,0.18);
  font-family: var(--mono);
}

/* ── Direction selection screen ─────────────────────────── */

.direction-content {
  gap: 0;
}

.dir-header {
  text-align: center;
  margin-bottom: 32px;
}

.dir-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.dir-sub {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.4;
}

.dir-options {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
}

.dir-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 22px;
  border-radius: 18px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.dir-card:active,
.dir-card-selected {
  background: rgba(245,158,11,0.12);
  border-color: rgba(245,158,11,0.5);
  transform: scale(0.98);
}

.dir-card-arrow {
  font-size: 28px;
  flex-shrink: 0;
  color: var(--accent);
  font-family: var(--mono);
}

.dir-card-label {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.dir-card-places {
  font-size: 13px;
  color: var(--muted);
}

.dir-gps-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.dir-gps-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.2; }
}

.dir-gps-status.gps-ok .dir-gps-dot {
  background: var(--safe);
  animation: none;
}

/* ── Direction chip in sheet header ─────────────────────── */

.dir-chip-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px 2px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
}

.dir-chip-change {
  margin-left: auto;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}

/* ── GPS overlays ────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.overlay-card {
  max-width: 360px;
  width: 100%;
  text-align: center;
}
.overlay-icon { font-size: 56px; margin-bottom: 16px; }
.overlay-card h2 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.overlay-card p {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 32px;
}
.btn-primary {
  display: block;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 12px;
  background: var(--danger);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.5px;
  font-family: var(--sans);
  transition: opacity 0.2s;
}
.btn-primary:active { opacity: 0.8; }

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
#gps-spin { display: inline-block; animation: spin 2s linear infinite; }

/* ── Account Modal (L2+) ─────────────────────────────────── */

.account-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
}
.account-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
}
.account-sheet {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  max-height: 88vh;
  overflow-y: auto;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
}
.account-handle-bar {
  width: 40px; height: 4px;
  background: rgba(255,255,255,0.18);
  border-radius: 2px;
  margin: 12px auto 16px;
}
.account-profile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px 18px;
  border-bottom: 1px solid var(--border);
}
.account-avatar-lg {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.account-profile-info { flex: 1; min-width: 0; }
.account-profile-name {
  font-size: 16px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.account-profile-email {
  font-size: 12px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.account-profile-tier {
  font-size: 11px; color: #f59e0b; font-family: var(--mono);
  font-weight: 700; margin-top: 4px; letter-spacing: 0.05em;
}
.account-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.account-section-last { border-bottom: none; }
.account-section-hd {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 12px;
}
.account-placeholder-note {
  font-size: 13px; color: var(--muted); line-height: 1.5;
}
.account-logout-btn {
  display: block; text-align: center;
  padding: 14px; border-radius: 12px;
  border: 1px solid var(--border);
  color: var(--danger); font-family: var(--mono);
  font-size: 14px; font-weight: 700; letter-spacing: 0.05em;
  text-decoration: none;
  transition: background 0.15s;
}
.account-logout-btn:active { background: rgba(239,68,68,0.1); }
.account-admin-links {
  display: flex; flex-direction: column; gap: 8px;
}
.account-admin-link {
  display: block; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border); color: var(--text);
  font-size: 14px; font-weight: 500;
  text-decoration: none; transition: background 0.15s;
}
.account-admin-link:active { background: rgba(245,158,11,0.1); }
.account-admin-debug {
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--border);
}
.account-admin-debug-hd {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.tier-toggle {
  display: flex; gap: 6px;
}
.tier-btn {
  flex: 1; padding: 10px 8px;
  background: transparent; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.tier-btn.active {
  background: rgba(245,158,11,0.15);
  border-color: var(--accent);
  color: var(--accent);
}
.tier-btn:active { background: rgba(245,158,11,0.08); }
.account-admin-debug-note {
  font-size: 11px; color: var(--muted); margin-top: 8px;
  min-height: 14px;
}
.account-fav-list { display: flex; flex-direction: column; }
.account-fav-empty {
  font-size: 13px; color: var(--muted); line-height: 1.6;
  text-align: center; padding: 12px 0;
}
.account-notif-btn {
  background: var(--safe);
  border: none;
  color: #000;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-family: var(--sans);
}
.account-notif-btn:disabled {
  background: var(--surface2);
  color: var(--muted);
  cursor: default;
}

/* field verifier button in fav list */
.fav-verify-row {
  padding: 6px 0 0;
}
.fav-verify-btn {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #000;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 14px;
  cursor: pointer;
  width: 100%;
}

/* ── FieldVerifier overlay ────────────────────────────────────────────── */
.fv-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 500;
  display: flex;
  align-items: flex-end;
}
.fv-sheet {
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 16px 20px 40px;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 80vh;
  overflow-y: auto;
}
.fv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.fv-title { font-size: 15px; font-weight: 700; color: var(--text); }
.fv-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}
.fv-recorded { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.fv-rec-label { color: var(--text-muted); }
.fv-rec-time  { color: var(--accent); font-family: 'Space Mono', monospace; }
.fv-current-step {
  background: var(--surface2);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fv-step-label { font-size: 16px; font-weight: 700; color: var(--text); }
.fv-step-hint  { font-size: 13px; color: var(--text-muted); }
.fv-tap-btn {
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #000;
  font-size: 16px;
  font-weight: 700;
  padding: 12px;
  cursor: pointer;
}
.fv-skip-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px;
  cursor: pointer;
}
.fv-done-msg { font-size: 15px; color: var(--green, #4caf50); text-align: center; padding: 8px 0; }
.fv-actions { margin-top: 4px; }
.fv-save-btn {
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 10px;
  width: 100%;
  cursor: pointer;
}
.fv-save-btn:not(:disabled):hover { background: var(--accent); color: #000; }
.fv-save-btn:disabled { opacity: 0.4; cursor: default; }

/* beta tester toggle */
.beta-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.beta-toggle-cb { width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent); }
.beta-toggle-label { font-size: 14px; color: var(--text); }

/* fav items (shared by account modal) */
.fav-item {
  display: flex;
  flex-direction: column;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.fav-item:last-child { border-bottom: none; }
.fav-item-row1 {
  display: flex;
  align-items: center;
  gap: 10px;
}
.fav-item-row2 {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 2px;
}
.fav-qh-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.fav-qh-sep   { font-size: 12px; color: var(--muted); }
.fav-qh-start, .fav-qh-end {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 12px;
  padding: 3px 6px;
  font-family: var(--mono);
  cursor: pointer;
  width: 82px;
}
.fav-item-info { flex: 1; min-width: 0; }
.fav-item-name {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fav-item-link {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(255,255,255,0.25);
  text-underline-offset: 3px;
}
.fav-item-link:active { opacity: 0.6; }
.fav-item-road { font-size: 12px; color: var(--muted); margin-top: 2px; }
.fav-item-lead { display: flex; align-items: center; gap: 6px; }
.fav-lead-select {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  padding: 4px 6px;
  cursor: pointer;
  font-family: var(--sans);
}
.fav-test-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--safe);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  flex-shrink: 0;
  opacity: 0.8;
}
.fav-test-btn:active { opacity: 1; transform: scale(0.9); }
.fav-remove-btn {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 17px;
  cursor: pointer;
  padding: 4px 6px;
  opacity: 0.7;
  border-radius: 8px;
  flex-shrink: 0;
}
.fav-remove-btn:active { opacity: 1; }
.fav-notif-btn {
  background: var(--safe);
  border: none;
  color: #000;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-family: var(--sans);
}

/* ── Desktop / browser: hide panel peek when collapsed ──────────────────── */
@media (pointer: fine) {
  :root { --panel-peek: 0px; }
  #sheet {
    transform: translateY(100%);
    border-radius: 24px 24px 0 0;
  }
  #sheet.info,
  #sheet.warn,
  #sheet.closed {
    transform: translateY(calc(100% - 340px));
  }
  .zoom-controls {
    bottom: 24px;
  }
}

/* ── Feedback card ───────────────────────────────────────────── */

.feedback-card {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--panel-peek) + var(--safe-bottom) + 12px);
  z-index: 130;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  flex-direction: column;
  gap: 12px;
  transform: translateY(16px);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.55);
  pointer-events: none;            /* trasparente al tocco quando nascosta */
}

.feedback-card.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;            /* riceve tap solo quando visibile */
}

.feedback-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.feedback-title {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  flex: 1;
}

.feedback-crossing-name {
  font-size: 11px;
  color: var(--muted);
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feedback-skip-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  font-family: var(--sans);
}

.feedback-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fb-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fb-label {
  font-size: 11px;
  color: var(--muted);
  width: 92px;
  flex-shrink: 0;
}

.fb-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.fb-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-size: 11px;
  padding: 5px 11px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: var(--sans);
}

.fb-btn.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 600;
}

.feedback-submit {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 12px;
  padding: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--sans);
  transition: opacity 0.2s;
  width: 100%;
}

.feedback-submit:disabled {
  opacity: 0.3;
  cursor: default;
}

/* ── Destination / Alternatives section ────────────────────────────────── */

/* ── Crossing report ────────────────────────────────────────────────────────── */

.l1-pt-report-btn {
  display: block;
  margin-top: 8px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
}
.l1-pt-report-btn:hover { color: var(--text); }
.l1-pt-report-hint {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  font-style: italic;
}

.popup-report-btn {
  display: block;
  margin-top: 8px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  width: 100%;
  text-align: left;
}
.popup-report-btn:hover { color: var(--text); }

#report-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.report-modal {
  background: var(--surface);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.report-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.report-sub {
  font-size: 12px;
  color: var(--muted);
}
.report-textarea {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  padding: 12px;
  resize: none;
  height: 100px;
  font-family: var(--sans);
}
.report-textarea:focus { outline: none; border-color: var(--accent); }
.report-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.report-cancel {
  background: none;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  padding: 8px 16px;
  cursor: pointer;
}
.report-submit {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #000;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 20px;
  cursor: pointer;
}
.report-submit:disabled { opacity: 0.5; }
.report-status {
  font-size: 13px;
  text-align: center;
  min-height: 18px;
}

/* ── Badge toast ──────────────────────────────────────────────────────── */
.badge-toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--accent);
  color: #000;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 24px;
  z-index: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  white-space: nowrap;
}
.badge-toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Badge grid in Account modal ──────────────────────────────────────── */
.account-badges-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 6px;
}
.account-badge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 10px;
  background: var(--surface2);
  text-align: center;
}
.account-badge-item.locked {
  opacity: 0.35;
  filter: grayscale(1);
}
.account-badge-emoji { font-size: 24px; }
.account-badge-name  { font-size: 11px; color: var(--text-muted); line-height: 1.2; }

/* ── CrowdReport modal ─────────────────────────────────────────────────── */
.crowd-modal {
  position: fixed;
  inset: 0;
  z-index: 450;
}
.crowd-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}
.crowd-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 12px 20px 32px;
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.crowd-handle-bar {
  width: 36px;
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  margin: 0 auto 4px;
}
.crowd-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.crowd-crossing-name {
  font-size: 13px;
  color: var(--text-muted);
}
.crowd-category {
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 8px 12px;
}
.crowd-text {
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 10px 12px;
  resize: none;
  min-height: 80px;
}
.crowd-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.crowd-cancel {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 14px;
  padding: 8px 16px;
  cursor: pointer;
}
.crowd-submit {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #000;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 20px;
  cursor: pointer;
}
.crowd-submit:disabled { opacity: 0.5; }
.crowd-feedback {
  font-size: 13px;
  text-align: center;
}
.fav-report-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  flex-shrink: 0;
}

/* ── L3 dest-section ─────────────────────────────────────────────────────── */
.dest-section {
  margin: 10px 16px 4px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
}
.dest-verdict {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.dest-badge {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 6px;
  flex-shrink: 0;
  margin-top: 1px;
}
.dest-badge.dest-deviate {
  background: rgba(34,197,94,0.18);
  color: var(--safe);
}
.dest-badge.dest-wait {
  background: rgba(234,179,8,0.18);
  color: var(--accent);
}
.dest-badge.dest-wait-no-alt {
  background: rgba(239,68,68,0.18);
  color: var(--danger);
}
.dest-reason {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  opacity: 0.88;
}
.dest-alt-slot:not(:empty) {
  margin-top: 8px;
  font-size: 12px;
  opacity: 0.75;
  font-family: var(--sans);
}
.tab-now-fallback {
  margin: 10px 16px 4px;
  padding: 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px dashed var(--border);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  opacity: 0.75;
  text-align: center;
}
/* ── Dir-choose inline (tab Passo o no, nessuna direzione impostata) ──── */
.dir-choose { text-align: center; }
.dir-choose-msg {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-family: var(--sans);
}
.dir-choose-btns {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.dir-choose-btn {
  flex: 1;
  max-width: 140px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}
.dir-choose-btn:hover { background: rgba(255,255,255,0.08); border-color: var(--accent); }
.dir-choose-btn:active { transform: scale(0.97); }
