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

:root {
  --bg: #f5f3ef;
  --surface: #ffffff;
  --surface2: #faf9f7;
  --border: #e8e4de;
  --border-light: #f0ede8;
  --text: #1a1a1a;
  --text-secondary: #6b6560;
  --text-dim: #9b9590;
  --accent: #2563eb;
  --accent-light: #dbeafe;
  --green: #16a34a;
  --green-light: #dcfce7;
  --amber: #d97706;
  --amber-light: #fef3c7;
  --red: #dc2626;
  --red-light: #fee2e2;
  --purple: #7c3aed;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --radius: 10px;
  --radius-sm: 6px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  height: 100vh;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 44px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 100;
  position: relative;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: -0.5px;
}

.title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}

.live-badge {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  background: var(--green-light);
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  color: var(--green);
}

.live-badge.error {
  background: var(--red-light);
  color: var(--red);
}

.live-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}

.live-badge.error .live-dot { background: var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-dim);
}
.header-stats b { font-weight: 600; margin-right: 2px; }
.header-stats .hs-blue { color: var(--accent); }
.header-stats .hs-green { color: var(--green); }
.header-stats .hs-amber { color: var(--amber); }
.header-stats .hs-purple { color: var(--purple); }

.header-right {
  display: flex; align-items: center; gap: 10px;
}

.weather-widget {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  padding-right: 8px;
  border-right: 1px solid var(--border);
  margin-right: 2px;
}
.weather-widget:empty { display: none; }
.weather-widget svg { flex-shrink: 0; }

.clock {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.header-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 11px;
  padding: 3px 10px;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  transition: all 0.15s;
}
.header-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Main layout ── */
.main {
  display: grid;
  grid-template-columns: auto 1fr;
  height: calc(100vh - 44px);
}

/* ── Sidebar ── */
.sidebar {
  width: 380px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: row;
  overflow: hidden;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: width;
}

body.sidebar-collapsed .sidebar { width: 48px; }

.sidebar-rail {
  width: 48px;
  min-width: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  gap: 2px;
  background: var(--surface2);
  border-right: 1px solid var(--border-light);
}

.rail-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.rail-icon:hover { background: var(--bg); color: var(--text); }
.rail-icon.active { background: var(--accent-light); color: var(--accent); }
.rail-spacer { flex: 1; }

