/* ── Reset & tokens ──────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  overflow-x: hidden;
  width: 100%;
}

:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface2: #e6edf6;
  --border: #8897ab;
  --border2: #bec9d8;
  --text: #0f1724;
  --muted: #2f3d4f;
  --dim: #5a687a;

  --brand: #005fa3;
  --brand-dim: #004b82;
  --teal: #0b7a69;
  --teal-dim: #086354;

  --safe: #1f8f3a;
  --safe-bg: rgba(31, 143, 58, .15);
  --caution: #b56b00;
  --caution-bg: rgba(181, 107, 0, .16);
  --danger: #b42318;
  --danger-bg: rgba(180, 35, 24, .14);

  --font: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Consolas", monospace;
  --r: 8px;
}

body {
  font-family: var(--font);
  background:
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 220px);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 60px;
  margin: 0;
  width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

/* ── Loading overlay ──────────────────────────────── */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 36, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.show {
  opacity: 1;
  visibility: visible;
}

.loading-content {
  text-align: center;
  color: #ffffff;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.topbar-centered {
  justify-content: center;
}

.modern-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  margin: 10px auto 8px auto;
  max-width: 1100px;
  width: calc(100% - 32px);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 2;
  overflow: hidden;
}

body:not(.night-jump) .modern-header {
  background: linear-gradient(180deg, #ffffff 0%, #f6f8fb 100%);
}

.header-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 10px 0 5px 0;
  gap: 1px;
}

/* Ensure station-bar never overlaps header */
.station-bar {
  margin-top: 0 !important;
  position: relative;
  z-index: 1;
  background: transparent;
  border-bottom: none;
  padding-top: 0;
}

.main-title-modern {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.1;
  text-align: center;
  margin-bottom: 0px;
}

.beta-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #b56b00;
  background: #fff2d9;
  color: #8a4f00;
  font-size: 0.62em;
  font-weight: 800;
  letter-spacing: 0.08em;
  vertical-align: middle;
}

.by-label-modern {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin-bottom: 0px;
  margin-top: 0px;
  text-align: center;
  opacity: 0.92;
}

.main-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.01em;
}

.dz-red {
  color: #ff0000;
  text-shadow: 2px 2px 0 #000, 4px 4px 0 #000;
}

.aloft-yellow {
  color: #ffd600;
  text-shadow: 2px 2px 0 #000, 4px 4px 0 #000;
}

.by-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: -2px;
}

.skyjunk-logo-small {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.topbar-sep {
  flex: 1;
}

.topbar-meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.provider-badge {
  display: inline-block;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  margin-right: 6px;
  background: var(--surface2);
  color: var(--text);
  font-size: 0.7rem;
  font-weight: 600;
}

.topbar-controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding-bottom: 6px;
  z-index: 10;
}

.btn-night {
  display: none !important;
  /* Hidden completely for now */
  position: absolute;
  top: 12px;
  right: 12px;
  height: 32px;
  padding: 0 10px;
  z-index: 20;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.btn-night.active {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* Night-vision-safe palette: dark base + low-glare warm/red accents */
body.night-jump {
  --bg: #0b0b0b;
  --surface: #111111;
  --surface2: #1a1a1a;
  --border: #5d4a4a;
  --border2: #3f3232;
  --text: #ffd7c2;
  --muted: #d39d83;
  --dim: #9a7161;
  --brand: #cc4b1f;
  --brand-dim: #a53a17;
  --teal: #c0612f;
  --teal-dim: #9d4f27;
  --safe: #d58e24;
  --safe-bg: rgba(213, 142, 36, .14);
  --caution: #e3651b;
  --caution-bg: rgba(227, 101, 27, .16);
  --danger: #f0472f;
  --danger-bg: rgba(240, 71, 47, .16);
}

/* ── Station input bar (Schulze-style search) ──── */
.station-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border2);
  padding: 8px 16px;
  width: 100%;
  box-sizing: border-box;
  margin-top: 0 !important;
}

.station-bar-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  width: 100%;
  box-sizing: border-box;
}

.quick-search {
  display: flex;
  align-items: center;
  width: 100%;
}

.btn-search-toggle {
  height: 34px;
  width: 34px;
  min-width: 34px;
  padding: 0;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 150ms, color 150ms, background 150ms;
}

