:root {
  color-scheme: dark;
  --cream: #f2e4c8;
  --paper: #fff8e9;
  --coral: #d76d5d;
  --teal: #173f43;
  --teal-2: #28585a;
  --ink: #102f32;
  --glass: rgba(14, 45, 48, 0.88);
  --line: rgba(242, 228, 200, 0.23);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body, #app { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #173f43; }
body { color: var(--cream); }
button, input, select { font: inherit; }
button, select, input { accent-color: var(--coral); }
button { color: var(--cream); background: rgba(20, 62, 65, 0.88); border: 1px solid var(--line); border-radius: 9px; padding: 0.6rem 0.78rem; cursor: pointer; }
button:hover, button:focus-visible { background: #295e60; outline: 2px solid rgba(242, 228, 200, 0.65); outline-offset: 2px; }
button.primary { color: #fff9ed; background: var(--coral); border-color: #ef9988; font-weight: 750; }
button:disabled { cursor: not-allowed; opacity: 0.48; }
#flight-canvas { position: fixed; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
.topbar { position: fixed; z-index: 20; inset: 0 0 auto 0; min-height: 58px; display: flex; align-items: center; gap: 0.8rem; padding: 0.5rem 0.75rem; background: linear-gradient(180deg, rgba(12, 42, 45, 0.92), rgba(12, 42, 45, 0.56) 72%, transparent); pointer-events: none; }
.topbar > * { pointer-events: auto; }
.brand-lockup { display: grid; line-height: 1.05; min-width: 155px; }
.brand-lockup strong { font-size: 1rem; letter-spacing: 0.02em; }
.brand-lockup span, small { font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.75; }
.status-line { margin-left: auto; display: flex; gap: 0.65rem; font-size: 0.72rem; color: #fff9e8; }
.top-actions { display: flex; align-items: center; gap: 0.45rem; }
.record-status { position: fixed; z-index: 24; right: 12px; top: 66px; padding: 0.38rem 0.55rem; font: 700 0.62rem ui-monospace, monospace; letter-spacing: 0.08em; }
.record-status.active { color: white; background: #b84138; border-color: #ffafa2; }
.quality-label { display: flex; align-items: center; gap: 0.3rem; font-size: 0.68rem; text-transform: uppercase; }
.quality-label select { max-width: 92px; color: var(--cream); background: #173f43; border: 1px solid var(--line); border-radius: 7px; padding: 0.48rem 0.35rem; }
.drawer { position: fixed; z-index: 30; background: var(--glass); backdrop-filter: blur(18px); border: 1px solid var(--line); box-shadow: 0 18px 70px rgba(0,0,0,0.26); transition: transform 200ms ease, opacity 200ms ease; }
.studio-drawer { top: 66px; left: 10px; bottom: 120px; width: min(400px, calc(100vw - 20px)); padding: 1rem; overflow: auto; border-radius: 16px; transform: translateX(calc(-100% - 18px)); opacity: 0; }
.studio-drawer.open { transform: translateX(0); opacity: 1; }
.drawer-heading { display: flex; justify-content: space-between; gap: 0.75rem; align-items: flex-start; }
.drawer-heading h1, .drawer-heading h2 { margin: 0.1rem 0 0; font-size: 1.35rem; }
.drawer-heading button { padding: 0.25rem 0.55rem; font-size: 1.2rem; }
.region-copy { margin: 0.75rem 0; color: rgba(255,248,233,0.78); font-size: 0.84rem; line-height: 1.45; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.3rem; margin: 0.75rem 0; }
.tabs button { font-size: 0.72rem; padding: 0.55rem 0.25rem; }
.tabs button.active { color: var(--ink); background: var(--cream); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.lesson-list, .start-grid { display: grid; gap: 0.5rem; }
.lesson-card, .start-grid button { text-align: left; display: grid; gap: 0.22rem; background: rgba(255,255,255,0.045); }
.lesson-card span, .start-grid span { font-size: 0.72rem; opacity: 0.68; }
.lesson-card.completed { border-color: rgba(134, 206, 160, 0.72); }
.lesson-card.completed::after { content: "COMPLETE"; color: #9de1b2; font-size: 0.62rem; letter-spacing: 0.11em; }
.drawer-note { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--line); font-size: 0.67rem; line-height: 1.45; opacity: 0.66; }
.section-line { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.section-line h2, .tab-panel h2 { font-size: 0.9rem; }
.logbook-list { display: grid; gap: 0.4rem; }
.log-entry { padding: 0.6rem; border: 1px solid var(--line); border-radius: 8px; font-size: 0.74rem; }
.weather-panel { top: 66px; right: 10px; width: min(310px, calc(100vw - 20px)); padding: 1rem; border-radius: 16px; transform: translateX(calc(100% + 18px)); opacity: 0; }
.weather-panel.open { transform: translateX(0); opacity: 1; }
.weather-panel label { display: grid; gap: 0.3rem; margin: 0.6rem 0; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }
.weather-panel select { color: var(--cream); background: #173f43; padding: 0.55rem; border: 1px solid var(--line); border-radius: 8px; }
.weather-grid output { float: right; color: #fff5dc; }
.weather-grid input { width: 100%; }
.weather-readouts { display: grid; gap: 0.35rem; border-top: 1px solid var(--line); padding-top: 0.7rem; font: 0.72rem ui-monospace, monospace; }
.modal-card { position: fixed; z-index: 60; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(620px, calc(100vw - 24px)); max-height: calc(100vh - 90px); overflow: auto; padding: 1.2rem; background: rgba(245, 235, 214, 0.97); color: var(--ink); border: 1px solid rgba(255,255,255,0.7); border-radius: 18px; box-shadow: 0 28px 100px rgba(0,0,0,0.44); }
.modal-card button:not(.primary) { color: var(--ink); background: rgba(23,63,67,0.08); border-color: rgba(23,63,67,0.18); }
.modal-heading { display: flex; justify-content: space-between; }
.modal-card h2 { margin: 0.25rem 0 0.5rem; }
.briefing-controls { display: grid; gap: 0.25rem; padding: 0.7rem; background: rgba(23,63,67,0.08); border-radius: 9px; font-size: 0.82rem; }
.briefing-checklist { display: grid; gap: 0.45rem; padding-left: 1.4rem; }
.lesson-hud { position: fixed; z-index: 22; top: 70px; left: 50%; transform: translateX(-50%); width: min(480px, calc(100vw - 30px)); background: rgba(12,42,45,0.82); border: 1px solid var(--line); border-radius: 13px; padding: 0.55rem 0.75rem; backdrop-filter: blur(12px); }
.lesson-hud > button { float: right; padding: 0.35rem 0.5rem; }
.lesson-hud p { margin: 0.3rem 0; font-size: 0.78rem; }
.lesson-hud ol { margin: 0.3rem 0 0; padding-left: 1.25rem; display: grid; grid-template-columns: 1fr 1fr; gap: 0.18rem 0.7rem; font-size: 0.68rem; }
.lesson-hud.collapsed #lesson-hud-body { display: none; }
.instrument-strip { position: fixed; z-index: 18; left: 50%; bottom: 10px; transform: translateX(-50%); width: min(960px, calc(100vw - 250px)); display: grid; grid-template-columns: repeat(5, minmax(90px, 1fr)); gap: 1px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: rgba(11,38,41,0.82); backdrop-filter: blur(12px); }
.instrument { min-width: 0; padding: 0.36rem 0.48rem; display: grid; border-radius: 7px; background: rgba(255,255,255,0.035); }
.instrument small { font-size: 0.52rem; }
.instrument strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 600 0.76rem ui-monospace, monospace; }
.instrument span { font-size: 0.58rem; opacity: 0.65; }
.panel-toggle { display: none; }
.qnh-control { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.35rem; font-size: 0.66rem; }
.qnh-control input { min-width: 0; width: 72px; color: var(--cream); background: transparent; border: 0; border-bottom: 1px solid var(--line); }
.flight-controls { position: fixed; z-index: 19; inset: auto 10px 10px 10px; pointer-events: none; display: flex; justify-content: space-between; align-items: flex-end; }
.flight-controls > * { pointer-events: auto; }
.yoke { width: 106px; height: 106px; border: 2px solid rgba(242,228,200,0.42); border-radius: 50%; background: rgba(11,38,41,0.52); position: relative; touch-action: none; display: grid; place-items: center; font-size: 0.56rem; letter-spacing: 0.1em; user-select: none; }
.yoke-cross::before, .yoke-cross::after { content: ""; position: absolute; background: rgba(242,228,200,0.34); left: 18%; right: 18%; height: 1px; top: 50%; }
.yoke-cross::after { top: 18%; bottom: 18%; width: 1px; height: auto; left: 50%; }
.throttle-control { width: 72px; display: grid; justify-items: center; gap: 0.25rem; padding: 0.5rem; border: 1px solid var(--line); border-radius: 12px; background: rgba(11,38,41,0.72); font-size: 0.58rem; }
.throttle-control input { width: 58px; }
.quick-controls { display: flex; gap: 0.3rem; max-width: 210px; flex-wrap: wrap; justify-content: flex-end; }
.quick-controls button { font-size: 0.65rem; padding: 0.5rem; }
.more-controls { position: fixed; z-index: 42; right: 10px; bottom: 130px; width: min(330px, calc(100vw - 20px)); display: none; grid-template-columns: 1fr 1fr; gap: 0.4rem; padding: 0.75rem; background: rgba(12,42,45,0.94); border: 1px solid var(--line); border-radius: 14px; }
.more-controls.open { display: grid; }
.more-controls p { grid-column: 1 / -1; margin: 0.2rem; font-size: 0.65rem; line-height: 1.35; opacity: 0.68; }
.state-overlay { position: fixed; z-index: 80; inset: 0; display: grid; align-content: center; justify-items: center; gap: 0.65rem; text-align: center; padding: 1rem; background: rgba(9,34,37,0.82); backdrop-filter: blur(10px); }
.state-overlay h2, .state-overlay p { margin: 0; }
.state-overlay p { max-width: 520px; opacity: 0.78; }
.loading-mark { width: 52px; height: 52px; border: 3px solid rgba(242,228,200,0.25); border-top-color: var(--coral); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.debrief { width: min(760px, calc(100vw - 24px)); }
.debrief-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.45rem; margin: 0.8rem 0; }
.debrief-stats div { padding: 0.6rem; background: rgba(23,63,67,0.08); border-radius: 8px; }
.debrief-stats small { display: block; color: var(--ink); }
#trace-chart { display: block; width: 100%; height: 180px; background: #173f43; border-radius: 10px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.8rem; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 145px; transform: translateX(-50%); padding: 0.65rem 0.9rem; background: rgba(215,109,93,0.95); border-radius: 9px; box-shadow: 0 10px 35px rgba(0,0,0,0.3); font-size: 0.78rem; }
.cockpit-view .instrument-strip:not(.full) { width: min(610px, calc(100vw - 260px)); grid-template-columns: repeat(4, 1fr); }
.cockpit-view .instrument-strip:not(.full) .secondary-instrument { display: none; }
[hidden] { display: none !important; }
[data-state="menu"] .flight-controls, [data-state="menu"] .instrument-strip,
[data-state="loading"] .flight-controls, [data-state="loading"] .instrument-strip,
[data-state="recovery"] .flight-controls, [data-state="recovery"] .instrument-strip { display: none; }

@media (max-width: 900px) {
  .status-line { display: none; }
  .instrument-strip { width: min(630px, calc(100vw - 210px)); grid-template-columns: repeat(4, minmax(75px, 1fr)); }
  .secondary-instrument { display: none; }
  .panel-toggle { display: block; grid-row: 1 / 2; font-size: 0.62rem; padding: 0.3rem; }
  .instrument-strip.full { position: fixed; width: calc(100vw - 20px); bottom: 10px; grid-template-columns: repeat(5, 1fr); z-index: 45; }
  .instrument-strip.full .secondary-instrument { display: grid; }
  .quick-controls { display: flex; }
}

@media (max-width: 700px) {
  .topbar { padding: 0.35rem; gap: 0.35rem; }
  .brand-lockup { min-width: 0; flex: 1; }
  .brand-lockup span, .quality-label { display: none; }
  .top-actions { gap: 0.25rem; }
  .topbar button { padding: 0.48rem 0.5rem; font-size: 0.68rem; }
  .record-status { top: 56px; right: 6px; }
  .studio-drawer { top: 58px; bottom: 8px; }
  .weather-panel { top: 58px; max-height: calc(100vh - 66px); overflow: auto; }
  .lesson-hud { top: 58px; width: calc(100vw - 16px); }
  .lesson-hud ol { grid-template-columns: 1fr; }
  .instrument-strip { bottom: 8px; width: calc(100vw - 174px); left: 50%; grid-template-columns: repeat(2, minmax(74px, 1fr)); }
  .instrument-strip .primary-instrument:nth-of-type(n+4) { display: none; }
  .instrument-strip.full { width: calc(100vw - 12px); grid-template-columns: repeat(2, 1fr); max-height: 48vh; overflow-y: auto; }
  .instrument-strip.full .instrument, .instrument-strip.full .qnh-control { display: grid; }
  .flight-controls { inset: auto 6px 6px 6px; }
  .yoke { width: 92px; height: 92px; }
  .throttle-control { width: 64px; }
  .quick-controls { position: fixed; right: 6px; bottom: 7px; max-width: 150px; }
  .quick-controls button:not(#more-controls) { display: none; }
  .more-controls { bottom: 56px; max-height: calc(100vh - 118px); overflow-y: auto; }
  .briefing { max-height: calc(100vh - 24px); }
  .debrief-stats { grid-template-columns: repeat(2, 1fr); }
  .toast { bottom: 114px; max-width: calc(100vw - 20px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: 0.001ms !important; }
}
