/* Cockpit-first styles: big targets (>= 56px), high contrast, tabular numbers, three themes.
   data-theme on <html>: "dark" (default), "day" (sunlight), "night" (red, preserves night vision). */
:root {
  --bg: #0b0f14;
  --panel: #131a23;
  --panel-2: #1a2330;
  --line: #263142;
  --text: #eef3f8;
  --muted: #9aa8ba;
  --faint: #6b7785;
  --emer: #e5484d;
  --emer-ink: #ffffff;
  --divert: #2f80ed;
  --divert-ink: #ffffff;
  --ok: #30a46c;
  --warn: #f5b40b;
  --bad: #e5484d;
  --grey: #7a8796;
  --accent: #7cc4ff;
  --ring-1: #30a46c;
  --ring-2: #f5b40b;
  --focus: #7cc4ff;
  --chip: #202b39;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --radius: 14px;
  --gutter: 16px;
  color-scheme: dark;
}
:root[data-theme="day"] {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #eef2f7;
  --line: #cfd7e2;
  --text: #0b1520;
  --muted: #3d4b5c;
  --faint: #66768a;
  --emer: #c8102e;
  --divert: #0b5fd6;
  --ok: #137a43;
  --warn: #9a6700;
  --bad: #c8102e;
  --grey: #66768a;
  --accent: #0b5fd6;
  --ring-1: #137a43;
  --ring-2: #b07800;
  --focus: #0b5fd6;
  --chip: #e6ebf2;
  --shadow: none;
  color-scheme: light;
}
:root[data-theme="night"] {
  --bg: #000000;
  --panel: #0d0000;
  --panel-2: #160202;
  --line: #3a0b0b;
  --text: #ff6b5e;
  --muted: #c4463c;
  --faint: #8a2f28;
  --emer: #ff3b30;
  --emer-ink: #000000;
  --divert: #a8261c;
  --divert-ink: #000000;
  --ok: #ff6b5e;
  --warn: #ff8a5e;
  --bad: #ff3b30;
  --grey: #8a2f28;
  --accent: #ff8a5e;
  --ring-1: #ff6b5e;
  --ring-2: #b5372d;
  --focus: #ff8a5e;
  --chip: #1d0505;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
  font-variant-numeric: tabular-nums;
  overscroll-behavior: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
a { color: var(--accent); }

.app {
  max-width: 1100px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.boot { margin: auto; text-align: center; padding: 40px var(--gutter); }
.boot-mark { font-weight: 800; letter-spacing: 0.18em; font-size: 28px; }
.boot-sub { color: var(--muted); margin-top: 8px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px var(--gutter);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky; top: 0; z-index: 5;
  min-height: 56px;
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 800; letter-spacing: 0.06em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar h1.emer { color: var(--emer); }
.iconbtn {
  min-width: 48px; min-height: 48px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 12px;
}
.iconbtn.hl { border-color: var(--warn); box-shadow: 0 0 0 2px color-mix(in srgb, var(--warn) 35%, transparent); }
.iconbtn svg { width: 22px; height: 22px; }

.status {
  display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center;
  padding: 8px var(--gutter); color: var(--muted); font-size: 14px;
  border-bottom: 1px solid var(--line);
}
.status b { color: var(--text); font-weight: 650; }
.sim-banner {
  background: repeating-linear-gradient(45deg, var(--warn), var(--warn) 10px, color-mix(in srgb, var(--warn) 70%, black) 10px, color-mix(in srgb, var(--warn) 70%, black) 20px);
  color: #000; font-weight: 800; text-align: center; padding: 4px; font-size: 13px; letter-spacing: 0.08em;
}
.banner {
  margin: 10px var(--gutter) 0; padding: 10px 12px; border-radius: 12px; font-size: 15px;
  border: 1px solid var(--line); background: var(--panel);
}
.banner.warn { border-color: var(--warn); }
.banner.bad { border-color: var(--bad); }
.banner button { margin-top: 8px; }

main { flex: 1; padding: 12px var(--gutter) 24px; }
.footer { color: var(--faint); font-size: 13px; padding: 10px var(--gutter) 18px; text-align: center; }

/* ---------- home ---------- */
.home-grid { display: grid; gap: 12px; }
.bigbtn {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  width: 100%; min-height: 150px; border: 0; border-radius: 20px; padding: 18px 20px; text-align: left;
}
.bigbtn .t { font-size: 34px; font-weight: 850; letter-spacing: 0.06em; }
.bigbtn .s { font-size: 16px; opacity: 0.92; margin-top: 4px; }
.bigbtn.emer { background: var(--emer); color: var(--emer-ink); min-height: 190px; }
.bigbtn.divert { background: var(--divert); color: var(--divert-ink); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow);
}
.card h2, .card h3 { margin: 0 0 6px; font-size: 16px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel-2); }
.seg button { min-height: 52px; min-width: 64px; padding: 0 14px; border: 0; background: transparent; font-weight: 650; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.seg.small button { min-height: 44px; min-width: 52px; font-size: 15px; }
.label { color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quick button { min-height: 56px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-weight: 600; }
.aircraft-line { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 60px; text-align: left; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); padding: 10px 14px; }
.aircraft-line .nm { font-weight: 700; flex: 1; }
.aircraft-line svg { width: 26px; height: 26px; flex: none; color: var(--muted); }

/* ---------- emergency ---------- */
.glide-banner {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  background: var(--emer); color: var(--emer-ink); border-radius: 16px; padding: 10px 16px; margin-bottom: 10px;
}
.glide-banner .v { font-size: 40px; font-weight: 900; line-height: 1; }
.glide-banner .k { font-size: 15px; font-weight: 700; letter-spacing: 0.08em; }
.glide-banner .side { text-align: right; font-size: 14px; font-weight: 700; }
.split { display: grid; gap: 12px; }
@media (min-width: 900px) {
  .split { grid-template-columns: minmax(320px, 420px) 1fr; align-items: start; }
  .split > .sticky { position: sticky; top: 70px; }
}
.scope { width: 100%; max-width: 420px; aspect-ratio: 1; display: block; margin: 0 auto; }
.scope text { font-family: inherit; }

.group-h { margin: 16px 0 8px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 750; display: flex; align-items: center; gap: 8px; }
.group-h .ct { color: var(--faint); font-weight: 600; }
.opt {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 4px 12px; align-items: start;
  width: 100%; text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius);
  padding: 12px; margin-bottom: 8px; min-height: 76px;
}
.opt:active { background: var(--panel-2); }
.opt .num { grid-row: span 2; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; background: var(--chip); font-size: 18px; }
.opt.t-comfortable .num { background: var(--ring-1); color: #000; }
.opt.t-marginal .num { background: var(--ring-2); color: #000; }
.opt .id { font-weight: 800; font-size: 20px; }
.opt .nm { color: var(--muted); font-size: 15px; margin-left: 6px; font-weight: 500; }
.opt .nav { text-align: right; font-weight: 750; font-size: 20px; white-space: nowrap; }
.opt .nav small { display: block; color: var(--muted); font-weight: 600; font-size: 14px; }
.opt .det { grid-column: 2 / 4; color: var(--muted); font-size: 15px; }
.opt .det b { color: var(--text); font-weight: 650; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { font-size: 13px; padding: 3px 8px; border-radius: 999px; background: var(--chip); color: var(--text); border: 1px solid var(--line); white-space: nowrap; }
.chip.warn { border-color: var(--warn); color: var(--warn); }
.chip.bad { border-color: var(--bad); color: var(--bad); }
.chip.ok { border-color: var(--ok); color: var(--ok); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 14px; }

/* provenance dots */
.pv { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 4px 1px 2px; vertical-align: middle; flex: none; }
.pv-g { background: var(--ok); }
.pv-y { background: var(--warn); }
.pv-r { background: var(--bad); }
.pv-x { background: var(--grey); }
.pv-u { background: transparent; border: 2px solid var(--text); width: 10px; height: 10px; }

/* ---------- divert / decided ---------- */
.refine-sum { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.decided-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin-bottom: 10px; }
.decided-head .big { font-size: 34px; font-weight: 900; }
.decided-head .nm { color: var(--muted); font-size: 18px; }
.direct { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.direct .cell { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.direct .cell .k { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.direct .cell .v { font-size: 26px; font-weight: 850; }
.diagram { width: 100%; max-width: 460px; aspect-ratio: 1; display: block; margin: 0 auto; background: var(--panel); border-radius: var(--radius); border: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: baseline; }
.kv .k { color: var(--muted); font-size: 14px; }
.kv .v { font-weight: 650; }
.freq { font-size: 22px; font-weight: 850; }
.rwy { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.rwy:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.rwy h4 { margin: 0 0 4px; font-size: 17px; }
.endline { margin: 4px 0 0 0; font-size: 15px; color: var(--muted); }
.endline b { color: var(--text); }
.rmk { font-size: 13px; color: var(--faint); margin-top: 4px; }
.stack { display: grid; gap: 12px; align-content: start; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  min-height: 52px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--text);
}
.btn.primary { background: var(--divert); border-color: var(--divert); color: var(--divert-ink); }
.btn.danger { background: var(--emer); border-color: var(--emer); color: var(--emer-ink); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
details.more { margin-top: 8px; }
details.more summary { cursor: pointer; min-height: 48px; display: flex; align-items: center; color: var(--muted); font-weight: 650; }

/* ---------- sheet (refine) ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 720px; max-height: 92vh; overflow: auto; background: var(--bg); border: 1px solid var(--line);
  border-radius: 18px 18px 0 0; padding: 12px var(--gutter) calc(18px + env(safe-area-inset-bottom));
}
.sheet h2 { margin: 6px 0 12px; font-size: 20px; }
.field { margin-bottom: 16px; }
.field .hint { color: var(--faint); font-size: 13px; margin-top: 4px; }
.num-in { width: 110px; min-height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); padding: 0 12px; font-size: 20px; font-weight: 700; }
.txt-in { width: 100%; min-height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); padding: 0 12px; font-size: 18px; }
.compass { display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(3, 56px); gap: 6px; }
.compass button { border-radius: 10px; border: 1px solid var(--line); background: var(--panel); font-weight: 700; }
.compass button[aria-pressed="true"] { background: var(--warn); color: #000; border-color: var(--warn); }
.compass .c { visibility: hidden; }

/* ---------- profile ---------- */
.ptable { width: 100%; border-collapse: collapse; }
.ptable td { padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: middle; }
.ptable td.l { color: var(--muted); font-size: 15px; }
.ptable input[type="number"] { width: 100px; min-height: 46px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); padding: 0 8px; font-size: 18px; font-weight: 700; }
.ptable input[type="checkbox"], .check input { width: 28px; height: 28px; accent-color: var(--ok); }
.check { display: flex; gap: 10px; align-items: center; min-height: 48px; }
.list-pick { display: grid; gap: 8px; }
.list-pick button { text-align: left; min-height: 56px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); padding: 8px 12px; }
.list-pick button[aria-pressed="true"] { border-color: var(--ok); box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok) 40%, transparent); }
.src { font-size: 12px; color: var(--faint); }
.legal { font-size: 16px; line-height: 1.5; }
.legal li { margin-bottom: 8px; }
.empty { padding: 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 650; z-index: 30; max-width: calc(100% - 32px); }
.btn[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
