/* ═══ Stratos mobile experience ═══════════════════════════════════════
   A phone-only presentation layer. Every layout rule sits behind the 767 px
   breakpoint, so the desktop interface, its rail and its panels are untouched.
   The map pages keep their own engine: this file only re-frames the surfaces
   the page already renders, never invents a value or a second data source.

   Design language: deep navy and charcoal, one cyan accent, hairline borders,
   square-line icons, generous but disciplined spacing, 46 px touch targets. */

.m-nav, .m-grip, .m-install, .m-nav-fade { display: none; }

@media (max-width: 767px) {
  :root {
    /* Aliases of the shared Stratos tokens (tokens.css): phones get the same
       palette and Day/Night/High theme as every other surface. */
    --m-bg: var(--bg);
    --m-bg-2: var(--land);
    --m-surface: var(--ui);
    --m-surface-2: var(--ui2);
    --m-line: var(--line, rgba(124, 168, 214, .13));
    --m-line-2: color-mix(in srgb, var(--mut) 34%, transparent);
    --m-ink: var(--txt);
    --m-mute: var(--mut);
    --m-faint: color-mix(in srgb, var(--mut) 72%, var(--bg));
    --m-cyan: var(--acc);
    --m-cyan-2: var(--acc);
    --m-cyan-soft: color-mix(in srgb, var(--acc) 12%, transparent);
    --m-good: var(--grn, #34d399);
    --m-warn: var(--warn, #f6c453);
    --m-bad: var(--red, #f87171);
    --m-r: 16px;
    --m-r-sm: 12px;
    --m-tap: 46px;
    --m-nav-h: 62px;
    --m-safe-t: env(safe-area-inset-top, 0px);
    --m-safe-b: env(safe-area-inset-bottom, 0px);
    /* The tab bar sits right on the home indicator (as low as iOS allows). */
    --m-nav-safe: max(2px, calc(env(safe-area-inset-bottom, 0px) - 32px));
    --m-gutter: 12px;
    color-scheme: dark;
  }

  html { -webkit-text-size-adjust: 100%; }
  body {
    background: var(--m-bg);
    color: var(--m-ink);
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
  }
  body.has-mnav { padding-bottom: calc(var(--m-nav-h) + var(--m-nav-safe)); }
  /* The map is edge to edge: its sheet and controls already clear the bar. */
  body[data-mobile-section="map"].has-mnav { padding-bottom: 0; }
  img, video { max-width: 100%; }
  button, [role="button"], a, input, select, textarea { touch-action: manipulation; }
  ::selection { background: rgba(34, 211, 238, .28); color: var(--m-ink); }

  /* ── Bottom navigation ─────────────────────────────────────────────
     Five destinations, always in the same order, always in the same place.
     The bar floats over content with a single hairline and a restrained blur;
     the active tab is cyan with a short indicator, never a filled pill. */
  .m-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    padding: 5px 6px var(--m-nav-safe);
    background: linear-gradient(180deg, rgba(18, 19, 22, .82), rgba(11, 12, 15, .98) 42%);
    -webkit-backdrop-filter: blur(22px) saturate(1.25);
    backdrop-filter: blur(22px) saturate(1.25);
    border-top: 1px solid var(--m-line);
  }
  .m-nav a, .m-nav button {
    appearance: none;
    border: 0;
    background: none;
    font-family: inherit;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 50px;
    padding: 5px 0 3px;
    border-radius: 12px;
    color: var(--m-faint);
    text-decoration: none;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    transition: color .18s ease, background-color .18s ease, transform .18s ease;
  }
  .m-nav a svg { width: 21px; height: 21px; display: block; }
  .m-nav button svg { width: 21px; height: 21px; display: block; }
  .m-nav [aria-current="page"] { color: var(--m-cyan); }
  .m-nav [aria-current="page"]::after {
    content: "";
    position: absolute;
    top: 0;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: var(--m-cyan);
    box-shadow: 0 0 10px rgba(34, 211, 238, .65);
  }
  .m-nav a:active, .m-nav button:active { background: rgba(34, 211, 238, .08); transform: scale(.96); }
  .m-nav a:focus-visible, .m-nav button:focus-visible { outline: 2px solid var(--m-cyan); outline-offset: -2px; }

  /* ── Shared shell bar ──────────────────────────────────────────────
     The desktop bar keeps a wordmark, five links, a search, two status pills
     and five actions. On a phone that is a different bar: identity, state and
     one search field, nothing else. The five links move to .m-nav. */
  .tb {
    height: auto;
    min-height: 50px;
    padding: calc(6px + var(--m-safe-t)) var(--m-gutter) 0;
    gap: 6px;
    flex-wrap: wrap;
    background: rgba(13, 14, 17, .78);
    -webkit-backdrop-filter: blur(18px) saturate(1.2);
    backdrop-filter: blur(18px) saturate(1.2);
    border-bottom: 1px solid var(--m-line);
  }
  .tb-nav, .tb-actions, .tb-status, .tb-support, .tb-clock, .tb-perf-wrap, .tb-efb { display: none !important; }
  .tb-brand { letter-spacing: .2em; font-size: 12px; gap: 8px; }
  .tb-brand .tb-name { display: flex; }
  .tb-brand .tb-state { font-size: 9.5px; letter-spacing: .06em; max-width: 22ch; }
  .tb-mark {
    width: 26px; height: 26px; border-radius: 8px;
    background: var(--m-cyan-soft);
    border: 1px solid rgba(34, 211, 238, .28);
  }
  .tb-gap { display: none; }
  .tb-search { order: 9; width: 100%; padding: 0 0 9px; }
  .tb-search:empty { display: none; }
  #appbar #sb {
    height: 40px;
    border-radius: 12px;
    background: rgba(34, 35, 38, .8);
    border: 1px solid var(--m-line);
    padding: 0 12px;
    box-shadow: none;
  }
  #appbar #sb span { font-size: 16px; color: var(--m-faint); }
  #appbar #q { font-size: 15px; padding: 10px 0; }

  /* ── Map: an immersive full-screen surface ─────────────────────────
     The bar floats over the chart instead of taking a row from it, the rail is
     gone (the bottom navigation owns those destinations), and the flight card
     becomes a bottom sheet above the bar. */
  /* Keep the shell's grid: the map's height comes from its 1fr row. Only the
     rail column and the bar's row are removed, and the bar floats above. */
  body[data-mobile-section="map"] .app-shell {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: 0 minmax(0, 1fr) !important;
    height: 100vh;
    height: 100dvh;
  }
  body[data-mobile-section="map"] .app-main { height: auto; }
  body[data-mobile-section="map"] #tabs { display: none !important; }
  body[data-mobile-section="map"] #app { height: 100vh; height: 100dvh; }
  body[data-mobile-section="map"] #appbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 42;
    border-bottom: 0;
    /* No band over the map: the search field carries its own background. */
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  body[data-mobile-section="map"] #appbar #sb {
    background: rgba(24, 25, 28, .86);
    border-color: rgba(124, 168, 214, .2);
  }
  body[data-mobile-section="map"] #res {
    position: fixed;
    top: calc(104px + var(--m-safe-t));
    left: var(--m-gutter);
    right: var(--m-gutter);
    width: auto;
    max-height: 46dvh;
    border-radius: 14px;
    z-index: 43;
    background: var(--m-surface);
    border: 1px solid var(--m-line-2);
  }
  body[data-mobile-section="map"] #online { display: none !important; }
  body[data-mobile-section="map"] #tel { display: none !important; }

  /* The controls sit in one column on the right, clear of the bar and sheet. */
  body[data-mobile-section="map"] #fab {
    position: fixed;
    top: auto;
    right: 10px;
    bottom: calc(var(--m-nav-h) + var(--m-nav-safe) + 14px);
    gap: 8px;
    z-index: 46;
    transition: bottom .24s ease;
  }
  body[data-mobile-section="map"].m-flight #fab { bottom: calc(var(--m-nav-h) + var(--m-nav-safe) + 208px); }
  body[data-mobile-section="map"] #fab .fab {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    font-size: 17px;
    color: var(--m-ink);
    background: rgba(26, 27, 30, .92);
    border: 1px solid var(--m-line-2);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
  }
  body[data-mobile-section="map"] #fab .fab:active { transform: scale(.94); }
  body[data-mobile-section="map"] #fab .fab.on { background: var(--m-cyan); color: #1b1c1f; border-color: transparent; }


  /* ── The flight sheet ─────────────────────────────────────────────
     The page keeps writing the card; the phone turns it into a sheet with
     three rests. Only the presentation changes, so every number stays the
     one the bridge reported. */
  body[data-mobile-section="map"] #fc {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    top: auto !important;
    bottom: calc(var(--m-nav-h) + var(--m-nav-safe) + 8px) !important;
    width: auto !important;
    max-width: none !important;
    z-index: 48;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0 16px 14px !important;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(31, 32, 35, .985), rgba(17, 18, 21, .995)) !important;
    border: 1px solid var(--m-line-2) !important;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, .45);
    scrollbar-width: none;
  }
  body[data-mobile-section="map"] #fc::-webkit-scrollbar { display: none; }
  body[data-mobile-section="map"] #fc[data-snap="peek"] { max-height: 196px; }
  body[data-mobile-section="map"] #fc[data-snap="half"] { max-height: 48dvh; }
  body[data-mobile-section="map"] #fc[data-snap="full"] { max-height: calc(100dvh - 118px); }
  body[data-mobile-section="map"] #fc .fh { padding-top: 2px; }
  body[data-mobile-section="map"] #fc .fr { font-size: 24px; margin: 9px 0 2px; }
  body[data-mobile-section="map"] #fc .fg { grid-template-columns: repeat(3, 1fr); row-gap: 10px; }
  body[data-mobile-section="map"] #fc .fca button { min-height: 40px; border-radius: 11px; }
  body[data-mobile-section="map"] #fc .fcph { margin: 0 -16px 10px; border-radius: 20px 20px 0 0; }
  body[data-mobile-section="map"] #fc .fcph img { height: 150px; }

  .m-grip {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    width: 100%;
    height: 26px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 20px 20px 0 0;
    background: linear-gradient(180deg, rgba(31, 32, 35, .99), rgba(31, 32, 35, .82));
    cursor: grab;
    touch-action: none;
  }
  .m-grip span {
    width: 42px;
    height: 4px;
    border-radius: 99px;
    background: rgba(148, 183, 214, .42);
  }
  .m-grip:active span { background: var(--m-cyan); }
  .m-grip:focus-visible { outline: 2px solid var(--m-cyan); outline-offset: -3px; }

  /* The plan card uses the same sheet language when no flight is live. */
  body[data-mobile-section="map"] #fp {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    top: auto !important;
    bottom: calc(var(--m-nav-h) + var(--m-nav-safe) + 8px) !important;
    width: auto !important;
    max-width: none !important;
    max-height: 46dvh;
    z-index: 47;
    border-radius: 20px;
    padding: 14px 16px !important;
    background: linear-gradient(180deg, rgba(31, 32, 35, .985), rgba(17, 18, 21, .995)) !important;
    border: 1px solid var(--m-line-2) !important;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, .45);
    scrollbar-width: none;
  }
  body[data-mobile-section="map"] #fp::-webkit-scrollbar { display: none; }

  /* Map settings arrive as a drawer, not a floating panel. */
  body[data-mobile-section="map"] #lay {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: auto;
    max-height: 84dvh;
    padding: 0 0 calc(10px + var(--m-safe-b));
    border-radius: 22px 22px 0 0;
    z-index: 60;
    background: var(--m-surface);
    border: 1px solid var(--m-line-2);
    border-bottom: 0;
    box-shadow: 0 -18px 50px rgba(0, 0, 0, .5);
  }
  body[data-mobile-section="map"] #lay .lay-h {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 14px 16px 10px;
    background: var(--m-surface);
    border-bottom: 1px solid var(--m-line);
    border-radius: 22px 22px 0 0;
  }
  body[data-mobile-section="map"] #lay .lay-body { padding: 4px 14px 8px; overscroll-behavior: contain; }
  body[data-mobile-section="map"] #lay .lay-chips button,
  body[data-mobile-section="map"] #lay #ms button { min-height: 42px; border-radius: 11px; }
  body[data-mobile-section="map"] #ms { grid-template-columns: 1fr 1fr; gap: 8px; }
  body[data-mobile-section="map"] #lay .lay-s { padding: 12px 0; }

  /* Chart viewer is a document: full height, safe areas, one back control. */
  #cv { padding-top: var(--m-safe-t); }
  #cv .cvh { min-height: 50px; padding: 6px 10px; gap: 8px; }
  #cv .cvh button { min-width: 42px; min-height: 42px; }
  #cv .seg { margin: 6px 10px 10px; }
  #cv .seg button { min-height: 40px; }
  #chart { padding: calc(8px + var(--m-safe-t)) 8px calc(8px + var(--m-safe-b)); }

  /* ── Flights: a list of flights, not a dashboard ─────────────────── */
  body[data-mobile-section="flights"] #topbar {
    padding: calc(8px + var(--m-safe-t)) var(--m-gutter) 8px;
    background: rgba(13, 14, 17, .82);
    -webkit-backdrop-filter: blur(18px) saturate(1.2);
    backdrop-filter: blur(18px) saturate(1.2);
    border-bottom: 1px solid var(--m-line);
  }
  body[data-mobile-section="flights"] #topbar a.home { font-size: 15px; letter-spacing: .18em; }
  body[data-mobile-section="flights"] #topbar h1 {
    font-size: 10px; letter-spacing: .16em; border-left-color: var(--m-line);
    color: var(--m-faint);
  }
  body[data-mobile-section="flights"] #tab-bar {
    position: sticky;
    top: calc(46px + var(--m-safe-t));
    z-index: 19;
    gap: 6px;
    padding: 8px var(--m-gutter);
    background: rgba(13, 14, 17, .94);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--m-line);
    scrollbar-width: none;
  }
  body[data-mobile-section="flights"] #tab-bar::-webkit-scrollbar { display: none; }
  body[data-mobile-section="flights"] .tab-btn {
    flex: 0 0 auto;
    padding: 0 14px;
    min-height: 38px;
    border: 1px solid var(--m-line);
    border-bottom: 1px solid var(--m-line);
    border-radius: 999px;
    background: var(--m-surface);
    font-size: 12px;
    color: var(--m-mute);
  }
  body[data-mobile-section="flights"] .tab-btn.act {
    color: #1b1c1f;
    background: var(--m-cyan);
    border-color: var(--m-cyan);
  }
  body[data-mobile-section="flights"] #main {
    padding: var(--m-gutter) var(--m-gutter) calc(16px + var(--m-safe-b));
    max-width: none;
  }
  body[data-mobile-section="flights"] .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  body[data-mobile-section="flights"] .stat-tile {
    padding: 12px;
    border-radius: 14px;
    background: var(--m-surface);
    border-color: var(--m-line);
  }
  body[data-mobile-section="flights"] .stat-tile b { font-size: 22px; }
  body[data-mobile-section="flights"] .section {
    padding: 4px 12px 8px;
    border-radius: var(--m-r);
    background: var(--m-surface);
    border-color: var(--m-line);
  }
  body[data-mobile-section="flights"] .section h2 { padding-top: 10px; color: var(--m-faint); letter-spacing: .14em; }
  body[data-mobile-section="flights"] .flight-row {
    gap: 12px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--m-line);
    border-radius: 0;
  }
  body[data-mobile-section="flights"] .flight-row:active { background: rgba(34, 211, 238, .06); }
  body[data-mobile-section="flights"] .fl-badge {
    min-width: 54px;
    border-radius: 9px;
    background: rgba(34, 211, 238, .1);
    border-color: rgba(34, 211, 238, .28);
  }
  body[data-mobile-section="flights"] .fl-route { font-size: 15.5px; }
  body[data-mobile-section="flights"] .fl-sub { font-size: 11.5px; }
  body[data-mobile-section="flights"] .ac-grid { grid-template-columns: 1fr; }
  body[data-mobile-section="flights"] .ac-card { border-radius: 14px; background: var(--m-surface); }
  body[data-mobile-section="flights"] .table-wrap, body[data-mobile-section="flights"] .s-table-wrap { max-width: 100%; }

  /* ── Weather: compact panels, one airport at a time ──────────────── */
  body[data-mobile-section="weather"] #topbar {
    padding: calc(8px + var(--m-safe-t)) var(--m-gutter) 8px;
    background: rgba(13, 14, 17, .82);
    -webkit-backdrop-filter: blur(18px) saturate(1.2);
    backdrop-filter: blur(18px) saturate(1.2);
    border-bottom: 1px solid var(--m-line);
  }
  body[data-mobile-section="weather"] #topbar a.home { font-size: 15px; letter-spacing: .18em; }
  body[data-mobile-section="weather"] #topbar h1 { font-size: 10px; letter-spacing: .16em; border-left-color: var(--m-line); color: var(--m-faint); }
  body[data-mobile-section="weather"] #search-wrap {
    gap: 8px;
    padding: 10px var(--m-gutter);
    background: var(--m-bg);
    border-bottom: 1px solid var(--m-line);
  }
  body[data-mobile-section="weather"] #icao-input {
    min-height: var(--m-tap);
    border-radius: 12px;
    background: var(--m-surface);
    border-color: var(--m-line);
    font-size: 16px;
  }
  body[data-mobile-section="weather"] #search-btn {
    min-height: var(--m-tap);
    padding: 0 16px;
    border-radius: 12px;
    background: var(--m-cyan);
    color: #1b1c1f;
    font-weight: 750;
  }
  body[data-mobile-section="weather"] #recent-strip {
    gap: 6px;
    padding: 8px var(--m-gutter);
    background: var(--m-bg);
    border-bottom: 1px solid var(--m-line);
  }
  body[data-mobile-section="weather"] .rec-chip {
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    background: var(--m-surface);
    border-color: var(--m-line);
    color: var(--m-mute);
  }
  body[data-mobile-section="weather"] #main {
    padding: var(--m-gutter) var(--m-gutter) calc(16px + var(--m-safe-b));
    max-width: none;
  }
  body[data-mobile-section="weather"] #apt-header {
    gap: 10px;
    padding: 14px;
    border-radius: var(--m-r);
    background: var(--m-surface);
    border-color: var(--m-line);
  }
  body[data-mobile-section="weather"] .apt-id { font-size: 32px; }
  body[data-mobile-section="weather"] .apt-meta { min-width: 120px; }
  body[data-mobile-section="weather"] .apt-name { font-size: 14px; }
  body[data-mobile-section="weather"] .apt-right { flex-direction: row; align-items: center; gap: 8px; }
  body[data-mobile-section="weather"] .cat-badge { font-size: 11px; padding: 4px 10px; }
  body[data-mobile-section="weather"] .wx-section {
    padding: 12px 14px;
    border-radius: var(--m-r);
    background: var(--m-surface);
    border-color: var(--m-line);
  }
  body[data-mobile-section="weather"] .wx-section h2 { color: var(--m-faint); letter-spacing: .14em; }
  body[data-mobile-section="weather"] .raw-metar { font-size: 11px; line-height: 1.7; background: var(--m-bg-2); }
  body[data-mobile-section="weather"] .decoded-row { gap: 6px; padding: 7px 0; }
  body[data-mobile-section="weather"] .dec-label { min-width: 88px; font-size: 10.5px; letter-spacing: .04em; }
  body[data-mobile-section="weather"] .dec-val { font-size: 14px; }
  body[data-mobile-section="weather"] #empty-state,
  body[data-mobile-section="weather"] #loading-state,
  body[data-mobile-section="weather"] #error-state { padding: 48px 16px; }

  /* ── Charts: the EFB with a phone's proportions ───────────────────── */
  body[data-mobile-section="charts"] .efb-top {
    min-height: 52px;
    padding: calc(6px + var(--m-safe-t)) 10px 6px;
    gap: 8px;
    flex-wrap: nowrap;
    background: rgba(13, 14, 17, .9);
    border-bottom: 1px solid var(--m-line);
  }
  body[data-mobile-section="charts"] .et-brand small { display: none; }
  body[data-mobile-section="charts"] .et-flight { max-width: 42vw; font-size: 10.5px; }
  body[data-mobile-section="charts"] .et-airline { display: none; }
  body[data-mobile-section="charts"] .et-clock { font-size: 11px; }
  body[data-mobile-section="charts"] .et-icon { width: 38px; height: 38px; }
  body[data-mobile-section="charts"] .efb-nav {
    position: sticky;
    top: calc(52px + var(--m-safe-t));
    z-index: 21;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 4px;
    padding: 6px 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    background: rgba(15, 16, 19, .96);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--m-line);
  }
  body[data-mobile-section="charts"] .efb-nav::-webkit-scrollbar { display: none; }
  body[data-mobile-section="charts"] .efb-nav .en-home,
  body[data-mobile-section="charts"] .efb-nav .en-item {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 48px;
    padding: 4px 10px;
    border-radius: 11px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    background: transparent;
    border: 1px solid transparent;
    color: var(--m-faint);
    white-space: nowrap;
  }
  body[data-mobile-section="charts"] .efb-nav .en-home svg,
  body[data-mobile-section="charts"] .efb-nav .en-item svg { width: 19px; height: 19px; }
  body[data-mobile-section="charts"] .efb-nav .en-label { font-size: 9px; }
  body[data-mobile-section="charts"] .efb-nav .en-home[aria-current="page"],
  body[data-mobile-section="charts"] .efb-nav .en-item[aria-current="page"],
  body[data-mobile-section="charts"] .efb-nav .en-home.act,
  body[data-mobile-section="charts"] .efb-nav .en-item.act,
  body[data-mobile-section="charts"] .efb-nav .en-home.on,
  body[data-mobile-section="charts"] .efb-nav .en-item.on {
    color: var(--m-cyan);
    background: var(--m-cyan-soft);
    border-color: rgba(34, 211, 238, .26);
  }
  body[data-mobile-section="charts"] .efb-main {
    padding: 10px var(--m-gutter) calc(18px + var(--m-safe-b));
    max-width: none;
  }
  body[data-mobile-section="charts"] .efb-page-head {
    gap: 8px;
    padding: 0 0 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--m-line);
  }
  body[data-mobile-section="charts"] .efb-page-head h1 { font-size: 19px; }
  body[data-mobile-section="charts"] .efb-page-head p { font-size: 11.5px; }
  /* The EFB's sidebar rail has no place on a phone; the tab bar and the EFB home button replace it. */
  body[data-mobile-section="charts"] #efb-nav { display: none !important; }
  body[data-mobile-section="charts"] .efb-body,
  body[data-mobile-section="charts"] .efb-body * { min-width: 0; }
  body[data-mobile-section="charts"] .efb-body { font-size: 13.5px; }
  body[data-mobile-section="charts"] .efb-body button,
  body[data-mobile-section="charts"] .efb-body .btn,
  body[data-mobile-section="charts"] .efb-body input,
  body[data-mobile-section="charts"] .efb-body select { min-height: 42px; font-size: 14px; }
  body[data-mobile-section="charts"] .efb-body table { display: block; overflow-x: auto; max-width: 100%; }
  body[data-mobile-section="charts"] .perf-layout { grid-template-columns: minmax(0, 1fr); }
  body[data-mobile-section="charts"] .efb-body img,
  body[data-mobile-section="charts"] .efb-body canvas,
  body[data-mobile-section="charts"] .efb-body iframe { max-width: 100%; }
  body[data-mobile-section="charts"] .efb-body .card,
  body[data-mobile-section="charts"] .efb-body [class$="-card"] { border-radius: 14px; }
  /* The EFB's own deck keeps four columns instead of shrinking to specks. */
  body[data-mobile-section="charts"] .home-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
  body[data-mobile-section="charts"] .home-stage { padding: 0 12px 12px; }
  /* The dock sits in the column above the tab bar; the wallpaper still runs under it. */
  body[data-mobile-section="charts"] .efb-home { padding-bottom: calc(var(--m-nav-h) + var(--m-nav-safe)); }
  body[data-mobile-section="charts"] .home-dock { margin-bottom: 10px; }

  /* ── Profile: account and settings as a settings app ─────────────── */
  body[data-mobile-section="profile"] .page {
    padding: var(--m-gutter) var(--m-gutter) calc(16px + var(--m-safe-b));
    max-width: none;
  }
  body[data-mobile-section="profile"] .subnav {
    position: sticky;
    top: calc(50px + var(--m-safe-t));
    z-index: 25;
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    padding: 8px var(--m-gutter);
    overflow-x: auto;
    scrollbar-width: none;
    background: rgba(13, 14, 17, .94);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--m-line);
  }
  body[data-mobile-section="profile"] .subnav::-webkit-scrollbar { display: none; }
  body[data-mobile-section="profile"] .subnav button {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    background: var(--m-surface);
    border: 1px solid var(--m-line);
    color: var(--m-mute);
    font-size: 12px;
    font-weight: 650;
  }
  body[data-mobile-section="profile"] .subnav button.act,
  body[data-mobile-section="profile"] .subnav button[aria-current="page"],
  body[data-mobile-section="profile"] .subnav button.on {
    color: #1b1c1f;
    background: var(--m-cyan);
    border-color: var(--m-cyan);
  }
  body[data-mobile-section="profile"] .grid-2,
  body[data-mobile-section="profile"] .grid-3,
  body[data-mobile-section="profile"] .grid-4,
  body[data-mobile-section="profile"] .grid-main { grid-template-columns: minmax(0, 1fr) !important; }
  body[data-mobile-section="profile"] .grid-main > .span-2 { grid-column: auto; }
  body[data-mobile-section="profile"] .card {
    padding: 14px;
    border-radius: var(--m-r);
    background: var(--m-surface);
    border-color: var(--m-line);
  }
  body[data-mobile-section="profile"] .stat-value { font-size: 24px; }
  body[data-mobile-section="profile"] .btn,
  body[data-mobile-section="profile"] button { min-height: 42px; }
  body[data-mobile-section="profile"] table.data { min-width: 0; }
  body[data-mobile-section="profile"] .dashboard-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Install card: the one place the app asks to be installed. */
  .m-install {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 12px;
    padding: 12px 14px;
    width: 100%;
    text-align: left;
    border-radius: var(--m-r);
    background: var(--m-cyan-soft);
    border: 1px solid rgba(34, 211, 238, .28);
    color: var(--m-ink);
    font: inherit;
  }
  .m-install svg { width: 22px; height: 22px; color: var(--m-cyan); flex: 0 0 auto; }
  .m-install b { display: block; font-size: 13px; font-weight: 700; }
  .m-install span { display: block; font-size: 11px; color: var(--m-mute); margin-top: 1px; }
  .m-install-row { display: flex; align-items: stretch; gap: 6px; margin: 0 0 12px; }
  .m-install-row .m-install { margin: 0; flex: 1 1 auto; }
  .m-install-x {
    flex: 0 0 40px;
    min-height: 40px;
    border-radius: 12px;
    background: transparent;
    border: 1px solid var(--m-line);
    color: var(--m-mute);
    font-size: 16px;
    line-height: 1;
  }

  /* ── Motion ───────────────────────────────────────────────────────
     Two short transitions, both transform/opacity only. Nothing here runs
     while the map draws. */
  @media (prefers-reduced-motion: no-preference) {
    body.m-enter { animation: mFade .2s ease both; }
    body.m-leaving { opacity: .55; transition: opacity .12s ease; }
    body[data-mobile-section="map"] #fc,
    body[data-mobile-section="map"] #fp { transition: max-height .24s cubic-bezier(.22, .61, .36, 1); }
    .m-nav a svg { transition: transform .18s ease; }
    .m-nav a[aria-current="page"] svg { transform: translateY(-1px); }
  }
  @keyframes mFade { from { opacity: .35; } to { opacity: 1; } }

  @media (prefers-reduced-motion: reduce) {
    .m-nav a, body[data-mobile-section="map"] #fc { transition: none !important; }
    body.m-enter, body.m-leaving { animation: none !important; opacity: 1 !important; }
  }

  /* Small phones: tighter gutters, same rhythm. */
  @media (max-width: 380px) {
    :root { --m-gutter: 10px; --m-nav-h: 58px; }
    .m-nav a { font-size: 8.5px; letter-spacing: .08em; }
    .m-nav a svg { width: 21px; height: 21px; }
    body[data-mobile-section="map"] #fc[data-snap="peek"] { max-height: 184px; }
  }

  /* Landscape phone: the sheet must leave the map usable. */
  @media (max-height: 520px) and (orientation: landscape) {
    body[data-mobile-section="map"] #fc[data-snap="peek"] { max-height: 150px; }
    body[data-mobile-section="map"] #fc[data-snap="half"] { max-height: 58dvh; }
    body[data-mobile-section="map"] #fc[data-snap="full"] { max-height: calc(100dvh - 96px); }
    .m-nav { padding-top: 2px; }
    .m-nav a { min-height: 42px; }
    .m-nav a svg { width: 20px; height: 20px; }
  }

  /* ── Phone Mode: the PC deck at /phone ─────────────────────────────
     The tracker's phone layout normally swaps the telemetry strip for a
     draggable flight sheet. At /phone the pilot asked for the desktop deck, so
     the PC strip and control column stay where the desktop puts them and the
     sheet is never mounted: the same instruments, scaled to the screen. */
  /* Not permanent: the strip opens when the pilot taps their own aircraft and
     closes when the selection is cleared. */
  html.phone-mode #tel { display: none !important; }
  html.phone-mode.tel-open #tel {
    display: block !important;
    left: var(--m-gutter);
    right: var(--m-gutter);
    bottom: calc(var(--m-nav-h) + var(--m-nav-safe) + 8px);
    padding: 6px 8px;
    border-radius: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  html.phone-mode #tel .tel-main { gap: 8px; }
  html.phone-mode #tel .tel-k { font-size: 8px; letter-spacing: .1em; }
  html.phone-mode #tel .tel-cell b { font-size: 13px; }
  html.phone-mode #tel .tel-u { font-size: 8px; }
  html.phone-mode #tel .tel-route { font-size: 10px; gap: 6px; }
  html.phone-mode #tel .tel-status { font-size: 9px; gap: 6px; flex-wrap: wrap; }
  html.phone-mode #tel .tel-extra, html.phone-mode #tel .tel-more { display: none; }
  /* The desktop's new UI retires the old flight-plan card (#fp) and the flight
     sheet (#fc); the phone shows the same new tracking UI, so they are retired
     here too rather than left lying over the map. */
  html.phone-mode #fc, html.phone-mode #fp, html.phone-mode #efbbar,
  html.phone-mode .m-grip { display: none !important; }
  /* The retired card keeps its "expanded" class, and the desktop rule that hides
     the controls while it is open would hide them for good. Phone Mode owns the
     column, so it stays: the same follow / track / zoom controls as the PC. */
  html.phone-mode #app #fab {
    display: flex !important;
    bottom: calc(var(--m-nav-h) + var(--m-nav-safe) + 128px);
    z-index: 48;
  }
}

