:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--page);
  --radius: 8px;
  --on-navy: #fff;
  --text: #172e45;
  --control-text: #14283f;
  --page: #edf2f5;
  --navy: #14283f;
  --gold: #f0b840;
  --paper: #fff;
  --muted: #4b657b;
  --rule: #cddae3;
  --wash: #f4f8fa;
  --button-border: #b9cbd8;
  --button-hover: #e9f2f8;
  --button-hover-border: #819aaf;
  --button-active: #e0edf7;
  --button-active-border: #698aa4;
  --focus: #97700f;
  --brand-muted: #c9d8e4;
  --overlay-control: #203c57;
  --overlay-border: #688197;
  --overlay-hover: #294964;
  --intro-rule: #aebfcd;
  --input-border: #adbfce;
  --group-heading: #e6eff5;
  --card-rule: #e3ebf1;
  --sidebar: #f7fafc;
  --sidebar-hover: #eaf2f7;
  --side-accent: #bc8515;
  --side-active: #e5eef4;
  --positive-ink: #198f7f;
  --positive-text: #145849;
  --positive-bg: #d6eee8;
  --negative-ink: #d9525a;
  --negative-text: #842b37;
  --negative-bg: #f9e2e4;
  --neutral-ink: #2a7fb8;
  --neutral-text: #22557c;
  --neutral-bg: #deedf8;
  --mock-text: #6c4705;
  --mock-bg: #f7e9c5;
  --player-border: #b7c9d7;
  --sky: #d9edf6;
  --hud-paper: #f9fcf8f5;
  --hud-border: #abc0cf;
  --hud-shadow: #14283f17;
  --hud-muted: #3a576d;
  --scheme-text: #28445d;
  --hud-positive-ink: #147665;
  --hud-positive-text: #0c5b4d;
  --hud-negative-ink: #c53f4d;
  --hud-negative-text: #8e2936;
  --hud-neutral-text: #1d608b;
  --hud-meter: #d8e5eb;
  --hud-meter-zero: #425d71;
  --overlay-paper: #14283ff5;
  --overlay-rule: #516d83;
  --overlay-caption: #e6ca7f;
  --timeline-bg: #dbe6ed;
  --timeline-line: #b9d5e7;
  --timeline-line-alt: #a7c4d8;
  --timeline-line-third: #c3d2df;
  --timeline-arc: #a7d2c8;
  --timeline-arc-alt: #bfded4;
  --timeline-roll: #d9c7a0;
  --timeline-spin: #e6b8bc;
  --timeline-marker: #48677f;
  --reverse-accent: #5e83a0;
  --play-hover: #2a4864;
  --toggle-accent: #6a8eac;
  --scheme-paper: #f4f8f9;
  --scheme-ink: #183853;
  --guide-text: #334f66;
  --training-text: #6f4c13;
  --station-rule: #e1eaf0;
  --station-hover: #edf5f8;
  --station-active: #e8f1f7;
  --station-accent: #b88118;
  --adjacent-hover: #e6f0f6;
  --dialog-border: #97aebb;
  --backdrop: #14283fa8;
  --shortcut-rule: #e4ebf0;
  --key-bg: #eaf1f6;
  --key-border: #b8ccd9;
  --axes-paper: #14283f99;
  --axes-border: #dceaf32e;
  --overlay-text: #f2f7fb;
  --overlay-shadow: #14283f40;
  --overlay-hover-border: #a1bacd;
  --overlay-disabled: #9bafc0;
  --overlay-copy: #d3e0ea;
  --overlay-label: #9bb6cb;
  --overlay-link: #f0c46a;
  --fullscreen-paper: #0d1a28;
  --fullscreen-gradient-start: #0a1420eb;
  --fullscreen-gradient-mid: #0a1420c4;
  --fullscreen-gradient-end: #0a142000;
  --fullscreen-text: #e8eff5;
  --fullscreen-muted: #c5d4e0;
  --fullscreen-control: #203c57d9;
  --fixed-scheme-text: #28445d;
  --fixed-mock-text: #6c4705;
  --fixed-neutral-ink: #2a7fb8;
  --hud-mock-bg: #f7e9c5;
  --fixed-text: #172e45;
  --scheme-grid: #dbe6ea;
  --scheme-active: #f8e5ad;
  --scheme-active-border: #a56e17;
  --scheme-leader: #718a9b;
  --scheme-roll: #8b5709;
}