.sidebar-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.sidebar-collapsed .sidebar-content { display: none; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.panel-tabs {
  display: flex;
  gap: 0;
}

.panel-tab {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.panel-tab:hover { color: var(--text); }
.panel-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* Mobile info buttons — hidden on desktop (rail handles it), shown on mobile */
.mobile-info-btns { display: none; }

.sidebar-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.pill-btn {
  padding: 3px 9px;
  font-size: 10px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Inter', sans-serif;
}
.pill-btn:hover { border-color: var(--accent); color: var(--accent); }
.pill-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.sort-select {
  padding: 3px 6px;
  font-size: 10px;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239b9590' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
}

.filter-info {
  font-size: 10px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  width: 100%;
  margin-top: 2px;
}

.sidebar-search {
  width: 100%;
  padding: 6px 10px;
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  margin-bottom: 4px;
}
.sidebar-search:focus { border-color: var(--accent); }
.sidebar-search::placeholder { color: var(--text-dim); }

/* ── Flight cards ── */
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.flight-cards { padding: 0; }

.flight-card {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
  display: flex;
  gap: 10px;
}
.flight-card:hover { background: var(--surface2); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.flight-card:active { transform: translateY(0); box-shadow: none; }
.flight-card.active-card { background: var(--accent-light); border-left: 3px solid var(--accent); }

.fc-photo {
  width: 64px;
  height: 48px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.fc-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  filter: blur(8px);
  transition: opacity 0.4s ease, filter 0.4s ease;
}
.fc-photo img.loaded {
  opacity: 1;
  filter: blur(0);
}
.fc-photo .fc-photo-placeholder {
  color: var(--text-dim);
  opacity: 0.3;
}

.fc-info { flex: 1; min-width: 0; }

.fc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
}

.fc-callsign {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.ytz-badge {
  font-family: 'Inter', sans-serif;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  background: var(--green-light);
  color: var(--green);
  border-radius: 4px;
  margin-left: 6px;
  letter-spacing: 0.3px;
  vertical-align: middle;
}
.ytz-dir-badge {
  font-size: 10px;
  margin-left: 3px;
  vertical-align: middle;
}
.ytz-dir-badge.arr { color: var(--green); }
.ytz-dir-badge.dep { color: var(--accent); }

.fc-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fc-route {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 2px;
}
.fc-route .arrow { color: var(--text-dim); margin: 0 3px; }

.fc-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 10px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
}

.fc-details .fc-vrate-down { color: var(--green); }
.fc-details .fc-vrate-up { color: var(--amber); }
.fc-details .fc-seen { opacity: 0.6; }

.status-pill {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.status-pill.descending { background: var(--green-light); color: var(--green); }
.status-pill.climbing { background: var(--amber-light); color: var(--amber); }
.status-pill.level { background: #f0f0ee; color: var(--text-dim); }
.status-pill.ground { background: #fdf4e7; color: #b45309; }
.status-pill.lost { background: #f0f0ee; color: var(--text-dim); }

/* ── History tab ── */
.history-view { padding: 12px; overflow: auto; }

.history-stats {
  display: flex; gap: 8px; margin-bottom: 12px;
}

.history-card {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 10px;
  text-align: center;
}

.history-card .hc-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}

.history-card .hc-label {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-top: 1px;
}

.history-card.hc-active {
  border-color: var(--accent);
  background: var(--accent-light);
}

.history-log {
  display: flex; flex-direction: column; gap: 0;
}

.history-entry {
  display: flex;
  gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-light);
  font-size: 11px;
  transition: background 0.1s;
}
.history-entry:hover { background: var(--surface2); }

.he-photo {
  width: 56px;
  height: 42px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.he-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.he-info { flex: 1; min-width: 0; }

.he-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.he-flight {
  font-weight: 600; color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

.he-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-dim);
}

.he-dir {
  display: inline-block;
  font-size: 9px; font-weight: 600; padding: 1px 6px; border-radius: 4px;
  margin-left: 6px;
}
.he-dir.arr { background: var(--green-light); color: var(--green); }
.he-dir.dep { background: var(--accent-light); color: var(--accent); }
.he-dir.ovr { background: var(--surface2); color: var(--text-dim); }

.he-meta {
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.he-route {
  font-size: 11px;
  color: var(--text);
  font-weight: 500;
}
.he-route .arrow { color: var(--text-dim); margin: 0 3px; }

.he-stats {
  font-size: 10px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.he-contact {
  display: flex;
  align-items: center;
  gap: 4px;
}
.he-contact-label {
  font-size: 6px;
  line-height: 1;
}

.no-data {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-dim);
  font-size: 13px;
}

/* ── Trail endpoint tooltips ── */
.trail-tooltip {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 11px;
  line-height: 1.4;
  padding: 4px 8px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  border: none;
  text-align: center;
}
.trail-tooltip b {
  font-weight: 600;
  font-size: 12px;
}

/* ── Previously Seen section ── */
.prev-seen-divider {
  padding: 8px 12px 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-top: 1px solid var(--border-light);
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.prev-seen-divider:hover { color: var(--text-secondary); }
.prev-seen-chevron {
  font-size: 10px;
  transition: transform 0.2s;
}
.prev-seen-collapsed .prev-seen-chevron { transform: rotate(-90deg); }

/* ── Version history ── */
.version-entry {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}
.version-entry:last-child { border-bottom: none; }
.version-tag {
  font-size: 13px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
}
.version-date {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}
.version-changes {
  margin: 6px 0 0 16px;
  padding: 0;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.version-changes li { margin-bottom: 2px; }

.flight-card.prev-seen {
  opacity: 0.55;
  cursor: pointer;
}
.flight-card.prev-seen:hover { opacity: 0.8; }
.flight-card.prev-seen.frozen-active {
  opacity: 1;
  border-left: 3px solid var(--accent);
  background: var(--accent-light);
}

.fc-seen-ago {
  font-size: 10px;
  color: var(--text-dim);
  font-style: italic;
}

/* ── Dot legend ── */
.dot-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-top: 1px solid var(--border-light);
  font-size: 10px;
  color: var(--text-dim);
  flex-wrap: wrap;
  flex-shrink: 0; /* never squished — sits below scroll area */
  background: var(--surface);
}
.dot-legend-title {
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 9px;
}
.dot-legend span {
  display: flex;
  align-items: center;
  gap: 4px;
}
.dot-legend .freshness-dot {
  position: static;
  border: 1.5px solid rgba(0,0,0,0.2);
  flex-shrink: 0;
}

/* ── Analytics ── */
.analytics-section {
  padding: 10px 12px 4px;
  border-bottom: 1px solid var(--border-light);
}
.analytics-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.analytics-card {
  flex: 1;
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 8px 10px;
  min-width: 0;
}
.analytics-card .ac-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.analytics-card .ac-label {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-top: 2px;
}
.analytics-card .ac-delta {
  font-size: 9px;
  font-weight: 600;
  margin-top: 2px;
}
.ac-delta.positive { color: #16a34a; }
.ac-delta.negative { color: #dc2626; }
.ac-delta.neutral { color: var(--text-dim); }

.analytics-types, .analytics-routes {
  margin-bottom: 10px;
}
.analytics-subtitle {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 6px;
}
.type-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 11px;
}
.type-bar-bg {
  flex: 1;
  height: 4px;
  background: var(--border-light);
  border-radius: 2px;
  overflow: hidden;
}
.type-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.type-name { color: var(--text-secondary); min-width: 80px; font-size: 10px; }
.type-count { color: var(--text-dim); font-family: 'JetBrains Mono', monospace; font-size: 10px; min-width: 16px; text-align: right; }

/* ── History date navigation ── */
.history-date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.hist-nav-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: background 0.15s;
}
.hist-nav-btn:hover { background: var(--surface2); }
.hist-nav-btn:disabled { opacity: 0.3; cursor: default; }
.hist-date-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text);
}

/* ── Center button ── */
.center-btn {
  width: 26px; height: 26px;
  background: white;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #444;
}
.center-btn:hover { background: #f4f4f4; }

/* ── Map ── */
.map-container { position: relative; overflow: hidden; }
#map { width: 100%; height: 100%; background: var(--bg); }
.leaflet-container { background: var(--bg) !important; }

/* ── Aircraft labels on map ── */
.aircraft-icon-wrapper {
  position: relative;
  pointer-events: auto;
  /* Promote each aircraft marker to its own compositor layer. Without
     this, every position update at 60fps re-rasterises the SVG + label
     text inline with the rest of the map — visible as text "shimmer" on
     planes flying steady. With will-change set, the browser keeps a
     pre-rasterised bitmap on the GPU and only retransforms it. */
  will-change: transform;
  backface-visibility: hidden;
  transform: translateZ(0);
}

/* Counter-scale aircraft markers during a zoom animation so they stay
   at constant pixel size instead of ballooning/shrinking with the map
   and snapping back at zoomend. app.js sets --marker-counter-scale on
   the markerPane in zoomanim, removed at zoomend. */
.leaflet-marker-pane.zooming .aircraft-icon-wrapper {
  transform: translateZ(0) scale(var(--marker-counter-scale, 1));
  transform-origin: center;
}

/* Freshness dot */
.freshness-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.9);
  pointer-events: none;
  z-index: 10;
}
.freshness-dot.fresh  { background: #16a34a; }
.freshness-dot.ok     { background: #d97706; }
.freshness-dot.stale  { background: #dc2626; }
.freshness-dot.lost   { background: #9b9590; }

.aircraft-svg {
  display: block;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.15));
  transition: opacity 0.5s ease;
}

.aircraft-label {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
  font-size: 9px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  pointer-events: none;
  padding-bottom: 3px;
}

.aircraft-label .label-callsign {
  display: block;
  color: var(--text);
  text-shadow: 0 0 4px rgba(255,255,255,0.9), 0 0 8px rgba(255,255,255,0.7);
}

.aircraft-label .label-detail {
  display: block;
  font-size: 8px;
  font-weight: 400;
  color: var(--text-secondary);
  text-shadow: 0 0 4px rgba(255,255,255,0.9);
}

.aircraft-icon-wrapper.highlighted .aircraft-svg {
  filter: drop-shadow(0 0 6px rgba(37,99,235,0.6)) drop-shadow(0 1px 3px rgba(0,0,0,0.15));
}

/* ── Range ring labels ── */
.range-ring-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--text-dim);
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  letter-spacing: 0.3px;
}
/* ── YTZ marker ── */
.ytz-marker {
  width: 18px; height: 18px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: rgba(37,99,235,0.15);
  box-shadow: 0 0 0 4px rgba(37,99,235,0.08);
}

/* ── Popup (hidden — replaced by .plane-card top-right floating panel) ──
   We keep Leaflet's popup machinery alive (it drives activePopupIcao,
   trail rendering, and sidebar card highlighting) but never show the
   bubble on the map. The visible UI is .plane-card below. */
.leaflet-popup { display: none !important; }

/* ── Selected aircraft card (top-right floating panel) ── */
.plane-card {
  position: fixed;
  top: 60px;
  right: 14px;
  width: 272px;                          /* ~20% smaller than original 340px */
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 72px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  z-index: 600;                          /* above map (~400), below modals (1500+) */
  overflow: hidden;
  display: none;
  flex-direction: column;
  font-family: 'Inter', sans-serif;
}
.plane-card.visible { display: flex; }

.plane-card-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.45);
  color: white;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.15s;
}
.plane-card-close:hover { background: rgba(0,0,0,0.7); }

.plane-card-photo {
  width: 100%;
  height: 144px;                          /* 180 → 144 (~20% smaller) */
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 11px;
  flex-shrink: 0;
}
.plane-card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.plane-card-photo.placeholder::before { content: 'No photo available'; }
.plane-card-photo.loading::before { content: 'Loading photo…'; }

.plane-card-body {
  padding: 11px 13px 13px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
  overflow-y: auto;
}
.plane-card-body .pc-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 1px;
}
.plane-card-body .pc-callsign {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.plane-card-body .pc-vstatus {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface2);
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}
.plane-card-body .pc-vstatus.climb { color: #16a34a; background: rgba(22,163,74,0.10); }
.plane-card-body .pc-vstatus.descend { color: #ea580c; background: rgba(234,88,12,0.10); }
.plane-card-body .pc-vstatus.ground { color: var(--text-dim); background: var(--border-light); }
[data-theme="dark"] .plane-card-body .pc-vstatus.climb { color: #4ade80; background: rgba(74,222,128,0.12); }
[data-theme="dark"] .plane-card-body .pc-vstatus.descend { color: #fb923c; background: rgba(251,146,60,0.12); }

.plane-card-body .pc-airline { color: var(--text-secondary); font-size: 11px; }
.plane-card-body .pc-type {
  color: var(--text-secondary);
  font-size: 11px;
  margin-bottom: 6px;
}
.plane-card-body .pc-route {
  font-size: 12px;
  margin: 5px 0 7px;
  padding: 5px 7px;
  background: var(--surface2);
  border-radius: 5px;
}
.plane-card-body .pc-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 8px;
  font-size: 11px;
  color: var(--text-secondary);
}
.plane-card-body .pc-stats b { color: var(--text); font-weight: 600; font-size: 12px; }

@media (max-width: 768px) {
  /* Horizontal compact layout on mobile: small thumbnail on the left,
     body on the right. Roughly halves the vertical screen footprint vs the
     stacked desktop layout (~110-130px tall instead of ~280px). */
  .plane-card {
    top: auto;
    bottom: 8px;
    right: 8px;
    left: 8px;
    width: auto;
    max-width: none;
    max-height: 36vh;
    flex-direction: row;
    align-items: stretch;
  }
  .plane-card-photo {
    width: 88px;
    height: auto;                  /* let flex stretch fill body height */
    min-height: 88px;
    flex-shrink: 0;
    font-size: 9px;                /* "Loading photo…" placeholder text */
  }
  .plane-card-body {
    padding: 8px 10px 9px;
    font-size: 11px;
    line-height: 1.4;
    flex: 1;
    min-width: 0;                  /* allow text to wrap inside flex child */
    overflow-y: auto;
  }
  .plane-card-body .pc-header { gap: 5px; margin-bottom: 0; }
  .plane-card-body .pc-callsign { font-size: 13px; }
  .plane-card-body .pc-vstatus { font-size: 9px; padding: 1px 5px; letter-spacing: 0.02em; }
  .plane-card-body .pc-airline { font-size: 10px; }
  .plane-card-body .pc-type { font-size: 10px; margin-bottom: 3px; }
  .plane-card-body .pc-route {
    font-size: 11px;
    padding: 3px 6px;
    margin: 3px 0 4px;
    border-radius: 4px;
  }
  .plane-card-body .pc-stats {
    font-size: 10px;
    gap: 2px 8px;
    line-height: 1.25;
  }
  .plane-card-body .pc-stats b { font-size: 11px; }
  .plane-card-close {
    top: 3px;
    right: 3px;
    width: 18px;
    height: 18px;
    font-size: 13px;
  }
}

/* ── About overlay ── */
/* ── Info overlay (Notes / Uptime / Version) ── */
.info-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.info-overlay.visible { display: flex; }
.info-panel {
  background: var(--surface);
  border-radius: 16px;
  padding: 32px;
  max-width: 540px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  position: relative;
}
.info-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-dim);
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
}
.info-close:hover { background: var(--surface2); color: var(--text); }

.about-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.about-overlay.visible { display: flex; }

.about-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 0;
  max-width: 460px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.about-card-body {
  padding: 24px 28px 28px;
}

.about-photo {
  width: 100%;
  height: 220px;
  object-fit: cover;
  object-position: center;
  display: block;
  border-radius: 16px 16px 0 0;
}

.about-card h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.about-card p { font-size: 13px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 12px; }
.about-card a { color: var(--accent); text-decoration: none; }
.about-card a:hover { text-decoration: underline; }
.about-card .about-close {
  display: block;
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.about-card .about-close:hover { opacity: 0.9; }

/* ── Dark mode ── */
[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #1e2130;
  --border: #2a2d3a;
  --border-light: #252837;
  --text: #e8e6e1;
  --text-secondary: #9b98a0;
  --text-dim: #5c5a62;
  --accent: #3b82f6;
  --accent-light: #1e3a5f;
  --green-light: #14281e;
  --amber-light: #2a1f0a;
  --red-light: #2a1010;
}

[data-theme="dark"] .leaflet-container { background: #1a1d27 !important; }
[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg); }
[data-theme="dark"] .trail-tooltip { background: var(--surface); color: var(--text); box-shadow: 0 2px 6px rgba(0,0,0,0.4); }

[data-theme="dark"] .aircraft-label .label-callsign {
  text-shadow: 0 0 4px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.7);
}
[data-theme="dark"] .aircraft-label .label-detail {
  text-shadow: 0 0 4px rgba(0,0,0,0.9);
}

[data-theme="dark"] .about-overlay { background: rgba(0,0,0,0.6); }
[data-theme="dark"] .info-overlay { background: rgba(0,0,0,0.6); }

[data-theme="dark"] .status-pill.level { background: var(--border); color: var(--text-dim); }
[data-theme="dark"] .status-pill.ground { background: #3d2f1e; color: #d4a24e; }
[data-theme="dark"] .status-pill.lost { background: var(--border); color: var(--text-dim); }

[data-theme="dark"] .center-btn { background: var(--surface); color: var(--text); }
[data-theme="dark"] .center-btn:hover { background: var(--border-light); }

/* ── Skeleton loading ── */
@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border-light) 37%, var(--surface2) 63%);
  background-size: 400px 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