.btn-search-toggle:hover,
.btn-search-toggle[aria-expanded="true"] {
  border-color: var(--teal);
  color: var(--text);
}

.quick-search-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 0;
  opacity: 0;
  overflow: hidden;
  max-height: 0;
  transition: width 200ms ease, opacity 150ms ease, max-height 180ms ease;
  width: 100%;
}

.quick-search.expanded .quick-search-input-wrap {
  width: 100%;
  opacity: 1;
  max-height: 44px;
}

#dz-search-input {
  height: 36px;
  flex: 1;
  width: auto;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.92rem;
  padding: 0 10px;
}

#dz-search-input:focus {
  border-color: var(--brand);
  outline: none;
}

.btn-search-fetch {
  height: 36px;
  min-width: 58px;
  padding: 0 10px;
  border: 1px solid var(--brand);
  border-radius: var(--r);
  background: var(--brand);
  color: #fff;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.btn-search-fetch:hover {
  background: var(--brand-dim);
  border-color: var(--brand-dim);
}

.btn-search-fetch:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 600;
}

.field input,
.field select {
  height: 44px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-family: var(--mono);
  font-size: 1rem;
  padding: 0 12px;
  outline: none;
  transition: border-color 150ms;
}

.field input:focus,
.field select:focus {
  border-color: var(--brand);
}

.field.wide {
  flex: 1;
}

.field.icao {
  min-width: 70px;
  flex: 0 1 auto;
}

.field-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.field.action-field {
  justify-content: flex-end;
  gap: 0;
}

.field-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.advanced-controls {
  display: none;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.advanced-controls.show {
  display: flex;
}

.btn-advanced {
  height: 40px;
  padding: 0 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--r);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  align-self: flex-start;
  cursor: pointer;
}

.btn-advanced:hover {
  border-color: var(--brand);
  color: var(--text);
}

.btn-share-link {
  height: 34px;
  width: 34px;
  min-width: 34px;
  padding: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--r);
  font-size: 0.8rem;
  align-self: center;
  position: relative;
  cursor: pointer;
  transition: border-color 150ms, color 150ms, background 150ms, opacity 150ms;
}

.btn-share-link:hover:not(:disabled) {
  border-color: var(--teal);
  color: var(--text);
}

.btn-share-link:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-share-link svg {
  opacity: 0.85;
}

.btn-share-link:hover:not(:disabled) svg {
  opacity: 1;
}

.btn-share-link.is-copied {
  border-color: var(--safe);
  color: var(--safe);
}

.btn-share-link.is-copied::after {
  content: attr(data-copy-state);
  position: absolute;
  top: -24px;
  right: -2px;
  background: var(--safe);
  color: #fff;
  border-radius: 10px;
  padding: 2px 7px;
  font-size: 0.62rem;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.03em;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
  pointer-events: none;
}

.field-actions .btn-advanced {
  height: 34px;
  padding: 0 10px;
  font-size: 0.73rem;
  align-self: center;
}

.btn {
  height: 44px;
  padding: 0 18px;
  border-radius: var(--r);
  border: none;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 150ms, opacity 150ms;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-dim);
}

.btn-geo {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-geo:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.btn-geo.geo-denied {
  border-color: var(--danger);
  color: var(--danger);
}

.geo-permission-note {
  margin-top: 4px;
  min-height: 14px;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--dim);
}

.geo-permission-note.denied {
  color: var(--danger);
}

.btn-unit {
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  height: 36px;
  padding: 0 12px;
}

.btn-unit.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* ── Main layout ────────────────────────────────── */
.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}

/* ── Left column ───────────────────────────────── */
.left-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  max-width: 100%;
  min-width: 0;
}

/* All card elements - ensure they don't exceed container */
.loc-card,
.compass-card,
.wind-table-wrap,
.jr-card,
.drift-card,
.weather-card,
.nearby-wrap {
  max-width: 100%;
  box-sizing: border-box;
}

/* ── Location card (Schulze style) ──────────────── */
.loc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px;
}

