/* AeroMind — cockpit-inspired UI. Dark is the default; light mirrors it. */
/* Brand: deep navy + aviator gold (see build/icon.svg). Sky blue is reserved for diagrams/data. */
:root, [data-theme="dark"] {
  --bg: #0c1321; --bg2: #0f1829; --panel: #141f34; --panel2: #1a2741; --line: #233251; --line2: #2f4268;
  --tx: #eef2f8; --tx2: #a6b2c9; --tx3: #6f7e9b;
  --gold: #d4b06a; --gold-hi: #ecd08f; --gold-lo: #a9823e; --navy: #131d30;
  --pri: #d4b06a; --pri-ink: #10192b; --amber: #e0bf7c; --sky: #6cb8f0;
  --ok: #45d39a; --bad: #ff7272; --mid: #f2c75c;
  --hi: rgba(108, 184, 240, .26); --shadow: 0 14px 40px rgba(0, 0, 0, .38);
  --s1: rgba(108, 184, 240, .16); --s2: rgba(108, 184, 240, .10); --s3: rgba(212, 176, 106, .09); --s4: rgba(255, 255, 255, .03); --s5: rgba(69, 211, 154, .10);
  --hero-bg: linear-gradient(160deg, #1a2742 0%, #121b2e 55%, #0d1424 100%); --hero-tx: #f4f6fb; --hero-tx2: #c9d1e0;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f4f2ed; --bg2: #ebe8e0; --panel: #ffffff; --panel2: #f8f6f1; --line: #e2ddd1; --line2: #cfc8b7;
  --tx: #121c2f; --tx2: #4b5670; --tx3: #858ca0;
  --gold: #b48c45; --gold-hi: #cfa95f; --gold-lo: #8d6a2c; --navy: #131d30;
  --pri: #18243d; --pri-ink: #f6e7c5; --amber: #9c7631; --sky: #2b72b5;
  --ok: #138a59; --bad: #cf3b3b; --mid: #a77c00;
  --hi: rgba(43, 114, 181, .18); --shadow: 0 10px 28px rgba(18, 28, 47, .09);
  --s1: rgba(43, 114, 181, .13); --s2: rgba(43, 114, 181, .07); --s3: rgba(180, 140, 69, .10); --s4: rgba(18, 28, 47, .02); --s5: rgba(19, 138, 89, .08);
  --hero-bg: linear-gradient(160deg, #1a2742 0%, #121b2e 55%, #0d1424 100%); --hero-tx: #f4f6fb; --hero-tx2: #c9d1e0;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--tx);
  font: 15.5px/1.62 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
a { color: var(--pri); text-decoration: none; }
h1, h2, h3, h4 { font-family: Montserrat, Inter, sans-serif; line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.005em; }
h1 { font-size: 1.9rem; font-weight: 700; }
h2 { font-size: 1.25rem; margin-top: 1.8em; }
h3 { font-size: 1.05rem; margin-top: 1.4em; }
p { margin: 0 0 1em; }
.muted { color: var(--tx2); }
.small { font-size: .85rem; }
.timer, .g-val, .stat-v, .rb-score, .speed-stage .q-text, .num-in { font-family: "JetBrains Mono", ui-monospace, monospace; }
.m, .formula, .stat-v, .timer, .g-val, .u-idx, .ch-num, .qnav button, .rb-score { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
#shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
#nav {
  position: sticky; top: 0; height: 100vh; background: var(--bg2); border-right: 1px solid var(--line);
  padding: 22px 14px; display: flex; flex-direction: column; gap: 22px;
  padding-top: max(22px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--tx); padding: 2px 6px 18px; border-bottom: 1px solid var(--line); }
.emblem { width: 40px; height: 40px; color: var(--gold); flex: none; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand-txt b { font-family: Montserrat, sans-serif; font-weight: 800; font-size: 1.12rem; letter-spacing: .1em; }
.brand-txt small { font-size: .58rem; font-weight: 650; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); margin-top: 3px; }
#nav nav { display: flex; flex-direction: column; gap: 2px; }
#nav nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--tx2); font-weight: 550; }
#nav nav a:hover { background: var(--panel); color: var(--tx); }
#nav nav a.active { background: var(--panel2); color: var(--tx); box-shadow: inset 3px 0 0 var(--amber); }
.ico { width: 20px; text-align: center; opacity: .85; }
#view { outline: none; min-width: 0; }
.page { max-width: 1080px; margin: 0 auto; padding: 34px 36px 80px; }
.page.narrow, .narrow { max-width: 760px; margin-left: auto; margin-right: auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.page-head .sub { color: var(--tx2); margin: 0; max-width: 640px; }
.crumbs { font-size: .85rem; color: var(--tx3); margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs a { color: var(--tx2); } .crumbs .sep { opacity: .5; }

/* ---------- primitives ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; cursor: pointer;
  background: var(--pri); color: var(--pri-ink); font: inherit; font-weight: 650; padding: 10px 18px; border-radius: 10px; transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(1.08); } .btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.ghost { background: transparent; color: var(--tx); border-color: var(--line2); }
.btn.ghost:hover { background: var(--panel2); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.sm { padding: 6px 12px; font-size: .9rem; }
.row-gap { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 18px 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px; margin-bottom: 18px; }
.card-k, .side-k, .check-k, .callout-k, .unit-kind {
  font-size: .72rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; color: var(--amber); margin-bottom: 10px;
}
.bar { flex: 1; height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; min-width: 60px; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-lo), var(--gold-hi)); border-radius: 99px; transition: width .4s; }
.badge, .pill { display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: var(--panel2); color: var(--tx2); border: 1px solid var(--line); }
.badge.ok { color: var(--ok); border-color: currentColor; } .badge.bad { color: var(--bad); border-color: currentColor; } .badge.mid { color: var(--mid); border-color: currentColor; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.grid2 .card { margin: 0; }

/* ---------- gauges ---------- */
.instruments { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.inst { background: radial-gradient(circle at 50% 40%, var(--panel2), var(--panel)); border: 1px solid var(--line); border-radius: 18px; display: grid; place-items: center; padding: 14px; min-height: 150px; }
.gauge .g-track { fill: none; stroke: var(--line); stroke-width: 7; stroke-linecap: round; }
.gauge .g-fill { fill: none; stroke: var(--amber); stroke-width: 7; stroke-linecap: round; transition: stroke-dasharray .6s; }
.gauge .g-tick { stroke: var(--tx3); stroke-width: 1.5; }
.gauge .g-val { fill: var(--tx); font-size: 26px; font-weight: 750; text-anchor: middle; }
.gauge .g-unit { font-size: 13px; fill: var(--tx2); }
.gauge .g-lbl { fill: var(--tx2); font-size: 8.5px; letter-spacing: .16em; text-anchor: middle; font-weight: 700; }
.stat-col { display: flex; flex-direction: column; gap: 10px; align-items: stretch; justify-content: center; place-items: stretch; }
.stat { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.stat:last-child { border: 0; }
.stat-v { font-size: 1.35rem; font-weight: 750; color: var(--tx); }
.stat-k { font-size: .8rem; color: var(--tx2); }

/* ---------- dashboard ---------- */
.resume h3 { margin-top: 0; font-size: 1.3rem; }
.quick { display: grid; gap: 8px; }
.quick-btn { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); color: var(--tx); }
.quick-btn:hover { border-color: var(--pri); }
.quick-btn span { color: var(--tx2); font-size: .85rem; }
.prog-group h4 { color: var(--tx2); font-size: .85rem; margin: 14px 0 6px; }
.prog-row { display: grid; grid-template-columns: minmax(140px, 230px) 1fr 100px; gap: 14px; align-items: center; padding: 8px 6px; border-radius: 8px; color: var(--tx); }
.prog-row:hover { background: var(--panel2); }
.prog-q { font-size: .82rem; color: var(--tx3); text-align: right; } .prog-q.ok { color: var(--ok); }

/* ---------- courses ---------- */
.subject { margin-bottom: 34px; }
.subject-head h2 { margin: 0 0 4px; font-size: 1.4rem; }
.chapter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 14px; }
.chapter-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; color: var(--tx); display: flex; flex-direction: column; transition: border-color .15s, transform .15s; }
.chapter-card:hover { border-color: var(--pri); transform: translateY(-2px); }
.chapter-card h3 { margin: 6px 0 6px; }
.chapter-card p { font-size: .88rem; flex: 1; }
.ch-num { font-size: .8rem; font-weight: 800; color: var(--amber); letter-spacing: .1em; }
.ch-foot { display: flex; align-items: center; gap: 10px; font-size: .82rem; color: var(--tx2); }
.head-gauge { flex: none; }
.unit-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.unit-row { display: grid; grid-template-columns: 34px 24px 1fr auto; gap: 12px; align-items: center; padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; color: var(--tx); }
.unit-row:hover { border-color: var(--pri); }
.u-idx { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700; background: var(--panel2); border: 1px solid var(--line2); color: var(--tx2); }
.unit-row.done .u-idx { background: var(--ok); color: #fff; border-color: var(--ok); }
.u-ico { color: var(--tx3); text-align: center; }
.u-kind { font-size: .8rem; color: var(--tx3); }

/* ---------- unit page ---------- */
.unit-layout { display: grid; grid-template-columns: 230px 1fr; gap: 30px; align-items: start; }
.unit-side { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow: auto; padding-right: 4px; }
.side-link { display: flex; gap: 10px; padding: 7px 10px; border-radius: 8px; font-size: .86rem; color: var(--tx2); line-height: 1.35; }
.side-link span { flex: none; width: 18px; color: var(--tx3); font-size: .78rem; padding-top: 1px; }
.side-link:hover { background: var(--panel); color: var(--tx); }
.side-link.cur { background: var(--panel2); color: var(--tx); font-weight: 600; }
.side-link.done span { color: var(--ok); }
.unit-main { min-width: 0; max-width: 760px; }
.unit-main > h1 { font-size: 2rem; }
.lesson-body { font-size: 1.02rem; }
.lesson-body ul, .lesson-body ol { padding-left: 1.3em; margin: 0 0 1.1em; }
.lesson-body li { margin-bottom: .35em; }
.steps { counter-reset: s; list-style: none; padding-left: 0 !important; }
.steps li { counter-increment: s; position: relative; padding-left: 38px; margin-bottom: .6em; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--s3); color: var(--amber); font-weight: 700; font-size: .82rem; display: grid; place-items: center; }
.m { font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", Cambria, Georgia, serif; font-size: 1.05em; white-space: nowrap; }
.formula {
  font-family: "Cambria Math", "STIX Two Math", Cambria, Georgia, serif; font-size: 1.18rem; text-align: center; padding: 16px 18px; margin: 0 0 1.2em;
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 10px; line-height: 1.9; overflow-x: auto;
}
.callout { border-radius: 12px; padding: 14px 16px; margin: 0 0 1.2em; border: 1px solid var(--line); background: var(--panel); }
.callout.note { border-left: 3px solid var(--amber); }
.callout.tip { border-left: 3px solid var(--ok); background: var(--s5); }
.callout.tip .callout-k { color: var(--ok); }
figure { margin: 0 0 1.3em; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; text-align: center; }
figcaption { font-size: .86rem; color: var(--tx2); margin-top: 8px; }
.table-wrap { overflow-x: auto; margin: 0 0 1.2em; border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { background: var(--panel2); font-weight: 650; color: var(--tx2); font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: 0; }
.unit-nav { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-top: 34px; padding-top: 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* ---------- diagrams ---------- */
.dia { width: 100%; max-width: 420px; height: auto; display: block; margin: 0 auto; }
.dia-sm { max-width: 300px; }
.dia .d-line { stroke: var(--tx2); stroke-width: 2; fill: none; stroke-linecap: round; }
.dia .d-thick { stroke-width: 4; }
.dia .d-axis { stroke: var(--tx3); stroke-width: 1.5; }
.dia .d-grid { stroke: var(--line); stroke-width: 1; }
.dia .d-dash { stroke-dasharray: 5 5; stroke: var(--tx3); stroke-width: 1.6; fill: none; }
.dia .d-acc-s { stroke: var(--amber); stroke-width: 2.5; }
.dia .d-shape { fill: var(--s2); stroke: var(--sky); stroke-width: 2; stroke-linejoin: round; }
.dia .d-s1 { fill: var(--s1); } .dia .d-s2 { fill: var(--s1); } .dia .d-s3 { fill: var(--s3); stroke: var(--amber); } .dia .d-s4 { fill: var(--s4); stroke: var(--tx3); } .dia .d-s5 { fill: var(--s5); stroke: var(--ok); }
.dia .d-alpha { opacity: .85; }
.dia .d-frame { fill: none; stroke: var(--tx3); stroke-width: 1.5; }
.dia .d-ring { fill: none; stroke: var(--sky); stroke-width: 2.2; }
.dia .d-hi, .dia .d-hi circle { fill: var(--hi); stroke: none; }
.dia .d-dot { fill: var(--amber); }
.dia .d-txt { fill: var(--tx); font-size: 15px; font-family: "Cambria Math", Cambria, Georgia, serif; }
.dia .d-small { font-size: 12.5px; fill: var(--tx2); font-family: inherit; }
.dia .d-bold { font-weight: 700; }
.dia .d-acc { fill: var(--amber); }
.dia .d-curve { fill: none; stroke-width: 2.6; stroke-linecap: round; }
.dia .c0 { stroke: var(--sky); } .dia .c1 { stroke: var(--amber); } .dia .c2 { stroke: var(--ok); }
.dia .c0-t { fill: var(--sky); } .dia .c1-t { fill: var(--amber); } .dia .c2-t { fill: var(--ok); }
.dia .d-dashc { stroke-dasharray: 4 5; stroke: var(--tx3) !important; stroke-width: 1.5; }

/* ---------- questions ---------- */
.check-box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; margin: 0 0 1.4em; }
.check-box .question + .question { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 18px; }
.question { position: relative; }
.q-num { font-size: .78rem; font-weight: 700; color: var(--tx3); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .08em; }
.q-text { font-weight: 600; margin-bottom: 12px; font-size: 1.02rem; }
.options { display: grid; gap: 8px; }
.opt { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; font: inherit; color: var(--tx); background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; transition: border-color .12s, background .12s; }
.opt:hover:not(:disabled) { border-color: var(--pri); }
.opt-key { flex: none; width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; font-size: .78rem; font-weight: 750; background: var(--panel); border: 1px solid var(--line2); color: var(--tx2); }
.opt.sel { border-color: var(--gold); background: var(--s3); }
.opt.sel .opt-key { background: var(--gold); color: #10192b; border-color: var(--gold); }
.opt.right { border-color: var(--ok); background: var(--s5); }
.opt.right .opt-key { background: var(--ok); border-color: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: rgba(255, 107, 107, .1); }
.opt.wrong .opt-key { background: var(--bad); border-color: var(--bad); color: #fff; }
.opt:disabled { cursor: default; }
.num-row { display: flex; align-items: center; gap: 10px; }
.num-in, .search, .form input, .form select, .match select {
  font: inherit; color: var(--tx); background: var(--panel2); border: 1px solid var(--line2); border-radius: 10px; padding: 10px 14px; outline: none;
}
.num-in { width: 200px; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.num-in:focus, .search:focus, .form input:focus, .form select:focus, .match select:focus { border-color: var(--pri); box-shadow: 0 0 0 3px var(--hi); }
.is-right .num-in { border-color: var(--ok); } .is-wrong .num-in { border-color: var(--bad); }
.unit { color: var(--tx2); }
.match { display: grid; gap: 8px; }
.match-row { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr; gap: 10px; align-items: center; }
.match select { width: 100%; padding: 8px 10px; }
.match-row.right select { border-color: var(--ok); } .match-row.wrong select { border-color: var(--bad); }
.match-fix { grid-column: 2; font-size: .85rem; color: var(--ok); }
.match-term { font-weight: 600; }
.sort { display: grid; gap: 8px; }
.sort-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 8px 10px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); }
.sort-row.right { border-color: var(--ok); } .sort-row.wrong { border-color: var(--bad); }
.sort-item { font-weight: 650; font-family: "Cambria Math", Cambria, Georgia, serif; font-size: 1.08rem; min-width: 60px; }
.chips, .topic-links { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: .84rem; padding: 5px 11px; border-radius: 99px; background: var(--panel); color: var(--tx2); border: 1px solid var(--line2); cursor: pointer; }
a.chip:hover, .chip:hover:not(:disabled) { border-color: var(--pri); color: var(--tx); }
.chip.sel { background: var(--pri); border-color: var(--pri); color: var(--pri-ink); }
.chip.right { box-shadow: 0 0 0 2px var(--ok); }
.chip:disabled { cursor: default; }
.q-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.hint { display: none; margin-top: 10px; padding: 10px 12px; background: var(--s3); border-radius: 10px; font-size: .93rem; }
.hint.show { display: block; }
.q-feedback:empty { display: none; }
.q-feedback { margin-top: 12px; padding: 12px 14px; border-radius: 10px; font-size: .94rem; }
.is-right .q-feedback { background: var(--s5); border: 1px solid var(--ok); }
.is-wrong .q-feedback { background: rgba(255, 107, 107, .08); border: 1px solid var(--bad); }
.fb-head { font-weight: 700; margin-bottom: 4px; }
.is-right .fb-head { color: var(--ok); } .is-wrong .fb-head { color: var(--bad); }
.fb-head b { color: var(--tx); }
.fb-explain { color: var(--tx2); }
.practice-box .question { margin-top: 6px; }
.practice-box > div > .btn { margin-top: 12px; }

/* ---------- quiz / results ---------- */
.quiz > .question { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin-bottom: 12px; }
.quiz > .question.is-right { border-color: var(--ok); } .quiz > .question.is-wrong { border-color: var(--bad); }
.result-banner { display: flex; align-items: center; gap: 18px; padding: 18px 20px; border-radius: 16px; margin: 0 0 18px; border: 1px solid; }
.result-banner > div:nth-child(2) { flex: 1; }
.result-banner.ok { border-color: var(--ok); background: var(--s5); } .result-banner.bad { border-color: var(--bad); background: rgba(255, 107, 107, .08); }
.rb-score { font-size: 2.2rem; font-weight: 800; }
.result-banner.ok .rb-score { color: var(--ok); } .result-banner.bad .rb-score { color: var(--bad); }
.review { margin-top: 18px; display: grid; gap: 12px; }
.review .question { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.review .question.is-right { border-color: var(--ok); } .review .question.is-wrong { border-color: var(--bad); }

/* ---------- glossary / flashcards ---------- */
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 10px; overflow: hidden; margin-bottom: 16px; }
.seg button { font: inherit; padding: 7px 16px; background: transparent; color: var(--tx2); border: 0; cursor: pointer; }
.seg button.on { background: var(--pri); color: var(--pri-ink); font-weight: 650; }
.glossary { margin: 0; display: grid; grid-template-columns: minmax(150px, 240px) 1fr; }
.glossary dt, .glossary dd { padding: 10px 0; border-bottom: 1px solid var(--line); margin: 0; }
.glossary dt { font-weight: 700; padding-right: 16px; }
.glossary dd { color: var(--tx2); }
.flash-wrap { display: grid; gap: 14px; max-width: 560px; }
.flash { font: inherit; color: var(--tx); min-height: 210px; border-radius: 18px; border: 1px solid var(--line2); background: linear-gradient(160deg, var(--panel2), var(--panel)); cursor: pointer; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 26px; gap: 12px; text-align: center; box-shadow: var(--shadow); transition: transform .2s; }
.flash:hover { transform: translateY(-2px); }
.flash-face { font-size: 1.3rem; font-weight: 700; }
.flash.flipped .flash-face { font-size: 1.05rem; font-weight: 500; color: var(--tx2); }
.flash.flipped { border-color: var(--amber); }
.flash-hint { font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--tx3); }
.search { width: min(420px, 100%); }
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal-box { background: var(--bg2); border: 1px solid var(--line2); border-radius: 18px; padding: 20px; width: min(620px, 100%); display: grid; gap: 14px; }

/* ---------- exams ---------- */
.exam-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; margin-bottom: 20px; }
.exam-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 22px; color: var(--tx); display: flex; flex-direction: column; gap: 4px; }
a.exam-card:hover { border-color: var(--pri); }
.exam-card.hero { grid-row: span 2; background: radial-gradient(circle at 85% 0%, var(--s1), transparent 60%), var(--panel); }
.exam-card:last-child { grid-column: 1 / -1; }
.exam-card h3 { margin: 6px 0 2px; font-size: 1.2rem; }
.exam-card p { color: var(--tx2); margin-bottom: 8px; }
.ex-ico { font-size: 1.6rem; color: var(--amber); }
.ex-meta { margin-top: auto; font-size: .85rem; color: var(--amber); font-weight: 650; }
.briefing { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; }
.brief-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.brief-list li { padding: 6px 12px; border: 1px solid var(--line2); border-radius: 99px; font-size: .88rem; font-weight: 600; }
.brief-rules { color: var(--tx2); padding-left: 1.2em; }
.exam-page { padding-top: 18px; }
.exam-bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 12px 16px; margin: 0 -16px 20px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.exam-bar b { flex: 1; }
.timer { font-weight: 800; font-size: 1.1rem; color: var(--amber); padding: 4px 12px; border-radius: 8px; border: 1px solid var(--line2); }
.timer.low { color: var(--bad); border-color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.exam-layout { display: grid; grid-template-columns: 1fr 220px; gap: 24px; align-items: start; }
.exam-stage .question { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; min-height: 260px; }
.exam-side { position: sticky; top: 80px; }
.qnav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.qnav button { font: inherit; font-size: .82rem; padding: 7px 0; border-radius: 8px; border: 1px solid var(--line2); background: var(--panel); color: var(--tx2); cursor: pointer; position: relative; }
.qnav button.ans { background: var(--s3); color: var(--tx); border-color: var(--gold); }
.qnav button.flag::after { content: ''; position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.qnav button.cur { outline: 2px solid var(--amber); outline-offset: 1px; }
.legend { display: flex; gap: 12px; margin-top: 12px; font-size: .78rem; color: var(--tx3); }
.lg::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.lg.ans::before { background: var(--s3); border: 1px solid var(--gold); } .lg.flag::before { background: var(--amber); border-radius: 50%; }
.speed-stage { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 34px; text-align: center; transition: box-shadow .3s; }
.speed-stage .q-text { font-size: 1.7rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.speed-stage .num-row { justify-content: center; }
.speed-stage .num-in { font-size: 1.5rem; text-align: center; width: 240px; }
.speed-stage.flash-ok { animation: fok .5s; } .speed-stage.flash-bad { animation: fbad .5s; }
@keyframes fok { from { box-shadow: 0 0 0 4px var(--ok); } } @keyframes fbad { from { box-shadow: 0 0 0 4px var(--bad); } }
.speed-count { font-weight: 700; color: var(--ok); }
.log td { white-space: nowrap; }
.form label { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.form label:last-child { border: 0; }
.form input { width: 110px; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; background: var(--panel2); color: var(--tx); border: 1px solid var(--line2); padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow); transition: all .25s; z-index: 99; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: var(--ok); } .toast.bad { border-color: var(--bad); }

/* ---------- responsive (tablet / phone, incl. future mobile builds) ---------- */
@media (max-width: 1000px) {
  .unit-layout { grid-template-columns: 1fr; }
  .unit-side { display: none; }
  .exam-layout { grid-template-columns: 1fr; }
  .exam-side { position: static; }
  .qnav { grid-template-columns: repeat(10, 1fr); }
}
@media (max-width: 760px) {
  #shell { grid-template-columns: 1fr; }
  #nav { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); z-index: 20; }
  .brand { display: none; }
  #nav nav { flex-direction: row; justify-content: space-around; width: 100%; }
  #nav nav a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: .68rem; flex: 1; text-align: center; }
  #nav nav a.active { box-shadow: inset 0 2px 0 var(--amber); }
  .page { padding: 20px 16px 100px; padding-top: max(20px, env(safe-area-inset-top)); }
  h1 { font-size: 1.5rem; } .unit-main > h1 { font-size: 1.55rem; }
  .instruments { grid-template-columns: 1fr 1fr; }
  .grid2, .exam-grid { grid-template-columns: 1fr; }
  .exam-card.hero { grid-row: auto; }
  .prog-row { grid-template-columns: 1fr 70px; } .prog-row .bar { grid-column: 1 / -1; grid-row: 2; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .glossary { grid-template-columns: 1fr; } .glossary dt { border: 0; padding-bottom: 0; }
  .match-row { grid-template-columns: 1fr; } .match-fix { grid-column: 1; }
  .qnav { grid-template-columns: repeat(6, 1fr); }
  .exam-bar { margin: 0 -16px 16px; gap: 10px; flex-wrap: wrap; }
}
