/* Layout: app shell — sticky top bar, course map rail on the left, lesson column on the right. OSD/goggles vernacular for data. */
:root {
  --bg: #0c0f12;
  --surface: #141a1f;
  --surface-2: #1b232a;
  --surface-3: #232d36;
  --line: #2b3640;
  --fg: #e6ebee;
  --muted: #8a98a4;
  --accent: #ffbb00;      /* Betaflight amber */
  --accent-text: #ffc933;
  --accent-ink: #1b1400;
  --good: #3fd98a;
  --warn: #ff8a3d;
  --bad: #ff4f63;
  --info: #4cc3ff;
  --osd: #ffffff;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --f-display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --f-body: "Onest", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 10px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef1f3; --surface: #ffffff; --surface-2: #f3f5f7; --surface-3: #e6eaee; --line: #d2d9df;
    --fg: #11171c; --muted: #56636e; --accent: #f0a800; --accent-text: #8a5c00; --accent-ink: #1b1400;
    --good: #138a4c; --warn: #c25a10; --bad: #cc2236; --info: #0071a8; --osd: #ffffff;
    --shadow: 0 8px 24px rgba(20,30,40,.10);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #eef1f3; --surface: #ffffff; --surface-2: #f3f5f7; --surface-3: #e6eaee; --line: #d2d9df;
  --fg: #11171c; --muted: #56636e; --accent: #f0a800; --accent-text: #8a5c00; --accent-ink: #1b1400;
  --good: #138a4c; --warn: #c25a10; --bad: #cc2236; --info: #0071a8; --osd: #ffffff;
  --shadow: 0 8px 24px rgba(20,30,40,.10);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.6 var(--f-body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 3.6vw, 2.5rem); font-weight: 700; }