.loc-name {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.loc-detail {
  font-size: 0.82rem;
  color: var(--muted);
  font-family: var(--mono);
  margin-bottom: 10px;
}

.loc-coords {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.coord-pill {
  font-family: var(--mono);
  font-size: 0.74rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 7px;
  color: var(--muted);
}

.weather-buttons {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-weather {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 120ms;
  font-family: inherit;
  flex: 1;
  min-width: 120px;
  justify-content: center;
}

.btn-weather:hover {
  background: var(--surface2);
  border-color: var(--brand);
  color: var(--brand);
}

.btn-weather svg {
  opacity: 0.7;
}

.btn-weather:hover svg {
  opacity: 1;
}

/* ── Compass card (Schulze style) ───────────────── */
.compass-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px;
  text-align: center;
}

.compass-card-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 10px;
}

.compass-wrap {
  position: relative;
  width: 176px;
  height: 176px;
  margin: 0 auto 12px;
}

.compass-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: radial-gradient(circle at 50% 50%, rgba(31, 111, 235, .06), transparent 70%);
}

/* Cardinal labels */
.compass-cardinal {
  position: absolute;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--dim);
  line-height: 1;
}

.cardinal-n {
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
}

.cardinal-s {
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
}

.cardinal-e {
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
}

.cardinal-w {
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
}

/* Tick marks */
.compass-ticks {
  position: absolute;
  inset: 0;
}

.needle-group {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.needle-svg {
  width: 70%;
  height: 70%;
  transform-origin: center;
  transform: rotate(278deg);
  transition: transform 600ms cubic-bezier(.34, 1.56, .64, 1);
}

.compass-readout {
  font-family: var(--mono);
  font-size: 1rem;
}

.compass-readout strong {
  font-size: 1.45rem;
  color: var(--text);
}

.compass-readout .muted {
  color: var(--muted);
  font-size: 0.86rem;
}

.gust-inline {
  color: var(--caution);
  font-size: 1.05rem;
  font-weight: 700;
  margin-left: 6px;
}

/* ── Safety summary cards (skydiver additions) ──── */
.safety-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.safety-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px;
  position: relative;
  overflow: hidden;
}

.safety-tile::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}

.safety-tile.safe::before {
  background: var(--safe);
}

.safety-tile.caution::before {
  background: var(--caution);
}

.safety-tile.danger::before {
  background: var(--danger);
}

.safety-tile-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}

.safety-tile-val {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 600;
  margin-top: 2px;
}

.safety-tile-sub {
  font-size: 0.72rem;
  color: var(--muted);
}

.safety-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 3px;
  padding: 2px 5px;
  margin-top: 4px;
}

.badge-safe {
  background: var(--safe-bg);
  color: var(--safe);
}

.badge-caution {
  background: var(--caution-bg);
  color: var(--caution);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.risk-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid var(--border);
}

.risk-dot.badge-safe {
  background: var(--safe);
}

.risk-dot.badge-caution {
  background: var(--caution);
}

.risk-dot.badge-danger {
  background: var(--danger);
}

/* ── Right column ──────────────────────────────── */
.right-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 100%;
  min-width: 0;
}

/* ── Issued / valid header (USAirnet style) ───── */
.isu-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.isu-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.isu-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 600;
}

.isu-val {
  font-family: var(--mono);
  font-size: 0.88rem;
}

.data-age {
  font-size: 0.68rem;
  font-weight: 500;
  margin-top: 2px;
}

.data-age.fresh {
  color: #22c55e;
}

.data-age.moderate {
  color: #f59e0b;
}

.data-age.stale {
  color: #ef4444;
}

.next-update {
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 2px;
  opacity: 0.85;
}

.isu-sep {
  flex: 1;
}

.unit-toggle {
  display: flex;
  gap: 4px;
  align-items: center;
}

/* ── Wind table (USAirnet style) ─────────────── */
.wind-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: visible;
  width: 100%;
  max-width: 100%;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 100%;
  border-radius: 0 0 var(--r) var(--r);
}

.wind-table-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border2);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  position: relative;
}

.wind-table-header h2 {
  font-size: 0.92rem;
  font-weight: 600;
}

.table-mode-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface2);
}

.table-mode-btn {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 7px 11px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.table-mode-btn:hover {
  color: var(--text);
}

.table-mode-btn.active {
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 95, 163, 0.22);
}