.skeleton-card {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
}
.skeleton-photo { width: 64px; height: 48px; flex-shrink: 0; border-radius: var(--radius-sm); }
.skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.skeleton-line { height: 10px; border-radius: 4px; }
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w80 { width: 80%; }
.skeleton-line.w40 { width: 40%; }

/* ── Card entrance animation ── */
@keyframes cardEnter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.flight-card.entering {
  animation: cardEnter 0.25s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* ── SVG Charts ── */
.sparkline-container { padding: 12px 0 4px; }
.sparkline-bar-rect { transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1), y 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
.trend-container { padding: 8px 0 4px; }
.donut-container {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
}
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--text-secondary);
}
.donut-legend-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.donut-legend-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--text);
}
.chart-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin: 12px 0 4px;
}

/* ── Toast notifications ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1500;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1), toastOut 0.3s 4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.toast-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.toast-icon.arr { background: rgba(22,163,74,0.1); color: var(--green); }
.toast-icon.dep { background: rgba(37,99,235,0.1); color: var(--accent); }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 600; font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast-subtitle { font-size: 10px; color: var(--text-secondary); margin-top: 1px; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-8px); }
}

/* ── Responsive: mobile edge drawer ── */
@media (max-width: 768px) {
  .header { padding: 0 12px; }
  .header-stats { display: none; }
  .weather-widget { font-size: 10px; padding-right: 6px; }
  .title { font-size: 14px; }

  .main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    position: relative;
  }

  /* Drawer: slides in from the left edge (right side reserved for zoom + center controls) */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: auto;
    width: min(90vw, 420px);
    max-width: 420px;
    height: 100vh;
    max-height: 100vh;
    border-right: 1px solid var(--border);
    border-left: none;
    border-top: none;
    border-radius: 0;
    box-shadow: 8px 0 24px rgba(0,0,0,0.18);
    z-index: 1000;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
  }

  /* Desktop collapse class is a no-op on mobile (drawer is controlled by drawer-open).
     Override the desktop width: 48px rule too, otherwise the drawer opens as a 48px sliver. */
  body.sidebar-collapsed .sidebar {
    width: min(90vw, 420px);
    max-width: 420px;
    transform: translateX(-100%);
  }

  /* Drawer-open wins over sidebar-collapsed when both are set (restored from desktop state) */
  body.drawer-open .sidebar { transform: translateX(0); }

  .sidebar-rail { display: none; }
  .mobile-info-btns {
    display: flex; align-items: center; gap: 2px; margin-left: auto;
  }
  .mobile-info-btn {
    width: 32px; height: 32px; border: none; background: none;
    color: var(--text-dim); cursor: pointer; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s; flex-shrink: 0;
  }
  .mobile-info-btn:active { color: var(--accent); background: var(--surface2); }

  .sidebar-content {
    display: flex !important;
    flex: 1;
    min-height: 0;
  }

  /* Map fills viewport below header */
  .map-container {
    height: calc(100vh - 44px);
  }

  /* Backdrop when drawer is open */
  .drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s;
    z-index: 999;
  }
  body.drawer-open .drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* Floating chip: aircraft count + drawer opener (left side — right reserved for zoom controls) */
  .mobile-fab {
    position: fixed;
    top: 56px;
    left: 12px;
    z-index: 800;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
  }
  .mobile-fab:active { background: var(--surface2); }
  .mobile-fab .fab-count {
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    font-family: 'JetBrains Mono', monospace;
  }
  /* Hide the FAB while the drawer is open (drawer itself is the visible target) */
  body.drawer-open .mobile-fab {
    opacity: 0;
    pointer-events: none;
  }

  /* Mobile: larger touch targets */
  .pill-btn { padding: 6px 12px; font-size: 12px; min-height: 32px; }
  .sort-select { padding: 6px 10px; font-size: 12px; min-height: 32px; }
  .panel-tab { padding: 8px 14px; font-size: 13px; min-height: 36px; }
  .sidebar-search { padding: 10px 12px; font-size: 14px; }

  /* Mobile: compact cards */
  .flight-card { padding: 8px 10px; gap: 8px; }
  .fc-photo { width: 48px; height: 36px; }
  .fc-callsign { font-size: 12px; }
  .fc-meta { font-size: 10px; }
  .fc-details { font-size: 9px; gap: 6px; }
  .he-photo { width: 44px; height: 33px; }
  .history-entry { padding: 8px 6px; }

  /* Mobile: toast position (below FAB) */
  .toast-container { bottom: auto; top: 104px; right: 12px; left: 12px; }
}

