:root {
  --bg: #0c1015;
  --panel: #141b24;
  --panel-2: #1b2530;
  --line: #26323f;
  --text: #e6edf3;
  --muted: #8b9aa9;
  --accent: #38bdf8;
  --accent-2: #0ea5e9;
  --green: #4ade80;
  --amber: #fbbf24;
  --danger: #f87171;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--text); display: flex; flex-direction: column;
  overflow: hidden;
}

/* ---------------- top bar ---------------- */
#topbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: linear-gradient(180deg, #131a23, #0e141b);
  border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  font-size: 22px; width: 38px; height: 38px; display: grid; place-items: center;
  background: var(--accent); color: #04222e; border-radius: 9px; transform: rotate(-10deg);
}
.brand h1 { font-size: 15px; margin: 0; letter-spacing: .3px; }
.brand .sub { font-size: 11px; color: var(--muted); }
.plan-name-wrap { flex: 1; max-width: 460px; }
#planName {
  width: 100%; padding: 9px 12px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; color: var(--text); font-size: 13px;
}
.top-actions { display: flex; gap: 8px; margin-left: auto; }
.status { font-size: 11px; color: var(--muted); min-width: 120px; text-align: right; }
.status.ok { color: var(--green); }
.status.warn { color: var(--amber); }

button {
  font-family: inherit; cursor: pointer; border-radius: 8px; font-size: 13px;
  padding: 8px 13px; border: 1px solid var(--line); transition: .12s;
}
button.ghost { background: var(--panel-2); color: var(--text); }
button.ghost:hover { background: #243140; }
button.primary { background: var(--accent); color: #04222e; border-color: var(--accent); font-weight: 600; }
button.primary:hover { background: var(--accent-2); }
button:disabled { opacity: .45; cursor: not-allowed; }

/* ---------------- layout ---------------- */
main { flex: 1; display: flex; min-height: 0; }
#sidebar {
  width: 380px; flex: 0 0 380px; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow-y: auto;
}
.panel { padding: 14px 14px 0; }
/* min-height keeps the panel from collapsing to 0 (which spilled the empty-state
   text over the panel below); overflow:hidden contains the inner scrolling list. */
.panel.route-panel { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 150px; overflow: hidden; padding-bottom: 8px; }
.lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 600; }

.search-wrap { position: relative; margin-top: 8px; }
#search {
  width: 100%; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; color: var(--text); font-size: 13px;
}
#search:focus, #planName:focus { outline: none; border-color: var(--accent); }
.hint { font-size: 11px; color: var(--muted); margin: 8px 0 4px; }