html.theme-dark {
  color-scheme: dark;
  --text: #e5edf5;
  --control-text: #e5edf5;
  --page: #122031;
  --paper: #1a2c40;
  --muted: #b3c6d8;
  --rule: #41566c;
  --wash: #22394f;
  --button-border: #60798f;
  --button-hover: #29445e;
  --button-hover-border: #92acc1;
  --button-active: #304d68;
  --button-active-border: #93b5d0;
  --focus: #f0b840;
  --intro-rule: #536c83;
  --input-border: #60798f;
  --group-heading: #243d55;
  --card-rule: #344c62;
  --sidebar: #182a3c;
  --sidebar-hover: #294157;
  --side-accent: #f0b840;
  --side-active: #30485f;
  --positive-ink: #51cab6;
  --positive-text: #a4f0dc;
  --positive-bg: #173f3c;
  --negative-ink: #ff8b96;
  --negative-text: #ffd2d8;
  --negative-bg: #512b3a;
  --neutral-ink: #73bfee;
  --neutral-text: #bfe5ff;
  --neutral-bg: #243f59;
  --mock-text: #f6d99b;
  --mock-bg: #4a3c22;
  --player-border: #536c83;
  --scheme-text: #c8ddef;
  --timeline-bg: #334b62;
  --timeline-line: #6587a4;
  --timeline-line-alt: #557992;
  --timeline-line-third: #7891a6;
  --timeline-arc: #407d73;
  --timeline-arc-alt: #578c80;
  --timeline-roll: #a58b57;
  --timeline-spin: #a66b77;
  --timeline-marker: #acc8df;
  --reverse-accent: #9dc5e5;
  --play-hover: #365d7e;
  --toggle-accent: #9dc5e5;
  --scheme-paper: #182b3d;
  --scheme-ink: #d7e7f5;
  --guide-text: #c8d8e7;
  --training-text: #e9ca8c;
  --station-rule: #344c62;
  --station-hover: #253e55;
  --station-active: #30485f;
  --station-accent: #f0b840;
  --adjacent-hover: #294157;
  --dialog-border: #718da4;
  --shortcut-rule: #41566c;
  --key-bg: #294157;
  --key-border: #718da4;
  --scheme-grid: #30495d;
  --scheme-active: #68501d;
  --scheme-active-border: #f0b840;
  --scheme-leader: #9fb6c8;
  --scheme-roll: #f0c46a;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button, select {
  min-height: 44px;
  border: 1px solid var(--button-border);
  border-radius: 6px;
  background: var(--paper);
  padding: 0 11px;
}
button { cursor: pointer; font-weight: 650; }
button:hover, select:hover { background: var(--button-hover); border-color: var(--button-hover-border); }
button[aria-pressed="true"] { background: var(--button-active); border-color: var(--button-active-border); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.85rem, 3.4vw, 3.2rem); font-weight: 750; letter-spacing: -.045em; line-height: 1.06; }
h2 { font-size: 1.12rem; letter-spacing: -.02em; }
h3 { font-size: .83rem; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.masthead { background: var(--navy); color: var(--on-navy); border-bottom: 3px solid var(--gold); }
.masthead-inner, .shell, .footer { width: min(100%, 1520px); margin-inline: auto; padding-inline: clamp(16px, 3vw, 43px); }
.masthead-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 69px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; font-weight: 750; line-height: 1.06; }
.brand:focus-visible, .masthead-links a:focus-visible, .masthead-links button:focus-visible { outline-color: var(--gold); }
.brand-accent { color: var(--gold); }
.brand small { display: block; color: var(--brand-muted); font-size: .68rem; font-weight: 550; margin-top: 5px; }
.masthead-links { display: flex; align-items: center; gap: 13px; font-size: .84rem; font-weight: 650; }
.masthead-links a { display: grid; place-items: center; min-height: 44px; white-space: nowrap; }
.masthead-links a:hover { color: var(--gold); }
.masthead-links button { background: var(--overlay-control); color: var(--on-navy); border-color: var(--overlay-border); min-width: 44px; }
.masthead-links button:hover { background: var(--overlay-hover); }
.shell { padding-block: 24px 34px; }
.notice { border: 1px solid var(--rule); background: var(--paper); padding: 16px; }
.footer { border-top: 1px solid var(--rule); padding-block: 20px 30px; color: var(--muted); font-size: .82rem; line-height: 1.6; }
.footer p { max-width: 92ch; }
.footer p + p { margin-top: 7px; }

