/* WingsLevel PWA. dp -> CSS px, sp -> CSS px (default font scale). */
:root {
  --primary: #66BB6A;
  --on-primary: #0B0C0F;
  --surface: #0B0C0F;
  --on-surface: #EDEDED;
  --night-text: #FF4444;
  --mono: 'Roboto Mono', 'Droid Sans Mono', 'DejaVu Sans Mono', Menlo, Consolas, monospace;
  --sans: Roboto, 'Segoe UI', system-ui, -apple-system, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; background: #000; color: var(--on-surface);
  font-family: var(--sans); overflow: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
#app { position: fixed; inset: 0; background: #000; overflow: hidden; }
button { font: inherit; color: inherit; }
canvas { display: block; }

/* ---------------------------------------------------------------- Disclaimer */
.disclaimer { position: absolute; inset: 0; background: #121212; overflow-y: auto; }
.disclaimer-col {
  min-height: 100%; padding: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  max-width: 640px; margin: 0 auto;
}
.disclaimer-icon { width: 64px; height: 64px; flex: none; }
.disclaimer-title { font-size: 28px; line-height: 36px; font-weight: 700; color: #fff; text-align: center; }
.disclaimer-card { background: #222; border-radius: 8px; padding: 16px; align-self: stretch; }
.disclaimer-card-title { font-size: 16px; line-height: 24px; font-weight: 700; color: #FF5555; padding-bottom: 8px; letter-spacing: .15px; }
.disclaimer-card-body { font-size: 16px; line-height: 24px; color: #fff; letter-spacing: .5px; }
.disclaimer-bullets { align-self: stretch; color: #CCCCCC; font-size: 16px; line-height: 24px; letter-spacing: .5px; }
.disclaimer-bullets > div + div { margin-top: 4px; }
.disclaimer-check {
  align-self: stretch; display: flex; align-items: center; gap: 8px; padding: 8px; cursor: pointer;
  color: #fff; font-size: 16px; line-height: 24px; letter-spacing: .5px;
}
.m3-checkbox {
  flex: none; width: 18px; height: 18px; margin: 11px; border: 2px solid #C4C7C5; border-radius: 2px; position: relative;
}
.m3-checkbox.checked { background: var(--primary); border-color: var(--primary); }
.m3-checkbox.checked::after {
  content: ''; position: absolute; left: 4px; top: 0; width: 5px; height: 10px;
  border: solid var(--on-primary); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.disclaimer-accept { align-self: stretch; height: 56px; font-size: 18px !important; font-weight: 700 !important; }

/* ---------------------------------------------------------------- Material-style controls */
.m3-button {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 40px; padding: 10px 24px;
  border: 0; border-radius: 20px; background: var(--primary); color: var(--on-primary);
  font-size: 14px; font-weight: 500; letter-spacing: .1px; line-height: 20px; cursor: pointer; text-align: center;
}
.m3-button:active { filter: brightness(1.12); }
.m3-button:disabled { background: rgba(237, 237, 237, .12); color: rgba(237, 237, 237, .38); cursor: default; filter: none; }
.m3-button.tall { height: 60px; }

.m3-field { position: relative; display: block; width: 100%; }
.m3-field-input {
  width: 100%; height: 56px; padding: 16px; border: 1px solid #8E918F; border-radius: 4px; background: transparent;
  color: var(--on-surface); font-size: 16px; letter-spacing: .5px; outline: none;
  -webkit-user-select: text; user-select: text;
}
.m3-field-input:focus { border: 2px solid var(--primary); padding: 15px; }
.m3-field-label {
  position: absolute; left: 12px; top: 16px; padding: 0 4px; color: #C4C7C5; font-size: 16px; line-height: 24px;
  pointer-events: none; transition: all .15s; background: #000;
}
.m3-field-input:focus + .m3-field-label,
.m3-field-input:not(:placeholder-shown) + .m3-field-label { top: -10px; font-size: 12px; line-height: 16px; }
.m3-field-input:focus + .m3-field-label { color: var(--primary); }

.m3-switch {
  flex: none; position: relative; width: 52px; height: 32px; border-radius: 16px; border: 2px solid #8E918F; background: #333537;
}
.m3-switch::after {
  content: ''; position: absolute; top: 6px; left: 6px; width: 16px; height: 16px; border-radius: 50%; background: #8E918F;
  transition: all .15s;
}
.m3-switch.checked { background: #1B5E20; border-color: #1B5E20; }
.m3-switch.checked::after { left: 22px; top: 2px; width: 24px; height: 24px; background: var(--primary); }
.sheet.night .m3-switch.checked { background: #330000; border-color: #330000; }
.sheet.night .m3-switch.checked::after { background: var(--night-text); }

/* ---------------------------------------------------------------- Main layout */
.main { position: absolute; inset: 0; display: flex; background: #000; overflow: hidden; }
.main.portrait { flex-direction: column; }
.main.landscape { flex-direction: row; }
.main > * { flex: 1 1 0; min-width: 0; min-height: 0; }

/* ---------------------------------------------------------------- Attitude pane */
.att-pane { position: relative; overflow: hidden; }
.att-row { position: absolute; inset: 0; display: flex; flex-direction: row; align-items: center; }
.tape-wrap { flex: none; height: 70%; padding: 8px 0; }
.tape-wrap > canvas { height: 100%; }
.tape-speed { width: 28px; }
.tape-alt { width: 36px; }
.tape-vsi { width: 24px; }
.alt-col { position: relative; flex: none; align-self: stretch; display: flex; flex-direction: column; justify-content: center; cursor: pointer; }
.alt-col-tapes { display: flex; flex-direction: row; height: 70%; }
.alt-col-tapes > .tape-wrap { height: 100%; }
/* Altitude bug readout under the altitude and VSI tapes (orange like HDG BUG; dim while none is set). */
.alt-bug {
  position: absolute; left: 0; right: 0; top: calc(85% + 2px); padding: 2px 0; background: #000; border: 1px solid #5E5E5E;
  font-family: var(--mono); font-weight: 700; text-align: center; color: #8A8A8A; line-height: 1.15;
}
.alt-bug-label { font-size: 9px; letter-spacing: .3px; }
.alt-bug-value { font-size: 14px; }
.alt-bug.set { color: #FF8A00; border-color: #FF8A00; }
.alt-bug.night { color: #802222; border-color: #802222; }
.alt-bug.night.set { color: #FF0000; border-color: #FF0000; }
.att-center { position: relative; flex: 1 1 0; min-width: 0; height: 100%; padding: 8px 0; }
.att-center > .att-canvas, .att-center > .svt-canvas {
  position: absolute; left: 0; right: 0; top: 8px; bottom: 8px; width: 100%; height: calc(100% - 16px);
}
.svt-msg { position: absolute; left: 8px; bottom: 16px; font-size: 10px; line-height: 16px; color: #fff; letter-spacing: .5px; }
.svt-canvas.estimated { opacity: .55; }
.svt-gps-lost {
  position: absolute; left: 50%; top: 22%; transform: translateX(-50%); z-index: 1; pointer-events: none; white-space: nowrap;
  background: #000; border: 2px solid #FFB300; color: #FFB300; padding: 3px 10px;
  font-family: var(--mono); font-weight: 700; font-size: 14px; letter-spacing: .5px;
}
.turnslip { position: absolute; left: 50%; bottom: 18px; width: 150px; height: 64px; transform: translateX(-50%); pointer-events: none; }

.small-label { font-size: 10px; line-height: 16px; letter-spacing: .5px; color: #fff; font-weight: 500; white-space: pre; }
.att-topleft {
  position: absolute; left: 0; top: 0; padding: 12px; display: flex; flex-direction: column; gap: 8px; z-index: 2;
}
.status-row { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.status-gps { width: 22px; height: 22px; }
.status-batt { width: 28px; height: 22px; }
.icon-btn {
  width: 36px; height: 36px; padding: 8px; border: 0; border-radius: 50%; background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: rgba(255, 255, 255, .12); }
.icon-btn svg { width: 20px; height: 20px; }

.att-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.att-overlay > * { pointer-events: auto; }
.debug-overlay { position: absolute; top: 0; right: 0; padding: 12px; text-align: left; pointer-events: none !important; }
.no-sensor { position: absolute; left: 0; bottom: 0; padding: 16px; font-size: 16px; line-height: 24px; color: var(--on-surface); }
.compass-wrap {
  position: absolute; top: 0; left: 50%; width: 65%; height: 32px; transform: translateX(-50%); overflow: hidden; pointer-events: none !important;
}
.compass-wrap > canvas { width: 100%; height: 100%; }
/* During a Direct-To the heading tape also shows outside full screen (in portrait the status icons move under
   it, as in full screen), with the destination readout under it (js/ui/navHud.js). In landscape the
   attitude view is narrower, so the tape is too, to stay clear of the status icons. */
.compass-wrap.nav-narrow { width: 40%; }
.nav-readout {
  position: absolute; left: 50%; top: 36px; transform: translateX(-50%); pointer-events: none !important; white-space: nowrap;
  background: rgba(0, 0, 0, .6); padding: 1px 6px; font-family: var(--mono); font-weight: 700; font-size: 11px; letter-spacing: .3px;
}
.hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, calc(-50% - 48px)); pointer-events: none !important;
}
.hint-box {
  background: rgba(0, 0, 0, .8); border-radius: 8px; padding: 16px 24px; display: flex; flex-direction: column; align-items: center;
}
.hint-text { color: #fff; font-size: 16px; line-height: 24px; font-weight: 500; text-align: center; letter-spacing: .15px; white-space: nowrap; }
.hint-progress { margin-top: 8px; width: 180px; height: 6px; border-radius: 3px; background: #444; overflow: hidden; }
.hint-progress-fill { height: 100%; width: 0; background: var(--primary); border-radius: 3px; }
.fs-btn {
  position: absolute; top: 4px; right: 4px; width: 48px; height: 48px; padding: 8px; border: 0; border-radius: 50%;
  background: transparent; cursor: pointer;
}
.fs-circle {
  display: flex; width: 100%; height: 100%; padding: 6px; border-radius: 50%; background: rgba(0, 0, 0, .5); border: 1px solid #fff;
}
.fs-circle svg { width: 100%; height: 100%; }

/* ---------------------------------------------------------------- HSI pane */
.hsi-pane { position: relative; background: #000; overflow: hidden; }
.hsi-view, .sub-screen { position: absolute; inset: 0; }
.hsi-canvas, .hsi-gesture { position: absolute; inset: 0; width: 100%; height: 100%; }
.hsi-gesture { touch-action: none; }
.hsi-hdg {
  position: absolute; transform: translateX(-50%); background: #000; border: 2px solid #fff; padding: 2px 10px;
  font-family: var(--mono); font-weight: 700; line-height: 1.2; white-space: nowrap; pointer-events: none;
}
.hsi-readouts {
  position: absolute; display: flex; flex-direction: column; gap: 0; padding: 0 6px; box-sizing: border-box;
  font-family: var(--mono); font-weight: 700; pointer-events: none;
}
.hsi-readout { white-space: nowrap; text-align: left; pointer-events: none; }
.hsi-readout.clickable { pointer-events: auto; cursor: pointer; }
.dt-banner { position: absolute; color: #FF00FF; text-align: left; cursor: pointer; letter-spacing: .4px; }
.dt-banner-code, .dt-banner-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.25; }
.dt-banner-code { font-weight: 700; }
.dt-banner-name { font-size: .8em; }
.dt-banner-name:empty { display: none; }
/* Runway for the approach path under a Direct-To airport (Auto or picked), and its list. */
.dt-rwy-chip {
  display: inline-block; margin-top: 6px; padding: 3px 10px; border: 2px solid #FF00FF; border-radius: 14px;
  background: rgba(255, 0, 255, .08); color: #FF00FF; font: 700 14px var(--mono); letter-spacing: .3px; cursor: pointer;
}
.dt-rwy-chip.night { border-color: var(--night-text); color: var(--night-text); background: transparent; }
.rwy-menu-scrim { position: fixed; inset: 0; z-index: 50; }
.rwy-menu {
  position: fixed; width: 250px; background: #1b1b1b; border: 2px solid #FF00FF; border-radius: 10px; overflow: hidden;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .6); font: 700 15px var(--mono);
}
.rwy-menu-row {
  display: flex; gap: 12px; align-items: center; width: 100%; padding: 9px 14px; border: 0; border-bottom: 1px solid #333;
  background: transparent; text-align: left; font: inherit; cursor: pointer;
}
.rwy-menu-row:last-child { border-bottom: 0; }
.rwy-menu-row[aria-pressed="true"] { background: rgba(255, 0, 255, .18); }
.rwy-menu-ident { width: 52px; flex: none; color: #FF00FF; }
.rwy-menu-text { color: #ddd; font-weight: 400; }
.rwy-menu-scrim.night .rwy-menu { background: #111; border-color: var(--night-text); }
.rwy-menu-scrim.night .rwy-menu-row { border-color: #802222; }
.rwy-menu-scrim.night .rwy-menu-row[aria-pressed="true"] { background: #330000; }
.rwy-menu-scrim.night .rwy-menu-ident, .rwy-menu-scrim.night .rwy-menu-text { color: var(--night-text); }
/* Direct-To keys: styled after avionics bezel softkeys (dark key, legend glyph + caption). */
.dt-btn {
  position: absolute; left: 12px; width: 60px; height: 60px; padding: 6px 0 5px; border-radius: 7px;
  background: linear-gradient(#2e2e2e, #151515); border: 1px solid #5a5a5a; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 2px 4px rgba(0,0,0,.6);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  -webkit-tap-highlight-color: transparent;
}
.dt-btn:active { background: linear-gradient(#151515, #222); box-shadow: inset 0 2px 4px rgba(0,0,0,.7); }
.dt-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.dt-set { top: 12px; }
.dt-cancel { bottom: 12px; }
/* Annunciator bar: lit while a Direct-To is active, like a softkey whose function is engaged. */
.dt-set::after {
  content: ''; position: absolute; left: 14px; right: 14px; top: 3px; height: 3px; border-radius: 2px; background: #3a3a3a;
}
.dt-set.active::after { background: #FF00FF; box-shadow: 0 0 4px #FF00FF; }
.dt-svg { width: 38px; height: 28px; margin-top: 4px; }
.dt-set .dt-glyph { stroke: #FF00FF; }
.dt-set .dt-head { fill: #FF00FF; }
.dt-cancel .dt-glyph { stroke: #9a9a9a; }
.dt-cancel .dt-head { fill: #9a9a9a; }
.dt-knock { stroke: #202020; }
.dt-strike { stroke: #FF3B30; }
.dt-caption { font-family: var(--mono); font-weight: 700; font-size: 10px; letter-spacing: .8px; line-height: 1; color: #e6e6e6; }

.round-btn {
  position: absolute; top: 12px; left: 12px; min-width: 48px; height: 48px; border-radius: 24px; background: #000;
  border: 2px solid #fff; color: #fff; font-size: 16px; line-height: 24px; letter-spacing: .5px; padding: 0 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; z-index: 2;
}

/* ---------------------------------------------------------------- Direct-To screens */
.dt-menu { position: absolute; inset: 0; padding: 16px; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.dt-search, .dt-nearest, .dt-info {
  position: absolute; inset: 0; padding: 56px 16px 16px; display: flex; flex-direction: column; overflow: hidden;
}
.dt-nearest, .dt-info { padding-top: 76px; }
.dt-info { overflow-y: auto; display: block; }
.dt-results { flex: 1 1 0; overflow-y: auto; min-height: 0; }
.dt-empty { text-align: center; padding-top: 24px; color: #fff; font-size: 16px; line-height: 24px; }
.dt-nogps { padding-top: 24px; color: #fff; font-size: 16px; line-height: 24px; }
.dt-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px; cursor: pointer; }
.dt-row:active { background: rgba(255, 255, 255, .08); }
.dt-row-main { flex: 1 1 0; min-width: 0; padding-right: 12px; }
.dt-row-code { color: #fff; font-size: 16px; line-height: 24px; letter-spacing: .5px; }
.dt-row-sub {
  color: rgba(255, 255, 255, .7); font-size: 16px; line-height: 24px; letter-spacing: .5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.dt-row-dist { flex: none; width: 22%; text-align: right; white-space: nowrap; color: rgba(255, 255, 255, .85); font-size: 16px; line-height: 24px; }
.dt-info-title {
  color: #fff; font-size: 16px; line-height: 24px; font-weight: 500; letter-spacing: .15px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.dt-info-section { color: #fff; font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: .1px; }
.dt-info-row { color: #fff; font-size: 14px; line-height: 20px; letter-spacing: .25px; padding: 2px 0; -webkit-user-select: text; user-select: text; }

/* ---------------------------------------------------------------- Settings sheet */
.scrim { position: absolute; inset: 0; z-index: 10; background: rgba(0, 0, 0, 0); transition: background .2s; display: flex; align-items: flex-end; justify-content: center; }
.scrim.open { background: rgba(0, 0, 0, .32); }
.sheet {
  width: 100%; max-width: 640px; max-height: calc(100% - 56px); display: flex; flex-direction: column;
  background: var(--surface); border-radius: 28px 28px 0 0; transform: translateY(100%); transition: transform .2s ease-out;
}
.scrim.open .sheet { transform: translateY(0); }
.sheet.night { background: #111111; }
.sheet-handle-area { flex: none; padding: 22px 0; display: flex; justify-content: center; touch-action: none; cursor: grab; }
.sheet-handle { width: 32px; height: 4px; border-radius: 2px; background: rgba(196, 199, 197, .4); }
.sheet-content { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.sheet-title { font-size: 24px; line-height: 32px; color: var(--on-surface); }
.sheet.night .sheet-title, .sheet.night .sheet-row-label { color: var(--night-text); }
.sheet-row { display: flex; align-items: center; padding: 8px 0; cursor: pointer; }
.sheet-row-label { flex: 1; font-size: 16px; line-height: 24px; letter-spacing: .5px; color: var(--on-surface); }

/* Offline terrain tiles (settings sheet) */
.sheet-group { display: flex; flex-direction: column; gap: 8px; }
.sheet-progress { width: 100%; margin-top: 0; }
.sheet-status { font-size: 12px; line-height: 16px; letter-spacing: .4px; color: #C4C7C5; white-space: pre-line; }
.sheet-status:empty { display: none; }
.sheet.night .sheet-status { color: var(--night-text); }

/* Screen orientation (settings sheet): two-way segmented choice */
.seg { display: flex; border: 1px solid #8E918F; border-radius: 20px; overflow: hidden; }
.seg-btn {
  flex: 1; min-height: 40px; border: 0; background: transparent; color: var(--on-surface);
  font-size: 14px; font-weight: 500; letter-spacing: .1px; cursor: pointer;
}
.seg-btn + .seg-btn { border-left: 1px solid #8E918F; }
.seg-btn.selected { background: var(--primary); color: var(--on-primary); }
.sheet.night .seg { border-color: var(--night-text); }
.sheet.night .seg-btn { color: var(--night-text); }
.sheet.night .seg-btn.selected { background: #330000; }

/* Ground attitude (settings sheet): minus / value / plus */
.stepper { align-items: center; }
.stepper-btn { flex: 0 0 56px; font-size: 20px; }
.stepper-value { flex: 1; text-align: center; font-size: 14px; font-weight: 500; color: var(--on-surface); border-left: 1px solid #8E918F; border-right: 1px solid #8E918F; line-height: 40px; }
.sheet.night .stepper-value { color: var(--night-text); border-color: var(--night-text); }

/* Realign prompt after the screen orientation changed */
.scrim.realign { align-items: center; padding: 24px; z-index: 20; }
.dialog {
  width: 100%; max-width: 420px; padding: 24px; border-radius: 28px; background: #1E2022;
  display: flex; flex-direction: column; gap: 16px;
}
.dialog-title { font-size: 24px; line-height: 32px; color: var(--on-surface); }
.dialog-body { font-size: 14px; line-height: 20px; letter-spacing: .25px; color: #C4C7C5; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.dialog-actions .m3-button { width: auto; }
.text-btn { border: 0; background: transparent; color: var(--primary); font-size: 14px; font-weight: 500; padding: 10px 12px; cursor: pointer; }
.realign.night .dialog { background: #111111; }
.realign.night .dialog-title, .realign.night .dialog-body, .realign.night .text-btn { color: var(--night-text); }
.realign.night .m3-button { background: #330000; color: var(--night-text); }
/* Altitude bug picker (tap the altitude tape) */
.alt-picker-value { font-family: var(--mono); font-size: 40px; line-height: 48px; font-weight: 700; text-align: center; color: #FF8A00; }
.alt-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.alt-step {
  min-height: 56px; border: 1px solid #8E918F; border-radius: 12px; background: #2A2C2E; color: var(--on-surface);
  font-family: var(--mono); font-size: 18px; font-weight: 700; cursor: pointer; padding: 0;
}
.alt-step:active { background: #3A3C3E; }
.alt-picker-row { display: flex; justify-content: center; }
.alt-picker .dialog-actions { flex-wrap: wrap; }
.alt-picker .alt-clear { margin-right: auto; }
.realign.night .alt-picker-value { color: #FF0000; }
.realign.night .alt-step { background: #1A0000; border-color: var(--night-text); color: var(--night-text); }
.magcal-steps { margin: 0; padding-left: 20px; font-size: 14px; line-height: 20px; letter-spacing: .25px; color: #C4C7C5; }
.magcal-steps li + li { margin-top: 6px; }
.magcal-progress { width: 100%; }
.magcal-status { font-size: 14px; line-height: 20px; color: var(--on-surface); }
.magcal-heading { font-family: var(--mono); font-size: 22px; font-weight: 700; color: var(--on-surface); }
.realign.night .magcal-steps, .realign.night .magcal-status, .realign.night .magcal-heading { color: var(--night-text); }
.realign.night .magcal-progress .hint-progress-fill { background: var(--night-text); }
.hsi-card { font-size: .5em; line-height: 1.2; text-align: center; color: #FFB300; }

/* Flight recorder indicator (status row) */
.rec-indicator {
  color: #FF3B30; font-size: 12px; font-weight: 700; letter-spacing: .5px; font-family: var(--mono);
  background: rgba(0, 0, 0, .55); border-radius: 4px; padding: 2px 6px; white-space: nowrap;
}

/* ---------------------------------------------------------------- Terrain manager */
.tm-overlay { position: absolute; inset: 0; z-index: 12; background: rgba(0, 0, 0, 0); transition: background .2s; display: flex; justify-content: center; }
.tm-overlay.open { background: rgba(0, 0, 0, .32); }
.tm {
  width: 100%; max-width: 640px; height: 100%; display: flex; flex-direction: column; background: var(--surface);
  transform: translateY(100%); transition: transform .2s ease-out;
}
.tm-overlay.open .tm { transform: translateY(0); }
.tm-head { flex: none; display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid rgba(196, 199, 197, .16); }
.tm-title { flex: 1; font-size: 24px; line-height: 32px; color: var(--on-surface); }
.tm-close { width: auto; padding: 0 20px; height: 40px; }
.tm-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.tm-intro, .tm-storage, .tm-status, .tm-attrib { font-size: 13px; line-height: 18px; color: #C4C7C5; }
.tm-storage { color: var(--on-surface); font-size: 14px; }
.tm-status:empty { display: none; }
.tm-attrib { font-size: 11px; line-height: 15px; opacity: .8; padding: 8px 0 24px; }
.tm-list { display: flex; flex-direction: column; gap: 10px; }
.tm-group { margin-top: 8px; font-size: 14px; font-weight: 500; letter-spacing: .1px; color: var(--primary); text-transform: uppercase; }
.tm-group-toggle { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 4px 0; font-family: inherit; cursor: pointer; }
.tm-group-areas { display: flex; flex-direction: column; gap: 10px; }
.tm-area { background: rgba(255, 255, 255, .05); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.tm-area-name { font-size: 16px; line-height: 22px; font-weight: 500; color: var(--on-surface); }
.tm-layer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tm-layer-text { flex: 1 1 160px; min-width: 0; }
.tm-layer-label { font-size: 14px; line-height: 20px; color: var(--on-surface); }
.tm-layer-info { font-size: 12px; line-height: 16px; color: #C4C7C5; }
.tm-layer.saved .tm-layer-info { color: var(--primary); }
.tm-actions { flex: none; display: flex; gap: 8px; margin-left: auto; }
.tm-btn { width: auto; height: 36px; padding: 0 16px; font-size: 14px; }
.tm-del { background: transparent; color: var(--on-surface); border: 1px solid rgba(196, 199, 197, .4); }
.tm-progress { flex: 1 1 100%; width: 100%; margin-top: 0; }
.tm.night { background: #111111; }
.tm.night .tm-title, .tm.night .tm-area-name, .tm.night .tm-layer-label, .tm.night .tm-storage,
.tm.night .tm-group, .tm.night .tm-layer-info, .tm.night .tm-intro, .tm.night .tm-attrib, .tm.night .tm-del { color: var(--night-text); }
.tm.night .tm-btn:not(.tm-del), .tm.night .tm-close { background: #330000; color: var(--night-text); }
.tm.night .tm-progress .hint-progress-fill { background: var(--night-text); }

/* ---------------------------------------------------------------- App update prompt (js/appUpdate.js) */
.update-scrim {
  position: absolute; inset: 0; z-index: 20; background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.update-dialog {
  width: 100%; max-width: 480px; max-height: 100%; overflow-y: auto; background: #1B1C1F; border-radius: 16px;
  padding: 24px; display: flex; flex-direction: column; gap: 12px; color: var(--on-surface);
}
.update-title { font-size: 24px; line-height: 32px; font-weight: 700; }
.update-body, .update-note { font-size: 14px; line-height: 20px; letter-spacing: .25px; color: #C4C7C5; }
.update-list { background: #222; border-radius: 8px; padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; }
.update-version-title { font-size: 14px; line-height: 20px; font-weight: 700; color: var(--primary); }
.update-version ul { margin: 4px 0 0; padding-left: 20px; font-size: 14px; line-height: 20px; }
.update-version li + li { margin-top: 4px; }
.update-actions { display: flex; gap: 12px; margin-top: 4px; }
.m3-button.update-later { background: transparent; color: var(--primary); border: 1px solid #8E918F; }

/* First start: language of the app, before the disclaimer */
.lang-options { display: flex; flex-direction: column; gap: 8px; }
.lang-option {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 16px; border: 1px solid #8E918F;
  border-radius: 12px; background: transparent; color: var(--on-surface); font-size: 16px; text-align: left; cursor: pointer;
}
.lang-option.selected { border-color: var(--primary); background: rgba(102, 187, 106, .12); }
.lang-radio { flex: none; width: 20px; height: 20px; border: 2px solid #8E918F; border-radius: 50%; box-sizing: border-box; }
.lang-option.selected .lang-radio { border-color: var(--primary); box-shadow: inset 0 0 0 4px #1E2022; background: var(--primary); }
.lang-seg .seg-btn { padding: 4px 6px; line-height: 18px; }

/* ---------------------------------------------------------------- Night mode (red) */
/* #app carries .night while night mode is on (app.js frame()): every screen, popup and control
   below takes the red of the instruments. Buttons: dark red fill, red outline and red text, like the
   segmented choices. Brightness, not hue, tells states apart (dim = off or secondary). */
#app.night {
  --primary: var(--night-text);
  --on-primary: #110000;
  --on-surface: var(--night-text);
  --night-dim: #992A2A;
  --night-fill: #330000;
  --night-deep: #1A0000;
  --night-line: #802222;
}
#app.night .m3-button {
  background: var(--night-fill); color: var(--night-text); border: 1px solid var(--night-text);
}
#app.night .m3-button:disabled { background: var(--night-deep); color: var(--night-line); border-color: #551111; }
#app.night .m3-button.update-later { background: transparent; color: var(--night-text); border-color: var(--night-text); }
#app.night .text-btn { color: var(--night-text); }
#app.night .m3-switch { background: var(--night-deep); border-color: var(--night-line); }
#app.night .m3-switch::after { background: var(--night-line); }
#app.night .m3-switch.checked { background: var(--night-fill); border-color: var(--night-fill); }
#app.night .m3-switch.checked::after { background: var(--night-text); }
#app.night .m3-checkbox { border-color: var(--night-line); }
#app.night .m3-field-input { border-color: var(--night-line); color: var(--night-text); }
#app.night .m3-field-input:focus { border-color: var(--night-text); }
#app.night .m3-field-label { color: var(--night-dim); }
#app.night .m3-field-input:focus + .m3-field-label { color: var(--night-text); }
#app.night .m3-field-input::selection, #app.night .dt-info-row::selection { background: var(--night-fill); color: var(--night-text); }

/* Attitude pane overlays */
#app.night .svt-gps-lost { color: var(--night-text); border-color: var(--night-text); }
#app.night .small-label, #app.night .svt-msg, #app.night .no-sensor, #app.night .hint-text { color: var(--night-text); }
#app.night .hint-progress { background: var(--night-fill); }
#app.night .hint-progress-fill { background: var(--night-text); }
#app.night .fs-circle { border-color: var(--night-text); }
#app.night .icon-btn:active, #app.night .dt-row:active { background: rgba(255, 68, 68, .12); }

/* HSI pane: Direct-To keys and the Back / Close button */
#app.night .hsi-card { color: var(--night-text); }
#app.night .dt-btn {
  background: linear-gradient(#260000, #0D0000); border-color: var(--night-line);
  box-shadow: inset 0 1px 0 rgba(255, 68, 68, .12), 0 2px 4px rgba(0, 0, 0, .6);
}
#app.night .dt-btn:active { background: linear-gradient(#0D0000, #1A0000); }
#app.night .dt-btn:focus-visible { outline-color: var(--night-text); }
#app.night .dt-set::after { background: var(--night-fill); }
#app.night .dt-set.active::after { background: #FF0000; box-shadow: 0 0 4px #FF0000; }
#app.night .dt-set .dt-glyph { stroke: var(--night-text); }
#app.night .dt-set .dt-head { fill: var(--night-text); }
#app.night .dt-cancel .dt-glyph { stroke: var(--night-line); }
#app.night .dt-cancel .dt-head { fill: var(--night-line); }
#app.night .dt-knock { stroke: #0D0000; }
#app.night .dt-strike { stroke: #FF0000; }
#app.night .dt-caption { color: var(--night-text); }
#app.night .round-btn { border-color: var(--night-text); color: var(--night-text); }

/* Direct-To lists and airport info */
#app.night .dt-empty, #app.night .dt-nogps, #app.night .dt-row-code, #app.night .dt-row-dist,
#app.night .dt-info-title, #app.night .dt-info-section, #app.night .dt-info-row { color: var(--night-text); }
#app.night .dt-row-sub { color: var(--night-dim); }

/* Settings, dialogs, pickers */
#app.night .sheet { background: #111111; }
#app.night .sheet-handle { background: var(--night-line); }
#app.night .sheet-status, #app.night .dialog-body, #app.night .magcal-steps { color: var(--night-text); }
#app.night .seg, #app.night .seg-btn + .seg-btn, #app.night .stepper-value { border-color: var(--night-text); }
#app.night .seg-btn { color: var(--night-text); }
#app.night .seg-btn.selected { background: var(--night-fill); color: var(--night-text); }
#app.night .dialog { background: #111111; }
#app.night .alt-picker-value { color: #FF0000; }
#app.night .alt-step { background: var(--night-deep); border-color: var(--night-text); color: var(--night-text); }
#app.night .alt-step:active { background: var(--night-fill); }

/* Terrain manager */
#app.night .tm { background: #111111; }
#app.night .tm-head { border-bottom-color: var(--night-fill); }
#app.night .tm-intro, #app.night .tm-status, #app.night .tm-attrib, #app.night .tm-layer-info { color: var(--night-dim); }
#app.night .tm-layer.saved .tm-layer-info { color: var(--night-text); }
#app.night .tm-area { background: var(--night-deep); }
#app.night .tm-del { background: transparent; color: var(--night-text); border-color: var(--night-line); }

/* App update prompt */
#app.night .update-dialog { background: #111111; color: var(--night-text); }
#app.night .update-body, #app.night .update-note { color: var(--night-text); }
#app.night .update-list { background: var(--night-deep); }
#app.night .update-version-title { color: #FF0000; }

/* Language and disclaimer screens (shown before the instruments, e.g. after a reload in night mode) */
#app.night .disclaimer { background: #111111; }
#app.night .disclaimer-title, #app.night .disclaimer-card-body, #app.night .disclaimer-check,
#app.night .disclaimer-bullets { color: var(--night-text); }
#app.night .disclaimer-card-title { color: #FF0000; }
#app.night .disclaimer-card { background: var(--night-deep); }
#app.night .disclaimer-icon path { fill: #FF0000; }
#app.night .lang-option, #app.night .lang-radio { border-color: var(--night-line); }
#app.night .lang-option.selected { border-color: var(--night-text); background: var(--night-fill); }
#app.night .lang-option.selected .lang-radio { border-color: var(--night-text); background: var(--night-text); box-shadow: inset 0 0 0 4px #111111; }
