:root {
    /* Pure black — matches the monitor screens' own background exactly, so
       the page behind the gauges/panels doesn't read as a lighter frame. */
    --panel-bg: #000;
    --bezel: #1c1d1f;
    --bezel-edge: #2e3033;
    --face: #101113;
    --needle: #f2f2f2;
    --text-dim: #8a8f96;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--panel-bg);
    color: #e8e8e8;
    font-family: 'Segoe UI', Arial, sans-serif;
    overflow: hidden;
}

.cockpit-wrap {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    padding: 14px;
    gap: var(--gap-gauges-v, 12px);
}

.cockpit-label {
    display: none;
    flex: 0 0 auto;
    text-align: center;
    color: #35d6c8;
    font-family: 'Menlo', 'Consolas', monospace;
    font-weight: 700;
    letter-spacing: 3px;
    font-size: clamp(12px, 2vw, 18px);
}

.cockpit-label.visible {
    display: block;
}

.cockpit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--gap-gauges-h, 14px);
    width: 100%;
    flex: 0 0 auto;
    /* Instructor-set push-down of the whole gauge row (control.php's
       Layout modal, "ZEGARY: ODSTĘP OD GÓRY"). */
    margin-top: var(--gauges-top-offset, 0px);
}

.gauge {
    position: relative;
    width: auto;
    aspect-ratio: 1 / 1;
}

.gauge svg {
    width: 100%;
    height: 100%;
    display: block;
}

.gauge .screw {
    fill: #45484c;
    stroke: #0a0a0a;
    stroke-width: 0.6;
}

.gauge .screw-slot {
    stroke: #0a0a0a;
    stroke-width: 1;
}

.needle {
    /* Rotation (center AND animation) is driven entirely in JS now — see
       gauges.js's animateRotation(). Rotation center comes from the SVG
       transform ATTRIBUTE itself (rotate(angle, 100, 100)) rather than
       transform-origin/transform-box, which need a specific, fairly recent
       level of browser support to agree on what "100px 100px" is even
       measured from. Animation used to be a CSS transition on this
       property, but attribute-driven transform changes aren't reliably
       animated by a CSS transition on at least one real browser this app
       runs on — requestAnimationFrame doesn't have that ambiguity. */
    filter: drop-shadow(1px 1.5px 1px rgba(0, 0, 0, 0.55));
}

.tick-major {
    stroke: #e8e8e8;
    stroke-width: 2;
}

.tick-minor {
    stroke: #8a8f96;
    stroke-width: 1;
}

.tick-label {
    fill: #e8e8e8;
    font-size: 13px;
    font-family: Arial, sans-serif;
    text-anchor: middle;
    dominant-baseline: middle;
}

.face-label {
    fill: #d8d8d8;
    font-size: 10.5px;
    letter-spacing: 0.5px;
    text-anchor: middle;
    font-family: Arial, sans-serif;
}

.redline {
    stroke: #e74c3c;
    stroke-width: 2.5;
}

/* ---- MFD monitors row ---- */
/* Two independent columns (left/right), each its own vertical flex stack —
   a plain 2x2 CSS grid can't give one column a different row-height ratio
   than the other, and the left column (fuel/caution 70% over the empty
   placeholder 30%) needs exactly that, while the right stays an even 50/50. */

.monitors-row {
    display: flex;
    flex-direction: row;
    gap: var(--gap-screens-h, 14px);
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
}

.monitors-col {
    display: flex;
    flex-direction: column;
    gap: var(--gap-screens-v, 14px);
    flex: 1 1 50%;
    min-width: 0;
    min-height: 0;
}

.monitors-col > .monitor {
    flex: 1 1 0;
}

/* Per-window vertical sizing (control.php's Layout modal, "WYSOKOŚĆ: ..."
   sliders) — flex-grow ratios, not literal heights, so two sliders in the
   same column always exactly fill it edge-to-edge with no gap or overflow
   regardless of their values. When they add up to 100 (the sliders'
   defaults, and the natural way to read "top 55 / bottom 45") the result IS
   literally that — the ratio and the percentage only diverge if the two
   don't sum to 100, and even then this just reflows cleanly instead of
   breaking. See db.php's layout_row_* instruments and gauges.js's poll(). */
.monitors-col-left > .monitor-cautions {
    flex: var(--row-cautions-pct, 70) 1 0;
}

.monitors-col-left > .monitor-fuel {
    flex: var(--row-fuel-pct, 30) 1 0;
}

.monitors-col-right > .monitor-engine {
    flex: var(--row-engine-pct, 50) 1 0;
}

.monitors-col-right > .monitor-system {
    flex: var(--row-system-pct, 50) 1 0;
}

.monitor {
    min-height: 0;
    min-width: 0;
}

.screen {
    background: #000;
    height: 100%;
    width: 100%;
    padding: 14px 20px;
    font-family: 'Menlo', 'Consolas', monospace;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
}

/* fuel screen */

.caution-grid {
    display: grid;
    grid-template-columns: 1fr 1.15fr 1fr;
    gap: 1px 10px;
    font-size: var(--caution-font-size, clamp(9px, 4.3vw, 21px));
    /* Sized to content, not stretched — the block (this + .master-warning
       above it) is positioned within whatever extra space the screen has
       via the ::before/::after spacers below instead, controlled by
       control.php's "Komunikaty — pozycja pionowa" slider. */
    flex: 0 1 auto;
}

