  /* Visually hidden but accessible to search crawlers and screen readers. */
  .sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  :root {
    --sky: #0a1628;
    --sky-mid: #0d2045;
    --sky-light: #102850;
    --panel: #0e1e38;
    --panel-border: rgba(100,160,255,0.15);
    --accent: #4fa3ff;
    --accent-dim: rgba(79,163,255,0.15);
    --accent-glow: rgba(79,163,255,0.4);
    --green: #3de8a0;
    --green-dim: rgba(61,232,160,0.12);
    --amber: #f5c842;
    --amber-dim: rgba(245,200,66,0.12);
    --red: #ff5e5e;
    --text: #e8f0ff;
    --text-dim: rgba(200,220,255,0.5);
    --text-muted: rgba(200,220,255,0.3);
    --mono: 'JetBrains Mono', monospace;
    --sans: 'DM Sans', sans-serif;
    --radius: 6px;
    /* live header height (incl. safe-area); JS refreshes it so the mobile drawer always sits flush under the header */
    --header-h: calc(52px + env(safe-area-inset-top, 0));
  }

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

  html, body { height: 100%; }
  body {
    background: var(--sky);
    color: var(--text);
    font-family: var(--sans);
    min-height: 100vh;
    min-height: 100dvh;        /* dynamic viewport: fit the *visible* area, not under iOS/iPadOS Safari toolbars */
    height: 100dvh;
    overflow: hidden;          /* fixed full-viewport shell — no page-level scrollbar */
    display: flex;
    flex-direction: column;
  }

  /* HEADER */
  header {
    background: var(--panel);
    border-bottom: 1px solid var(--panel-border);
    /* reserve room for the notch/safe-area so the bar is never clipped under browser chrome */
    padding: env(safe-area-inset-top, 0) calc(20px + env(safe-area-inset-right, 0)) 0 calc(20px + env(safe-area-inset-left, 0));
    height: calc(52px + env(safe-area-inset-top, 0));
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
    position: relative;
    z-index: 1200;                 /* keep the hover bubble above the map */
  }
  .brand {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .brand-mark {
    font-family: var(--mono);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--text);
    text-transform: uppercase;
  }
  .brand-air { color: var(--accent); }
  .brand-chip {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    padding: 2px 7px;
    white-space: nowrap;
  }
  .header-sep { flex: 1; }
  .lang-switch {
    display: flex;
    gap: 2px;
    margin-left: 14px;
    background: rgba(10,22,40,0.6);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    padding: 3px;
  }
  .lang-btn {
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-dim);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 4px 8px;
    cursor: pointer;
    transition: all 0.15s;
  }
  .lang-btn:hover { color: var(--text); background: rgba(255,255,255,0.06); }
  .lang-btn.active { background: var(--accent); color: var(--sky); box-shadow: 0 0 12px var(--accent-glow); }
  .info-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    margin-left: 10px;
    padding: 0;
    background: rgba(10,22,40,0.6);
    border: 1px solid var(--panel-border);
    border-radius: 50%;
    color: var(--text-dim);
    cursor: pointer;
    flex-shrink: 0;
    transition: color .15s, background .15s, border-color .15s;
  }
  .info-btn:hover { color: var(--accent); background: rgba(79,163,255,0.12); border-color: rgba(79,163,255,0.3); }

  /* MOBILE DRAWER CONTROLS — hidden on desktop, revealed in the phone media query */
  .panel-toggle {
    display: none;
    position: relative;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    padding: 0;
    margin-right: 2px;
    background: rgba(10,22,40,0.6);
    border: 1px solid var(--panel-border);
    border-radius: 9px;
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
    transition: color .15s, background .15s, border-color .15s;
  }
  .panel-toggle:active { transform: scale(0.95); }
  body.drawer-open .panel-toggle {
    color: var(--accent);
    background: rgba(79,163,255,0.14);
    border-color: rgba(79,163,255,0.35);
  }
  .panel-toggle-badge {
    position: absolute;
    top: -5px; right: -5px;
    min-width: 17px; height: 17px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: var(--sky);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    border-radius: 9px;
    box-shadow: 0 0 0 2px var(--panel), 0 0 10px var(--accent-glow);
  }
  .panel-toggle-badge[hidden] { display: none; }

  .drawer-close {
    display: none;
    position: absolute;
    top: 9px; right: 10px;
    z-index: 5;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    padding: 0;
    background: rgba(10,22,40,0.6);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    color: var(--text-dim);
    cursor: pointer;
  }
  .drawer-close:active { transform: scale(0.95); }

  .drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1050;
    background: rgba(5,11,22,0.55);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s ease;
  }
  .header-badge {
    background: var(--accent-dim);
    border: 1px solid rgba(79,163,255,0.3);
    border-radius: 4px;
    padding: 3px 10px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--accent);
  }

  /* HEADER READOUT (avionics strip) */
  .readout {
    display: flex;
    align-items: stretch;
    font-family: var(--mono);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(16,40,80,0.5), rgba(10,22,40,0.5));
    box-shadow: inset 0 0 0 1px rgba(79,163,255,0.04);
  }
  .readout .ro {
    display: flex;
    align-items: baseline;
    gap: 4px;
    padding: 5px 13px;
    border-right: 1px solid var(--panel-border);
  }
  .readout .ro:last-child { border-right: none; }
  .readout .ro-val {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    font-variant-numeric: tabular-nums;
  }
  .readout .ro-val.blue { color: var(--accent); }
  .readout .ro.time .ro-val { color: var(--amber); text-shadow: 0 0 12px rgba(245,200,66,0.35); }
  .readout .ro.fuel .ro-val { color: var(--green); }
  .readout .ro-unit {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    text-transform: uppercase;
  }
  .readout .ro-sub {
    font-size: 10px;
    color: var(--text-dim);
    margin-left: 7px;
    white-space: nowrap;
  }
  .readout .ro-paren {
    font-size: 11px;
    color: var(--text-dim);
    margin-left: 6px;
    white-space: nowrap;
  }
  .readout .ro-sub:empty { display: none; }
  /* On a wide strip the details (km, +minutes, fuel breakdown) show inline.
     On a narrower strip — where they wouldn't fit without wrapping — we hide them,
     but hovering the cell reveals the same info in a bubble. */
  @media (max-width: 1200px) {
    .readout { overflow: visible; }
    .readout .ro { position: relative; }
    .readout .ro-sub,
    .readout .ro-paren {
      position: absolute;
      top: calc(100% + 6px);
      left: 50%;
      margin: 0;
      padding: 5px 9px;
      font-size: 11px;
      color: var(--text);
      background: var(--panel);
      border: 1px solid var(--panel-border);
      border-radius: var(--radius);
      box-shadow: 0 8px 22px rgba(0,0,0,0.5);
      z-index: 60;
      opacity: 0;
      transform: translate(-50%, -3px);
      pointer-events: none;
      transition: opacity .14s ease, transform .14s ease;
    }
    .readout .ro:hover .ro-sub,
    .readout .ro:hover .ro-paren {
      opacity: 1;
      transform: translate(-50%, 0);
    }
  }
  .readout-note {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-muted);
    margin-right: 4px;
    white-space: nowrap;
  }
  @media (max-width: 1080px) { .brand-chip { display: none; } }
  @media (max-width: 760px)  { .readout .ro { padding: 5px 9px; } }

  /* LAYOUT */
  .app {
    display: flex;
    flex: 1;
    min-height: 0;             /* let flexbox own the height (dvh-aware) instead of a 100vh calc that overflows under iOS toolbars */
    overflow: hidden;
    position: relative;
  }

  /* SIDEBAR */
  .sidebar {
    width: 320px;
    flex-shrink: 0;
    background: var(--panel);
    border-right: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  /* RESIZER */
  .resizer {
    flex-shrink: 0;
    width: 6px;
    cursor: col-resize;
    background: transparent;
    position: relative;
    z-index: 500;
    transition: background 0.15s;
  }
  .resizer::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 28px;
    border-radius: 2px;
    background: var(--panel-border);
    transition: background 0.15s;
  }
  .resizer:hover, .resizer.dragging { background: var(--accent-dim); }
  .resizer:hover::before, .resizer.dragging::before { background: var(--accent); }
  body.resizing { cursor: col-resize; user-select: none; }
  body.resizing .leaflet-container { pointer-events: none; }

  .sidebar-section {
    padding: 11px 16px;
    border-bottom: 1px solid var(--panel-border);
  }

  .section-title {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 8px;
  }

  /* ROUTE LIST HEADER */
  .route-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 10px 16px 5px;
  }
  .route-hint {
    font-family: var(--mono);
    font-size: 9px;
    color: var(--text-muted);
    letter-spacing: 0.04em;
  }

  /* route summary at the bottom of the list (WP/LEG moved here from the header) —
     a thin status bar, so the waypoint list gets as much room as possible */
  .route-foot {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 9px;
    padding: 5px 16px;
    font-family: var(--mono);
    border-top: 1px solid var(--panel-border);
    background: rgba(16,40,80,0.28);
  }
  .route-foot[hidden] { display: none; }
  .route-foot-item {
    display: flex;
    align-items: baseline;
    gap: 5px;
  }
  .route-foot-val {
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 10px var(--accent-glow);
  }
  .route-foot-lbl {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
  }
  .route-foot-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-muted);
    align-self: center;
  }

  /* SEARCH */
  .search-row {
    display: flex;
    gap: 6px;
  }
  .search-input {
    flex: 1;
    background: var(--sky-light);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 8px 12px;
    color: var(--text);
    font-family: var(--sans);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
  }
  .search-input::placeholder { color: var(--text-muted); }
  .search-input:focus { border-color: var(--accent); }
  .btn {
    background: var(--accent-dim);
    border: 1px solid rgba(79,163,255,0.35);
    border-radius: var(--radius);
    color: var(--accent);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    padding: 0 14px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    letter-spacing: 0.05em;
  }
  .btn:hover { background: rgba(79,163,255,0.25); }
  .btn:active { transform: scale(0.97); }
  .btn-danger {
    background: rgba(255,94,94,0.1);
    border-color: rgba(255,94,94,0.3);
    color: var(--red);
  }
  .btn-danger:hover { background: rgba(255,94,94,0.2); }

  /* REPORTING POINTS */
  .rp-row { display: flex; gap: 6px; flex-wrap: wrap; }
  .rp-row .btn { flex: 1; padding: 8px 0; min-width: 0; }

  /* SPEED */
  .speed-row {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .speed-label { font-size: 12px; color: var(--text-dim); }
  .speed-slider {
    flex: 1;
    -webkit-appearance: none;
    height: 3px;
    background: var(--sky-light);
    border-radius: 2px;
    outline: none;
  }
  .speed-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--sky);
  }
  .speed-val {
    font-family: var(--mono);
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    min-width: 38px;
    text-align: right;
  }

  /* SETTINGS — gear FAB + expanding instrument panel (map bottom-right, above the "Fit route" button) */
  .settings-fab-wrap {
    position: absolute;
    bottom: 76px;          /* above the "Fit route" pill (bottom:30px) */
    right: 14px;
    z-index: 1001;
  }
  .settings-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px; height: 42px;
    padding: 0;
    background: rgba(10,22,40,0.85);
    border: 1px solid var(--panel-border);
    border-radius: 50%;
    color: var(--accent);
    cursor: pointer;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
    transition: background .15s, color .15s, border-color .15s, box-shadow .2s, transform .12s;
  }
  .settings-fab svg { transition: transform .55s cubic-bezier(.34,1.56,.64,1); }
  .settings-fab:hover { background: rgba(79,163,255,0.18); color: var(--text); }
  .settings-fab:hover svg { transform: rotate(40deg); }
  .settings-fab:active { transform: scale(0.94); }
  .settings-fab.open {
    background: var(--accent);
    color: var(--sky);
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent), 0 0 18px var(--accent-glow);
  }
  .settings-fab.open svg { transform: rotate(150deg); }

  .settings-pop {
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    width: 256px;
    background: rgba(11,24,44,0.95);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    box-shadow: 0 18px 44px rgba(0,0,0,0.5), 0 0 0 1px rgba(79,163,255,0.05);
    backdrop-filter: blur(10px);
    padding: 13px 0;
    transform-origin: bottom right;
    /* no scroll: the content fits, and overflow:auto would otherwise treat the
       little arrow hanging below (::after) as "overflow" → a scrollbar */
    overflow: visible;
    /* closed state */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(14px) scale(0.92);
    transition: opacity .22s ease, transform .34s cubic-bezier(.16,1,.3,1), visibility 0s linear .34s;
  }
  .settings-pop.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
    transition: opacity .26s ease, transform .46s cubic-bezier(.34,1.4,.5,1), visibility 0s;
  }
  /* small arrow pointing down toward the gear */
  .settings-pop::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 17px;
    width: 11px; height: 11px;
    background: rgba(11,24,44,0.95);
    border-right: 1px solid var(--panel-border);
    border-bottom: 1px solid var(--panel-border);
    transform: rotate(45deg);
  }
  .settings-pop-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px 11px;
    border-bottom: 1px solid var(--panel-border);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
  }
  .settings-pop-gear { color: var(--accent); flex-shrink: 0; }
  .settings-body { padding: 9px 16px 0; }
  .settings-body .speed-slider { display: block; width: 100%; margin: 4px 0 4px; }

  /* inner elements appear in a staggered way as the panel opens */
  .settings-pop-head,
  .settings-body > * { opacity: 0; }
  .settings-pop.open .settings-pop-head,
  .settings-pop.open .settings-body > * {
    animation: settingsItemIn .42s cubic-bezier(.16,1,.3,1) forwards;
  }
  .settings-pop.open .settings-pop-head        { animation-delay: .04s; }
  .settings-pop.open .settings-body > *:nth-child(1) { animation-delay: .09s; }
  .settings-pop.open .settings-body > *:nth-child(2) { animation-delay: .13s; }
  .settings-pop.open .settings-body > *:nth-child(3) { animation-delay: .17s; }
  .settings-pop.open .settings-body > *:nth-child(4) { animation-delay: .21s; }
  .settings-pop.open .settings-body > *:nth-child(5) { animation-delay: .25s; }
  @keyframes settingsItemIn {
    from { opacity: 0; transform: translateY(9px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  @media (prefers-reduced-motion: reduce) {
    .settings-pop, .settings-pop.open { transition: opacity .15s ease, visibility 0s; transform: none; }
    .settings-fab svg, .settings-fab.open svg { transition: none; transform: none; }
    .settings-pop-head, .settings-body > * { opacity: 1; }
    .settings-pop.open .settings-pop-head,
    .settings-pop.open .settings-body > * { animation: none; }
  }
  .settings-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
  }
  .settings-row label {
    flex: 1;
    font-size: 13px;
    color: var(--text-dim);
  }
  .settings-row input[type="number"] {
    width: 64px;
    background: var(--sky-light);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 6px 8px;
    color: var(--text);
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 700;
    text-align: right;
    outline: none;
    transition: border-color 0.2s;
  }
  .settings-row input[type="number"]:focus { border-color: var(--accent); }
  .settings-unit {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-muted);
    min-width: 26px;
  }

  /* UNIT SELECTORS */
  .units-block {
    margin-top: 13px;
    padding-top: 11px;
    border-top: 1px solid var(--panel-border);
  }
  .units-title {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
  }
  .unit-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 7px;
  }
  .unit-row label {
    flex: 1;
    font-size: 13px;
    color: var(--text-dim);
  }
  .unit-seg {
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    background: var(--sky-light);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
  }
  .unit-seg button {
    background: transparent;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    color: var(--text-dim);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 3px 11px;
    cursor: pointer;
    transition: all 0.15s;
  }
  .unit-seg button:hover { color: var(--text); background: rgba(255,255,255,0.06); }
  .unit-seg button.active {
    background: var(--accent);
    color: var(--sky);
    box-shadow: 0 0 10px var(--accent-glow);
  }

  /* AIRSPACE FILTER (sidebar – below Route) */
  .as-panel {
    text-align: left;
    flex-shrink: 0;
  }
  .as-switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
  .as-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
  .as-switch-track {
    position: relative;
    width: 38px;
    height: 20px;
    flex-shrink: 0;
    background: rgba(120,150,200,0.16);
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    transition: all 0.22s cubic-bezier(0.4,0.2,0.2,1);
  }
  .as-switch-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--text-dim);
    border-radius: 50%;
    transition: all 0.22s cubic-bezier(0.4,0.2,0.2,1);
  }
  .as-switch input:checked + .as-switch-track {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow), inset 0 0 0 1px rgba(255,255,255,0.12);
  }
  .as-switch input:checked + .as-switch-track .as-switch-knob { left: 20px; background: #fff; }
  .as-switch input:focus-visible + .as-switch-track { outline: 2px solid var(--accent-glow); outline-offset: 2px; }
  .as-switch-text {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    transition: color 0.2s;
  }
  .as-switch input:checked ~ .as-switch-text { color: var(--accent); }
  .as-panel-body { display: none; margin-top: 12px; }
  .as-panel.open .as-panel-body { display: block; }
  .as-status { margin-top: 8px; font-family: var(--mono); font-size: 10px; color: var(--text-muted); min-height: 12px; }
  .as-status.warn { color: var(--amber); }

  /* STATS */
  .stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .stat-card {
    background: var(--sky-light);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 10px 12px;
  }
  .stat-card.full { grid-column: span 2; }
  .stat-card-label {
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 4px;
  }
  .stat-card-value {
    font-family: var(--mono);
    font-size: 22px;
    font-weight: 700;
    color: var(--green);
    line-height: 1;
  }
  .stat-card-unit {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-dim);
    margin-left: 4px;
  }
  .stat-card-value.amber { color: var(--amber); }
  .stat-card-value.blue { color: var(--accent); }

  /* WAYPOINT LIST */
  .wp-list-wrap {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 8px 16px;
    scrollbar-width: thin;                                   /* Firefox: thin, not the thick default */
    scrollbar-color: var(--panel-border) transparent;
  }
  .wp-list-wrap::-webkit-scrollbar { width: 4px; }
  .wp-list-wrap::-webkit-scrollbar-track { background: transparent; }
  .wp-list-wrap::-webkit-scrollbar-thumb { background: var(--panel-border); border-radius: 2px; }

  .wp-empty {
    padding: 24px 0;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--mono);
  }

  .wp-item {
    margin-bottom: 3px;
  }
  .wp-row {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 8px;
    border-radius: var(--radius);
    background: var(--sky-light);
    border: 1px solid var(--panel-border);
    cursor: default;
    transition: border-color 0.15s;
  }
  .wp-row:hover { border-color: rgba(79,163,255,0.4); }
  .wp-dot {
    width: 20px; height: 20px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
  }
  .wp-dot.start { background: var(--green); color: var(--sky); }
  .wp-dot.end   { background: var(--red); color: #fff; }
  .wp-dot.mid   { background: var(--accent); color: var(--sky); }
  .wp-name {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    font-size: 12px;
    color: var(--text);
  }
  .wp-name-main {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .wp-city {
    flex-shrink: 0;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
  }
  .wp-city::before { content: '·'; margin: 0 5px; }
  .wp-dist-badge {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-dim);
    white-space: nowrap;
  }
  .wp-del {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    padding: 2px;
    transition: color 0.15s;
    flex-shrink: 0;
  }
  .wp-del:hover { color: var(--red); }

  .wp-grip {
    cursor: grab;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1;
    flex-shrink: 0;
    user-select: none;
    touch-action: none;        /* let us drag-reorder on touch instead of scrolling the list */
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    padding: 4px 6px;          /* larger tap/drag target for fingers */
    margin: -4px -2px;
  }
  .wp-grip:active { cursor: grabbing; }
  .wp-item.dragging { opacity: 0.35; }
  /* floating clone that follows the pointer while dragging to reorder */
  .wp-ghost {
    position: fixed;
    left: 0; top: 0;
    margin: 0;
    z-index: 3000;
    pointer-events: none;
    opacity: 0.92;
    background: var(--panel);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.45), 0 0 0 1px var(--accent-glow);
    transform: scale(1.02) rotate(-1deg);
    transition: none;
  }
  .wp-item.drop-target .wp-row {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent-glow);
  }

  .leg-row {
    display: flex;
    gap: 10px;
    padding: 2px 8px 4px 35px;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-muted);
  }
  .leg-val { color: var(--text-dim); }
  /* TC = true (blue), MC = magnetic (amber) — same color code as the map labels */
  .leg-true, .leg-true .leg-val { color: var(--accent); }
  .leg-mag, .leg-mag .leg-val { color: var(--amber); }
  .phase-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 8px 3px 35px;
    font-family: var(--mono);
    font-size: 9px;
    color: var(--text-muted);
  }
  .phase-badge {
    padding: 1px 7px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
  }
  .phase-badge.takeoff { background: rgba(61,232,160,0.12); color: #3de8a0; border: 1px solid rgba(61,232,160,0.25); }
  .phase-badge.landing { background: rgba(255,94,94,0.1); color: #ff5e5e; border: 1px solid rgba(255,94,94,0.25); }

  /* MAP */
  .map-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
  }
  #map {
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  /* MAP OVERLAY HINT */
  .map-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
  }
  .layer-switcher {
    display: flex;
    gap: 4px;
    background: rgba(10,22,40,0.85);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    padding: 4px;
    backdrop-filter: blur(4px);
  }
  .map-btn {
    background: rgba(10,22,40,0.85);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    color: var(--accent);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    padding: 6px 12px;
    cursor: pointer;
    letter-spacing: 0.04em;
    backdrop-filter: blur(4px);
    transition: all 0.15s;
  }
  .map-btn:hover { background: rgba(79,163,255,0.18); color: var(--text); }
  .map-btn:active { transform: scale(0.97); }
  /* active = "instrument switch on": solid accent, dark label, subtle glow */
  .map-btn.active {
    background: var(--accent);
    color: var(--sky);
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent), 0 0 16px var(--accent-glow);
  }
  .map-btn.active:hover { background: #6cb6ff; color: var(--sky); }
  .layer-btn {
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-dim);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    cursor: pointer;
    letter-spacing: 0.04em;
    transition: all 0.15s;
  }
  .layer-btn:hover { color: var(--text); background: rgba(255,255,255,0.06); }
  .layer-btn.active { background: var(--accent); color: var(--sky); box-shadow: 0 0 12px var(--accent-glow); }
  .layer-btn.active:hover { background: #6cb6ff; color: var(--sky); }

  /* 3D TERRAIN VIEW — MapLibre canvas overlays the 2D map; the shared map
     controls (top-right) and FABs keep their z-index:1000 and stay on top. */
  #map3d {
    position: absolute;
    inset: 0;
    display: none;
    background: #0a1628;
    /* above every Leaflet pane/control (their z-index goes up to 1000 in the same
       stacking context), below the shared map controls/FABs (also 1000, but they
       come later in the DOM) */
    z-index: 999;
  }
  #map3d.on { display: block; }
  /* While 3D is shown, fully hide the 2D map so its zoom control and panes can't
     bleed through (and Leaflet stops painting for free). */
  .map-wrap.mode-3d #map { visibility: hidden; }
  /* Airport markers aren't rendered in 3D, so their legend would only mislead. */
  .map-wrap.mode-3d .map-legend { display: none; }
  #map3d .maplibregl-ctrl-attrib {
    background: rgba(10,22,40,0.75);
    color: var(--text-dim);
    font-size: 10px;
  }
  #map3d .maplibregl-ctrl-attrib a { color: var(--accent); }
  #map3d .maplibregl-ctrl-group {
    background: rgba(10,22,40,0.85);
    border: 1px solid var(--panel-border);
  }
  #map3d .maplibregl-ctrl-group button { background: transparent; }
  #map3d .maplibregl-ctrl button .maplibregl-ctrl-icon { filter: invert(0.85); }

  /* Fly-through transport bar (play/pause, speed, scrub) — bottom centre,
     leaving room for the fit-route FAB on the right */
  .fly-bar {
    position: absolute;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 7px;
    width: min(540px, calc(100% - 340px));   /* keep clear of the settings/fit FABs on the right */
    padding: 8px 14px;
    background: rgba(10,22,40,0.85);
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
  }
  /* display:flex above would defeat the hidden attribute (author styles beat the
     UA's [hidden]{display:none}) — so the bar must opt out explicitly */
  .fly-bar[hidden] { display: none; }
  .fly-ctl {
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--accent);
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    padding: 4px 7px;
    cursor: pointer;
    transition: all 0.15s;
  }
  .fly-ctl:hover { background: rgba(79,163,255,0.18); color: var(--text); }
  .fly-ctl:active { transform: scale(0.94); }
  #fly-play { min-width: 30px; }
  .fly-speed {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
    min-width: 30px;
    text-align: center;
  }
  .fly-range {
    flex: 1;
    min-width: 60px;
    accent-color: var(--accent);
    cursor: pointer;
  }
  .fly-dist {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-dim);
    white-space: nowrap;
  }
  .fly-alt-wrap { display: flex; align-items: center; gap: 4px; }
  .fly-alt-wrap input {
    width: 56px;
    background: rgba(255,255,255,0.07);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 6px;
    text-align: right;
  }
  .fly-alt-u {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-dim);
  }

  .map-hint {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10,22,40,0.85);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    padding: 6px 16px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-dim);
    pointer-events: none;
    backdrop-filter: blur(4px);
    white-space: nowrap;
    z-index: 1000;
    transition: opacity 0.4s;
  }
  .map-hint.hidden { opacity: 0; }

  /* "Fit route" — a standalone view action, kept separate from the layer toggles */
  .fit-fab {
    position: absolute;
    bottom: 30px;
    right: 14px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 14px 9px 11px;
    background: rgba(10,22,40,0.85);
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    color: var(--accent);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
    transition: all 0.15s;
  }
  .fit-fab svg { flex-shrink: 0; }
  .fit-fab:hover {
    background: var(--accent);
    color: var(--sky);
    border-color: var(--accent);
    box-shadow: 0 0 18px var(--accent-glow);
  }
  .fit-fab:active { transform: scale(0.96); }

  .map-legend {
    position: absolute;
    bottom: 16px;
    left: 12px;
    z-index: 1000;
    background: rgba(10,22,40,0.85);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    padding: 8px 10px;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-dim);
    backdrop-filter: blur(4px);
    pointer-events: none;
  }
  .map-legend[hidden] { display: none; }
  .legend-title {
    /* desktop: plain title, not interactive; mobile turns it into a toggle */
    display: flex; align-items: center; gap: 6px;
    width: 100%; margin: 0 0 5px; padding: 0;
    background: none; border: 0; cursor: default;
    font-family: inherit; font-size: inherit; text-align: left;
    font-weight: 600; color: var(--text);
  }
  .legend-chevron { display: none; margin-left: auto; transition: transform .15s ease; }
  .legend-row { display: flex; align-items: center; gap: 6px; line-height: 1.7; }
  .legend-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: #0a1628; border: 2px solid var(--c); flex-shrink: 0;
  }

  /* WAYPOINT MAP LABELS (settlement name next to the point) */
  .wp-map-label.leaflet-tooltip {
    background: rgba(10,22,40,0.82);
    border: 1px solid var(--panel-border);
    color: var(--text);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 500;
    padding: 2px 7px;
    border-radius: 4px;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.45);
    white-space: nowrap;
  }
  .wp-map-label.leaflet-tooltip::before { display: none; }   /* hide the arrow */

  .airport-label.leaflet-tooltip {
    background: transparent;
    border: none;
    box-shadow: none;
    color: var(--accent);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    padding: 0;
    text-shadow: 0 0 3px rgba(0,0,0,0.95), 0 0 3px rgba(0,0,0,0.95);
    pointer-events: none;
    white-space: nowrap;
  }
  .airport-label.leaflet-tooltip::before { display: none; }

  .popup-add-btn {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 5px 8px;
    background: var(--accent);
    color: #061018;
    border: none;
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
  }
  .popup-add-btn:hover { filter: brightness(1.1); }
  .popup-add-btn:active { transform: scale(0.98); }

  /* LEAFLET OVERRIDES */
  .leaflet-container { background: var(--sky-mid) !important; }
  .leaflet-control-zoom a {
    background: var(--panel) !important;
    color: var(--text) !important;
    border-color: var(--panel-border) !important;
  }
  .leaflet-control-zoom a:hover { background: var(--sky-light) !important; }
  .leaflet-control-attribution {
    background: rgba(10,22,40,0.7) !important;
    color: var(--text-muted) !important;
    font-size: 10px !important;
  }

  /* BOTTOM ACTIONS */
  .sidebar-actions {
    padding: 10px 16px;
    border-top: 1px solid var(--panel-border);
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
  }
  .sidebar-actions .btn { padding: 8px 0; font-size: 11px; }
  .sidebar-actions .btn-danger { grid-column: span 2; }
  .btn:disabled { opacity: 0.3; cursor: not-allowed; pointer-events: none; }

  /* LEG LABELS */
  .leg-label {
    background: rgba(10, 22, 40, 0.82);
    border: 1px solid rgba(79,163,255,0.3);
    border-radius: 5px;
    padding: 4px 8px;
    width: max-content;
    white-space: nowrap;
    transform: translateX(-50%);   /* center horizontally (iconAnchor x=0) */
    backdrop-filter: blur(4px);
    pointer-events: none;
    text-align: center;
  }
  .leg-label-hdg {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    display: flex;
    justify-content: center;
    gap: 9px;
  }
  /* same color code as in the route panel: TC blue, MC amber */
  .leg-label-hdg .lh-tc { color: var(--accent); }
  .leg-label-hdg .lh-mc { color: var(--amber); }
  .leg-label-sep {
    height: 1px;
    background: rgba(79,163,255,0.2);
    margin: 3px 0;
  }
  .leg-label-info {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: rgba(200,220,255,0.7);
    letter-spacing: 0.02em;
  }

  /* NOTIFICATION */
  .notif {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translate(-50%, -8px);
    background: rgba(10,22,40,0.92);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 8px 14px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--accent);
    z-index: 2000;
    opacity: 0;
    transition: all 0.2s;
    pointer-events: none;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
    white-space: nowrap;
  }
  .notif.show { opacity: 1; transform: translate(-50%, 0); }

  /* ABOUT / LEGAL / IMPRESSUM MODAL */
  .legal-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(4,10,22,0.66);
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity .2s ease;
  }
  .legal-overlay[hidden] { display: none; }
  .legal-overlay.show { opacity: 1; }
  .legal-modal {
    position: relative;
    width: 100%;
    max-width: 540px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: rgba(11,24,44,0.97);
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(79,163,255,0.05);
    padding: 22px 24px 24px;
    transform: translateY(12px) scale(0.97);
    transition: transform .34s cubic-bezier(.16,1,.3,1);
  }
  .legal-overlay.show .legal-modal { transform: translateY(0) scale(1); }
  .legal-close {
    position: absolute;
    top: 12px; right: 14px;
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    background: transparent;
    border: 1px solid var(--panel-border);
    border-radius: 50%;
    color: var(--text-dim);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: color .15s, background .15s, border-color .15s;
  }
  .legal-close:hover { color: var(--red); background: rgba(255,94,94,0.12); border-color: rgba(255,94,94,0.35); }
  .legal-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--panel-border);
  }
  .legal-head .brand-mark { font-size: 16px; }
  .legal-body { font-size: 13.5px; line-height: 1.6; color: var(--text); }
  .legal-body p { color: rgba(200,220,255,0.8); }
  .legal-about { margin-bottom: 16px; }
  .legal-warn {
    background: rgba(245,200,66,0.07);
    border: 1px solid var(--amber-dim);
    border-left: 3px solid var(--amber);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 16px;
  }
  .legal-warn-title {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--amber);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 7px;
  }
  .legal-warn p { color: rgba(245,225,180,0.92); }
  .legal-block { margin-bottom: 16px; }
  .legal-block-title {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 5px;
  }
  .legal-privacy { color: rgba(200,220,255,0.8); }
  .legal-privacy ul {
    list-style: none;
    margin: 8px 0;
    padding: 0;
  }
  .legal-privacy li {
    position: relative;
    padding-left: 16px;
    margin-bottom: 6px;
  }
  .legal-privacy li::before {
    content: '';
    position: absolute;
    left: 2px; top: 9px;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.7;
  }
  .legal-privacy b { color: var(--text); font-weight: 500; }
  .legal-contact {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 14px;
    border-top: 1px solid var(--panel-border);
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-dim);
  }
  .legal-contact-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 7px;
  }
  .legal-contact a { color: var(--accent); text-decoration: none; }
  .legal-contact a:hover { text-decoration: underline; }

  /* ============================================================
     PHONE LAYOUT (≤760px)
     The desktop side-by-side (sidebar | resizer | map) collapses:
     the map becomes the full-screen hero and the planner slides in
     from the left as a dismissible drawer.
     ============================================================ */
  @media (max-width: 760px) {
    /* --- reveal the mobile-only chrome --- */
    .panel-toggle { display: flex; }
    .drawer-close { display: flex; }
    .drawer-backdrop { display: block; }

    /* iOS Safari force-zooms into any focused field whose text is < 16px.
       Bump every editable field to 16px on phones to suppress that zoom. */
    .search-input,
    .settings-row input[type="number"] { font-size: 16px; }

    /* --- header: compact, readout drops to its own avionics strip --- */
    header {
      flex-wrap: wrap;
      height: auto;
      min-height: calc(52px + env(safe-area-inset-top, 0));
      gap: 10px;
      /* extra top room so the toggle's badge (top:-5px) clears the browser chrome */
      padding-top: calc(env(safe-area-inset-top, 0) + 8px);
      padding-bottom: 9px;
      row-gap: 9px;
    }
    .header-sep { display: none; }
    .lang-switch { margin-left: auto; }
    .brand-mark { font-size: 14px; letter-spacing: 0.1em; }
    .readout {
      order: 10;
      flex: 1 0 100%;
      justify-content: space-between;
    }
    .readout .ro { flex: 1; justify-content: center; padding: 6px 8px; }

    /* --- no drag-resizer on touch --- */
    .resizer { display: none; }

    /* --- sidebar becomes a slide-in drawer --- */
    .sidebar {
      position: fixed;
      top: var(--header-h);
      left: 0;
      bottom: 0;
      width: min(86vw, 360px) !important;   /* override the inline px width the desktop resizer may have stored */
      padding-top: 44px;                     /* clearance for the floating close button */
      padding-bottom: env(safe-area-inset-bottom, 0);
      border-right: 1px solid var(--panel-border);
      box-shadow: 10px 0 50px rgba(0,0,0,0.55);
      transform: translateX(-100%);
      transition: transform .3s cubic-bezier(.4, 0, .2, 1);
      z-index: 1100;
      will-change: transform;
    }
    body.drawer-open .sidebar { transform: translateX(0); }
    body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }

    /* the map fills everything behind the drawer */
    .map-wrap { width: 100%; }

    /* keep map controls clear of the notch / safe areas */
    .map-controls { top: 10px; right: 10px; }
    .map-legend {
      bottom: calc(16px + env(safe-area-inset-bottom, 0));
      pointer-events: auto;          /* the title must be tappable to toggle */
    }
    .legend-title { cursor: pointer; }
    .legend-chevron { display: block; }
    .map-legend.legend-open .legend-chevron { transform: rotate(180deg); }
    /* collapsed by default on phones — only the title shows until tapped open */
    .map-legend:not(.legend-open) .legend-title { margin-bottom: 0; }
    .map-legend:not(.legend-open) .legend-body { display: none; }
    .fit-fab { bottom: calc(24px + env(safe-area-inset-bottom, 0)); }
    .map-hint { bottom: calc(14px + env(safe-area-inset-bottom, 0)); }
    /* phones: the transport bar takes the bottom edge, full width — the FABs it
       would collide with are hidden while it's up (playback mode; Stop restores them) */
    .fly-bar {
      bottom: calc(14px + env(safe-area-inset-bottom, 0));
      width: calc(100% - 16px);
      padding: 7px 10px;
      gap: 5px;
    }
    .fly-alt-wrap input { width: 48px; }
    .map-wrap:has(.fly-bar:not([hidden])) .fit-fab,
    .map-wrap:has(.fly-bar:not([hidden])) .settings-fab-wrap { display: none; }
  }

  @media (prefers-reduced-motion: reduce) {
    .sidebar, .drawer-backdrop { transition: none; }
  }

  /* TERRAIN ELEVATION PROFILE (SkyDemon-style) — bottom panel over the map */
  .profile-panel {
    position: absolute;
    left: 12px; right: 12px;
    bottom: 10px;
    height: 200px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    background: rgba(10,22,40,0.88);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
    padding: 8px 10px 6px;
  }
  /* display:flex would defeat the hidden attribute (same as .fly-bar) */
  .profile-panel[hidden] { display: none; }
  .profile-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 2px 4px;
  }
  .profile-title {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
    white-space: nowrap;
  }
  .profile-summary {
    flex: 1;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .profile-panel .ok { color: var(--green); }
  .profile-panel .caution { color: var(--amber); font-weight: 700; }
  .profile-panel .warn { color: var(--red); font-weight: 700; }
  .profile-credit {
    font-size: 9px;
    color: var(--text-muted);
    white-space: nowrap;
  }
  .profile-close {
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-dim);
    font-size: 16px;
    line-height: 1;
    padding: 2px 6px;
    cursor: pointer;
  }
  .profile-close:hover { color: var(--text); background: rgba(255,255,255,0.08); }
  .profile-chart { flex: 1; position: relative; min-height: 0; }
  .profile-chart svg { display: block; touch-action: none; }
  .profile-chart .prof-axis { font-family: var(--mono); font-size: 9px; fill: rgba(200,220,255,0.45); }
  .profile-chart .prof-badge { font-family: var(--mono); font-size: 9px; font-weight: 700; fill: #0a1628; }
  .profile-chart .prof-warn-txt { font-family: var(--mono); font-size: 9px; font-weight: 700; fill: #0a1628; }
  .profile-chart .prof-altlabel { font-family: var(--mono); font-size: 10px; font-weight: 700; fill: #9cc7ff; }
  /* airspace block labels: dark halo (paint-order) keeps them readable over terrain */
  .profile-chart .prof-as { font-family: var(--mono); font-size: 8px; font-weight: 700; letter-spacing: 0.02em; paint-order: stroke; stroke: rgba(10,22,40,0.8); stroke-width: 2px; }
  .profile-chart .prof-as-lim { font-family: var(--mono); font-size: 7.5px; paint-order: stroke; stroke: rgba(10,22,40,0.8); stroke-width: 2px; }
  .profile-msg {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-dim);
    font-family: var(--mono);
    font-size: 12px;
  }
  .profile-loading {
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-dim);
    background: rgba(10,22,40,0.85);
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    padding: 3px 10px;
    pointer-events: none;
  }
  .profile-tip {
    position: absolute;
    top: 34px;
    z-index: 1001;
    pointer-events: none;
    background: rgba(10,22,40,0.95);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    padding: 5px 8px;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-dim);
    white-space: nowrap;
  }
  .profile-tip b { color: var(--text); }
  .profile-tip .prof-tip-as { margin-top: 3px; }
  /* lift everything parked on the map's bottom edge above the open panel */
  .map-wrap.profile-open .fit-fab { bottom: 224px; }
  .map-wrap.profile-open .settings-fab-wrap { bottom: 270px; }
  .map-wrap.profile-open .leaflet-bottom { bottom: 212px; }
  .map-wrap.profile-open .map-legend { bottom: 222px; }
  .map-wrap.profile-open .fly-bar { bottom: 222px; }
  .map-wrap.profile-open .map-hint { bottom: 222px; }
  .map-wrap.profile-open #map3d .maplibregl-ctrl-bottom-left { bottom: 212px; }

  @media (max-width: 760px) {
    .profile-panel {
      left: 8px; right: 8px;
      bottom: calc(8px + env(safe-area-inset-bottom, 0));
      height: 150px;
    }
    .profile-credit { display: none; }
    .map-wrap.profile-open .fit-fab { bottom: calc(170px + env(safe-area-inset-bottom, 0)); }
    .map-wrap.profile-open .settings-fab-wrap { bottom: calc(216px + env(safe-area-inset-bottom, 0)); }
    .map-wrap.profile-open .leaflet-bottom { bottom: calc(160px + env(safe-area-inset-bottom, 0)); }
    .map-wrap.profile-open .map-legend { bottom: calc(168px + env(safe-area-inset-bottom, 0)); }
    .map-wrap.profile-open .map-hint { bottom: calc(168px + env(safe-area-inset-bottom, 0)); }
    .map-wrap.profile-open .fly-bar { bottom: calc(160px + env(safe-area-inset-bottom, 0)); }
  }