h2 { font-size: 1.35rem; font-weight: 600; }
h3 { font-size: 1.02rem; font-weight: 600; }
code, kbd, .mono { font-family: var(--f-mono); font-size: .9em; }
code { background: var(--surface-3); padding: .08em .35em; border-radius: 4px; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; padding: 0 .4em; border-radius: 4px; background: var(--surface-2); }
.label { font: 600 .7rem/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-name { font: 700 .95rem/1 var(--f-display); letter-spacing: .02em; }
.brand-name span { color: var(--accent-text); }
.topnav { display: flex; gap: 4px; margin-left: 8px; flex-wrap: wrap; }
.topnav a {
  text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 8px; font-weight: 500; font-size: .92rem;
}
.topnav a:hover { color: var(--fg); background: var(--surface-2); }
.topnav a.on { color: var(--accent-ink); background: var(--accent); }
.rankbox { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.rank-name { font: 600 .78rem/1.1 var(--f-mono); text-align: right; }
.rank-name small { display: block; color: var(--muted); font-weight: 400; }
.xpbar { width: 120px; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.xpbar i { display: block; height: 100%; background: var(--accent); transition: width .5s; }
.iconbtn { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; cursor: pointer; line-height: 1; }
.iconbtn:hover { border-color: var(--accent); }
.menu-btn { display: none; }

.shell { display: grid; grid-template-columns: 290px minmax(0, 1fr); min-height: calc(100% - 52px); }
.rail {
  border-right: 1px solid var(--line); padding: 18px 12px 40px; position: sticky; top: 52px;
  height: calc(100vh - 52px); overflow-y: auto; background: var(--bg);
}
.rail .label { padding: 0 10px 8px; display: block; }
.mod { margin-bottom: 4px; }
.mod-head {
  width: 100%; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px;
  text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.mod-head:hover { background: var(--surface-2); }
.mod-num { font: 600 .75rem/1 var(--f-mono); color: var(--muted); }
.mod-title { font-weight: 600; font-size: .9rem; line-height: 1.25; }
.mod-pct { font: 500 .7rem/1 var(--f-mono); color: var(--muted); }
.mod-pct.done { color: var(--good); }
.mod-lessons { list-style: none; margin: 2px 0 8px; padding: 0 0 0 46px; display: none; }
.mod.open .mod-lessons { display: block; }
.mod-lessons a {
  display: flex; gap: 8px; align-items: baseline; padding: 4px 8px; border-radius: 6px; text-decoration: none;
  color: var(--muted); font-size: .86rem; line-height: 1.35;
}
.mod-lessons a:hover { color: var(--fg); background: var(--surface-2); }
.mod-lessons a.on { color: var(--fg); background: var(--surface-3); }
.mod-lessons .dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--muted); flex: none; transform: translateY(1px); }
.mod-lessons .done .dot { background: var(--good); border-color: var(--good); }

.main { min-width: 0; padding-block: 28px 80px; padding-inline: clamp(16px, 4vw, 48px); }
.page { max-width: 880px; margin: 0 auto; display: grid; gap: 22px; }
.page.wide { max-width: 1180px; }

/* ---------- home ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 28px; align-items: center;
  padding: 28px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface);
  position: relative; overflow: hidden;
}
.hero p { color: var(--muted); max-width: 52ch; margin: 12px 0 0; }
.hero h1 em { font-style: normal; color: var(--accent-text); }
.hero-osd {
  position: relative; aspect-ratio: 4/3; border-radius: 12px; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 100%, #3b4a3a 0%, #1f2a24 45%, #0d1418 46%, #26394a 100%);
  max-width: 100%;
}
.hero-osd canvas { width: 100%; height: 100%; display: block; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface-2);
  padding: 9px 16px; border-radius: 9px; cursor: pointer; text-decoration: none; color: var(--fg); font-weight: 600; font-size: .92rem;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 5px 10px; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.stat { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.stat b { display: block; font: 700 1.5rem/1.1 var(--f-mono); font-variant-numeric: tabular-nums; margin-top: 6px; }

.roadmap { display: grid; gap: 0; position: relative; }
.rm-step { display: grid; grid-template-columns: 44px minmax(0,1fr) auto; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.rm-step:last-child { border-bottom: 0; }
.rm-badge { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font: 700 .8rem var(--f-mono); border: 2px solid var(--line); color: var(--muted); }
.rm-step.reached .rm-badge { border-color: var(--accent); color: var(--accent-text); }
.rm-step.current .rm-badge { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.rm-step p { margin: 2px 0 0; color: var(--muted); font-size: .88rem; }

.modgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.modcard {
  display: grid; gap: 8px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  text-decoration: none; color: var(--fg); transition: border-color .15s, transform .15s;
}
.modcard:hover { border-color: var(--accent); transform: translateY(-2px); }
.modcard p { margin: 0; color: var(--muted); font-size: .87rem; line-height: 1.45; }
.progress { height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--good); }

/* ---------- lesson ---------- */
.crumbs { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lesson-head { display: grid; gap: 10px; }
.lesson-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font: .78rem var(--f-mono); }
.prose { font-size: 1rem; }
.prose > * { max-width: 70ch; }
.prose > .widget, .prose > .tablewrap, .prose > .cards, .prose > .callout, .prose > .steps { max-width: none; }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { margin: 0 0 14px; padding-left: 1.3em; }
.prose li { margin-bottom: 6px; }
.prose h2 { margin: 30px 0 12px; font-size: 1.15rem; }
.prose h3 { margin: 22px 0 8px; }
.prose strong { color: var(--fg); }
.callout {
  border: 1px solid var(--line); border-left: 3px solid var(--info); background: var(--surface);
  padding: 12px 16px; border-radius: 8px; margin: 0 0 16px; font-size: .95rem;
}
.callout.warn { border-left-color: var(--warn); }
.callout.bad { border-left-color: var(--bad); }
.callout.good { border-left-color: var(--good); }
.callout b:first-child { display: block; font: 600 .72rem/1.4 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; margin-bottom: 4px; color: var(--muted); }
.tablewrap { overflow-x: auto; margin: 0 0 16px; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font: 600 .72rem/1.3 var(--f-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.mono, td .mono { font-variant-numeric: tabular-nums; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin: 0 0 16px; }
.cards > div { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--surface); font-size: .9rem; }
.cards > div b { display: block; margin-bottom: 4px; }
.steps { counter-reset: s; display: grid; gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; }
.steps li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font: 600 .78rem var(--f-mono); }

.lesson-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 20px; }

/* ---------- widget frame ---------- */
.widget {
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); margin: 6px 0 22px;
  overflow: hidden;
}
.w-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.w-head .label { color: var(--accent-text); }
.w-head h3 { font-size: .92rem; }
.w-body { padding: 16px; display: grid; gap: 14px; }
.w-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.w-cols { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 16px; }
.field { display: grid; gap: 4px; min-width: 120px; flex: 1; }
.field label, .field .label { font-size: .78rem; color: var(--muted); font-family: var(--f-mono); }
.field input[type=number], .field select, .field input[type=text] {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px; width: 100%;
  font-family: var(--f-mono); font-variant-numeric: tabular-nums;
}
.field input[type=range] { width: 100%; accent-color: var(--accent); }
.field output { font: 600 .9rem var(--f-mono); }
.readouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.ro { background: var(--surface-2); border-radius: 9px; padding: 10px 12px; border: 1px solid var(--line); }
.ro span { display: block; font: .72rem var(--f-mono); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.ro b { font: 700 1.25rem/1.3 var(--f-mono); font-variant-numeric: tabular-nums; }
.ro.good b { color: var(--good); } .ro.warn b { color: var(--warn); } .ro.bad b { color: var(--bad); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font: 600 .75rem/1.6 var(--f-mono); background: var(--surface-3); }
.pill.good { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.pill.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pill.bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.pill.info { background: color-mix(in srgb, var(--info) 18%, transparent); color: var(--info); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex-wrap: wrap; }
.seg button { background: var(--surface-2); border: 0; padding: 6px 12px; cursor: pointer; font-size: .85rem; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
canvas.chart { width: 100%; display: block; border-radius: 8px; background: var(--surface-2); }
.hint { font-size: .85rem; color: var(--muted); }
.codeout {
  font: .85rem/1.55 var(--f-mono); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; white-space: pre; overflow-x: auto; margin: 0;
}

/* anatomy */
.anatomy { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.anatomy svg { width: 100%; height: auto; max-width: 100%; }
.anatomy .hot { cursor: pointer; }
.anatomy .hot:hover > *, .anatomy .hot.on > * { stroke: var(--accent); }
.anatomy .info { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; min-height: 220px; }
.anatomy .info h3 { margin-bottom: 6px; color: var(--accent-text); }
.anatomy .info p { margin: 0 0 8px; font-size: .92rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface-2); padding: 3px 10px; border-radius: 999px; cursor: pointer; font-size: .8rem; }
.chip.on { border-color: var(--accent); color: var(--accent-text); }

/* sticks */
.sticks { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; }
.stick { width: 150px; height: 150px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); position: relative; touch-action: none; cursor: grab; }
.stick::before, .stick::after { content: ""; position: absolute; background: var(--line); }
.stick::before { left: 50%; top: 10px; bottom: 10px; width: 1px; }
.stick::after { top: 50%; left: 10px; right: 10px; height: 1px; }
.stick .knob { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; background: var(--accent); box-shadow: 0 2px 10px rgba(0,0,0,.4); z-index: 1; }
.stick-label { text-align: center; font: .75rem var(--f-mono); color: var(--muted); margin-top: 6px; }
.chbars { display: grid; gap: 6px; }
.chbar { display: grid; grid-template-columns: 82px 1fr 52px; gap: 8px; align-items: center; font: .78rem var(--f-mono); }
.chbar .track { height: 12px; background: var(--surface-3); border-radius: 3px; position: relative; overflow: hidden; }
.chbar .track i { position: absolute; top: 0; bottom: 0; left: 0; background: var(--accent); }
.chbar .track::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--muted); opacity: .5; }