.library-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 290px);
  align-items: end;
  gap: 24px;
  padding: 24px 0 26px;
  border-bottom: 1px solid var(--intro-rule);
  margin-bottom: 23px;
}
.library-intro p { color: var(--muted); line-height: 1.6; margin-top: 12px; max-width: 55ch; }
.search-field { display: grid; gap: 7px; font-size: .83rem; font-weight: 700; }
input[type="search"] { width: 100%; min-height: 44px; border: 1px solid var(--input-border); border-radius: 6px; padding: 0 11px; background: var(--paper); }
.home-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; gap: 18px; }
.home-group { background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.home-group h2 { padding: 14px 16px; background: var(--group-heading); border-bottom: 1px solid var(--rule); }
.home-group a { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 0 10px; align-items: center; padding: 11px 15px; }
.home-group a + a { border-top: 1px solid var(--card-rule); }
.home-group a:hover { background: var(--wash); }
.home-group a:focus-visible, .side-link:focus-visible { outline-offset: -3px; }
.library-number { color: var(--muted); font-size: .73rem; font-variant-numeric: tabular-nums; }
.library-title { font-size: .91rem; font-weight: 650; overflow-wrap: anywhere; }
.library-badge { grid-column: 2; justify-self: start; margin-top: 3px; color: var(--muted); font-size: .73rem; }
.library-empty { color: var(--muted); padding: 14px 13px; }

.viewer-layout { display: grid; grid-template-columns: clamp(188px, 19vw, 249px) minmax(0, 1fr); gap: clamp(16px, 2vw, 29px); align-items: start; }
.sidebar { position: sticky; top: 16px; max-height: calc(100dvh - 32px); overflow: auto; background: var(--sidebar); border: 1px solid var(--rule); border-radius: 8px; }
.sidebar-head { position: sticky; top: 0; z-index: 2; background: var(--sidebar); padding: 14px 12px 12px; border-bottom: 1px solid var(--rule); }
.sidebar-head h2 { margin-bottom: 11px; }
.side-group { padding: 10px 0 3px; }
.side-group h3 { padding: 5px 11px 8px; color: var(--muted); }
.side-link {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 6px;
  align-items: center;
  gap: 5px;
  border-left: 3px solid transparent;
  padding: 4px 10px 4px 8px;
  min-height: 44px;
}
.side-link .library-title { font-size: .81rem; }
.side-link:hover { background: var(--sidebar-hover); }
.side-link[aria-current="page"] { border-color: var(--side-accent); background: var(--side-active); }
.library-color { width: 6px; height: 6px; border-radius: 50%; background: var(--badge-ink); }

.figure-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px 14px; margin-bottom: 16px; flex-wrap: wrap; }
.figure-group { color: var(--muted); font-size: .81rem; font-weight: 720; margin-bottom: 5px; }
.figure-badges { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 2px; }
.figure-badge, .mock-badge { border-radius: 5px; padding: 5px 9px; font-weight: 700; font-size: .73rem; }
[data-badge="positive"] { --badge-ink: var(--positive-ink); --badge-text: var(--positive-text); --badge-bg: var(--positive-bg); }
[data-badge="negative"] { --badge-ink: var(--negative-ink); --badge-text: var(--negative-text); --badge-bg: var(--negative-bg); }
[data-badge="neutral"] { --badge-ink: var(--neutral-ink); --badge-text: var(--neutral-text); --badge-bg: var(--neutral-bg); }
.figure-badge { color: var(--badge-text); background: var(--badge-bg); border-left: 3px solid var(--badge-ink); }
.mock-badge { color: var(--mock-text); background: var(--mock-bg); }
.player { min-width: 0; border: 1px solid var(--player-border); border-radius: 8px; background: var(--paper); overflow: hidden; }
.viewport {
  position: relative;
  height: clamp(350px, 53vw, 525px);
  min-width: 0;
  background: var(--sky);
  overflow: hidden;
}
.viewport[data-manual="true"] canvas { cursor: ew-resize; }
.viewport[data-orbit="true"] canvas { cursor: grab; }
.viewport[data-orbit="true"] canvas:active { cursor: grabbing; }
canvas { width: 100%; height: 100%; display: block; }
.hud {
  color: var(--fixed-text);
  position: absolute;
  inset: 0;
  display: flex;
  flex-flow: column;
  justify-content: space-between;
  pointer-events: none;
  padding: 12px;
  font-size: .79rem;
  font-variant-numeric: tabular-nums;
}
.hud-top, .hud-bottom { display: flex; align-items: flex-start; gap: 7px; }
.hud-bottom { justify-content: space-between; align-items: end; }
.hud-chip, .instrument-strip, .orientation {
  background: var(--hud-paper);
  border: 1px solid var(--hud-border);
  border-radius: 5px;
  box-shadow: 0 1px 3px var(--hud-shadow);
}
.hud-chip { padding: 6px 8px; display: flex; align-items: center; gap: 6px; line-height: 1.15; }
#canopy-chip, .g-chip { flex: 0 0 auto; }
.hud span:not(.nz-meter) { color: var(--hud-muted); font-size: .68rem; font-weight: 660; }
#canopy-chip strong { letter-spacing: .025em; }
.aircraft-view { width: 25px; height: 25px; color: var(--fixed-scheme-text); }
#canopy-chip[data-attitude="DOWN"] .aircraft-view { transform: rotate(180deg); }
#canopy-chip[data-attitude="SIDE"] .aircraft-view { transform: rotate(90deg); }
.hud .hud-mock { color: var(--fixed-mock-text); background: var(--hud-mock-bg); flex: 0 0 auto; }
.phase-chip { margin-left: auto; min-width: 0; text-align: right; max-width: 54%; overflow-wrap: anywhere; }
.phase-chip span { flex: none; white-space: nowrap; }
.g-chip { display: grid; grid-template-columns: auto 1fr; min-width: 65px; column-gap: 5px; row-gap: 3px; }
.g-chip[data-load="positive"] { --g-ink: var(--hud-positive-ink); color: var(--hud-positive-text); }
.g-chip[data-load="negative"] { --g-ink: var(--hud-negative-ink); color: var(--hud-negative-text); }
.g-chip[data-load="neutral"] { --g-ink: var(--fixed-neutral-ink); color: var(--hud-neutral-text); }
.nz-meter { grid-column: 1 / -1; position: relative; background: var(--hud-meter); height: 4px; border-radius: 3px; }
.nz-meter::before { content: ""; position: absolute; left: var(--nz-offset); width: var(--nz-width); height: 100%; background: var(--g-ink); }
.nz-meter::after { content: ""; position: absolute; left: 40%; width: 1px; height: 100%; background: var(--hud-meter-zero); }
.instrument-strip, .orientation { padding: 6px 8px; }
.instrument-strip { display: flex; gap: 10px; }
.instrument-strip > div, .orientation { display: grid; align-content: center; gap: 1px; line-height: 1.13; }
.instrument-strip strong, .orientation strong { white-space: nowrap; }
.orientation { color: var(--on-navy); background: var(--overlay-paper); border-color: var(--overlay-rule); }
.hud .orientation span { color: var(--overlay-caption); }
.stage-notice { position: absolute; inset: 42% 12px auto; max-width: 320px; margin-inline: auto; text-align: center; padding: 12px; background: var(--paper); border: 1px solid var(--rule); border-radius: 5px; }

