* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #141414; color: #e6eaf0; overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
#map { position: absolute; inset: 0; z-index: 1; background: #141414; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Leaflet dark tweaks */
.leaflet-control-zoom a {
  background: #242424 !important; color: #e6eaf0 !important;
  border-color: #2e2e2e !important;
  width: 40px !important; height: 40px !important; line-height: 40px !important; font-size: 20px !important;
}
.leaflet-bar { box-shadow: 0 2px 10px rgba(0,0,0,.5) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: #1c1c1c; color: #e6eaf0; border: 1px solid #2e2e2e;
  box-shadow: 0 8px 30px rgba(0,0,0,.6);
}
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; }
.leaflet-tooltip {
  background: #1c1c1c; color: #e6eaf0; border: 1px solid #2e2e2e;
  box-shadow: 0 2px 10px rgba(0,0,0,.5); font-size: 11px;
}
.leaflet-tooltip-top:before { border-top-color: #2e2e2e; }

/* Hover/selected aircraft label (FR24-style tag) */
.plane-label.leaflet-tooltip {
  background: #1c1c1c; color: #e6edf6; border: 1px solid #3b82f6; border-radius: 4px;
  padding: 2px 7px; font: 600 11px -apple-system, system-ui, sans-serif; box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.plane-label b { color: #60a5fa; font-weight: 700; }
.plane-label.leaflet-tooltip:before { display: none; }

/* Top bar — slim solid FR24 strip */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 500;
  display: flex; align-items: center; gap: 14px;
  padding: max(8px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
  background: rgba(20,20,20,.92); backdrop-filter: blur(10px); border-bottom: 1px solid #2e2e2e;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 20px; line-height: 1; color: #3b82f6; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; letter-spacing: .2px; color: #f0f0f0; }
.tagline { font-size: 10px; color: #8a8a8a; letter-spacing: .3px; text-transform: uppercase; }

.search { margin-left: auto; position: relative; }
.search input {
  width: 220px; max-width: 42vw; min-height: 40px;
  background: #242424; border: 1px solid #2e2e2e; border-radius: 999px;
  color: #e6eaf0; padding: 8px 14px; font-size: 13px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.2); }
.search input::placeholder { color: #7a8494; }

.stats { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.count-row { display: flex; align-items: center; gap: 4px; }
.stats #count { font-size: 18px; font-weight: 700; color: #60a5fa; }
.filter-badge { width: 7px; height: 7px; border-radius: 50%; background: #3b82f6; box-shadow: 0 0 6px rgba(59,130,246,.8); }
.filter-badge.hidden { display: none; }
.stats-label { font-size: 9px; color: #8a93a3; text-transform: uppercase; letter-spacing: .5px; }

/* Search dropdown */
.search-results {
  position: absolute; top: calc(100% + 6px); right: 0; width: 290px; max-width: 78vw;
  background: #1c1c1c; border: 1px solid #2e2e2e; border-radius: 12px;
  box-shadow: 0 14px 36px rgba(0,0,0,.55); overflow-y: auto; max-height: 52vh; z-index: 650;
}
.search-results.hidden { display: none; }
.sr-head { padding: 8px 12px 4px; font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: #60a5fa; background: #181818; position: sticky; top: 0; }
.sr-item { display: flex; align-items: baseline; gap: 8px; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #242424; }
.sr-item:last-child { border-bottom: none; }
.sr-item:hover { background: #242424; }
.sr-ico { font-size: 12px; width: 16px; flex-shrink: 0; align-self: center; }
.sr-cs { font-weight: 700; color: #e6eaf0; font-size: 13px; min-width: 46px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-sub { font-size: 11px; color: #8b97a8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-empty { padding: 14px 12px; font-size: 12px; color: #8b97a8; text-align: center; }

/* Airline filter chip */
.airline-chip {
  position: absolute; top: max(56px, env(safe-area-inset-top) + 46px); left: 50%; transform: translateX(-50%);
  z-index: 511; background: #1d4ed8; color: #fff; font-size: 12px; font-weight: 600;
  padding: 6px 14px; border-radius: 999px; box-shadow: 0 4px 14px rgba(59,130,246,.4);
  cursor: pointer; white-space: nowrap; max-width: 80vw; overflow: hidden; text-overflow: ellipsis;
}
.airline-chip:active { transform: translateX(-50%) scale(.95); }
.airline-chip.hidden { display: none; }
/* if a follow badge is also showing, drop the airline chip one row so they don't overlap */
.follow-lock:not(.hidden) ~ .airline-chip { top: max(92px, env(safe-area-inset-top) + 82px); }

/* Runway number labels on the map */
.rwy-num-icon { background: none; border: none; }
.rwy-num {
  font: 800 10px -apple-system, system-ui, sans-serif; color: #f4f7fb; letter-spacing: .5px;
  text-shadow: 0 0 2px #000, 0 0 2px #000; text-align: center; white-space: nowrap;
}

/* Airline logo + flight status badge */
.airline-logo { height: 20px; max-width: 96px; object-fit: contain; display: none; }
.flightno-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.flight-status { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.flight-status:empty { display: none; }
.st-enroute { background: rgba(59,130,246,.18); color: #60a5fa; }
.st-climb { background: rgba(76,175,80,.2); color: #6ee787; }
.st-descend { background: rgba(242,194,0,.2); color: #f2c200; }
.st-ground { background: rgba(139,151,168,.2); color: #b9c2cf; }

/* Altitude legend */
.alt-legend {
  position: absolute; left: max(8px, env(safe-area-inset-left)); bottom: 22px; z-index: 450;
  display: flex; align-items: center; gap: 7px;
  background: rgba(28,28,28,.92); border: 1px solid #2e2e2e; border-radius: 10px;
  padding: 6px 10px; font-size: 9.5px; color: #9aa4b2; pointer-events: none;
  box-shadow: 0 2px 10px rgba(0,0,0,.4);
}
.leg-title { text-transform: uppercase; letter-spacing: .5px; color: #cdd5df; font-weight: 600; }
.leg-swatch { width: 11px; height: 8px; border-radius: 2px; }
.leg-ground { background: #e8e8e8; }
.leg-cap { font-size: 9px; color: #8a93a3; }
.leg-bar {
  width: 84px; height: 8px; border-radius: 2px;
  background: linear-gradient(90deg, #3b82f6 0%, #22d3ee 25%, #4caf50 50%, #f2c200 75%, #ef4444 100%);
}

/* Boot loader — green radar with a sweeping beam */
.radar-loader {
  position: fixed; inset: 0; z-index: 850;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  background: radial-gradient(circle at 50% 44%, #0f1714 0%, #0a0d10 72%);
  transition: opacity .5s ease;
}
.radar-loader.done { opacity: 0; pointer-events: none; }
.radar-box { width: 152px; height: 152px; filter: drop-shadow(0 0 20px rgba(38,255,140,.28)); }
.radar-svg { width: 100%; height: 100%; display: block; }
.radar-ring { fill: none; stroke: rgba(46,229,140,.28); stroke-width: .8; }
.radar-cross { stroke: rgba(46,229,140,.16); stroke-width: .6; }
.radar-beam { stroke: #5dffa8; stroke-width: 1.3; stroke-linecap: round; filter: drop-shadow(0 0 3px #22ff88); }
.radar-center { fill: #5dffa8; }
.radar-sweep { transform-box: view-box; transform-origin: 50% 50%; animation: radar-spin 1.6s linear infinite; }
@keyframes radar-spin { to { transform: rotate(360deg); } }
.radar-blip { fill: #7dffbb; opacity: 0; }
.radar-blip.b1 { animation: radar-blip 1.6s linear infinite .28s; }
.radar-blip.b2 { animation: radar-blip 1.6s linear infinite .6s; }
.radar-blip.b3 { animation: radar-blip 1.6s linear infinite .98s; }
@keyframes radar-blip { 0%, 100% { opacity: 0; } 4% { opacity: 1; } 55% { opacity: 0; } }
.radar-text {
  font-size: 12.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  color: #7fe9b0; text-shadow: 0 0 10px rgba(38,255,140,.3);
}

/* Status pill */
.status {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 520; background: rgba(28,28,28,.94); border: 1px solid #2e2e2e;
  padding: 6px 14px; border-radius: 999px; font-size: 12px; color: #cdd5df;
  transition: opacity .3s; pointer-events: none; max-width: 86vw; text-align: center;
}
.status.err { color: #ff6b6b; border-color: #5a2a2a; }
.status.offline { color: #e0a72e; border-color: #4a3a1a; }
.status.hidden { opacity: 0; }

/* Follow lock badge */
.follow-lock {
  position: absolute; top: max(56px, env(safe-area-inset-top) + 46px); left: 50%; transform: translateX(-50%);
  z-index: 510; background: #3b82f6; color: #fff; font-size: 12px; font-weight: 600;
  padding: 6px 14px; border-radius: 999px; box-shadow: 0 4px 14px rgba(59,130,246,.4);
  display: flex; align-items: center; gap: 6px; pointer-events: auto; cursor: pointer;
}
.follow-lock:active { transform: translateX(-50%) scale(.95); }
.follow-lock.hidden { display: none; }

/* Floating action buttons */
.fab-stack {
  position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: 96px; z-index: 500;
  display: flex; flex-direction: column; gap: 12px;
}
.fab {
  width: 48px; height: 48px; border-radius: 50%;
  background: #242424; color: #60a5fa; border: 1px solid #2e2e2e;
  font-size: 19px; cursor: pointer; box-shadow: 0 1px 6px rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s cubic-bezier(.34,1.56,.64,1), background-color .15s, border-color .15s;
}
.fab:active { transform: scale(.92); }
.fab:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; }
.fab.active { background: #1d4ed8; border-color: #3b82f6; color: #fff; transform: scale(1.06); }

/* Filter panel */
.filter-panel {
  position: absolute; right: 72px; bottom: 96px; z-index: 600; width: 244px;
  background: #1c1c1c; border: 1px solid #2e2e2e; border-radius: 14px;
  padding: 14px 16px; box-shadow: 0 8px 24px rgba(0,0,0,.5);
  transform: none; transition: transform .18s ease-out;
}
.filter-panel.hidden { transform: translateY(8px) scale(.97); pointer-events: none; visibility: hidden; }
.fp-title { font-size: 13px; font-weight: 700; margin-bottom: 12px; }
.fp-title-gap { margin-top: 16px; }
.fp-units { display: flex; gap: 6px; margin-bottom: 8px; }
.fp-unit {
  flex: 1; background: #242424; color: #cdd5df; border: 1px solid #2e2e2e; border-radius: 9px;
  padding: 8px 4px; font-size: 12px; font-weight: 600; cursor: pointer; min-height: 36px;
  transition: border-color .15s, color .15s, background-color .15s;
}
.fp-unit:hover { border-color: #3b82f6; color: #fff; }
.fp-unit.active { background: #1d4ed8; border-color: #60a5fa; color: #fff; }
.fp-units-hint { font-size: 10.5px; color: #7a8494; text-align: center; font-variant-numeric: tabular-nums; }

/* Premium unlock */
.fp-premium-status { font-size: 12px; color: #9aa4b2; margin-bottom: 8px; }
.fp-premium-status.ok { color: #6ee787; font-weight: 600; }
.fp-redeem { display: flex; gap: 6px; margin-bottom: 6px; }
.fp-redeem input {
  flex: 1; min-width: 0; background: #242424; border: 1px solid #2e2e2e; border-radius: 8px;
  color: #e6eaf0; padding: 8px 10px; font-size: 12.5px; outline: none; text-transform: uppercase; letter-spacing: .5px;
}
.fp-redeem input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.2); }
.fp-redeem input::placeholder { color: #7a8494; letter-spacing: normal; }
.fp-redeem button {
  background: #1d4ed8; color: #fff; border: 1px solid #3b82f6; border-radius: 8px;
  padding: 0 14px; font-size: 12.5px; font-weight: 600; cursor: pointer; transition: background-color .15s;
}
.fp-redeem button:hover { background: #2563eb; }
.fp-lock-row { margin-bottom: 6px; }
.fp-premium-msg { font-size: 11.5px; min-height: 14px; }
.fp-premium-msg.ok { color: #6ee787; }
.fp-premium-msg.err { color: #ff9b9b; }
.fp-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 8px; margin-bottom: 12px; }
.fp-row span { font-size: 11px; color: #9aa4b2; }
.fp-row b { font-size: 11px; color: #60a5fa; font-variant-numeric: tabular-nums; }
.fp-row input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: #3b82f6; height: 22px; }
.fp-check { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #cdd5df; margin-bottom: 12px; cursor: pointer; min-height: 32px; }
.fp-check input { accent-color: #3b82f6; width: 16px; height: 16px; }
.fp-reset {
  width: 100%; background: #242424; color: #cdd5df; border: 1px solid #2e2e2e;
  border-radius: 8px; padding: 9px; font-size: 12px; cursor: pointer; min-height: 38px;
  transition: border-color .15s, color .15s;
}
.fp-reset:hover { color: #fff; border-color: #3b82f6; }

/* Plane markers — flat blue, FR24 style */
.plane-icon { background: none; border: none; }
.plane { width: 18px; height: 18px; position: relative; transition: transform .9s linear; transform-origin: 50% 50%; }
.plane::before { content: ''; position: absolute; inset: -8px; }  /* larger touch target */
.plane svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 0 1px rgba(7,12,20,.95)) drop-shadow(0 0 1px rgba(7,12,20,.95)); }
.plane svg:hover { filter: drop-shadow(0 0 4px rgba(59,130,246,.65)); }
.plane.selected { transform: scale(1.18); }
.plane.selected svg { color: #fff !important; filter: drop-shadow(0 0 1px rgba(7,12,20,.95)) drop-shadow(0 0 4px #3b82f6); }

/* Airport markers */
.airport-icon { background: none; border: none; }
.airport-dot {
  width: 8px; height: 8px; border-radius: 2px; background: #3b82f6;
  border: 1px solid #141414; box-shadow: 0 0 4px rgba(59,130,246,.7);
}

/* Drag handle (replaces ::before pseudo-element on mobile) */
#drag-handle {
  display: none; /* shown only on mobile */
  width: 40px; height: 4px; border-radius: 4px; background: #3a4351;
  margin: 10px auto 4px; flex-shrink: 0; touch-action: pan-y; cursor: grab;
}

/* Mini card strip */
#mini-strip {
  display: none; /* shown in sheet-mini state via .sheet-mini class */
  flex-direction: column; gap: 8px;
  padding: 2px 14px 14px;
}
.ms-row { display: flex; align-items: center; gap: 10px; }
.ms-thumb {
  width: 46px; height: 46px; border-radius: 8px; overflow: hidden;
  background: #242424; flex-shrink: 0; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.ms-thumb img { width: 100%; height: 100%; object-fit: cover; display: none; }
.ms-thumb img.ms-loaded { display: block; }
.ms-thumb-empty { font-size: 21px; color: #3a4351; }
.ms-info { flex: 1; min-width: 0; }
.ms-flightno { font-size: 18px; font-weight: 800; color: #f0f0f0; line-height: 1.1; }
.ms-sub { font-size: 11.5px; color: #8b97a8; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-follow {
  background: #1d4ed8; color: #fff; border: 1px solid #3b82f6;
  border-radius: 8px; padding: 8px 12px; font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap; flex-shrink: 0; min-height: 36px;
  transition: background-color .15s;
}
.ms-follow.active { background: #3b82f6; border-color: #60a5fa; }
.ms-follow:active { transform: scale(.95); }

/* Live tracker bar inside the mini card */
.ms-track { display: flex; align-items: center; gap: 9px; }
.ms-track-code { font-size: 15px; font-weight: 800; color: #f0f0f0; letter-spacing: .3px; min-width: 36px; }
.ms-track-code#ms-dst { text-align: right; }
.ms-track-bar {
  position: relative; flex: 1; height: 3px; border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6 var(--prog, 0%), #2a3340 var(--prog, 0%));
}
.ms-track-plane {
  position: absolute; top: 50%; left: var(--prog, 0%); width: 13px; height: 13px;
  color: #60a5fa; transform: translate(-50%, -50%) rotate(45deg);
  transition: left .8s ease-out; filter: drop-shadow(0 0 3px rgba(59,130,246,.7));
}
.ms-track-plane svg { width: 100%; height: 100%; display: block; }
.ms-meta {
  font-size: 11px; color: #aeb7c4; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center;
}
.ms-meta.late { color: #ff6b6b; }
.ms-meta.early, .ms-meta.ontime { color: #6ee787; }

/* Detail panel — FR24 left sidebar on desktop */
.panel {
  position: absolute; z-index: 600; top: 0; left: 0; bottom: 0; width: 360px; max-width: 92vw;
  height: 100vh; overflow-y: auto;
  background: #1c1c1c; border-right: 1px solid #2e2e2e;
  box-shadow: 8px 0 32px rgba(0,0,0,.45);
  transform: translateX(0);
  transition: transform .25s cubic-bezier(.16,1,.3,1);
}
.panel.hidden { transform: translateX(-24px); pointer-events: none; visibility: hidden; }
.panel-close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255,255,255,.08); border: none; color: #e6eaf0; font-size: 21px;
  line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background-color .15s;
}
.panel-close:hover { color: #fff; background: rgba(255,255,255,.18); }
.panel-close:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; }

.photo-wrap {
  position: relative; width: 100%; height: 200px; background: #1a1a1a; overflow: hidden;
}
.photo-wrap img { width: 100%; height: 100%; object-fit: cover; display: none; }
.photo-wrap img.loaded { display: block; animation: photo-fade .35s ease-out; }
@keyframes photo-fade { from { opacity: 0; } to { opacity: 1; } }
.photo-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; color: #5b6675; font: 500 11.5px -apple-system, system-ui, sans-serif; background: #1a1a1a;
}
.photo-empty.hidden { display: none; }
.photo-empty.loading {
  background: linear-gradient(90deg, #161616 25%, #222 50%, #161616 75%);
  background-size: 200% 100%; animation: photo-shimmer 1.4s ease-in-out infinite; color: transparent;
}
.photo-empty-icon { width: 40px; height: 40px; color: #39424f; transform: rotate(45deg); }
.photo-empty.loading .photo-empty-icon, .photo-empty.loading .photo-empty-label { visibility: hidden; }
@keyframes photo-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.photo-cred {
  position: absolute; bottom: 4px; right: 8px; font-size: 9.5px; color: #cdd5df;
  background: rgba(0,0,0,.6); padding: 1px 6px; border-radius: 6px;
}
.photo-cred a { color: #cdd5df; text-decoration: none; }
.photo-cred a:hover { color: #60a5fa; }

.panel-head { padding: 12px 16px 6px; }
.airline-row { display: flex; align-items: center; gap: 8px; }
.flag { font-size: 16px; line-height: 1; }
.airline { font-size: 13px; color: #60a5fa; font-weight: 600; }
.flightno-big { font-size: 23px; font-weight: 800; color: #f0f0f0; letter-spacing: .3px; margin-top: 2px; }
.callsign-row { display: flex; align-items: baseline; gap: 8px; margin-top: 1px; min-height: 14px; }
.callsign { font-size: 12px; color: #8b97a8; }
.typeline { font-size: 12px; color: #9aa4b2; margin-top: 4px; }

/* Route box */
.routebox {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  margin: 12px 16px; padding: 12px; background: #1a1a1a; border: 1px solid #2e2e2e; border-radius: 12px;
}
.routebox.hidden { display: none; }
.rb-end { min-width: 52px; }
.rb-end:first-child { text-align: left; }
.rb-right { text-align: right; }
.rb-code { font-size: 25px; font-weight: 800; color: #f0f0f0; letter-spacing: .5px; line-height: 1.05; }
.rb-city { font-size: 9.5px; color: #8b97a8; margin-top: 2px; max-width: 80px; }
.rb-right .rb-city { margin-left: auto; }
.rb-mid { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.rb-track {
  position: relative; width: 100%; height: 4px; border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6 var(--prog, 0%), #222b39 var(--prog, 0%));
}
.rb-plane {
  position: absolute; top: 50%; left: var(--prog, 0%); width: 14px; height: 14px;
  transform: translate(-50%, -50%); color: #60a5fa; transition: left .8s ease-out;
  filter: drop-shadow(0 0 4px rgba(59,130,246,.7));
}
.rb-plane svg { width: 100%; height: 100%; display: block; }
.rb-eta { font-size: 10.5px; color: #cdd5df; font-weight: 500; white-space: nowrap; }
.route-unknown { margin: 12px 16px; font-size: 11px; color: #7a8494; text-align: center; }
.route-unknown.hidden { display: none; }

/* Scheduled / actual times + delay (AeroDataBox) */
.times-block {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin: 0 16px 8px; padding: 12px; background: #1a1a1a; border: 1px solid #2e2e2e; border-radius: 12px;
}
.times-block.hidden { display: none; }
.tcol { display: flex; flex-direction: column; gap: 3px; }
.tright { text-align: right; }
.tlabel { font-size: 9.5px; text-transform: uppercase; letter-spacing: .5px; color: #7a8494; }
.tsched { font-size: 19px; font-weight: 700; color: #f0f0f0; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tact { font-size: 11.5px; font-variant-numeric: tabular-nums; min-height: 14px; }
.tact.late { color: #ff6b6b; }
.tact.early, .tact.ontime { color: #6ee787; }
.delay-line { margin: 0 16px 10px; font-size: 11.5px; font-weight: 600; text-align: center; }
.delay-line.hidden { display: none; }
.delay-line.late { color: #ff6b6b; }
.delay-line.early, .delay-line.ontime { color: #6ee787; }

/* Section titles + telemetry grid */
.panel-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: #60a5fa;
  margin: 14px 16px 8px; border-bottom: 1px solid #2e2e2e; padding-bottom: 6px;
}
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; padding: 0 16px; }
.cell { display: flex; flex-direction: column; gap: 2px; }
.cell label { font-size: 9.5px; text-transform: uppercase; letter-spacing: .5px; color: #7a8494; }
.cell span { font-size: 14px; color: #e6eaf0; font-variant-numeric: tabular-nums; }

/* ATC radio (beta) */
.beta-tag {
  font-size: 8.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  background: rgba(59,130,246,.2); color: #60a5fa; padding: 2px 6px; border-radius: 999px; margin-left: 4px;
}
.atc-block { margin: 0 16px; }
.atc-feeds { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.atc-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: #242424; color: #cdd5df; border: 1px solid #2e2e2e; border-radius: 999px;
  padding: 7px 13px; font-size: 12px; font-weight: 600; cursor: pointer; min-height: 34px;
  transition: border-color .15s, color .15s, background-color .15s;
}
.atc-btn:hover { border-color: #3b82f6; color: #fff; }
.atc-btn.playing { background: #1d4ed8; border-color: #60a5fa; color: #fff; }
.atc-btn.playing::before { content: '⏹'; }
.atc-btn:not(.playing)::before { content: '▶'; font-size: 9px; color: #60a5fa; }
.atc-status { font-size: 11.5px; color: #8b97a8; margin-bottom: 6px; min-height: 15px; }
.atc-status.live { color: #6ee787; font-weight: 600; }
.atc-status.err { color: #e0a72e; }
/* ATC live captions (Whisper via Cloudflare Workers AI) */
.atc-cc-row { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; }
.atc-cc-btn {
  background: #242424; color: #cdd5df; border: 1px solid #2e2e2e; border-radius: 6px;
  font-size: 11px; font-weight: 800; letter-spacing: .5px; padding: 4px 9px; cursor: pointer; min-height: 28px;
  transition: background-color .15s, border-color .15s, color .15s;
}
.atc-cc-btn:hover { border-color: #3b82f6; color: #fff; }
.atc-cc-btn.on { background: #1d4ed8; border-color: #60a5fa; color: #fff; }
.atc-cc-label { font-size: 11px; color: #8b97a8; }
.atc-captions {
  background: #111417; border: 1px solid #2e2e2e; border-radius: 10px; padding: 9px 11px;
  margin-bottom: 8px; font-size: 12.5px; line-height: 1.5; color: #cfe3d6; min-height: 40px; max-height: 120px;
  overflow-y: auto; font-variant-numeric: tabular-nums; white-space: pre-wrap; word-break: break-word;
}
.atc-captions .cc-hint { color: #7a8494; font-size: 11px; }
.atc-captions .cc-cur { color: #fff; }

.atc-links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 6px; }
.atc-link { display: inline-block; font-size: 11.5px; color: #60a5fa; text-decoration: none; }
.atc-link:hover { text-decoration: underline; }
#atc-yt { color: #f87171; }
.atc-cred { font-size: 9.5px; color: #6b7686; line-height: 1.4; margin-bottom: 4px; }
.atc-cred a { color: #8b97a8; text-decoration: none; }
.atc-cred a:hover { color: #60a5fa; }

.follow-btn {
  display: block; width: calc(100% - 32px); margin: 16px 16px 6px;
  background: #1d4ed8; color: #fff; border: 1px solid #3b82f6; border-radius: 10px;
  padding: 12px; font-size: 13px; font-weight: 600; cursor: pointer; min-height: 44px;
  transition: transform .15s cubic-bezier(.34,1.56,.64,1), background-color .15s, border-color .15s;
}
.follow-btn:hover { background: #2563eb; }
.follow-btn:active { transform: scale(.97); }
.follow-btn:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; }
.follow-btn.active { background: #3b82f6; color: #fff; border-color: #60a5fa; }

.panel-foot { padding: 6px 16px 16px; font-size: 10.5px; color: #7a8494; font-variant-numeric: tabular-nums; text-transform: uppercase; letter-spacing: .3px; }

/* Onboarding toast */
.onboard {
  position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 700; background: #1c1c1c; border: 1px solid #3b82f6; border-radius: 12px;
  padding: 12px 14px; max-width: 90vw; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.55); font-size: 12.5px; color: #e6eaf0;
  animation: onboard-in .3s cubic-bezier(.16,1,.3,1);
}
.onboard.hidden { display: none; }
.onboard button {
  background: #3b82f6; color: #fff; border: none; border-radius: 8px;
  padding: 7px 12px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
@keyframes onboard-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Feedback modal */
.modal {
  position: fixed; inset: 0; z-index: 900; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); backdrop-filter: blur(2px); padding: 20px;
}
.modal.hidden { display: none; }
.modal-card {
  width: 380px; max-width: 100%; background: #1c1c1c; border: 1px solid #2e2e2e; border-radius: 16px;
  padding: 22px 20px 20px; box-shadow: 0 20px 60px rgba(0,0,0,.6); position: relative;
}
.modal-close {
  position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255,255,255,.08); border: none; color: #e6eaf0; font-size: 21px; line-height: 1; cursor: pointer;
}
.modal-close:hover { background: rgba(255,255,255,.18); }
.modal-title { margin: 0 0 6px; font-size: 18px; color: #f0f0f0; }
.modal-sub { margin: 0 0 14px; font-size: 12.5px; color: #9aa4b2; line-height: 1.45; }
.modal-card textarea, .modal-card input {
  width: 100%; background: #242424; border: 1px solid #2e2e2e; border-radius: 10px; color: #e6eaf0;
  padding: 11px 12px; font-size: 13px; outline: none; margin-bottom: 10px; font-family: inherit; resize: vertical;
}
.modal-card textarea:focus, .modal-card input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.2); }
.modal-card textarea::placeholder, .modal-card input::placeholder { color: #7a8494; }
.modal-btn {
  width: 100%; background: #3b82f6; color: #fff; border: none; border-radius: 10px; padding: 12px;
  font-size: 13px; font-weight: 600; cursor: pointer; min-height: 44px; transition: background-color .15s, transform .12s;
}
.modal-btn:hover { background: #2563eb; }
.modal-btn:active { transform: scale(.98); }
.modal-btn:disabled { opacity: .65; cursor: default; }

/* Feedback type chips */
.fb-types { display: flex; gap: 8px; margin-bottom: 12px; }
.fb-type {
  flex: 1; background: #242424; color: #cdd5df; border: 1px solid #2e2e2e; border-radius: 10px;
  padding: 9px 6px; font-size: 12.5px; font-weight: 600; cursor: pointer; min-height: 40px;
  transition: border-color .15s, color .15s, background-color .15s;
}
.fb-type:hover { border-color: #3b82f6; color: #fff; }
.fb-type.active { background: #1d4ed8; border-color: #60a5fa; color: #fff; }
.fb-status { font-size: 12px; margin-top: 10px; min-height: 16px; text-align: center; }
.fb-status.ok { color: #6ee787; }
.fb-status.err { color: #ff9b9b; }

/* Private admin panel */
.admin {
  position: fixed; inset: 0; z-index: 950; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6); backdrop-filter: blur(2px); padding: 20px;
}
.admin.hidden { display: none; }
.admin-card {
  width: 420px; max-width: 100%; max-height: 88vh; overflow-y: auto;
  background: #1c1c1c; border: 1px solid #2e2e2e; border-radius: 16px; padding: 22px 20px 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6); position: relative;
}
.admin-close {
  position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255,255,255,.08); border: none; color: #e6eaf0; font-size: 21px; line-height: 1; cursor: pointer;
}
.admin-close:hover { background: rgba(255,255,255,.18); }
.admin-title { margin: 0 0 14px; font-size: 18px; color: #f0f0f0; }
.admin-sub { margin: 0 0 12px; font-size: 12.5px; color: #9aa4b2; }
.admin-gate-row, .admin-gen-row { display: flex; gap: 8px; margin-bottom: 8px; }
.admin-gate-row input, .admin-gen-row select {
  flex: 1; min-width: 0; background: #242424; border: 1px solid #2e2e2e; border-radius: 9px;
  color: #e6eaf0; padding: 9px 11px; font-size: 13px; outline: none;
}
.admin-gate-row input:focus, .admin-gen-row select:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.2); }
.admin-gate-row button, .admin-gen-row button {
  background: #1d4ed8; color: #fff; border: 1px solid #3b82f6; border-radius: 9px;
  padding: 0 16px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.admin-gate-row button:hover, .admin-gen-row button:hover { background: #2563eb; }
.admin-msg { font-size: 11.5px; color: #ff9b9b; min-height: 14px; }
.admin-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: #60a5fa;
  margin: 16px 0 10px; border-bottom: 1px solid #2e2e2e; padding-bottom: 6px;
}
.admin-codes { display: flex; flex-direction: column; gap: 6px; }
.admin-code-row { display: flex; align-items: center; gap: 8px; background: #141414; border: 1px solid #2e2e2e; border-radius: 8px; padding: 8px 10px; }
.admin-code { font: 700 14px ui-monospace, SFMono-Regular, Menlo, monospace; color: #6ee787; letter-spacing: 1px; }
.admin-code-tier { font-size: 11px; color: #8b97a8; margin-left: auto; }
.admin-copy { background: #242424; color: #cdd5df; border: 1px solid #2e2e2e; border-radius: 6px; padding: 5px 10px; font-size: 11px; font-weight: 600; cursor: pointer; }
.admin-copy:hover { border-color: #3b82f6; color: #fff; }
.admin-note { font-size: 11.5px; color: #7a8494; line-height: 1.5; margin: 0; }

/* Attribution */
.attrib { position: absolute; bottom: 4px; left: 8px; z-index: 400; font-size: 9.5px; color: #8a93a3; }
.attrib a { color: #9aa4b2; text-decoration: none; }
.attrib a:hover { color: #60a5fa; }
.attrib .made b { color: #60a5fa; }
.attrib .sep { margin: 0 5px; opacity: .5; }

/* When the sidebar is open on desktop, lift the legend out from under it */
body.panel-open .alt-legend { left: 372px; }

/* ---------- Mobile ---------- */
@media (max-width: 560px) {
  .brand-text { display: none; }
  .topbar { gap: 8px; }
  .search { flex: 1; margin-left: auto; }
  .search input { width: auto; max-width: none; min-height: 44px; }
  .search-results { width: auto; left: 0; right: 0; max-width: none; }

  .fab-stack { left: max(14px, env(safe-area-inset-left)); right: auto; bottom: max(20px, env(safe-area-inset-bottom) + 14px); }
  .filter-panel { left: 72px; right: auto; bottom: max(20px, env(safe-area-inset-bottom) + 14px); }
  .leaflet-bottom.leaflet-right { margin-bottom: max(8px, env(safe-area-inset-bottom)); }
  .status { top: max(56px, env(safe-area-inset-top) + 46px); bottom: auto; }
  .alt-legend { bottom: auto; top: max(56px, env(safe-area-inset-top) + 46px); left: max(8px, env(safe-area-inset-left)); }
  body.panel-open .alt-legend { left: max(8px, env(safe-area-inset-left)); }
  .follow-lock { top: max(96px, env(safe-area-inset-top) + 86px); }

  /* bottom sheet */
  #drag-handle { display: block; }
  .panel {
    top: auto; bottom: 0; right: 0; left: 0; width: 100%; max-width: 100%;
    border-radius: 18px 18px 0 0; border-right: none;
    box-shadow: 0 -8px 32px rgba(0,0,0,.55);
    overscroll-behavior: contain; scrollbar-width: thin;
    transition: height .28s cubic-bezier(.16,1,.3,1), transform .25s cubic-bezier(.16,1,.3,1);
    height: 85vh; overflow-y: auto;
  }
  .panel.hidden { transform: translateY(120px); pointer-events: none; visibility: hidden; }

  /* Mini state — compact strip only */
  .panel.sheet-mini {
    height: 150px; overflow: hidden;
  }
  .panel.sheet-mini #mini-strip { display: flex; }
  .panel.sheet-mini .photo-wrap,
  .panel.sheet-mini .panel-head,
  .panel.sheet-mini .routebox,
  .panel.sheet-mini .route-unknown,
  .panel.sheet-mini .times-block,
  .panel.sheet-mini .delay-line,
  .panel.sheet-mini .panel-section-title,
  .panel.sheet-mini .panel-grid,
  .panel.sheet-mini .atc-block,
  .panel.sheet-mini .follow-btn,
  .panel.sheet-mini .panel-foot,
  .panel.sheet-mini .panel-close { display: none !important; }

  /* Full state */
  .panel:not(.sheet-mini):not(.hidden) #mini-strip { display: none; }
  .panel:not(.sheet-mini):not(.hidden) { max-height: 85vh; height: 85vh; overflow-y: auto; }

  .photo-wrap { border-radius: 18px 18px 0 0; height: 220px; }
  .panel-foot { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .attrib { font-size: 8.5px; }
}

@media (max-width: 360px) {
  .panel-grid { grid-template-columns: 1fr; }
  .alt-legend .leg-title { display: none; }
}