/* Hide mobile-only elements on desktop */
@media (min-width: 769px) {
  .mobile-fab, .drawer-backdrop { display: none !important; }
}

/* ── Visualization tab ── */
.viz-view {
  display: flex;
  flex-direction: column;
  padding: 0;
}
.viz-sub-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 4px 12px;
  border-bottom: 1px solid var(--border-light);
}
.viz-sub-btn {
  flex: 1;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Inter', sans-serif;
}
.viz-sub-btn:hover { border-color: var(--accent); color: var(--accent); }
.viz-sub-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.viz-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 12px 12px 12px;
  border-bottom: 1px solid var(--border-light);
}
.viz-time-modes {
  display: flex;
  gap: 4px;
}
.viz-time-btn {
  flex: 1;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Inter', sans-serif;
}
.viz-time-btn:hover { border-color: var(--accent); color: var(--accent); }
.viz-time-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.viz-window-caption {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.35;
  padding: 0 2px;
}
.viz-window-caption:empty { display: none; }
.viz-date-input {
  padding: 5px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  outline: none;
}
.viz-date-input:focus { border-color: var(--accent); }
.viz-filter-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.viz-filter {
  padding: 5px 8px;
  font-size: 11px;
  font-family: 'Inter', sans-serif;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23687080' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}
.viz-filter:focus { border-color: var(--accent); }
.viz-scope-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  background: var(--surface-subtle, rgba(255,255,255,0.03));
  border: 1px solid var(--border);
  border-radius: 10px;
}
.viz-scope-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.viz-scope-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}
.viz-scope-hint {
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.4;
  padding-left: 22px;
}
.viz-stats {
  font-size: 11px;
  color: var(--text-dim);
  padding-top: 2px;
}
.viz-status {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}
.viz-status:empty { display: none; }
.viz-legend {
  padding: 10px 12px;
  font-size: 11px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-light);
}
.viz-legend-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}
.viz-legend-bar {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, rgba(0,0,255,0.2), rgba(0,255,255,0.6), rgba(0,255,0,0.7), rgba(255,255,0,0.8), rgba(255,0,0,0.9));
  margin-bottom: 4px;
}
.viz-legend-scale {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.viz-legend-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}
.viz-legend-lines > div {
  display: flex;
  align-items: center;
  gap: 8px;
}
.viz-line {
  display: inline-block;
  width: 32px;
  height: 2px;
  background: #2563eb;
  border-radius: 1px;
}
.viz-line.thin { height: 1px; opacity: 0.45; }
.viz-line.med  { height: 2px; opacity: 0.7; }
.viz-line.thick { height: 4px; opacity: 0.95; }
.viz-line.paths-demo { background: #38bdf8; height: 1px; opacity: 0.6; }
.viz-legend-note {
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.4;
}