.table-view-panel[hidden] {
  display: none;
}

.wind-source-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border2);
  background: var(--surface2);
}

.src-chip {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--surface);
}

.src-chip strong {
  color: var(--text);
  font-weight: 600;
}

.src-chip-aloft {
  background: #1f6feb;
  border-color: #1f6feb;
  color: #ffffff;
}

.src-chip-aloft strong,
.src-chip-aloft #src-aloft {
  color: #ffffff;
}

.src-chip-surface {
  background: #238636;
  border-color: #238636;
  color: #ffffff;
}

.src-chip-surface strong,
.src-chip-surface #src-surface {
  color: #ffffff;
}

.src-chip-time {
  background: #0b4f85;
  border-color: #0b4f85;
  color: #ffffff;
}

.src-chip-time strong,
.src-chip-time #src-local-time {
  color: #ffffff;
}

.src-chip-fallback {
  background: #f39c12;
  border-color: #f39c12;
  color: #1f1300;
  font-weight: 600;
}

.station-selector-advanced {
  position: relative;
  width: 100%;
}

.btn-station-picker {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 120ms, border-color 120ms;
}

.btn-station-picker:hover {
  background: var(--surface2);
  border-color: var(--brand);
}

.station-dropdown-icon {
  opacity: 0.6;
  transition: transform 150ms, opacity 150ms;
}

.btn-station-picker:hover .station-dropdown-icon {
  opacity: 1;
}

.station-selector-advanced.open .station-dropdown-icon {
  transform: rotate(180deg);
}

.station-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  max-height: 300px;
  overflow: hidden;
  z-index: 1000;
  display: none;
}

.station-selector-advanced.open .station-dropdown {
  display: block;
}

.station-dropdown-header {
  padding: 10px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.station-dropdown-list {
  max-height: 250px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 1px;
  background: var(--border2);
}

table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead {
  background: var(--surface2);
}

th {
  padding: 10px 12px;
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border2);
  font-family: var(--mono);
  font-size: 0.85rem;
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(0, 95, 163, .08);
}

/* ── Combined matrix (horizontal time-column forecast grid) ── */
.combined-matrix-shell {
  overflow: hidden;
}

.combined-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.combined-table-scroll::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 18px;
  background: linear-gradient(to right, transparent, rgba(244,245,247,0.9));
  pointer-events: none;
  z-index: 2;
}