/* Tablets keep the desktop layout, but the sheet language is phone-only. */
/* ── Phone Flight Deck layout (js/phonedeck.js) ──────────────────────
   The map tools as one rail on the left, and a
   tray above the tab bar with the plan's airports, their charts and Sync with
   flight. Search opens on demand from the rail. */
@media (max-width: 767px) {
  /* The tools: one rail on the left. */
  body.pd #app #fab {
    /* !important: older Flight Deck rules (#app:has(#fp.show) #fab) outrank this selector. */
    position: absolute !important; top: calc(env(safe-area-inset-top, 0px) + 8px) !important; bottom: auto !important;
    left: 8px !important; right: auto !important; transform: none !important;
    display: flex; flex-direction: column; gap: 2px; padding: 4px; border-radius: 12px;
    background: rgba(16, 17, 20, .94); border: 1px solid var(--m-line-2); box-shadow: 0 6px 18px rgba(0, 0, 0, .35); z-index: 49;
  }
  body.pd #app #fab .fab { position: static; width: 40px; height: 40px; border: 0; border-radius: 9px; background: none; box-shadow: none; }
  body.pd #app #fab .fab.on { background: var(--m-cyan); color: #04121e; }
  /* Pinch zooms on a phone, so the rail keeps to the tools. */
  body.pd #app #fab #bZi, body.pd #app #fab #bZo { display: none; }
  body.pd #attr { display: block !important; top: calc(env(safe-area-inset-top, 0px) + 8px) !important; bottom: auto !important; left: 64px !important; right: 8px !important; width: auto; text-align: right; font-size: 9px; background: none; }
  body.pd #app #fab .pd-style { font: 800 10.5px system-ui, sans-serif; letter-spacing: .04em; color: var(--m-ink); border: 1px solid var(--m-line-2); }

  /* Search opens from the rail, beside it. */
  body.pd #qbox { display: none; }
  body.pd.pd-search #qbox { display: flex; top: calc(env(safe-area-inset-top, 0px) + 8px); left: 64px; right: 8px; width: auto; z-index: 51; }
  body.pd #res { top: calc(env(safe-area-inset-top, 0px) + 84px); left: 64px; right: 8px; width: auto; }
  body.pd #txbar { top: calc(env(safe-area-inset-top, 0px) + 8px); left: 64px; right: 8px; }

  /* The tray: the plan's airports with their charts, and Sync with flight. */
  body.pd #pd-tray {
    position: fixed; z-index: 48; left: 0; right: 0; bottom: calc(var(--m-nav-h) + var(--m-nav-safe));
    display: grid; gap: 8px; padding: 10px 10px 8px;
    background: linear-gradient(180deg, #141518, #0e0f12); border-top: 1px solid var(--m-line);
  }
  body.pd .pd-apts { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
  body.pd .pd-apt { flex: none; display: flex; border-radius: 10px; overflow: hidden; border: 1px solid var(--m-line-2); }
  body.pd .pd-apt button { border: 0; height: 38px; padding: 0 12px; cursor: pointer; font: 700 13px system-ui, sans-serif; }
  body.pd .pd-icao { background: #0f6e5e; color: #fff; letter-spacing: .04em; }
  body.pd .pd-charts { background: rgba(255, 255, 255, .06); color: var(--m-ink); }
  body.pd .pd-none { color: var(--m-faint); font-size: 12px; padding: 4px 2px; }
  body.pd .pd-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  body.pd .pd-sync { display: flex; align-items: center; gap: 10px; color: var(--m-ink); font-size: 13px; font-weight: 600; cursor: pointer; }
  body.pd .pd-sync input { position: absolute; opacity: 0; width: 1px; height: 1px; }
  body.pd .pd-sync i { width: 42px; height: 24px; border-radius: 999px; background: rgba(255, 255, 255, .16); position: relative; transition: background .16s ease; }
  body.pd .pd-sync i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .16s ease; }
  body.pd .pd-sync input:checked + i { background: var(--m-cyan); }
  body.pd .pd-sync input:checked + i::after { transform: translateX(18px); }
  body.pd .pd-sync input:focus-visible + i { outline: 2px solid var(--m-cyan); outline-offset: 2px; }
  body.pd .pd-edit { height: 30px; padding: 0 14px; display: inline-flex; align-items: center; border-radius: 8px; background: #d97706; color: #fff; font-size: 12.5px; font-weight: 700; text-decoration: none; }

  /* A chart sheet takes the whole map; the deck steps aside. */
  body.pd.pd-chart #pd-tray { display: none; }
  /* Phone Mode's Status panel sits on top of the tray, not behind it. */
  html.phone-mode body.pd #tel { bottom: calc(var(--m-nav-h) + var(--m-nav-safe) + var(--pd-tray, 100px) + 6px); }

  /* More: the sections that are not tabs, in a sheet above the bar. */
  .m-more { position: fixed; inset: 0; z-index: 89; background: rgba(0, 0, 0, .35); }
  .m-more[hidden] { display: none; }
  .m-more-card {
    position: absolute; right: 8px; bottom: calc(var(--m-nav-h) + var(--m-nav-safe) + 8px); min-width: 220px;
    display: grid; padding: 6px; border-radius: 16px; background: rgba(22, 23, 27, .98); border: 1px solid var(--m-line-2);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, .5);
  }
  .m-more-card a { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 12px; border-radius: 10px; color: var(--m-ink); text-decoration: none; font-size: 14px; font-weight: 600; }
  .m-more-card a svg { width: 20px; height: 20px; color: var(--m-cyan); }
  .m-more-card a:active { background: rgba(34, 211, 238, .08); }
}

@media (min-width: 768px) {
  .m-nav, .m-grip, .m-install { display: none !important; }
}

@media print {
  .m-nav, .m-grip { display: none !important; }
}

/* The phone map runs under the status bar (black-translucent); the controls
   already sit below it by the safe-area inset. */
html:has(body.pd) { padding-top: 0 !important; }