.transport { padding: 11px 13px 13px; border-top: 1px solid var(--player-border); }
.timeline-row { display: flex; gap: 7px 14px; align-items: baseline; flex-wrap: wrap; }
.timecode { font-size: .94rem; font-weight: 760; font-variant-numeric: tabular-nums; }
.frame-number, .manual-status { color: var(--muted); font-size: .78rem; font-weight: 650; }
.manual-status { margin-left: auto; }
.timeline { display: grid; position: relative; margin: 0 2px 3px; }
.timeline-bands { position: absolute; left: 9px; right: 9px; top: 17px; height: 10px; border-radius: 3px; background: var(--timeline-bg); pointer-events: none; overflow: visible; }
.timeline-phase { position: absolute; inset-block: 0; border-radius: 2px; background: var(--timeline-line); }
.timeline-phase:nth-child(3n + 2) { background: var(--timeline-line-alt); }
.timeline-phase:nth-child(3n + 3) { background: var(--timeline-line-third); }
.timeline-phase[data-kind="arc"] { background: var(--timeline-arc); }
.timeline-phase[data-kind="arc"]:nth-child(even) { background: var(--timeline-arc-alt); }
.timeline-phase[data-kind="roll"], .timeline-phase[data-kind="pointRoll"] { background: var(--timeline-roll); }
.timeline-phase[data-kind="spin"], .timeline-phase[data-kind="snap"] { background: var(--timeline-spin); }
.timeline-marker { position: absolute; width: 2px; height: 8px; bottom: -7px; background: var(--timeline-marker); }
#timeline { position: relative; z-index: 1; appearance: none; background: transparent; width: 100%; height: 44px; margin: 0; cursor: ew-resize; touch-action: none; }
#timeline::-webkit-slider-runnable-track { background: transparent; }
#timeline::-moz-range-track { background: transparent; }
#timeline::-webkit-slider-thumb { appearance: none; height: 19px; width: 19px; border: 2px solid var(--text); border-radius: 50%; background: var(--gold); }
#timeline::-moz-range-thumb { height: 15px; width: 15px; border: 2px solid var(--text); border-radius: 50%; background: var(--gold); }
.controls-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 9px 12px; }
.play-controls { display: grid; grid-template-columns: repeat(8, minmax(44px, auto)); gap: 7px; }
.play-controls button { width: 100%; padding-inline: 7px; font-size: .95rem; white-space: nowrap; }
.play-controls button[aria-pressed="true"]:not(#play) { box-shadow: inset 0 -3px var(--reverse-accent); }
#play { background: var(--navy); border-color: var(--navy); color: var(--on-navy); }
#play:hover { background: var(--play-hover); }
.select-controls { display: flex; flex-wrap: wrap; gap: 8px 11px; }
.select-label { display: flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.select-label select { font-size: .85rem; font-weight: 650; color: var(--control-text); }
#size { min-width: 57px; }
.display-controls { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.display-controls button { font-size: .79rem; }
.display-controls button[aria-pressed="true"] { box-shadow: inset 0 -3px var(--toggle-accent); }

.study-grid { display: grid; grid-template-columns: minmax(0, 1.32fr) minmax(0, 1fr); align-items: start; gap: 15px; margin-top: 16px; }
.panel { border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); min-width: 0; }
.panel-head { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 7px 10px; padding: 7px 12px; border-bottom: 1px solid var(--rule); }
.scheme-controls { display: flex; align-items: center; gap: 6px; }
.scheme-controls button, .scheme-controls select { font-size: .78rem; padding-inline: 7px; white-space: nowrap; }
#scheme { display: block; width: 100%; touch-action: none; background: var(--scheme-paper); cursor: crosshair; }
.legend { display: flex; flex-wrap: wrap; list-style: none; gap: 6px 12px; margin: 0; padding: 10px 12px 5px; color: var(--muted); font-size: .75rem; }
.legend li { display: flex; align-items: center; gap: 5px; }
.legend i { display: inline-block; width: 13px; border-top: 3px solid var(--scheme-ink); }
.legend .positive { border-color: var(--positive-ink); }
.legend .negative { border-color: var(--negative-ink); }
.legend .neutral { border-color: var(--neutral-ink); }
.legend .dashed { border-top-style: dashed; }
.legend .entry, .legend .current-dot { width: 8px; height: 8px; border: 1px solid var(--scheme-ink); border-radius: 50%; background: var(--scheme-ink); }
.legend .current-dot { background: var(--gold); }
.legend .end-bar { width: 2px; height: 10px; border: 0; background: var(--scheme-ink); }
.scheme-note { padding: 4px 12px 12px; font-size: .76rem; color: var(--muted); }
.variants { display: flex; flex-wrap: wrap; padding: 11px 12px; gap: 8px 12px; border-bottom: 1px solid var(--rule); }
.guide-copy { padding: 13px 13px 14px; line-height: 1.55; }
.guide-copy p { color: var(--guide-text); font-size: .87rem; margin: 4px 0 12px; overflow-wrap: anywhere; }
.guide-copy p:last-of-type { margin-bottom: 0; }
#track-notes { color: var(--training-text); font-size: .81rem; padding-inline-start: 19px; margin: 12px 0 0; }
.stations-panel { grid-column: 1 / -1; }
#stations { list-style: none; margin: 0; padding: 0; }
#stations li + li { border-top: 1px solid var(--station-rule); }
.station-row {
  display: grid;
  grid-template-columns: 5.4rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 10px;
  width: 100%;
  text-align: left;
  min-height: 52px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0;
  padding: 7px 11px 7px 8px;
  background: transparent;
  font-size: .85rem;
}
.station-row:focus-visible { outline-offset: -3px; }
.station-row:hover { background: var(--station-hover); }
.station-row[aria-current="true"] { background: var(--station-active); border-color: var(--station-accent); }
.station-time { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; font-size: .76rem; color: var(--muted); white-space: nowrap; }
.station-number { display: grid; place-items: center; border-radius: 4px; min-width: 19px; min-height: 19px; color: var(--on-navy); background: var(--navy); }
.station-title, .station-note { display: block; overflow-wrap: anywhere; }
.station-note { font-size: .76rem; font-weight: 470; color: var(--muted); margin-top: 2px; }
.station-readout { font-size: .74rem; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.station-attitude { display: block; color: var(--muted); font-weight: 520; }
.figure-navigation { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.figure-navigation a { min-height: 44px; padding: 8px 11px; background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; overflow-wrap: anywhere; }
.figure-navigation a:hover { background: var(--adjacent-hover); }
.figure-navigation a:last-child[data-next] { grid-column: 2; text-align: right; }
.figure-navigation small { display: block; color: var(--muted); }
.figure-navigation strong { font-size: .84rem; }

dialog { max-width: min(460px, calc(100% - 28px)); width: 100%; max-height: 90dvh; padding: 0; border: 1px solid var(--dialog-border); background: var(--paper); border-radius: 8px; }
dialog::backdrop { background: var(--backdrop); }
.shortcuts { padding: 6px 14px 13px; margin: 0; }
.shortcuts div { display: grid; grid-template-columns: minmax(96px, auto) 1fr; gap: 8px; align-items: center; padding: 6px 0; font-size: .84rem; border-bottom: 1px solid var(--shortcut-rule); }
.shortcuts dd { margin: 0; }
kbd { background: var(--key-bg); border: 1px solid var(--key-border); border-radius: 3px; padding: 1px 4px; }

.scene-only .masthead, .scene-only .footer, .scene-only .sidebar,
.scene-only .figure-heading, .scene-only .transport, .scene-only .study-grid,
.scene-only .figure-navigation, .scene-only .stage-notice,
.scene-only .notice, .scene-only #home { display: none !important; }
.scene-only .shell { width: 100%; padding: 0; }
.scene-only .viewer-layout { display: block; }
.scene-only .player { border: 0; border-radius: 0; }
.scene-only .viewport { height: 100dvh; }

@media (max-width: 1100px) {
  .home-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 950px) {
  .study-grid { grid-template-columns: minmax(0, 1fr); }
  .stations-panel { grid-column: auto; }
}

@media (max-width: 727px), (max-width: 920px) and (max-height: 510px) {
  .masthead-inner { min-height: 59px; }
  .shell { padding-block: 16px 24px; }
  .viewer-layout { display: block; }
  .sidebar { display: none; }
  .figure-heading { margin-bottom: 11px; }
  .viewport { height: clamp(260px, 76vw, 400px); }
  .hud { padding: 7px; }
  .hud-bottom { flex-wrap: wrap-reverse; justify-content: flex-start; gap: 4px; }
  .instrument-strip { gap: clamp(5px, 2vw, 9px); padding: 5px 6px; max-width: 100%; }
  .hud span:not(.nz-meter) { font-size: .63rem; }
  .orientation { padding: 4px 6px; }
  .transport { padding: 10px 9px 11px; }
  .transport button, .transport select { min-height: 48px; }
  .library-intro { padding: 12px 0 17px; }
}

@media (max-width: 520px) {
  .masthead-inner, .shell, .footer { padding-inline: 12px; }
  .masthead-links { gap: 7px; }
  .masthead-links a { font-size: .75rem; }
  .library-intro, .home-groups { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .play-controls { grid-template-columns: repeat(4, minmax(44px, 1fr)); width: 100%; }
  .controls-row { gap: 8px; }
  .select-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; width: 100%; }
  .select-label { display: grid; gap: 3px; }
  .select-label select { width: 100%; padding-inline: 9px; }
  .study-grid { gap: 12px; }
}

@media (max-height: 510px) and (orientation: landscape) {
  .viewport { height: 272px; }
  .player[data-fullscreen] .hud-bottom { flex-wrap: nowrap; justify-content: space-between; }
}

/* Job V3: free-view controls and viewport overlays. The panel's grid area
   bounds its absolute positioning to the viewport, above the transport. */
.player { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); }
.viewport { grid-area: 1 / 1; }
.transport { grid-area: 2 / 1; }
.viewport[data-interactive="true"] canvas { touch-action: none; }
.viewport[data-interactive="false"] canvas { touch-action: pan-y; }

.world-axes {
  position: absolute;
  left: 12px;
  bottom: 88px;
  z-index: 1;
  width: 72px;
  height: 72px;
  pointer-events: none;
  background: var(--axes-paper);
  border: 1px solid var(--axes-border);
  border-radius: 9px;
}
.world-axes text { font: 700 9px system-ui, sans-serif; }
.world-axes line { stroke-width: 2; stroke-linecap: round; }

.view-panel {
  position: absolute;
  grid-area: 1 / 1 / 2 / 2;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: min(340px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0 12px 12px;
  color: var(--overlay-text);
  background: var(--overlay-paper);
  border: 1px solid var(--overlay-rule);
  border-radius: 8px;
  box-shadow: 0 5px 18px var(--overlay-shadow);
  font-size: .78rem;
  color-scheme: dark;
}
.view-panel-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-block: 10px;
  background: var(--navy);
  border-bottom: 1px solid var(--overlay-rule);
}
.view-panel-head h2 { font-size: .95rem; }
.view-panel button, .view-panel input[type="number"] {
  min-height: 40px;
  color: var(--overlay-text);
  background: var(--overlay-control);
  border: 1px solid var(--overlay-border);
  border-radius: 6px;
}
.view-panel button { padding-inline: 8px; }
.view-panel button:hover:enabled { background: var(--overlay-hover); border-color: var(--overlay-hover-border); }
.view-panel :is(button, input):disabled { opacity: .45; cursor: not-allowed; }
.view-panel :is(button, input):focus-visible { outline-color: var(--gold); }
.view-directions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-block: 10px;
}
.view-values { display: grid; gap: 5px; }
.view-value {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr) 4.5rem .6rem;
  align-items: center;
  gap: 5px;
}
.view-value label { line-height: 1.25; }
.view-value input[type="range"] { min-width: 0; width: 100%; height: 40px; margin: 0; accent-color: var(--gold); }
.view-value input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
  min-width: 0;
  width: 4.5rem;
  padding: 4px 5px;
  font-variant-numeric: tabular-nums;
}
.view-value input[type="number"]::-webkit-inner-spin-button,
.view-value input[type="number"]::-webkit-outer-spin-button { appearance: none; margin: 0; }
.view-overlays { display: grid; gap: 6px; margin-top: 10px; }
.view-overlays label { display: flex; align-items: center; gap: 7px; min-width: 0; min-height: 40px; line-height: 1.3; }
.view-overlays input { flex: none; width: 17px; height: 17px; margin: 0; accent-color: var(--gold); }
.view-overlays label:has(input:disabled) { color: var(--overlay-disabled); cursor: not-allowed; }
#drag-mode[aria-pressed="true"] { background: var(--button-active); border-color: var(--button-active-border); }
.select-controls, .select-label { min-width: 0; }
.select-label select { min-width: 0; max-width: 100%; }