.combined-matrix-table {
  width: max-content;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.combined-matrix-table .m-label-col { width: 72px; min-width: 72px; max-width: 72px; }
.combined-matrix-table .m-hour-col  { width: 60px; min-width: 60px; max-width: 60px; }

.combined-matrix-table th,
.combined-matrix-table td {
  border: 1px solid var(--border);
  text-align: center;
  padding: 0;
  line-height: 1;
  height: 22px;
}

.combined-matrix-table .m-sticky {
  position: sticky;
  left: 0;
  z-index: 3;
}

.combined-matrix-table thead .m-sticky { z-index: 5; }

/* Date header row */
.combined-matrix-table .m-head-date th {
  background: #121212;
  color: #f3f4f6;
  font-size: 13px;
  font-weight: 700;
  height: 20px;
}

/* Hour header row */
.combined-matrix-table .m-head-hour th {
  background: linear-gradient(180deg, #434343 0%, #2f2f2f 100%);
  color: #f3f4f6;
  font-size: 11px;
  font-weight: 700;
  height: 28px;
  line-height: 1.2;
  border-bottom: 2px solid #6b7280;
}

.combined-matrix-table .m-head-hour th.m-sticky {
  background: linear-gradient(180deg, #5b5b5b 0%, #434343 100%);
  color: #fff;
}

/* Row label cells (left sticky column) */
.combined-matrix-table .m-left {
  background: linear-gradient(180deg, #5f6b78 0%, #495462 100%);
  color: #f9fafb;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.03em;
  font-weight: 700;
  padding: 4px 5px;
  line-height: 1.1;
  text-align: left;
}

.combined-matrix-table .m-left small {
  display: block;
  font-size: 9px;
  text-transform: none;
  opacity: 0.96;
  color: #e5e7eb;
  letter-spacing: 0;
  margin-top: 2px;
}

/* Sky row */
.combined-matrix-table .m-sky-cell {
  font-size: 9px;
  font-weight: 600;
  line-height: 1.1;
  padding: 2px 1px;
  background: #fff;
  height: 46px;
  vertical-align: top;
}

.combined-matrix-table .m-sky-icon {
  display: block;
  font-size: 18px;
  line-height: 1;
  margin-bottom: 2px;
}

.combined-matrix-table .m-sky-label {
  display: block;
  font-size: 9px;
  color: #374151;
  word-break: break-word;
  hyphens: auto;
}

/* Precip row */
.combined-matrix-table .m-precip-cell {
  position: relative;
  height: 22px;
  background: linear-gradient(180deg, #fffdf8 0%, #f6eada 100%);
  overflow: hidden;
}

.combined-matrix-table .m-pfill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, #7da8e4 0%, #5a87c8 100%);
  opacity: 0.9;
}

.combined-matrix-table .m-pval {
  position: absolute;
  top: 3px; left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 700;
  color: #2f5388;
  z-index: 1;
  white-space: nowrap;
}

/* Cloud row */
.combined-matrix-table .m-cloud-cell {
  position: relative;
  height: 30px;
  background: linear-gradient(180deg, #fbfdff 0%, #edf2f8 100%);
  overflow: hidden;
}

.combined-matrix-table .m-cfill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, #a7b4c4 0%, #7f90a6 100%);
  opacity: 0.85;
}

.combined-matrix-table .m-cval {
  position: absolute;
  top: 2px; left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 700;
  color: #314255;
  z-index: 1;
  white-space: nowrap;
}

.combined-matrix-table .m-cbase {
  position: absolute;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 700;
  color: #46566a;
  z-index: 1;
  white-space: nowrap;
}

/* Temp row */
.combined-matrix-table .m-temp-cell {
  position: relative;
  height: 36px;
  background: #f0e6d9;
  overflow: hidden;
}

.combined-matrix-table .m-temp-fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, #b04036 0%, #cd623e 38%, #e6b84b 100%);
}

.combined-matrix-table .m-temp-val {
  position: absolute;
  top: 4px; left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  color: #3f2d29;
  z-index: 1;
  white-space: nowrap;
}

/* Wind direction row */
.combined-matrix-table .m-dir-cell {
  background: #f6eee6;
  padding: 2px;
  height: 30px;
}

.combined-matrix-table .m-dir-deg {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: #888;
  line-height: 1;
}

.combined-matrix-table .m-dir-card {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #5a3a31;
}

.combined-matrix-table .m-dir-arrow {
  display: block;
  font-size: 14px;
  color: #5678a7;
}

/* Surface wind + gust — numeric cells, ws-* color bands */
.combined-matrix-table .m-wind-cell {
  height: 22px;
  font-size: 13px;
  font-weight: 800;
}

/* Upper winds section header */
.combined-matrix-table .m-upper-head td {
  background: #121212;
  color: #f3f4f6;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.03em;
  font-weight: 700;
  height: 18px;
  padding: 2px 4px;
  text-align: left;
}

/* Upper wind data cells */
.combined-matrix-table .m-upper-row td:not(.m-sticky) {
  background: #f9f2e9;
  font-weight: 700;
  font-size: 11px;
  color: #563a32;
  height: 22px;
}

/* Wind speed color bands (applies to upper wind cells and surface/gust) */
.combined-matrix-table td.ws-calm     { background: #e9f5ff !important; color: #0f3d73 !important; }
.combined-matrix-table td.ws-light    { background: #d6ecff !important; color: #0f3d73 !important; }
.combined-matrix-table td.ws-moderate { background: #bfe1ff !important; color: #12365f !important; }
.combined-matrix-table td.ws-brisk    { background: #ffe9b8 !important; color: #5b3b00 !important; }
.combined-matrix-table td.ws-strong   { background: #ffd2a8 !important; color: #6a2d00 !important; }
.combined-matrix-table td.ws-extreme  { background: #ef4444 !important; color: #ffffff !important; }

/* legacy combined-* names kept so old JS refs don't hard-crash */
.combined-value-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.combined-empty {
  color: var(--dim);
}

/* Row left border — risk grade (same scale as dot + speed text) */
tr.speed-ok td:first-child {
  border-left: 3px solid var(--safe);
}

tr.speed-watch td:first-child {
  border-left: 3px solid var(--caution);
}

tr.speed-fast td:first-child {
  border-left: 3px solid var(--danger);
}

tr.speed-too-fast td:first-child {
  border-left: 3px solid var(--danger);
}

.alt-cell {
  font-weight: 600;
  color: var(--text);
}

.spd-cell {
  font-size: 0.92rem;
  font-weight: 600;
}

.spd-cell.speed-ok,
.gust-val.speed-ok {
  color: var(--safe);
}

.spd-cell.speed-watch,
.gust-val.speed-watch {
  color: var(--caution);
}

.spd-cell.speed-fast,
.spd-cell.speed-too-fast,
.gust-val.speed-fast,
.gust-val.speed-too-fast {
  color: var(--danger);
}

.dir-cell {
  color: #0c4f83;
  font-weight: 600;
  white-space: nowrap;
}

.dir-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.dir-compass {
  color: var(--dim);
  font-size: 0.75rem;
}

.dir-arrow {
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
  opacity: 0.7;
}

.temp-cell {
  color: var(--muted);
}

/* ── Column visibility ───────────────────────────── */
/* Layer now shown on all screen sizes including mobile */
th.col-layer,
td.col-layer {
  display: table-cell;
}

/* Risk hidden by default */
th.col-risk,
td.col-risk {
  display: none;
}

/* Gust value — color set by speed-* class from riskClass() */
.gust-val {
  font-weight: 500;
}

.gust-none {
  color: var(--dim);
}

/* Surface / low-alt rows */
tr.layer-surface td:first-child {
  border-left: 3px solid var(--safe);
}

/* ── Table horizontal scroll (mobile) ───────────── */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Jump run card ───────────────────────────────── */
.jr-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px;
  text-align: center;
}

.jr-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 2px;
}

.jr-sub {
  font-size: 0.72rem;
  color: var(--dim);
  margin-bottom: 10px;
}

#jr-compass {
  width: 176px;
  height: 176px;
  display: block;
  margin: 0 auto 10px;
  cursor: help;
}

.jr-readout {
  font-family: var(--mono);
  font-size: 0.82rem;
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.jr-readout strong {
  color: var(--text);
  font-size: 1rem;
}

.jr-method {
  font-size: 0.68rem;
  color: var(--dim);
  line-height: 1.45;
}

/* ── Drift estimate row ────────────────────────── */
.drift-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px;
}

.drift-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 10px;
}

.drift-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.drift-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  flex: 1;
  min-width: 100px;
}

.drift-item-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}

.drift-item-val {
  font-family: var(--mono);
  font-size: 1.0rem;
  font-weight: 600;
  margin-top: 3px;
}

.drift-item-sub {
  font-size: 0.7rem;
  color: var(--muted);
}

.weather-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px;
}

.radar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px;
  display: none;
}

.radar-card.show {
  display: block;
}

.radar-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.radar-card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.radar-source-link {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 8px;
}

.radar-source-link:hover {
  color: var(--text);
  text-decoration: underline;
}

.radar-image-wrap {
  border: 1px solid var(--border2);
  border-radius: 6px;
  overflow: hidden;
  background: #0b0f14;
}


#radar-embed {
  display: block;
  width: 100%;
  height: 420px;
  border: 0;
}