/* quiz */
.quiz { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; }
.quiz-head { padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.quiz-body { padding: 18px; display: grid; gap: 12px; }
.q-text { font-weight: 600; font-size: 1.02rem; }
.opts { display: grid; gap: 8px; }
.opt {
  text-align: left; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 14px; cursor: pointer;
  display: grid; grid-template-columns: 26px 1fr; gap: 8px; align-items: baseline;
}
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt .k { font: 600 .78rem var(--f-mono); color: var(--muted); }
.opt.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--surface-2)); }
.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface-2)); }
.opt:disabled { cursor: default; }
.why { font-size: .92rem; padding: 10px 14px; border-radius: 8px; background: var(--surface-2); border-left: 3px solid var(--info); }

/* toast */
.toast {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 60; background: var(--surface);
  border: 1px solid var(--accent); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); font: 600 .9rem var(--f-mono);
  transform: translateY(20px); opacity: 0; transition: .25s; pointer-events: none;
}
.toast.show { transform: none; opacity: 1; }

/* troubleshoot / checklist */
.tree-path { display: flex; gap: 6px; flex-wrap: wrap; font: .78rem var(--f-mono); color: var(--muted); }
.tree-opts { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.check { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.check:hover { background: var(--surface-2); }
.check input { width: 18px; height: 18px; accent-color: var(--good); margin-top: 3px; }
.check.done span { color: var(--muted); text-decoration: line-through; }

/* cli */
.cli { background: #07090b; color: #d8e0e6; font: .84rem/1.5 var(--f-mono); padding: 12px 14px; height: 340px; overflow-y: auto; border-radius: 8px; border: 1px solid var(--line); }
.cli .in { color: #ffcc33; }
.cli .err { color: #ff6b7a; }
.cli .ok { color: #5fe39b; }
.cli-input { display: flex; gap: 8px; align-items: center; background: #07090b; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.cli-input span { color: #ffcc33; font-family: var(--f-mono); }
.cli-input input { flex: 1; background: transparent; border: 0; color: #d8e0e6; font-family: var(--f-mono); outline: none; min-width: 0; }

/* sim */
.simwrap { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #000; aspect-ratio: 16/9; max-width: 100%; }
.simwrap.fs { aspect-ratio: auto; }
.simwrap canvas.gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.osd { position: absolute; inset: 0; pointer-events: none; font: 600 clamp(11px, 1.5vw, 16px)/1.2 var(--f-mono); color: var(--osd); text-shadow: 0 0 2px #000, 0 0 2px #000, 1px 1px 0 #000; }
.osd .tl, .osd .tr, .osd .bl, .osd .br, .osd .tc, .osd .bc, .osd .mc { position: absolute; }
.osd .tl { left: 4%; top: 5%; } .osd .tr { right: 4%; top: 5%; text-align: right; }
.osd .bl { left: 4%; bottom: 6%; } .osd .br { right: 4%; bottom: 6%; text-align: right; }
.osd .tc { left: 50%; top: 5%; transform: translateX(-50%); text-align: center; }
.osd .bc { left: 50%; bottom: 6%; transform: translateX(-50%); text-align: center; }
.osd .mc { left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; }
.osd .warnmsg { color: #ff5a5a; font-size: 1.2em; }
.osd .big { font-size: 2em; }
.touchpads { position: absolute; inset: auto 0 0 0; display: none; justify-content: space-between; padding: 10px; pointer-events: none; }
.touchpads .stick { pointer-events: auto; width: 120px; height: 120px; opacity: .75; }
.simwrap.touch .touchpads { display: flex; }
.simbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.gp-axes { display: grid; gap: 6px; }

/* flashcards */
.flash { perspective: 1200px; }
.flash-card { position: relative; height: 230px; transform-style: preserve-3d; transition: transform .5s; cursor: pointer; }
.flash-card.flip { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; padding: 22px; text-align: center; }
.flash-face.back { transform: rotateY(180deg); background: var(--surface-2); }
.flash-face h2 { font-size: 1.5rem; }
.gloss { display: grid; gap: 0; }
.gloss-item { display: grid; grid-template-columns: 200px minmax(0,1fr); gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.gloss-item b { font-family: var(--f-mono); color: var(--accent-text); font-size: .92rem; }
.searchbox { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; width: 100%; }

.drawer-backdrop { display: none; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; left: 0; top: 0; bottom: 0; width: min(320px, 86vw); z-index: 50; transform: translateX(-102%); transition: transform .25s; height: 100%; padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
  body.drawer .rail { transform: none; box-shadow: var(--shadow); }
  body.drawer .drawer-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; }
  .menu-btn { display: inline-block; }
  .hero { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .anatomy, .w-cols { grid-template-columns: 1fr; }
  .xpbar { width: 70px; }
}
@media (max-width: 720px) {
  .topnav { display: none; }
  .rank-name small { display: none; }
  .gloss-item { grid-template-columns: 1fr; gap: 4px; }
  .hero { padding: 18px; }
  .stick { width: 128px; height: 128px; }
}
.mobile-nav { display: none; }
@media (max-width: 720px) {
  .mobile-nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 0 0; }
  .mobile-nav a { text-decoration: none; color: var(--muted); font-size: .85rem; padding: 4px 8px; border-radius: 6px; background: var(--surface-2); }
  .mobile-nav a.on { background: var(--accent); color: var(--accent-ink); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- практика ---------- */
.practice-box { border: 1px dashed var(--accent); border-radius: 14px; background: color-mix(in srgb, var(--accent) 6%, var(--surface)); padding: 14px 16px; display: grid; gap: 4px; }
.today { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: 16px 18px; display: grid; gap: 12px; }
.today-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.today-grid > div { display: grid; gap: 6px; align-content: start; justify-items: start; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.today-grid b { line-height: 1.35; }

/* мастер настройки */
.wiz { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 18px; align-items: start; }
.wiz-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.wiz-list button { width: 100%; text-align: left; background: none; border: 0; padding: 6px 8px; border-radius: 6px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; color: var(--muted); font-size: .86rem; line-height: 1.3; }
.wiz-list button:hover { background: var(--surface-2); color: var(--fg); }
.wiz-list button.on { background: var(--surface-3); color: var(--fg); font-weight: 600; }
.wiz-list .dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--muted); flex: none; transform: translateY(1px); }
.wiz-list .done .dot { background: var(--good); border-color: var(--good); }
.wiz-body { display: grid; gap: 12px; min-width: 0; }

/* эмулятор EdgeTX: корпус пульта фиксированного вида в обеих темах */
.tx { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 18px; align-items: start; }
.tx-body { background: #23272b; border-radius: 22px; padding: 16px; display: grid; gap: 12px; box-shadow: inset 0 2px 0 rgba(255,255,255,.06), 0 8px 20px rgba(0,0,0,.25); }
.tx-lcd { width: 100%; height: auto; aspect-ratio: 2 / 1; border-radius: 6px; border: 3px solid #111; display: block; image-rendering: pixelated; cursor: ns-resize; }
.tx-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tx-keys button, .tx-sw button { background: #3a4046; color: #e8ecef; border: 1px solid #4b535a; border-radius: 8px; padding: 8px 0; font: 600 .8rem var(--f-mono); cursor: pointer; box-shadow: 0 2px 0 #15181b; }
.tx-keys button:active, .tx-sw button:active { transform: translateY(1px); box-shadow: none; }
.tx-keys button[data-k="ENT"] { background: #ffbb00; color: #1b1400; border-color: #ffbb00; }
.tx-sw { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tx-sw button { display: grid; gap: 2px; padding: 6px 0; }
.tx-sw span { font-size: 1rem; color: #ffbb00; }
.tx-tasks { display: grid; gap: 6px; align-content: start; }

/* редактор OSD */
.osd-ed { position: relative; aspect-ratio: 4 / 3; max-width: 100%; border-radius: 10px; overflow: hidden; touch-action: none; user-select: none;
  background: linear-gradient(180deg, #4e7aa3 0%, #9fc0dc 52%, #6f8b4c 52.5%, #33461f 100%); font: 700 clamp(9px, 1.9vw, 15px)/1 var(--f-mono); color: #fff; }
.osd-safe { position: absolute; left: calc(100% / 30); right: calc(100% / 30); top: calc(100% / 16); bottom: calc(100% / 16); border: 1px dashed rgba(255,255,255,.35); pointer-events: none; }
.osd-center { position: absolute; left: calc(9 * 100% / 30); width: calc(12 * 100% / 30); top: calc(5 * 100% / 16); height: calc(6 * 100% / 16); background: rgba(255,255,255,.07); border: 1px dashed rgba(255,255,255,.4); pointer-events: none; }
.osd-el { position: absolute; height: calc(100% / 16); display: flex; align-items: center; white-space: pre; text-shadow: 0 0 2px #000, 0 0 2px #000, 1px 1px 0 #000; cursor: grab; padding: 0 1px; border-radius: 2px; }
.osd-el:hover, .osd-el.drag { outline: 1px solid #ffbb00; background: rgba(0,0,0,.25); }
.osd-el.drag { cursor: grabbing; z-index: 2; }
.osd-el.fixed { cursor: default; transform: translate(-50%, -50%); height: auto; }
.osd-el.fixed:hover { outline: 0; background: none; }

/* программа, аварии, миссии */
.plan-row { display: grid; grid-template-columns: 22px 44px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; }
.plan-row input { width: 18px; height: 18px; accent-color: var(--good); }
.plan-row.next { background: color-mix(in srgb, var(--accent) 10%, transparent); outline: 1px solid color-mix(in srgb, var(--accent) 50%, transparent); }
.plan-row.done b { color: var(--muted); text-decoration: line-through; }
.em-timer { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.em-timer i { display: block; height: 100%; width: 100%; background: var(--good); }
.mission { display: grid; gap: 6px; align-content: start; justify-items: start; }
.stars { font-size: 1.15rem; letter-spacing: 2px; color: var(--line); }
.stars i { font-style: normal; }
.stars i.on { color: var(--accent); }
.osd .coach { position: absolute; left: 50%; bottom: 16%; transform: translateX(-50%); max-width: 80%; text-align: center; font-family: var(--f-body); font-weight: 600; font-size: clamp(11px, 1.4vw, 15px); background: rgba(0,0,0,.55); color: #ffe08a; padding: 6px 12px; border-radius: 8px; text-shadow: none; transition: opacity .3s; }

@media (max-width: 860px) {
  .wiz, .tx { grid-template-columns: 1fr; }
  .today-grid { grid-template-columns: 1fr; }
  .wiz-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plan-row { grid-template-columns: 22px 38px minmax(0, 1fr); }
  .plan-row .btn { grid-column: 3; justify-self: start; }
}

.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 6px; border-radius: 9px; background: var(--bad); color: #fff; font: 700 .68rem/1 var(--f-mono); vertical-align: 1px; }
@media (max-width: 1180px) { .today-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .today-grid { grid-template-columns: 1fr; } }
.telgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 720px) { .telgrid { grid-template-columns: 1fr; } }

/* модули 13–15 */
.mm-lcd { font: 700 1.5rem/1.2 var(--f-mono); background: #b9c8a6; color: #1a2416; border: 3px solid #23272b; border-radius: 8px; padding: 14px 16px; min-height: 64px; display: flex; align-items: center; font-variant-numeric: tabular-nums; }
.led { width: 26px; height: 26px; border-radius: 50%; background: #3a1414; border: 2px solid var(--line); box-shadow: inset 0 0 6px rgba(0,0,0,.6); }
.led.on { background: #ff3b3b; box-shadow: 0 0 14px 4px rgba(255,59,59,.7); }
.react-pad { width: 100%; min-height: 160px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface-2); color: var(--fg); font: 700 clamp(1rem, 3vw, 1.6rem) var(--f-mono); cursor: pointer; }
.react-pad.wait { background: #2a1015; color: #ff8a95; border-color: #ff4f63; }
.react-pad.go { background: #0f3a22; color: #6ff0a8; border-color: #3fd98a; }
.va-log { display: grid; gap: 4px; max-height: 160px; overflow-y: auto; font: .9rem var(--f-mono); }