.results {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  max-height: 320px; overflow-y: auto; box-shadow: 0 12px 30px rgba(0,0,0,.5);
}
.result {
  padding: 8px 11px; display: flex; align-items: center; gap: 10px; cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.result:last-child { border-bottom: none; }
.result:hover, .result.active { background: #243140; }
.r-ident { font-weight: 700; font-size: 13px; min-width: 56px; }
.r-name { font-size: 12px; color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  font-size: 9px; padding: 2px 6px; border-radius: 5px; font-weight: 700; letter-spacing: .5px;
  background: #2b3a49; color: var(--muted);
}
.badge.AIRPORT { background: #0e3a52; color: #7dd3fc; }
.badge.VOR { background: #3a2d52; color: #c4b5fd; }
.badge.NDB { background: #523a2d; color: #fdba74; }
.badge.USER { background: #2d5240; color: #86efac; }

/* ---------------- route list ---------------- */
.route-head { display: flex; justify-content: space-between; align-items: baseline; margin-top: 6px; }
.total { font-size: 12px; color: var(--accent); font-weight: 700; }
.route { list-style: none; margin: 8px 0 0; padding: 0; overflow-y: auto; flex: 1; }
.route-item {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; margin-bottom: 6px; display: flex; align-items: center; gap: 9px;
  cursor: grab;
}
.route-item.dragging { opacity: .4; }
.route-item.over { border-color: var(--accent); }
.seq {
  width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #04222e;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: 0 0 auto;
}
.ri-main { flex: 1; min-width: 0; }
.ri-ident { font-weight: 700; font-size: 13px; }
.ri-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri-leg { font-size: 10px; color: var(--amber); margin-top: 2px; }
.ri-del { color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.ri-del:hover { color: var(--danger); background: #2a1f23; }
.empty { font-size: 12px; color: var(--muted); padding: 16px 4px; text-align: center; }

/* radio frequency plan */
.radio-list { list-style: none; margin: 8px 0 0; padding: 0; }
.radio-step {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 9px; margin-bottom: 6px; display: flex; gap: 9px; align-items: flex-start;
}
.radio-step .rs-n {
  width: 20px; height: 20px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #04222e;
}
.radio-step.apt .rs-n { background: #38bdf8; }
.radio-step.airspace .rs-n { background: #60a5fa; }
.rs-main { flex: 1; min-width: 0; }
.rs-where { font-size: 12px; font-weight: 600; }
.rs-tag { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.radio-step.gfa .rs-tag { color: #a78bfa; }
.rs-note { font-size: 10px; color: var(--amber); margin-top: 4px; line-height: 1.3; }
.rs-freqs { margin-top: 3px; display: flex; flex-wrap: wrap; gap: 5px; }
.rs-freq {
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: #11202e; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px;
}
.rs-freq em { font-style: normal; font-weight: 600; font-size: 9px; color: var(--muted); margin-right: 4px; }

.custom-list { margin-top: 8px; }
details summary { cursor: pointer; font-size: 12px; color: var(--muted); padding: 4px 0 10px; }
.custom-row { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.custom-row .ri-del { margin-left: auto; }

/* ---------------- map ---------------- */
#mapWrap { flex: 1; position: relative; }
#map { position: absolute; inset: 0; background: #0a0e13; }
.map-coop-hint {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%) translateY(-8px);
  z-index: 700; pointer-events: none;
  background: rgba(20,27,36,.94); border: 1px solid var(--accent); color: var(--accent);
  font-size: 12px; font-weight: 600; padding: 7px 13px; border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5); opacity: 0; transition: opacity .3s, transform .3s;
}
.map-coop-hint.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.legbar {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 500;
  background: rgba(20,27,36,.94); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 16px; font-size: 12px; display: flex; gap: 18px; backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.legbar b { color: var(--accent); }
.wp-marker {
  background: var(--accent); color: #04222e; border: 2px solid #04222e; border-radius: 50%;
  width: 24px; height: 24px; display: grid; place-items: center; font-weight: 700; font-size: 11px;
}

/* ---------------- duty / liability disclaimer ---------------- */
.duty-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 6px 12px; font-size: 11px; line-height: 1.35;
  color: #fde9c8; background: linear-gradient(180deg, #3a2a10, #2c2008);
  border-bottom: 1px solid #5a431a;
}
.duty-bar b { color: var(--amber); }
.duty-info {
  flex: 0 0 auto; margin-left: auto; font-size: 11px; cursor: pointer;
  color: #2a1c06; background: var(--amber); border: 0; border-radius: 6px; padding: 3px 9px; font-weight: 700;
}
.duty-info:hover { filter: brightness(1.08); }

.duty-gate { position: fixed; inset: 0; z-index: 5000; background: rgba(5,8,12,.82);
  display: grid; place-items: center; padding: 20px; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.duty-gate-card {
  background: var(--panel); border: 1px solid #5a431a; border-top: 3px solid var(--amber);
  border-radius: 14px; width: 540px; max-width: 94vw; max-height: 88vh; overflow-y: auto;
  padding: 22px 24px; box-shadow: 0 24px 60px rgba(0,0,0,.55);
}
.duty-gate-card h2 { margin: 0 0 12px; font-size: 18px; color: var(--amber); }
.duty-gate-card p { margin: 0 0 11px; font-size: 13px; line-height: 1.5; color: var(--text); }
.duty-gate-card b { color: #fde9c8; }
.duty-check { display: flex; align-items: center; gap: 9px; margin: 16px 0 14px;
  font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text); }
.duty-check input { width: 17px; height: 17px; accent-color: var(--amber); cursor: pointer; }
.primary.wide { width: 100%; }
button.primary:disabled { opacity: .45; cursor: not-allowed; }

/* ===================== LOGIN / AUTH ===================== */
.auth-gate {
  position: fixed; inset: 0; z-index: 6000; overflow-y: auto;
  display: flex; align-items: safe center; justify-content: center; padding: 24px;
  background:
    radial-gradient(1000px 520px at 50% -10%, rgba(56,189,248,.14), transparent),
    linear-gradient(180deg, #0a0e13, #06090d);
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--panel);
  border: 1px solid var(--line); border-top: 3px solid var(--accent);
  border-radius: 16px; padding: 26px 24px; box-shadow: 0 24px 60px rgba(0,0,0,.55);
}
.auth-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-head .logo { width: 46px; height: 46px; font-size: 24px; }
.auth-head h2 { margin: 0; font-size: 16px; line-height: 1.25; letter-spacing: 1.5px; }
.auth-view h3 { margin: 0 0 14px; font-size: 15px; color: var(--accent); }
.auth-lbl { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); font-weight: 600; margin: 12px 0 5px; }
.auth-lbl em { text-transform: none; letter-spacing: 0; color: #6b7a89; font-style: normal; }
.auth-card input {
  width: 100%; padding: 11px 12px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 9px; color: var(--text); font-size: 15px;
}
.auth-card input:focus { outline: none; border-color: var(--accent); }
#cCode { letter-spacing: 8px; text-align: center; font-size: 22px; font-weight: 700; }
.auth-card .primary.wide { margin-top: 18px; padding: 12px; font-size: 14px; }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.auth-links a, .auth-alt a { color: var(--accent); text-decoration: none; font-size: 12px; }
.auth-links a:hover, .auth-alt a:hover { text-decoration: underline; }
.auth-alt { margin-top: 16px; text-align: center; font-size: 13px; color: var(--muted);
  border-top: 1px solid var(--line); padding-top: 14px; }
.auth-note { font-size: 13px; color: var(--muted); margin: 0 0 4px; }
.auth-note b { color: var(--text); }
.auth-msg { margin-top: 14px; font-size: 13px; min-height: 18px; }
.auth-msg.err { color: var(--danger); }
.auth-msg.ok { color: var(--green); }
.auth-banner { background: #3a2a10; border: 1px solid #5a431a; color: #fde9c8;
  font-size: 12px; padding: 8px 11px; border-radius: 8px; margin-bottom: 16px; }
.auth-disclaimer { margin: 18px 0 0; font-size: 11px; color: var(--muted); text-align: center; line-height: 1.45; opacity: .8; }

/* ---------------- modal & toast ---------------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 1000; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: 460px; max-width: 92vw; max-height: 80vh; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 14px; }
.modal-body { padding: 8px 16px 16px; overflow-y: auto; }
.plan-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.plan-row .pr-name { flex: 1; font-size: 13px; cursor: pointer; }
.plan-row .pr-name:hover { color: var(--accent); }
.plan-row .pr-date { font-size: 11px; color: var(--muted); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 2000;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 11px 18px; border-radius: 9px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.toast.ok { border-color: var(--green); }
.toast.err { border-color: var(--danger); }
.hidden { display: none !important; }

/* ===================== HANGAR / MACHINE SELECT ===================== */
.hangar {
  position: fixed; inset: 0; z-index: 3000; overflow-y: auto;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(56,189,248,.12), transparent),
    linear-gradient(180deg, #0a0e13, #070a0e);
  display: flex; align-items: safe center; justify-content: center; padding: 30px;
}
.hangar-inner { width: 100%; max-width: 1180px; }
.hangar-head { display: flex; align-items: center; gap: 16px; margin-bottom: 26px; justify-content: center; text-align: left; }
.hangar-head .logo { font-size: 30px; width: 56px; height: 56px; background: var(--accent); }
.hangar-head h1 { font-size: 26px; margin: 0; letter-spacing: 3px; }
.hangar-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.hangar-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 920px) { .hangar-cards { grid-template-columns: 1fr; } }

.machine-card {
  background: linear-gradient(180deg, #131c26, #0e151d);
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  display: flex; flex-direction: column; cursor: pointer;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.machine-card:hover { transform: translateY(-6px); border-color: var(--mc-accent, var(--accent)); box-shadow: 0 18px 40px rgba(0,0,0,.55); }
.machine-card .art {
  background: #0a0e13; border-bottom: 1px solid var(--line);
  overflow: hidden; height: 180px;
}
.machine-card .art img { width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .2s; }
.machine-card:hover .art img { transform: scale(1.04); }
.machine-card .body { padding: 14px 16px 18px; flex: 1; display: flex; flex-direction: column; }
.machine-card h3 { margin: 0; font-size: 17px; }
.machine-card .klass { font-size: 11px; color: var(--mc-accent, var(--accent)); text-transform: uppercase; letter-spacing: 1.5px; margin: 3px 0 12px; font-weight: 700; }
.spec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-bottom: 14px; }
.spec { background: var(--panel-2); border-radius: 8px; padding: 7px 9px; }
.spec .k { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.spec .v { font-size: 14px; font-weight: 700; margin-top: 1px; }
.machine-card .select-btn {
  margin-top: auto; background: var(--mc-accent, var(--accent)); color: #04222e;
  border: none; padding: 11px; border-radius: 9px; font-weight: 700; font-size: 14px;
  letter-spacing: 1px; cursor: pointer;
}
.machine-card .select-btn:hover { filter: brightness(1.08); }
.disclaimer { text-align: center; color: var(--amber); font-size: 12px; margin-top: 22px; opacity: .85; }

/* "scroll for more" hint pinned to the bottom of the hangar */
.hangar-more {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 3100; pointer-events: none;
  display: flex; align-items: center; gap: 7px;
  padding: 7px 15px; border-radius: 999px;
  background: rgba(20, 27, 36, .92); border: 1px solid var(--accent);
  color: var(--accent); font-size: 12px; font-weight: 700;
  letter-spacing: .6px; text-transform: uppercase;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  transition: opacity .25s; animation: hangarBob 1.6s ease-in-out infinite;
}
.hangar-more .chev { font-size: 14px; line-height: 1; }
@keyframes hangarBob { 0%,100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(5px); } }
@media (prefers-reduced-motion: reduce) { .hangar-more { animation: none; } }

/* account chip in topbar */
.acct-chip {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  font-weight: 600; font-size: 12px; padding: 7px 11px; border-radius: 20px;
  white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis;
}
.acct-chip:hover { border-color: var(--accent); color: var(--accent); }

/* aircraft badge in topbar */
.ac-badge {
  background: var(--panel-2); border: 1px solid var(--accent); color: var(--accent);
  font-weight: 700; font-size: 12px; padding: 7px 12px; border-radius: 20px; white-space: nowrap;
}
.ac-badge:hover { background: #243140; }

/* performance panel */
.perf-panel { border-top: 1px solid var(--line); padding-bottom: 16px; }
.perf-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.fld { display: flex; flex-direction: column; gap: 3px; }
.fld.fuel-fld { grid-column: 1 / -1; }
.fld span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.fld span em { text-transform: none; color: #6b7a89; font-style: normal; }
.fld input { background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; color: var(--text); padding: 7px 9px; font-size: 13px; width: 100%; }
.fld input:focus { outline: none; border-color: var(--accent); }
.fuel-row { display: flex; gap: 6px; }
.mini { padding: 0 10px; font-size: 11px; background: var(--panel-2); color: var(--text); }
.btn.wide, button.wide { width: 100%; margin-top: 4px; }

.perf-out { margin: 6px 0 10px; display: flex; flex-direction: column; gap: 8px; }
.gauge-wrap { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; }
.gauge-top { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.gauge-top .lab { color: var(--muted); }
.gauge-top .val { font-weight: 700; }
.gauge { height: 8px; background: #0c141c; border-radius: 5px; overflow: hidden; }
.gauge .fill { height: 100%; border-radius: 5px; transition: width .25s; }
.fill.ok { background: var(--green); } .fill.warn { background: var(--amber); } .fill.bad { background: var(--danger); }
.perf-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pstat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; }
.pstat .k { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.pstat .v { font-size: 13px; font-weight: 700; margin-top: 1px; }
.pstat .v.good { color: var(--green); } .pstat .v.bad { color: var(--danger); } .pstat .v.warn { color: var(--amber); }
.alert { font-size: 11px; border-radius: 8px; padding: 7px 10px; }
.alert.bad { background: #2a1b1e; color: #fca5a5; border: 1px solid #5b2b30; }
.alert.warn { background: #2a2410; color: #fcd34d; border: 1px solid #5b4f1e; }
.alert.ok { background: #122a1c; color: #86efac; border: 1px solid #1e5b38; }
.fuel-stop-seq { background: var(--amber) !important; color: #2a1a02 !important; }
.route-item.fuel .ri-ident::after { content: " ⛽"; }

/* ===================== MOBILE (does not affect desktop ≥761px) ===================== */
@media (max-width: 760px) {
  body { -webkit-text-size-adjust: 100%; }
  #topbar { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .brand h1 { font-size: 14px; }
  .ac-badge { order: 3; }
  .plan-name-wrap { order: 6; flex-basis: 100%; max-width: none; }
  .top-actions { order: 7; margin-left: 0; flex-wrap: wrap; gap: 6px; }
  .top-actions button { flex: 1 1 auto; }
  .status { order: 8; flex-basis: 100%; text-align: left; min-width: 0; }

  main { flex-direction: column; }
  #sidebar { width: 100%; flex: 0 0 auto; border-right: none; border-bottom: 1px solid var(--line); max-height: none; }
  #mapWrap { flex: 0 0 auto; height: 70vh; min-height: 380px; }

  .hangar { padding: 14px 14px 64px; }
  .hangar-head { flex-direction: column; text-align: center; gap: 8px; margin-bottom: 16px; }
  .hangar-head h1 { font-size: 17px; letter-spacing: 1.2px; }
  .hangar-head .logo { width: 48px; height: 48px; font-size: 26px; }
  .hangar-cards { grid-template-columns: 1fr; gap: 14px; }
  .machine-card .art { height: 190px; }

  .seat { width: 56px; }
  .map-legend { font-size: 10px; padding: 7px 9px; }

  /* prevent iOS Safari from zooming the page when a field is focused (needs ≥16px) */
  input, select, textarea, #search, #planName { font-size: 16px; }
  .fld input, .fld span { font-size: 13px; }
  .fld input { font-size: 16px; }

  /* comfortable touch targets */
  button, .select-btn, .ghost, .primary { min-height: 44px; }
  .mini, .duty-info { min-height: 32px; }
  .top-actions button { padding: 10px 12px; }

  /* the planner stacks vertically on mobile, so let the PAGE scroll.
     (desktop keeps body locked + scrolls the sidebar/map internally) */
  html, body { height: auto; min-height: 100%; }
  body { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
  main { flex: 0 0 auto; min-height: 0; }
  #sidebar { overflow: visible; max-height: none; }
  #mapWrap { height: 60vh; min-height: 320px; }
  #topbar { position: sticky; top: 0; z-index: 30; }

  /* on mobile the sidebar is content-height and the whole page scrolls, so let
     the route panel/list grow with content instead of scrolling internally. */
  .panel.route-panel { flex: 0 0 auto; min-height: 0; overflow: visible; }
  #route { flex: 0 0 auto; overflow: visible; }
}
@media (max-width: 760px) and (orientation: landscape) {
  #mapWrap { height: 88vh; }
}

/* ===================== SEAT LAYOUT / BALANCE ===================== */
.seat-layout {
  background: linear-gradient(180deg, #10171f, #0d141b);
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 12px 12px;
  margin: 10px 0 8px; position: relative;
}
.seat-layout::before {        /* "nose" marker */
  content: "▲ NOSE"; position: absolute; top: 4px; left: 50%; transform: translateX(-50%);
  font-size: 8px; letter-spacing: 1px; color: var(--muted);
}
.seat-row { display: flex; justify-content: center; gap: 10px; margin-top: 14px; }
.seat {
  width: 64px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 5px 6px; text-align: center;
}
.seat.pilot { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(56,189,248,.3) inset; }
.seat .slab { font-size: 8.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 3px; }
.seat.pilot .slab { color: var(--accent); font-weight: 700; }
.seat input { width: 100%; background: #0c141c; border: 1px solid var(--line); border-radius: 6px;
  color: var(--text); text-align: center; padding: 5px 2px; font-size: 13px; font-weight: 600; }
.seat input:focus { outline: none; border-color: var(--accent); }
.seat .unit { font-size: 8px; color: #5f6f7d; margin-top: 1px; }
.seat.suggested { animation: pop .5s; border-color: var(--green); }
@keyframes pop { 0%{transform:scale(.9)} 50%{transform:scale(1.06)} 100%{transform:scale(1)} }
.bag-fld { margin: 2px 0 8px; }

.balance-out { display: flex; flex-direction: column; gap: 9px; margin: 6px 0 8px; }
.bal { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
.bal-top { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 6px; }
.bal-top .lab { color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.bal-top .val { font-weight: 700; }
.bal-track { position: relative; height: 8px; background: #0c141c; border-radius: 5px; }
.bal-track .center { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: #3a4856; }
.bal-track .band { position: absolute; top: 0; bottom: 0; background: rgba(74,222,128,.16); border-radius: 5px; }
.bal-track .mark { position: absolute; top: -3px; width: 14px; height: 14px; border-radius: 50%;
  transform: translateX(-50%); border: 2px solid #0c141c; transition: left .25s; }
.mark.ok { background: var(--green); } .mark.warn { background: var(--amber); } .mark.bad { background: var(--danger); }
.bal-track .mark.land { background: transparent; border: 2px solid #cbd5e1; width: 11px; height: 11px;
  top: -1px; border-radius: 2px; transform: translateX(-50%) rotate(45deg); z-index: 1; }
.bal-ends { display: flex; justify-content: space-between; font-size: 8.5px; color: #5f6f7d; margin-top: 3px; }
.bal-fuelnote { font-size: 9.5px; color: var(--muted); margin-top: 7px; line-height: 1.35; opacity: .85; }
.balance-note { opacity: .8; }

/* ===================== WEATHER (right overlay on map) ===================== */
.wx-right {
  position: absolute; top: 12px; right: 12px; z-index: 600; width: 312px;
  max-width: 42vw; max-height: calc(100% - 24px); display: flex; flex-direction: column;
  background: rgba(15,21,29,.93); border: 1px solid var(--line); border-radius: 12px;
  backdrop-filter: blur(8px); box-shadow: 0 12px 34px rgba(0,0,0,.5); overflow: hidden;
}
.wx-right-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 12px;
  font-weight: 700; letter-spacing: .3px; flex: 0 0 auto;
}
.wx-out { display: flex; flex-direction: column; gap: 9px; padding: 11px; overflow-y: auto; }
.wx-near { font-size: 10px; color: var(--amber); margin: -3px 0 7px; }
@media (max-width: 760px) {
  /* bottom sheet instead of a narrow box that hides the map */
  .wx-right {
    top: auto; right: 8px; left: 8px; bottom: 8px;
    width: auto; max-width: none; max-height: 42%;
  }
  .wx-out { padding: 8px; } .wx-grid { grid-template-columns: 1fr 1fr; }
}
.wx-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; }
.wx-card.loading { opacity: .6; }
.wx-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.wx-role { font-size: 9px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; padding: 2px 7px; border-radius: 5px; background: #243140; color: var(--accent); }
.wx-role.dest { color: var(--green); }
.wx-id { font-weight: 700; font-size: 13px; }
.wx-name { font-size: 10px; color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wx-cat { font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 5px; }
.wx-cat.VFR { background: #123a22; color: #4ade80; }
.wx-cat.MVFR { background: #102a44; color: #60a5fa; }
.wx-cat.IFR { background: #3a1320; color: #f87171; }
.wx-cat.LIFR { background: #2a1233; color: #d8b4fe; }
.wx-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.wx-stat { background: #0c141c; border-radius: 7px; padding: 5px 8px; }
.wx-stat .k { font-size: 8.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.wx-stat .v { font-size: 13px; font-weight: 700; margin-top: 1px; }
.wx-stat .v.warn { color: var(--amber); } .wx-stat .v.bad { color: var(--danger); } .wx-stat .v.good { color: var(--green); }
.wx-stat.wide { grid-column: 1 / -1; }
.wx-raw { font-size: 10px; color: #7c8b9a; font-family: ui-monospace, Menlo, monospace; margin-top: 7px; word-break: break-word; line-height: 1.4; }
.wx-note { font-size: 10.5px; margin-top: 7px; border-radius: 7px; padding: 5px 8px; }
.wx-note.warn { background: #2a2410; color: #fcd34d; } .wx-note.bad { background: #2a1b1e; color: #fca5a5; }

/* ===================== AIRSPACE DEMO BANNER ===================== */
.as-demo-banner {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 650;
  background: rgba(127,29,29,.94); color: #fee2e2; border: 1px solid #ef4444;
  padding: 7px 14px; border-radius: 9px; font-size: 11.5px; max-width: 80%;
  text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.5); backdrop-filter: blur(6px);
}
@media (max-width: 760px) { .as-demo-banner { font-size: 10px; max-width: 92%; top: 6px; } }

/* ===================== MAP AIRPORT MARKERS ===================== */
.apt-dot { border-radius: 50%; border: 1.5px solid rgba(0,0,0,.55); box-sizing: border-box; cursor: pointer; }
.apt-dot.r3 { background: #38bdf8; }   /* large */
.apt-dot.r2 { background: #34d399; }   /* medium */
.apt-dot.r1 { background: #94a3b8; }   /* small */
.apt-dot.r0 { background: #64748b; }   /* heli/other */
.map-legend {
  position: absolute; bottom: 10px; left: 10px; z-index: 500;
  background: rgba(20,27,36,.92); border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 11px; font-size: 11px; backdrop-filter: blur(6px);
}
.map-legend b { display: block; margin-bottom: 5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-size: 9px; }
.map-legend .row { display: flex; align-items: center; gap: 7px; margin-top: 3px; }
.map-legend .sw { width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(0,0,0,.5); }
.map-legend .lg-check { cursor: pointer; margin-top: 5px; }
.map-legend .lg-check input { margin: 0; accent-color: var(--accent); }
.map-legend .lg-note { font-size: 9px; color: var(--amber); margin-top: 5px; }