/* Positions the MASTER WARNING + message-list block vertically within
   however tall this screen currently is (see the height sliders above) —
   0% keeps it flush at the top (this screen's original, only look before
   the position slider existed), 100% pushes it flush to the bottom, 50%
   centers it. Two flex spacers sharing the leftover space at a ratio
   controlled by one CSS var, instead of any fixed offset, so it's exact at
   any screen height. */
.monitor-cautions .screen::before {
    content: '';
    display: block;
    flex: var(--pos-cautions, 0) 1 0;
    order: -1;
}

.monitor-cautions .screen::after {
    content: '';
    display: block;
    flex: calc(100 - var(--pos-cautions, 0)) 1 0;
    order: 1;
}

.caution-col {
    display: flex;
    flex-direction: column;
    gap: var(--caution-line-gap, 3px);
}

/* Left margin on the first (left) message column only — pushes it away
   from the screen's left edge. */
.caution-col:first-child {
    margin-left: 2em;
}

.caution-page {
    color: var(--sys-cyan, #35d6c8);
    text-align: center;
    margin-bottom: 2px;
}

.caution-item {
    white-space: nowrap;
    letter-spacing: 0.5px;
}

@keyframes blink-red {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0.15; }
}

.state-off { visibility: hidden; }

.state-green {
    visibility: visible;
    color: var(--sys-green, #3ddc47);
}

.state-amber {
    visibility: visible;
    color: var(--sys-yellow, #f0d43a);
}

.state-red {
    visibility: visible;
    color: #ff3b30;
    font-weight: bold;
    animation: blink-red 1s steps(1, end) infinite;
}

.master-warning {
    visibility: hidden;
    text-align: center;
    color: #fff;
    font-weight: bold;
    letter-spacing: 2px;
    background: #e0392b;
    padding: 4px 0;
    margin-top: 10px;
    margin-bottom: 4px;
    flex: 0 0 auto;
}

.master-warning.visible {
    visibility: visible;
    animation: blink-red 1s steps(1, end) infinite;
}

.fuel-hr {
    height: 1px;
    background: var(--sys-cyan, #35d6c8);
    flex: 0 0 auto;
    margin-top: 4px;
}

.fuel-heading {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 16px;
    flex: 0 0 auto;
    padding: 6px 0 4px;
    position: relative;
}

.fuel-end {
    color: var(--sys-yellow, #f0d43a);
    font-size: 0.75em;
    position: absolute;
    left: 0;
}

.fuel-title {
    color: var(--sys-cyan, #35d6c8);
    font-size: 1.6em;
    font-weight: bold;
}

.fuel-section {
    /* Explicit content height (control.php's "WYSOKOŚĆ TREŚCI: FUEL"
       slider), not stretched to fill the screen — the tank bars need a
       definite height to render their percentage fills, but a SET one
       (unlike the old flex:1 1 auto that always consumed 100% of the
       leftover space) leaves the remaining (100 - this)% for the
       ::before/::after spacers below to move this whole block (+ the
       toolbar/heading above it) vertically within the screen, per
       control.php's "POZYCJA: FUEL" slider. */
    flex: 0 0 auto;
    height: var(--size-fuel, 80%);
    display: flex;
    align-items: stretch;
    gap: 10px;
    padding: 4px 0;
}

/* Positions the toolbar + FUEL heading + tank block vertically within
   however tall this screen currently is — same technique as
   .monitor-cautions below, controlled by control.php's "POZYCJA: FUEL"
   slider. */
.monitor-fuel .screen::before {
    content: '';
    display: block;
    flex: var(--pos-fuel, 0) 1 0;
    order: -1;
}

.monitor-fuel .screen::after {
    content: '';
    display: block;
    flex: calc(100 - var(--pos-fuel, 0)) 1 0;
    order: 1;
}

.fuel-flow-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 0 0 auto;
    width: 15%;
    color: #fff;
}

.fuel-flow-lbl { color: #fff; }
.fuel-flow-val { color: var(--sys-cyan, #35d6c8); font-size: 1.3em; }
.fuel-flow-unit { color: #fff; }

.fuel-tank {
    display: flex;
    align-items: stretch;
    flex: 1 1 auto;
    min-width: 0;
    border: 2px solid #fff;
}

.fuel-tank-section {
    position: relative;
    border-left: 2px solid #fff;
}

.fuel-tank-section:first-child {
    border-left: none;
}

.tank-side {
    flex: 1 1 22%;
}

.tank-center {
    flex: 1 1 56%;
}

.tank-notch {
    clip-path: polygon(0 0, 100% 0, 100% 78%, 75% 78%, 75% 100%, 0 100%);
}

.fuel-tank-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(180deg, #2f6fd8, #1c4a9e);
    transition: height 400ms linear;
}

.fuel-tank-value {
    position: absolute;
    top: 14%;
    left: 0;
    width: 100%;
    text-align: center;
    color: #fff;
    font-size: 1.15em;
    font-weight: bold;
}

/* engine screen */

.engine-screen {
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Content height set by control.php's "WYSOKOŚĆ TREŚCI: ENGINE" slider
       (not a fixed 100%) — leaves the remaining % for the ::before/::after
       spacers below to move it within the screen, per the "POZYCJA:
       ENGINE" slider. .engine-dial's own 96% is relative to this element,
       so it just scales down slightly along with it. */
    height: var(--size-engine, 80%);
    flex: 0 0 auto;
    gap: 2px;
}

.monitor-engine .screen::before {
    content: '';
    display: block;
    flex: var(--pos-engine, 0) 1 0;
    order: -1;
}

.monitor-engine .screen::after {
    content: '';
    display: block;
    flex: calc(100 - var(--pos-engine, 0)) 1 0;
    order: 1;
}

.engine-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Both instructor-tunable via control.php's Layout modal (see db.php's
       layout_engine_* instruments). */
    gap: var(--engine-line-gap, 2px);
    font-size: var(--engine-font-size, clamp(9px, 1.5vw, 16px));
    color: #7fd97f;
    width: 19%;
    text-align: center;
}

.engine-label-row {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #fff;
    margin-top: 6px;
}

.engine-dot {
    width: 0.7em;
    height: 0.7em;
    background: #2ecc40;
    display: inline-block;
    flex: 0 0 auto;
}

.engine-val {
    color: #fff;
    font-size: 1.15em;
}

.engine-unit {
    color: #fff;
    font-size: 1.15em;
}

/* Only the °C degree sign gets the cyan tint (the numeric value itself, and
   the % sign, stay white) — matches the real VEMD ENGINE page. */
.engine-unit-cyan {
    color: var(--sys-cyan, #35d6c8);
}

.engine-dial {
    width: auto;
    height: 96%;
    aspect-ratio: 1 / 1;
}

.engine-dial svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* system screen */

:root {
    --sys-cyan: #35d6c8;
    --sys-green: #3ddc47;
    --sys-yellow: #f0d43a;
    --sys-red: #e0392b;
}

.system-screen {
    display: flex;
    flex-direction: column;
    /* Content height set by control.php's "WYSOKOŚĆ TREŚCI: SYSTEM" slider
       (not a fixed 100%) — leaves the remaining % for the ::before/::after
       spacers below to move it within the screen, per the "POZYCJA:
       SYSTEM" slider. .sys-cols's own flex:1 1 auto still resolves fine
       against this now-smaller-than-100% definite height. */
    height: var(--size-system, 80%);
    flex: 0 0 auto;
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: clamp(12px, 1.7vw, 19px);
}

.monitor-system .screen::before {
    content: '';
    display: block;
    flex: var(--pos-system, 0) 1 0;
    order: -1;
}

.monitor-system .screen::after {
    content: '';
    display: block;
    flex: calc(100 - var(--pos-system, 0)) 1 0;
    order: 1;
}

.sys-top {
    display: flex;
    align-items: flex-start;
    flex: 0 0 auto;
    padding-bottom: 8px;
    gap: 16px;
}

.sys-oat { flex: 0 0 auto; color: #fff; white-space: nowrap; }
.sys-vdiv { width: 1px; background: var(--sys-cyan); align-self: stretch; }
.sys-vne { flex: 1 1 auto; text-align: right; line-height: 1.35; }
.sys-vne-main { color: #fff; white-space: nowrap; }
.sys-ias { color: var(--sys-yellow); }

.lbl-green { color: var(--sys-green); }
.lbl-white { color: #fff; }
.lbl-cyan { color: var(--sys-cyan); }
.unit-cyan { color: var(--sys-cyan); }
.arrow-green { color: var(--sys-green); font-weight: bold; margin-right: 4px; }
.val-white { color: #fff; }

.sys-hr {
    height: 1px;
    background: var(--sys-cyan);
    flex: 0 0 auto;
}

.sys-spacer {
    flex: 0 0 auto;
    height: calc(1.2em + 20px);
}

.sys-dc {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 16px;
    flex: 0 0 auto;
    padding: 10px 0;
    white-space: nowrap;
}

.sys-cols {
    display: flex;
    justify-content: space-between;
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 8px;
}

.sys-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 31%;
    min-height: 0;
}

.sys-col-title {
    color: #fff;
    white-space: nowrap;
    margin-bottom: 4px;
}

.sys-col-bars {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 14px;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    margin-top: 4px;
    padding: 0 10px;
}

.sys-col-bars .unit-cyan {
    align-self: flex-start;
    font-size: 0.9em;
}

.bar-v-track {
    width: 24%;
    max-width: 24px;
    background: transparent;
    border: none;
    position: relative;
}

.track-left {
    border-top: 2px solid #fff;
    border-bottom: 2px solid #fff;
    border-right: 2px solid #fff;
}

.track-right {
    border-top: 2px solid #fff;
    border-bottom: 2px solid #fff;
    border-left: 2px solid #fff;
}

.bar-v-track .zone {
    position: absolute;
    left: 0;
    width: 100%;
}

.zone-red { background: var(--sys-red); }
.zone-green { background: var(--sys-green); }
.zone-amber { background: var(--sys-yellow); }

.bar-v-pointer {
    position: absolute;
    width: 0;
    height: 0;
    border-top: 9px solid transparent;
    border-bottom: 9px solid transparent;
    transform: translateY(50%);
    transition: bottom 400ms linear;
}

.pointer-left-facing {
    left: 100%;
    border-right: 14px solid #cfd6d6;
}

.pointer-right-facing {
    right: 100%;
    border-left: 14px solid #cfd6d6;
}

.sys-col-values {
    display: flex;
    gap: 18px;
    color: #fff;
    margin-top: 6px;
    white-space: nowrap;
}

.status-bar {
    position: fixed;
    bottom: 6px;
    right: 10px;
    font-size: 11px;
    color: var(--text-dim);
    font-family: monospace;
}

/* Injected live by gauges.js/streetmap.js the moment data.php starts
   returning {error:"blocked"} — mirrors the server-rendered blocked page
   markup so a display doesn't need a manual reload to show it. */
.ip-blocked-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ip-blocked-overlay .blocked-box {
    border: 2px solid #e74c3c;
    border-radius: 8px;
    padding: 32px 48px;
    text-align: center;
    box-shadow: 0 0 24px rgba(231, 76, 60, 0.35);
}

.ip-blocked-overlay .blocked-box p {
    color: #e74c3c;
    font-size: 22px;
    font-weight: bold;
    letter-spacing: 0.5px;
    margin: 0;
    font-family: 'Menlo', 'Consolas', monospace;
}

/* Injected live by gauges.js/streetmap.js when control.php fires the
   "identify" remote trigger — a big, impossible-to-miss ID so whoever is
   standing at this computer can read it aloud and the instructor can match
   it to the right "Wykryte w sieci" entry before registering. Click or wait
   8s to dismiss. */
.identify-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.identify-popup-overlay .identify-popup-box {
    border: 3px solid var(--sys-cyan, #35d6c8);
    border-radius: 12px;
    padding: 40px 64px;
    text-align: center;
    background: #0a1012;
    box-shadow: 0 0 40px rgba(53, 214, 200, 0.45);
}

.identify-popup-overlay .identify-popup-label {
    color: var(--sys-cyan, #35d6c8);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 1px;
    font-family: 'Menlo', 'Consolas', monospace;
    margin-bottom: 12px;
}

.identify-popup-overlay .identify-popup-id {
    color: #fff;
    font-size: 96px;
    font-weight: 700;
    letter-spacing: 4px;
    font-family: 'Menlo', 'Consolas', monospace;
    text-shadow: 0 0 20px rgba(53, 214, 200, 0.6);
}

/* Shown when the instructor remotely requests this display to open kokpit
   dolne/bok — browsers only allow window.open() as the direct result of a
   local click, so this prompts the person at this computer to provide that
   click themselves rather than trying (and failing) to pop the window open
   automatically. Deliberately understated (small button in the otherwise-
   empty bottom-left monitor, not a banner) — this can appear mid-scene
   during filming, where anything more obtrusive is a real problem. */
.empty-monitor-trigger-btn {
    display: block;
    margin: 10px auto 0;
    background: #1a2226;
    color: var(--sys-cyan, #35d6c8);
    border: 1px solid #3a4a4e;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 0.9em;
    font-weight: 600;
    font-family: 'Menlo', 'Consolas', monospace;
    cursor: pointer;
}

.empty-monitor-trigger-btn:hover {
    filter: brightness(1.3);
}

/* Always-visible utility controls in the same panel, pinned to the bottom
   so they never collide with the reactive open-kokpit button above (which
   flows normally in the middle of the screen). */
#emptyMonitorScreen {
    position: relative;
}

.empty-monitor-toolbar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 10px;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.empty-monitor-tool-btn {
    background: #1a2226;
    color: var(--text-dim);
    border: 1px solid #3a4a4e;
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 0.7em;
    font-weight: 600;
    font-family: 'Menlo', 'Consolas', monospace;
    cursor: pointer;
}

.empty-monitor-tool-btn:hover {
    filter: brightness(1.3);
    color: var(--sys-cyan, #35d6c8);
}

/* ---- kokpit dolne: dual avionics-unit screens (options + streetmap) ---- */

.dolne-wrap {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    padding: 14px;
    gap: 10px;
}

.avionics-pair {
    display: flex;
    gap: var(--gap-screens-h, 6px);
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
}

.avionics-unit {
    flex: 1 1 50%;
    min-width: 0;
    background: linear-gradient(145deg, var(--bezel-edge), var(--bezel));
    border-radius: 14px;
    box-shadow:
        0 6px 18px rgba(0, 0, 0, 0.6),
        inset 0 0 0 1px rgba(255, 255, 255, 0.04);
    padding: 10px;
    display: flex;
}

.avionics-screen {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: #000;
    font-family: 'Menlo', 'Consolas', monospace;
    overflow: hidden;
    /* Query container so .avio-topbar (a direct, non-nested descendant)
       can size itself off THIS screen's actual rendered width instead of
       the whole viewport — see the cqw units below and on the icon grid. */
    container-type: inline-size;
}

.avio-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex: 0 0 auto;
    padding: 10px 14px;
    font-size: 20px; /* fallback for browsers without container query units */
    font-size: 3.5cqw;
    border-bottom: 1px solid #223;
    gap: 10px;
    background: linear-gradient(180deg, #1c3f6e, #0a1424);
}

.avio-field-group {
    display: flex;
    flex-direction: column;
    line-height: 1.35;
    white-space: nowrap;
}

.avio-field-active { color: var(--sys-green); font-size: 1.6em; font-weight: 700; }
.avio-field-standby { color: var(--sys-cyan); font-size: 0.9em; }
.avio-field-label { color: var(--sys-cyan); font-size: 0.75em; }
.avio-field-value { color: #fff; font-size: 0.95em; }
.field-swap-icon { font-size: 0.7em; margin-left: 3px; }

/* Rotary-knob caption at the far left edge of the top bar (e.g. "Com Vol"
   turn / "Psh Sq" push) — purely decorative labeling, matching the unit's
   physical bezel legend. */
.avio-knob-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    color: var(--sys-cyan);
    font-size: 0.5em;
    line-height: 1.15;
    text-align: center;
    flex: 0 0 auto;
}

.knob-arrow { font-size: 1.6em; color: #fff; line-height: 1; }

/* 2x2 cluster (e.g. DIS/DTK over GS/ETE) — two label+value pairs per
   column, arranged left-to-right then top-to-bottom via grid auto-flow. */
.avio-2x2 {
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 2px 18px;
    flex: 0 0 auto;
}

.avio-2x2-cell {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.avio-xpdr-box {
    border: 1px solid var(--sys-cyan);
    border-radius: 5px;
    padding: 3px 12px;
    text-align: center;
    background: rgba(47, 111, 216, 0.28);
}

.avio-xpdr-ident { color: #fff; font-weight: 500; font-size: 0.75em; }
.avio-xpdr-code { color: var(--sys-green); font-size: 1.5em; font-weight: 700; }
.avio-xpdr-mode { color: var(--sys-green); font-size: 0.8em; }

.avio-body {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    /* Blue-navy gradient — the whole non-map interface is blue/navy toned,
       only the map screen itself is grass-green/brown. Shows through the
       gaps between icon tiles, below the (content-sized, not full-bleed)
       icon grid, and behind subpages alike. */
    background: linear-gradient(165deg, #1c3f6e, #0a1424);
    /* flex column so the 20%-of-height spacer below the icon grid actually
       resolves against height — a plain CSS percentage margin/padding-top
       would resolve against the container's WIDTH instead, per spec. */
    display: flex;
    flex-direction: column;
    container-type: inline-size;
}

.avio-home-spacer {
    flex: 0 0 20%;
}

.avio-home-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: auto;
    justify-items: center;
    align-content: start;
    gap: 12px;
    width: 100%;
    padding: 16px;
    box-sizing: border-box;
    flex: 1 1 auto;
    min-height: 0;
}

.avio-icon-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    aspect-ratio: 1 / 1;
    /* Blue accent band across the top 20%, navy for the remaining 80% —
       a glossy highlight-style button face rather than a flat fill. */
    background: linear-gradient(180deg, #2f6fd8 0%, #0d1830 20%, #0d1830 100%);
    border: 1.5px solid #7ec8ff;
    border-radius: 12px;
    color: #e8e8e8;
    cursor: pointer;
    font-family: 'Segoe UI', Arial, sans-serif;
    /* Makes this button a query container so its own children (the icon
       glyph/label) can size themselves off ITS rendered size — see the cqw
       units below. A viewport-relative clamp() would cap out on a large
       screen/window while the button itself kept growing, making the icon
       look disproportionately small instead of scaling with the screen. */
    container-type: inline-size;
}

.avio-icon-btn:hover {
    border-color: var(--sys-cyan);
}

.avio-icon-btn:active {
    filter: brightness(1.3);
}

.avio-icon-glyph {
    font-size: 64px; /* fallback for browsers without container query units */
    font-size: 46cqw;
    line-height: 1;
}

.avio-icon-label {
    font-size: 20px; /* fallback for browsers without container query units */
    font-size: 13cqw;
    color: #bcdfff;
}

.avio-subpage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    color: #e8e8e8;
    font-family: 'Segoe UI', Arial, sans-serif;
    text-align: center;
    padding: 20px;
}

.avio-subpage-icon { font-size: 90px; font-size: 22cqw; }
.avio-subpage-title { font-size: 32px; font-size: 8cqw; color: var(--sys-cyan); }
.avio-subpage-text { font-size: 20px; font-size: 5cqw; color: var(--text-dim); max-width: 80%; }

/* Small print (credits/version info) — noticeably smaller than the normal
   single-sentence subpage text, one line per array entry. */
.avio-subpage-small { font-size: 11px; font-size: 2.6cqw; line-height: 1.6; }

/* Flight Plan subpage: real route info + an on-screen keyboard mockup, so
   it needs a lot more vertical room than the generic centered subpage. */
.avio-flightplan-page {
    justify-content: flex-start;
    gap: 10px;
    padding: 14px;
    overflow-y: auto;
}

.avio-flightplan-page .avio-subpage-icon { font-size: 10cqw; }
.avio-flightplan-page .avio-subpage-title { font-size: 6cqw; margin-bottom: 2px; }

.avio-flightplan-info {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 3.2cqw;
    color: #bcdfff;
    text-align: left;
}

.fp-row { margin: 3px 0; }
.fp-label { color: var(--sys-cyan); font-weight: 700; margin-right: 6px; }

.avio-keyboard-wrap {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.avio-keyboard-preview {
    background: #000;
    border: 1px solid #3a4a4e;
    border-radius: 4px;
    padding: 6px 10px;
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 3cqw;
    color: #fff;
    text-align: left;
    min-height: 1.4em;
}

.avio-keyboard-preview-text {
    color: var(--sys-cyan);
    font-weight: 700;
}

.avio-keyboard {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.avio-keyboard-row {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.avio-key {
    flex: 1 1 0;
    max-width: 9%;
    background: linear-gradient(145deg, #2a2f37, #1a1e24);
    border: 1px solid #3a4a4e;
    border-radius: 4px;
    color: #e8e8e8;
    font-size: 2.8cqw;
    font-weight: 600;
    padding: 8px 0;
    cursor: pointer;
}

.avio-key:hover { filter: brightness(1.3); }
.avio-key:active { filter: brightness(0.8); }

.avio-key-space { max-width: 40%; flex: 4 1 0; }
.avio-key-back { max-width: 15%; flex: 1.5 1 0; }

/* Weather subpage — content set live by renderWeatherContent() in
   streetmap.js, driven by control.php's message + severity below the
   cautions panel. */
.avio-weather-page { justify-content: flex-start; gap: 10px; padding: 14px; }
.avio-weather-page .avio-subpage-icon { font-size: 10cqw; }
.avio-weather-page .avio-subpage-title { font-size: 6cqw; margin-bottom: 2px; }

.weather-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    flex: 1 1 auto;
}

.weather-important-tile {
    align-self: flex-start;
    background: rgba(241, 196, 15, 0.15);
    border: 1px solid #f1c40f;
    color: #f1c40f;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 3cqw;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.weather-important-icon { margin-right: 4px; }

.weather-warning-box {
    background: #a12b20;
    border: 2px solid #ff3b30;
    border-radius: 8px;
    padding: 10px 16px;
    text-align: center;
    color: #ffe14d;
    font-size: 6cqw;
    font-weight: 800;
    letter-spacing: 2px;
    animation: weather-warning-flash 1s infinite;
}

@keyframes weather-warning-flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.weather-text-scroll {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 10px 14px;
}

.weather-text-inner {
    color: #bcdfff;
    font-size: 3.2cqw;
    text-align: left;
    white-space: pre-wrap;
}

.avio-back-btn {
    align-self: flex-start;
    margin: 10px 0 0 10px;
    background: #1a2c4a;
    border: 1px solid #2a4570;
    color: #e8e8e8;
    border-radius: 8px;
    padding: 12px 22px;
    font-size: clamp(18px, 2.2vw, 24px);
    cursor: pointer;
}

/* panel_tablet.php only: overlaid on the map (which normally has its own
   dedicated screen, so nothing else needs to share this space) instead of
   sitting inline above content like the subpage .avio-back-btn does. */
.tablet-menu-back-btn {
    position: absolute;
    /* Below .map-corner-readout.left (GS/ALT), which sits at top:12px and
       runs about 48px tall — stacking underneath it instead of overlapping. */
    top: 68px;
    left: 8px;
    z-index: 20;
    margin: 0;
}

.avio-back-btn:hover {
    border-color: var(--sys-cyan);
}

.avio-softkeys {
    display: flex;
    justify-content: space-between;
    flex: 0 0 auto;
    padding: 8px 14px;
    font-size: clamp(14px, 1.8vw, 19px);
    color: #fff;
    font-weight: 600;
    border-top: 1px solid #4a76ad;
    background: linear-gradient(180deg, #4f8fd6, #2a5aa0);
}

.avio-softkeys span:not(:last-child) {
    padding-right: 16px;
    border-right: 1px solid rgba(255, 255, 255, 0.35);
}

.avio-softkeys span:not(:first-child) {
    padding-left: 16px;
}

.avio-softkeys .sk-enr { color: var(--sys-green); }
.avio-softkeys .sk-loi { color: var(--sys-yellow); }
.avio-softkeys .sk-gps { color: #e35bf0; }
.avio-softkeys .dim { color: rgba(255, 255, 255, 0.55); }

/* Cache-reset softkey — same "force a fresh, un-cached reload" escape
   hatch as gauges.js's empty-monitor toolbar button, placed here too since
   kokpit dolne doesn't have that monitor panel to put it in. */
.avio-softkeys .sk-rst { color: #ff9f4a; cursor: pointer; }
.avio-softkeys .sk-rst:hover { color: #ffc48a; }

/* Same cache-reset escape hatch as kokpit dolne's RST softkey, for kokpit
   bok — this page has no softkey row, so it sits fixed in the one corner
   least likely to overlap the SAI/HSI instruments themselves. */
.bok-rst-btn {
    position: absolute;
    left: 8px;
    bottom: 8px;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 600;
    color: #ff9f4a;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid #ff9f4a;
    border-radius: 4px;
    cursor: pointer;
    z-index: 10;
}
.bok-rst-btn:hover { color: #ffc48a; border-color: #ffc48a; }

/* map (streetmap) screen */

.avio-map-body {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    display: flex;
    flex-direction: column;
}

.map-canvas-wrap {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    /* Clips .map-rotate-wrap back down to this element's own bounds — that
       inner wrap is deliberately oversized (see below) so rotating it never
       reveals blank corners. */
    overflow: hidden;
}

/* Heading-up mode (streetmap.js): rotated by -heading each poll so the
   current direction of travel is always "up" on screen, with the ownship
   arrow counter-rotated back to vertical (see updateOwnshipRotation()).
   Sized well past the diagonal of the visible viewport and centered via
   inset, so a rotation at any angle still fully covers the corners —
   otherwise the corners would show blank space past the rotated edge. */
.map-rotate-wrap {
    position: absolute;
    inset: -30%;
    transform-origin: center center;
}

.leaflet-map-el {
    position: absolute;
    inset: 0;
}

/* Duotone terrain look — grass green for open/low terrain, brown-orange for
   roads/relief/other features (see the #terrainDuotone SVG filters in
   kokpit_dolne.php). Scoped to the tile <img> elements themselves, NOT the
   .leaflet-tile-pane container — Leaflet positions tiles purely via CSS
   transform on children, so the pane itself is a 0x0 box. Safari computes
   an SVG filter's region from the target element's own layout box, so
   applying the filter to that 0x0 pane clipped the output to nothing and
   rendered solid black there (confirmed: Chromium is more lenient and
   computes it from paint bounds instead, which is why it looked fine in
   testing here but not for the user in Safari). Each <img> tile has real
   256x256 dimensions, so filtering them directly sidesteps the bug. */
.leaflet-map-el .leaflet-tile-pane img {
    filter: url(#terrainDuotone) saturate(1.3) contrast(1.15);
}

.leaflet-map-el.terrain-mode .leaflet-tile-pane img {
    filter: url(#terrainDuotoneLight) saturate(1.3) contrast(1.15);
}

.map-compass-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 400;
}

/* Manual up/down pan — press and hold to scroll the view; suspends the
   normal ownship auto-recenter until "Back" is pressed again. Sits outside
   .map-compass-overlay (which is pointer-events:none) so it stays clickable. */
.map-pan-controls {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 410;
}

.map-pan-btn {
    width: clamp(38px, 5vw, 54px);
    height: clamp(38px, 5vw, 54px);
    background: linear-gradient(180deg, #2f6fd8 0%, #0d1830 20%, #0d1830 100%);
    border: 1.5px solid #7ec8ff;
    border-radius: 8px;
    color: #fff;
    font-size: clamp(16px, 2vw, 22px);
    cursor: pointer;
    user-select: none;
    touch-action: none;
}

.map-pan-btn:hover {
    border-color: var(--sys-cyan);
}

.map-pan-btn:active {
    filter: brightness(1.3);
}

.map-hdg-label {
    position: absolute;
    left: 14px;
    bottom: 14px;
    color: #fff;
    font-size: clamp(15px, 1.9vw, 21px);
    background: rgba(0, 0, 0, 0.45);
    padding: 4px 10px;
    border-radius: 4px;
}

.map-corner-readout {
    position: absolute;
    top: 12px;
    color: #fff;
    font-size: clamp(15px, 1.9vw, 21px);
    background: rgba(0, 0, 0, 0.35);
    padding: 4px 10px;
    border-radius: 4px;
}

.map-corner-readout.left { left: 12px; }
.map-corner-readout.right { right: 12px; }

.map-scale-label {
    position: absolute;
    right: 14px;
    bottom: 14px;
    color: #fff;
    font-size: clamp(15px, 1.9vw, 21px);
    background: rgba(0, 0, 0, 0.45);
    padding: 4px 10px;
    border-radius: 4px;
}

.map-cdi-strip {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
    padding: 8px 14px;
    background: linear-gradient(165deg, #1c3f6e, #0a1424);
    border-top: 1px solid #223;
}

.map-terrain-btn {
    flex: 0 0 auto;
}

.map-cdi-line {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cdi-flag {
    color: #bcdfff;
    font-size: clamp(13px, 1.6vw, 17px);
    flex: 0 0 auto;
}

.cdi-track {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 2px;
    background: repeating-linear-gradient(90deg, #d16bd1 0 8px, transparent 8px 16px);
}

.cdi-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d16bd1;
    flex: 0 0 auto;
}

.cdi-diamond {
    width: 14px;
    height: 14px;
    background: #d16bd1;
    transform: rotate(45deg);
    flex: 0 0 auto;
}

.cdi-dis-label {
    color: #bcdfff;
    font-size: clamp(11px, 1.3vw, 14px);
    line-height: 1.1;
    text-align: center;
    flex: 0 0 auto;
}

.map-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
    padding: 10px 14px;
    gap: 10px;
    background: linear-gradient(165deg, #1c3f6e, #0a1424);
    border-top: 1px solid #223;
}

.map-toolbar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: #1a2c4a;
    border: 1.5px solid #7ec8ff;
    color: #e8e8e8;
    border-radius: 8px;
    padding: 8px 18px;
    font-size: clamp(13px, 1.6vw, 17px);
    cursor: pointer;
    white-space: nowrap;
}

.map-toolbar-icon {
    font-size: clamp(20px, 2.6vw, 28px);
    line-height: 1;
}

.map-toolbar-btn:hover {
    border-color: var(--sys-cyan);
}

.map-toolbar-btn.active {
    background: var(--sys-green);
    color: #071018;
    border-color: var(--sys-green);
    font-weight: 700;
}

.map-zoom-group {
    display: flex;
    gap: 4px;
}

.no-gps-banner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--sys-yellow);
    font-weight: 700;
    font-size: clamp(24px, 3.2vw, 34px);
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 22px;
    border-radius: 6px;
    z-index: 450;
    pointer-events: none;
}

/* Circular compass ring + linear CDI-style strip, drawn once as a static
   SVG overlay centered on the map — the aircraft marker always sits at the
   map's center point since the view re-centers on it every poll. */
.map-compass-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* ---- kokpit bok: stacked SAI (attitude+altitude) + HSI screens ---- */

.bok-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    padding: 14px;
    gap: 10px;
}

.bok-pair {
    display: flex;
    flex-direction: column;
    gap: var(--gap-screens-v, 6px);
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
}

.bok-unit {
    flex: 1 1 50%;
    min-width: 0;
    min-height: 0;
    background: #050505;
    border: 1px solid #3a3f45;
    border-radius: 6px;
    padding: 6px 40px 6px 6px;
    display: flex;
    position: relative;
}

.sai-wrap, .hsi-wrap {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: #000;
    color: #fff;
    font-family: 'Menlo', 'Consolas', monospace;
    position: relative;
}

.sai-topbar {
    display: flex;
    justify-content: space-between;
    padding: 6px 20px 0;
    color: #ff9800;
    font-weight: bold;
    font-size: 1.4em;
    flex: 0 0 auto;
}

.sai-body {
    flex: 1 1 auto;
    display: flex;
    align-items: stretch;
    min-height: 0;
    padding: 4px 10px 10px;
    gap: 4px;
}

.sai-ball-host {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sai-ball-host svg {
    width: 100%;
    height: 100%;
}

/* Both side tapes (airspeed left, altitude-style right) share this frame —
   bordered like the real instrument's side panels, instead of floating
   numbers with no edge. */
.sai-tape {
    flex: 0 0 70px;
    display: flex;
    align-items: stretch;
    justify-content: center;
    position: relative;
    border: 1.5px solid #667;
    border-radius: 2px;
}

.sai-tape svg {
    width: 100%;
    height: 100%;
}

/* Right tape only: svg ruler on top, N + baro readout stacked below it —
   same column as the tape itself, not pulled out to the panel's edge. */
.sai-tape-alt {
    flex-direction: column;
}

.sai-tape-alt svg {
    height: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.sai-ul {
    color: var(--sys-cyan, #35d6c8);
    font-size: 0.75em;
    align-self: center;
}

.sai-radio-alt {
    flex: 0 0 auto;
    text-align: center;
    color: #ffd400;
    font-weight: bold;
    font-size: 1.3em;
    letter-spacing: 1px;
    padding: 2px 0 0;
}

.sai-baro-stack {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 0;
}

.sai-baro-n {
    color: #fff;
    font-weight: 600;
    font-size: 11px;
}

.sai-baro-standalone {
    font-size: 9px;
    font-weight: 600;
    color: #fff;
    border: 1px solid #556;
    padding: 1px 3px;
    border-radius: 2px;
    white-space: nowrap;
}

.sai-baro-unit { color: #9ab; font-size: 0.8em; }

.sai-knob-col {
    position: absolute;
    right: -32px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.75em;
    color: #cde;
}

.sai-knob {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #667, #223);
    border: 2px solid var(--sys-green, #3ddc47);
}

.sai-knob-off { border-color: #778; }

.hsi-dial-wrap {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hsi-dial-wrap svg { width: 88%; height: 88%; }

.hsi-readout {
    position: absolute;
    display: flex;
    color: var(--sys-cyan, #35d6c8);
    font-size: 1.15em;
    font-weight: 600;
    line-height: 1.5;
}

.hsi-readout-left {
    top: 14px;
    left: 18px;
    flex-direction: column;
}

.hsi-readout-top {
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: column;
    align-items: center;
}

.hsi-readout-right {
    top: 14px;
    right: 68px;
    flex-direction: column;
    align-items: flex-end;
}

.hsi-field-label { color: #9ab; margin-right: 5px; }
.hsi-vor-label { color: #9ab; font-size: 0.8em; }

.hsi-dh-wrap {
    position: absolute;
    right: 16px;
    top: 16px;
    bottom: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    font-size: 1.1em;
    font-weight: 600;
    color: #fff;
}

.hsi-dh-track {
    flex: 1 1 auto;
    width: 18px;
    margin: 6px 0;
}

.hsi-dh-zone-below {
    bottom: 0;
    height: 45%;
    background: #d4832e;
}

/* ---- phone layout (kokpit środek) ---- */
/* Everything in ONE scrollable column at 100% width: the five gauges first,
   then each monitor screen. The desktop layout squeezes everything into a
   single 100vh viewport; on a phone that's unreadable, so instead the page
   scrolls and every element gets the full width. */
@media (max-width: 700px) {
    html, body {
        overflow: auto;
        height: auto;
    }

    .cockpit-wrap {
        height: auto;
        width: 100%;
    }

    .cockpit {
        flex-direction: column;
        align-items: center;
    }

    .cockpit .gauge {
        width: min(92vw, 420px);
    }

    .monitors-row {
        flex-direction: column;
        flex: 0 0 auto;
    }

    .monitors-col {
        flex: 0 0 auto;
    }

    /* flex-grow height ratios only work against a fixed-height container;
       in a scrolling column each screen needs its own definite height
       instead (the fuel bars / engine dial / system bars all size
       themselves as percentages of it). Cautions sizes to its content. */
    .monitors-col > .monitor {
        flex: 0 0 auto;
        height: min(110vw, 480px);
    }

    .monitors-col-left > .monitor-cautions {
        flex: 0 0 auto;
        height: auto;
        min-height: 0;
    }

    .monitors-col-left > .monitor-cautions .screen {
        height: auto;
    }
}

/* Phone-width caution list: the instructor-set fixed font size and the 2em
   left indent are tuned for the big wall display — at 375px three columns
   with those settings clip off the right edge, so both give way to a
   fits-the-width size here (this later rule outranks the base one). */
@media (max-width: 700px) {
    .caution-grid {
        font-size: clamp(8px, 3.4vw, 14px);
    }

    .caution-col:first-child {
        margin-left: 0;
    }
}