@media (max-width: 600px) {
  #radar-embed {
    height: 320px;
  }
}

/* ── Nearby stations (USAirnet style) ─────────── */
.nearby-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  width: 100%;
}

.nearby-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border2);
  font-size: 0.85rem;
  font-weight: 600;
}

.nearby-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 1px;
  background: var(--border2);
}

.nearby-station {
  background: var(--surface);
  padding: 8px 10px;
  cursor: pointer;
  transition: background 120ms;
}

.nearby-station:hover {
  background: var(--surface2);
}

.nearby-station.active {
  background: rgba(31, 111, 235, .15);
  border-bottom: 2px solid var(--brand);
}

.nearby-station.nearby-major {
  background: rgba(11, 122, 105, .12);
  border-left: 3px solid var(--teal);
}

.nearby-station.nearby-major:hover {
  background: rgba(11, 122, 105, .18);
}

.nearby-icao {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.nearby-dist {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 1px;
}

/* ── Footer note ──────────────────────────────── */
.footer-note {
  max-width: 1100px;
  margin: 16px auto 0;
  padding: 0 16px;
  font-size: 0.78rem;
  color: var(--dim);
  line-height: 1.5;
}

.footer-about-link {
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.footer-about-link:hover {
  color: var(--text);
  text-decoration: underline;
}

.pre-header-nav {
  text-align: center;
  padding: 0 16px 8px;
}

.footer-brand {
  max-width: 1100px;
  margin: 14px auto 0;
  padding: 0 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.footer-brand-copy {
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.footer-brand-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  gap: 8px;
  color: inherit;
  text-decoration: none;
}

.footer-brand-link:hover,
.footer-brand-link:focus,
.footer-brand-link:active,
.footer-brand-link:visited {
  color: inherit;
  text-decoration: none;
}

.footer-brand-logo {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.footer-brand-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
}

.footer-support {
  max-width: 1100px;
  margin: 14px auto 20px;
  padding: 0 16px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.raw-tools {
  max-width: 1100px;
  margin: 10px auto 0;
  padding: 0 16px;
  display: flex;
  justify-content: flex-end;
}

.raw-panel {
  max-width: 1100px;
  margin: 8px auto 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.45;
  white-space: pre-wrap;
  display: none;
  overflow-x: auto;
}

.raw-panel.show {
  display: block;
}

/* ── Responsive ───────────────────────────────── */
@media (min-width: 900px) {
  .station-bar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .field-stack {
    flex: 1 1 560px;
  }

  .field.action-field {
    flex: 0 0 auto;
    padding-top: 23px;
    align-self: flex-start;
  }

  .field.action-field .btn {
    white-space: nowrap;
  }

  .main {
    max-width: 1280px;
    grid-template-columns: minmax(320px, 360px) 1fr;
  }

  .left-col {
    display: flex;
    flex-direction: column;
  }

  .topbar-meta {
    display: block;
  }
}

@media (max-width: 899px) {
  .main {
    grid-template-columns: 1fr;
  }

  .left-col {
    grid-template-columns: 1fr 1fr;
  }

  .loc-card {
    grid-column: 1 / -1;
  }

  .jr-card {
    grid-column: 1 / -1;
  }

  .safety-grid {
    grid-template-columns: repeat(4, 1fr);
    grid-column: 1 / -1;
  }

  .isu-header {
    gap: 10px;
  }

  .topbar-meta {
    display: none;
  }
}

@media (max-width: 600px) {
  .left-col {
    grid-template-columns: 1fr;
  }

  .table-mode-toggle {
    width: 100%;
    margin-left: 0;
  }

  .table-mode-btn {
    flex: 1 1 0;
    text-align: center;
  }

  .compass-card {
    grid-column: 1 / -1;
  }

  .compass-wrap {
    width: 140px;
    height: 140px;
  }

  .safety-grid {
    grid-template-columns: 1fr 1fr;
  }

  .drift-row {
    flex-direction: column;
  }

  .drift-item {
    min-width: unset;
  }

  .isu-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .unit-toggle {
    align-self: flex-start;
  }

  .field.icao {
    min-width: 60px;
  }
}

@media (max-width: 520px) {
  html {
    margin: 0;
    width: 100%;
    box-sizing: border-box;
  }

  body {
    padding-bottom: 20px;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
  }

  .station-bar {
    padding: 10px 16px;
  }

  .station-bar-inner {
    max-width: 100%;
    margin: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .quick-search {
    width: 100%;
  }

  .quick-search-input-wrap {
    width: 0;
    opacity: 0;
    max-height: 0;
  }

  .quick-search.expanded .quick-search-input-wrap {
    width: 100%;
    opacity: 1;
    max-height: 44px;
  }

  .btn-search-toggle {
    display: inline-flex;
  }

  #dz-search-input {
    height: 44px;
    font-size: 16px;
  }

  .btn-search-fetch {
    height: 44px;
    min-width: 66px;
    font-size: 0.86rem;
  }

  .field-stack {
    width: 100%;
  }

  .compass-wrap {
    width: 120px;
    height: 120px;
  }

  .field {
    gap: 6px;
  }

  .field input,
  .field select {
    font-size: 16px;
    height: 44px;
  }

  .field.icao {
    width: 100%;
  }

  .field.wide {
    width: 100%;
  }

  .advanced-controls {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .field-actions {
    width: 100%;
  }

  .nearby-list {
    grid-template-columns: repeat(3, 1fr);
  }

  .jr-readout {
    gap: 8px;
    flex-direction: column;
  }

  .topbar {
    padding: 0 16px;
    height: auto;
  }

  .topbar-logo {
    font-size: 0.95rem;
  }

  .btn-night {
    font-size: 0.75rem;
    padding: 0 10px;
    height: 36px;
  }

  .btn-primary,
  .btn-geo,
  .btn {
    height: 44px;
    font-size: 0.9rem;
    width: 100%;
  }

  .field-actions .btn-share-link,
  .field-actions .btn-search-toggle,
  .field-actions .btn-advanced {
    height: 40px;
  }

  .field-actions .btn-advanced {
    flex: 1;
    min-width: 120px;
  }

  .field-actions .btn-share-link,
  .field-actions .btn-search-toggle {
    flex: 0 0 40px;
    width: 40px;
    min-width: 40px;
  }

  .main {
    max-width: 100%;
    padding: 16px;
    gap: 12px;
    margin: 0;
  }

  .loc-card,
  .compass-card,
  .wind-table-wrap,
  .jr-card,
  .drift-card,
  .weather-card,
  .radar-card,
  .nearby-wrap {
    padding: 12px;
  }

  .wind-table-wrap {
    overflow: visible;
  }

  .table-scroll {
    overflow-x: auto;
    width: 100%;
  }

  table {
    font-size: 0.85rem;
  }

  th,
  td {
    padding: 8px 10px;
  }

  .compass-wrap {
    width: 140px;
    height: 140px;
  }

  .drift-item {
    min-width: unset;
    padding: 8px 10px;
  }

  .drift-item-val {
    font-size: 0.95rem;
  }

  .drift-row {
    gap: 8px;
  }

  .footer-note,
  .footer-brand,
  .footer-support {
    padding: 0 16px;
  }

  .raw-tools {
    padding: 0 12px;
  }

  .raw-panel {
    padding: 10px;
    margin: 8px auto 0;
  }
}

@media (max-width: 380px) {
  .topbar-logo small {
    display: none;
  }

  .topbar {
    padding: 0 10px;
  }

  .nearby-list {
    grid-template-columns: repeat(2, 1fr);
  }

  .safety-grid {
    grid-template-columns: 1fr;
  }

  .isu-header {
    padding: 8px 10px;
    gap: 8px;
  }

  .isu-val {
    font-size: 0.8rem;
  }

  .main {
    padding: 10px 10px 0;
  }

  .station-bar {
    padding: 10px;
  }

  .station-bar-inner {
    gap: 6px;
  }

  .field.icao {
    min-width: 55px;
    font-size: 0.85rem;
  }

  .btn {
    font-size: 0.85rem;
    padding: 0 10px;
  }

  .field-actions .btn-share-link,
  .field-actions .btn-search-toggle,
  .field-actions .btn-advanced {
    font-size: 0.74rem;
    padding: 0 10px;
  }

  .field-actions .btn-share-link,
  .field-actions .btn-search-toggle {
    width: 36px;
    min-width: 36px;
    flex-basis: 36px;
  }

  th,
  td {
    padding: 6px 8px;
    font-size: 0.75rem;
  }

  .compass-wrap {
    width: 100px;
    height: 100px;
  }
}

/* ── Subtle entrance animation ──────────────────── */
.fade-in {
  opacity: 0;
  animation: fi 400ms ease forwards;
}

.fi-1 {
  animation-delay: 60ms;
}

.fi-2 {
  animation-delay: 120ms;
}

.fi-3 {
  animation-delay: 180ms;
}

.fi-4 {
  animation-delay: 240ms;
}

.fi-5 {
  animation-delay: 300ms;
}

@keyframes fi {
  to {
    opacity: 1;
  }
}