@media (max-width: 719px) {
  .world-axes { left: 7px; bottom: 92px; width: 56px; height: 56px; }
  .view-panel {
    inset: auto 0 0;
    width: 100%;
    max-height: min(52vh, 380px, 64%);
    padding: 0 max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    border-radius: 10px 10px 0 0;
  }
  .view-overlays { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #view-reset { grid-column: 1 / -1; }
}

/* Aircraft selector: details panel and the custom-plane form (reuses the View panel's overlay styles). */
.aircraft-panel h3 { margin: 10px 0 2px; font-size: 1rem; }
.aircraft-panel p { margin: 2px 0 8px; line-height: 1.4; color: var(--overlay-copy); }
.plane-specs { display: grid; grid-template-columns: minmax(0, 7.5rem) minmax(0, 1fr); gap: 3px 10px; margin: 6px 0 8px; }
.plane-specs dt { color: var(--overlay-label); }
.plane-specs dd { margin: 0; overflow-wrap: anywhere; }
.plane-notes:empty, .plane-sources:empty { display: none; }
.plane-sources { margin: 0 0 8px; padding-left: 1.1rem; font-size: .74rem; }
.plane-sources a { color: var(--overlay-link); }
.custom-editor { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--overlay-rule); }
.custom-editor summary { cursor: pointer; font-weight: 700; min-height: 40px; display: flex; align-items: center; }
.custom-help { font-size: .74rem; }
.custom-row { display: grid; grid-template-columns: minmax(0, 8.2rem) minmax(0, 1fr); align-items: center; gap: 8px; margin-bottom: 6px; }
.custom-fields { display: grid; gap: 0; }
.aircraft-panel :is(select, input[type="text"], input[type="number"], input[type="color"]) {
  min-width: 0; width: 100%; min-height: 40px; box-sizing: border-box; color: var(--overlay-text); background: var(--overlay-control);
  border: 1px solid var(--overlay-border); border-radius: 6px; padding: 4px 6px; font: inherit;
}
.aircraft-panel input[type="color"] { padding: 2px; cursor: pointer; }
.aircraft-panel select:disabled { opacity: .45; }
.custom-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
@media (max-width: 719px) {
  .aircraft-panel { max-height: min(60vh, 460px, 80%); }
  .custom-row { grid-template-columns: minmax(0, 7rem) minmax(0, 1fr); }
}
.plane-photo { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; margin-top: 10px; border-radius: 6px; background: var(--overlay-control); }

/* Fullscreen (real, or the window-filling fallback): the 3D view fills the screen and the controls float over its
   bottom edge like a video player; they fade while playing and come back on movement (site/js/ui/fullscreen.js). */
.player[data-fullscreen] { display: block; position: relative; border: 0; border-radius: 0; background: var(--fullscreen-paper); }
.player[data-fullscreen] .viewport { position: absolute; inset: 0; height: auto; }
.player[data-fullscreen] .transport {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; border-top: 0; color: var(--overlay-text);
  padding: 30px max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: linear-gradient(to top, var(--fullscreen-gradient-start), var(--fullscreen-gradient-mid) 65%, var(--fullscreen-gradient-end));
  transition: opacity .35s ease, transform .35s ease;
}
.player[data-fullscreen][data-controls="hidden"] .transport { opacity: 0; transform: translateY(14px); pointer-events: none; }
.player[data-fullscreen][data-controls="hidden"] canvas { cursor: none; }
.player[data-fullscreen] :is(.timecode, .frame-number, .manual-status) { color: var(--fullscreen-text); }
.player[data-fullscreen] .select-label { color: var(--fullscreen-muted); }
.player[data-fullscreen] .transport :is(button, select) { color: var(--overlay-text); background: var(--fullscreen-control); border-color: var(--overlay-border); }
.player[data-fullscreen] .transport :is(button, select):hover { background: var(--overlay-hover); }
.player[data-fullscreen] .transport #play { color: var(--navy); background: var(--gold); border-color: var(--gold); }
.player[data-fullscreen] .timeline-bands { opacity: .75; }
.player[data-fullscreen] .display-controls { margin-top: 6px; }
.player[data-fullscreen] .hud { padding-bottom: calc(12px + var(--lift, 0px)); transition: padding-bottom .35s ease; }
.player[data-fullscreen] .world-axes { bottom: calc(88px + var(--lift, 0px)); transition: bottom .35s ease; }
.player[data-fullscreen] :is(.view-panel, .aircraft-panel) { z-index: 5; max-height: calc(100% - 24px - var(--lift, 0px)); }
.player[data-fullscreen]:not(:fullscreen) { position: fixed; inset: 0; z-index: 1000; width: 100vw; height: 100dvh; }
body.fullscreen-fallback { overflow: hidden; }
@media (max-width: 719px) {
  .player[data-fullscreen] .transport { padding-top: 22px; }
  .player[data-fullscreen] .world-axes { bottom: calc(92px + var(--lift, 0px)); }
  /* On a phone the floating bar keeps the timeline, the play buttons and View / Aircraft / Exit; the rest waits outside. */
  .player[data-fullscreen] .select-controls, .player[data-fullscreen] .display-controls [data-toggle] { display: none; }
  .player[data-fullscreen] :is(.view-panel, .aircraft-panel) { bottom: var(--lift, 0px); }
}

/* Shared masthead controls for the library and static guides. */
.masthead-links a[aria-current="page"] { color: var(--gold); text-decoration: underline; text-underline-offset: .25em; }
.theme-toggle { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: 50%; flex: none; }
.theme-toggle svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-sun, .theme-dark .theme-moon { display: none; }
.theme-dark .theme-sun { display: block; }
.library-intro .new-guide { font-size: .84rem; }
.new-guide a { display: inline-flex; align-items: center; min-height: 44px; text-decoration: underline; text-underline-offset: .18em; }
@media (max-width: 520px) {
  .masthead-inner { flex-wrap: wrap; gap: 0; padding-block: 8px; }
  .brand { min-height: 44px; }
  .masthead-links { width: 100%; justify-content: flex-end; }
  .masthead-links a { padding-inline: 7px; }
}
