/* EA Trainer: one stylesheet, three themes. Hierarchy comes from type and
 * space, not from borders, gradients and shadow. Themes swap the token block. */

/* bundled offline typeface: Inter variable (SIL OFL). The single biggest lift away
   from the system-font "AI default" look. */
@font-face {
  font-family: "Inter var";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter.woff2") format("woff2");
}

/* ---- structure + default (slate) palette: restrained, near-black, one accent ---- */
:root {
  --radius: 12px; --radius-sm: 8px; --shadow: 0 1px 2px #00000066, 0 10px 30px -18px #000000cc; --maxw: 1120px; --measure: 68ch;
  --font-head: "Inter var", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "Inter var", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --bg: #0b0c0e; --bg2: #0f1012; --surface: #131518; --surface2: #191c20;
  --border: #212428; --border2: #2d3137;
  --text: #e7e9ec; --muted: #969ba3; --faint: #686d76;
  --accent: #7c84e8; --accent-dim: #646ddb; --accent2: #8aa0cf; --on-accent: #ffffff;
  --ok: #56c08a; --no: #e08a74;

  /* content callout hues: tasteful, reserved for key moments in a card */
  --c-exam: var(--accent); --c-trap: #e0896f; --c-eg: #79a7d6; --c-why: #d9b36a;
}
:root[data-theme="slate"] { /* the defaults above */ }

:root[data-theme="dusk"] {
  --bg: #100e16; --bg2: #15121d; --surface: #181521; --surface2: #201b2c;
  --border: #2a2438; --border2: #3b3350;
  --text: #ece8f3; --muted: #aaa1bd; --faint: #776e8c;
  --accent: #b58ce0; --accent-dim: #9a6fd0; --accent2: #e0a35c; --on-accent: #140f1c;
  --ok: #8cb97f; --no: #e08a84;
  --c-exam: #b58ce0; --c-trap: #e08a84; --c-eg: #e0a35c; --c-why: #d9c06a;
}

:root[data-theme="mono"] {
  --radius: 2px; --radius-sm: 2px; --shadow: none;
  --font-head: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --font-body: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --bg: #0d100e; --bg2: #111613; --surface: #10150f; --surface2: #161c15;
  --border: #273027; --border2: #37463a;
  --text: #cdd6cd; --muted: #8aa08c; --faint: #607261;
  --accent: #79c07a; --accent-dim: #5f9a5e; --accent2: #9ac17f; --on-accent: #0a0e0a;
  --ok: #79c07a; --no: #d08b6a;
  --c-exam: #79c07a; --c-trap: #d08b6a; --c-eg: #8fb7cf; --c-why: #d9c06a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.65 var(--font-body);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  letter-spacing: -0.006em; font-feature-settings: "cv11", "ss01";  /* Inter, dialed in */
  -webkit-tap-highlight-color: transparent;    /* no grey flash on tap */
  overflow-x: hidden;                           /* never scroll sideways */
  overscroll-behavior-y: none;                  /* no pull-to-refresh hijack */
}
/* app shell: header fixed, the view below it fills the rest */
#root { min-height: 100dvh; display: flex; flex-direction: column; }
#root > .top { flex: 0 0 auto; }
#root > .wrap { flex: 1 0 auto; }   /* grow to push footer down, but never shrink below content */
#root > .foot { flex: 0 0 auto; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 24px clamp(16px, 3.5vw, 56px) 72px; }
.learnwrap { max-width: none; margin: 0; } /* Learn stays full width beside the nav (owner request) */
h1, h2, h3 { font-family: var(--font-head); line-height: 1.2; font-weight: 650; letter-spacing: -0.021em; }
b, strong { color: var(--text); font-weight: 700; }
a { color: var(--accent); }
.muted { color: var(--muted); font-weight: 400; }

/* ---- top bar ---- */
.top { max-width: none; margin: 0;
  padding: 18px clamp(16px, 3.5vw, 56px);
  padding-top: calc(18px + env(safe-area-inset-top));
  padding-left: calc(clamp(16px, 3.5vw, 56px) + env(safe-area-inset-left));
  padding-right: calc(clamp(16px, 3.5vw, 56px) + env(safe-area-inset-right));
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; border-bottom: 1px solid var(--border);
  background: var(--bg); }
.top .brand { justify-self: start; }
.top .lvl { justify-self: center; }
.top .topright { justify-self: end; }
.brand { font-family: var(--font-head); font-size: 18px; font-weight: 650; color: var(--text); cursor: pointer; letter-spacing: -0.01em; user-select: none; display: inline-flex; align-items: center; gap: 8px; }
.brand .mk { color: var(--accent); display: inline-flex; }
.brand .mk .ic { width: 16px; height: 16px; }
.navfav .ic { width: 12px; height: 12px; vertical-align: -1px; }
.topright { display: flex; align-items: center; gap: 18px; }
.lvl { display: flex; align-items: center; gap: 10px; }
.lvlnum { font-size: 13px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.xpbar { width: 120px; height: 6px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.xpbar i { display: block; height: 100%; background: var(--accent); }
.themesel { font: inherit; font-size: 13px; color: var(--text); background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius-sm); padding: 5px 8px; cursor: pointer; }
.themesel:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---- hero ---- */
.hero { padding: 40px 0 10px; max-width: var(--measure); }
.hero h1 { font-size: 40px; margin: 0 0 14px; color: var(--text); letter-spacing: -0.01em; }
.hero p { color: var(--muted); font-size: 17px; margin: 0; }

/* ---- parts ---- */
/* three equal-size cards: two side by side, the bonus one centered beneath, none stretched */
.parts { display: grid; grid-template-columns: repeat(2, minmax(0, 480px)); justify-content: center; gap: 22px; margin-top: 28px; }
/* home: centered when it fits, flows + scrolls when it doesn't (margin:auto on the inner
   block centers without clipping, unlike justify-content:center which hid the top on tall pages) */
.homewrap { display: flex; flex-direction: column; padding-bottom: 24px; max-width: none; }
.homeinner { margin: auto 0; width: 100%; }
.homewrap .hero { padding-top: 0; margin: 0 auto; text-align: center; }
.partcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); transition: border-color .16s, transform .16s; }
@media (hover: hover) { .partcard:hover { border-color: var(--border2); transform: translateY(-2px); } }
.partcard.bonus { border-color: var(--accent2); grid-column: 1 / -1; justify-self: center; width: 480px; max-width: 100%; } /* same width as one card, centered beneath the two TOGAF tracks */
.pc-soon { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 18px 0 2px; }
.pc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.pc-head h2 { margin: 0; font-size: 23px; }
.pc-sub { color: var(--faint); font-size: 13px; }
.pc-stats { display: flex; flex-wrap: wrap; gap: 20px 26px; margin: 18px 0 16px; }
.pc-stats > div { padding: 0; text-align: left; }
.pc-stats b { display: block; font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; font-weight: 650; letter-spacing: -0.01em; }
.pc-stats span { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }
.pc-bar { height: 4px; background: var(--surface2); border-radius: 99px; overflow: hidden; margin-bottom: 18px; }
.pc-bar i { display: block; height: 100%; background: var(--accent); }
.pc-actions { display: block; }
.pc-cta { width: 100%; }
.pc-more { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px; }
.pc-more .btn { justify-content: flex-start; }

/* ---- buttons ---- */
.btn { appearance: none; cursor: pointer; font: inherit; font-weight: 550; font-size: 14px; color: var(--text); background: transparent; border: 1px solid var(--border2); border-radius: var(--radius-sm); padding: 9px 14px; transition: border-color .14s, color .14s, background .14s, transform .08s; touch-action: manipulation; user-select: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.ic { width: 17px; height: 17px; flex: 0 0 auto; display: inline-block; }
.btn .ic { margin: 0 -1px; }
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-dim); border-color: var(--accent-dim); color: var(--on-accent); }
.btn.mark { border-color: var(--accent2); color: var(--accent2); }
.btn.ghost { border-color: var(--border); color: var(--muted); }
.btn.full { width: 100%; margin-top: 10px; }
.btn:focus-visible, .brand:focus-visible, .opt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.opt:active:not(.done):not(:disabled) { transform: translateY(1px); }

/* ---- learn layout ---- */
.learnwrap { display: grid; grid-template-columns: 300px 1fr; gap: 34px; align-items: start; }
.sidebar { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 6px; }
.sbtop { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin-bottom: 8px; }
.sbsearch { width: 100%; background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius-sm); color: var(--text); padding: 10px 12px; margin-bottom: 10px; font: inherit; font-size: 16px; }
.sbsearch::placeholder { color: var(--faint); }
.sbsearch:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.navscroll { display: flex; flex-direction: column; gap: 2px; max-height: 74vh; overflow: auto; overscroll-behavior: contain; padding-right: 4px; }
/* Learn nav drawer scaffolding (desktop: button + scrim hidden, tools float as before) */
.learntop { display: contents; }
.drawerbtn { display: none; }
.scrim { display: none; }
.navgroup { display: flex; flex-direction: column; }
.navchap { display: flex; align-items: center; gap: 8px; text-align: left; background: transparent; border: none; border-bottom: 1px solid var(--border); padding: 10px 4px; cursor: pointer; color: var(--text); font-weight: 600; font-size: 14px; }
.navchap:hover { color: var(--accent); }
.navchap.open { color: var(--text); }
.navchap.done .chtitle::after { content: " ✓"; color: var(--ok); }
.chcaret { color: var(--faint); font-size: 10px; width: 10px; }
.chtitle { flex: 1; font-family: var(--font-head); }
.chprog { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.navitem { text-align: left; background: transparent; border: none; border-left: 2px solid transparent; padding: 7px 10px 7px 22px; cursor: pointer; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.navitem:hover { color: var(--text); }
.navitem.on { color: var(--accent); border-left-color: var(--accent); }
.navitem.done .ntitle::after { content: " ✓"; color: var(--ok); }
.nprog { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.nomatch { color: var(--muted); font-size: 13px; padding: 10px; }
/* sections of the active module, shown nested under it */
.navsub { display: flex; flex-direction: column; margin: 1px 0 7px 24px; border-left: 1px solid var(--border); }
.navsec { text-align: left; background: transparent; border: none; border-left: 2px solid transparent; margin-left: -1px; color: var(--faint); padding: 5px 10px; font-size: 12.5px; line-height: 1.35; cursor: pointer; }
.navsec:hover { color: var(--text); }
.navsec.on { color: var(--accent); border-left-color: var(--accent); }
.navsec.done::after { content: " ✓"; color: var(--ok); }

.learnmain { min-width: 0; display: flex; flex-direction: column; min-height: calc(100vh - 110px); position: relative; }
.learnscroll { flex: 1 1 auto; min-height: 0; }
/* floating action buttons, top-right of the content (not a second header) */
.lessontools { position: absolute; top: 2px; right: 14px; z-index: 6; display: flex; gap: 8px; }
.lessontools .btn { padding: 6px 12px; font-size: 13px; box-shadow: var(--shadow); background: var(--surface); }
.btn.faved { color: var(--accent); border-color: var(--accent); }
.navfav { color: var(--accent); font-size: 11px; margin-left: 6px; }
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .06em; }
.lesson-mod { font-size: 13px; color: var(--muted); font-weight: 600; margin: 2px 0; }
.lesson-title { font-family: var(--font-head); font-size: 28px; line-height: 1.2; margin: 2px 0 14px; }
.secprog { align-self: center; font-size: 13px; color: var(--faint); font-variant-numeric: tabular-nums; }
.lessonbody .lsec { scroll-margin-top: 12px; }
.lessonbody .lsec h2 { margin-top: 0; }
.lessonbody .lsec + .lsec h2 { margin-top: 32px; }
.learncard { padding: 4px 0 8px; }
.learncard h2 { margin: 0 0 18px; font-size: 27px; color: var(--text); }
.cbody { font-size: 17px; line-height: 1.75; color: var(--text); max-width: 80ch; }
.cbody i, .cbody em { color: var(--accent2); font-style: italic; }
.cbody h2 { font-size: 21px; margin: 30px 0 12px; color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 7px; }
.cbody h3 { font-size: 16px; margin: 24px 0 8px; color: var(--accent); letter-spacing: .01em; }
.cbody > :first-child { margin-top: 0; }
.cbody p { margin: 0 0 14px; }
.cbody ul, .cbody ol { margin: 0 0 14px; padding-left: 22px; }
.cbody li { margin: 5px 0; }
.cbody blockquote { margin: 0 0 14px; padding: 4px 0 4px 16px; border-left: 2px solid var(--accent); color: var(--muted); }
.cbody code { font-family: var(--font-mono); font-size: .9em; background: var(--surface2); padding: 1px 5px; border-radius: 3px; }
.cbody pre { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; overflow: auto; }
.cbody pre code { background: none; padding: 0; }
.cbody table { border-collapse: collapse; width: 100%; margin: 0 0 16px; font-size: 15px; }
.cbody th, .cbody td { border: 1px solid var(--border2); padding: 7px 10px; text-align: left; vertical-align: top; }
.cbody th { background: var(--surface2); font-family: var(--font-head); }
.cbody hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
/* inline lesson diagrams (SVG), theme-aware via currentColor + token classes */
.cbody svg.diagram { display: block; width: 100%; max-width: 560px; height: auto; margin: 18px auto; }
.cbody svg text { fill: currentColor; font-family: var(--font-body); }
.cbody svg .d-box { fill: var(--surface2); stroke: var(--border2); stroke-width: 1.5; }
.cbody svg .d-accent-box { fill: color-mix(in srgb, var(--accent) 20%, transparent); stroke: var(--accent); stroke-width: 1.5; }
.cbody svg .d-accent { fill: var(--accent); }
.cbody svg .d-line { stroke: currentColor; opacity: .5; stroke-width: 1.5; fill: none; }
.cbody svg rect { rx: 8; }
/* structured card body: bullet list + colored callouts, so a card reads with rhythm */
.cbody ul.cl { list-style: none; margin: 0 0 16px; padding: 0; }
.cbody ul.cl li { position: relative; padding-left: 20px; margin: 8px 0; }
.cbody ul.cl li::before { content: ""; position: absolute; left: 3px; top: .62em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.cbody p { margin: 0 0 14px; }
.cue { display: block; margin: 12px 0; padding: 10px 14px; border-left: 3px solid var(--cue, var(--accent)); background: color-mix(in srgb, var(--cue, var(--accent)) 13%, transparent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 15px; line-height: 1.6; }
.cue + .cue { margin-top: 8px; }
.cue b { color: var(--text); }
.cue-exam { --cue: var(--c-exam); }
.cue-trap { --cue: var(--c-trap); }
.cue-eg { --cue: var(--c-eg); }
.cue-why { --cue: var(--c-why); }
/* pinned to the bottom of the viewport so Prev/Known/Next never move as card length changes */
/* fixed bottom bar of the content pane: just Prev / Next, always in the same place */
.learnbottom { flex: 0 0 auto; display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid var(--border); padding: 12px 0 0; background: var(--bg); }

/* ---- test / exam / scenario shared ---- */
.testwrap { max-width: 860px; }
.testbar { margin-bottom: 20px; }
.tprog { height: 4px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.tprog i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.tmeta { display: flex; justify-content: space-between; margin-top: 10px; font-size: 13px; color: var(--muted); }
.streak.hot { color: var(--accent); font-weight: 700; }
.qcard { padding: 4px 0; }
.qmod { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin-bottom: 12px; }
.qtext { margin: 0 0 22px; font-size: 22px; }
.scenstem { font-size: 16px; line-height: 1.75; color: var(--text); margin: 4px 0 22px; }
.scenstem b { color: var(--text); }
.opts { display: grid; gap: 10px; }
.opt { text-align: left; background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius-sm); padding: 14px 16px; color: var(--text); cursor: pointer; font: inherit; font-size: 15px; transition: border-color .12s, background .12s; }
.opt:hover:not(.done):not(:disabled) { border-color: var(--accent); }
.opt.done { cursor: default; }
.opt.sel { border-color: var(--accent2); background: color-mix(in srgb, var(--accent2) 14%, transparent); }
.opt.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 16%, transparent); }
.opt.wrong { border-color: var(--no); background: color-mix(in srgb, var(--no) 16%, transparent); }
.explain:empty { display: none; }
.ex { margin-top: 18px; padding: 14px 16px; border-radius: var(--radius-sm); font-size: 15px; line-height: 1.6; border: 1px solid var(--border2); }
.ex.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.ex.no { background: color-mix(in srgb, var(--no) 12%, transparent); border-color: color-mix(in srgb, var(--no) 45%, transparent); }
.qfoot { margin-top: 18px; }

/* ---- results ---- */
.results { padding: 8px 0; max-width: 620px; }
.results h1 { margin: 0 0 18px; font-size: 26px; }
.verdict { font-size: 25px; font-weight: 700; font-family: var(--font-head); padding: 16px 18px; border-radius: var(--radius-sm); margin-bottom: 20px; border: 1px solid var(--border2); }
.verdict span { font-size: 14px; font-weight: 500; color: var(--muted); }
.verdict.pass { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.verdict.fail { color: var(--no); background: color-mix(in srgb, var(--no) 10%, transparent); border-color: color-mix(in srgb, var(--no) 40%, transparent); }
.rstats { display: flex; gap: 32px; margin: 20px 0 26px; }
.rstats b { display: block; font-size: 22px; color: var(--accent); font-variant-numeric: tabular-nums; }
.rstats span { font-size: 12px; color: var(--muted); }
.ractions { display: flex; gap: 10px; flex-wrap: wrap; }
.homeback { text-align: center; margin: 22px 0 0; }
.backupcard { margin-bottom: 18px; }
.backupcard h2 { margin: 0 0 8px; }
.backupcard .ractions { margin: 12px 0; }
.pdata { width: 100%; background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius-sm); color: var(--text); padding: 10px 12px; font: 12px/1.45 ui-monospace, monospace; resize: vertical; }
.pdata:focus-visible, .pfile:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pfile { display: block; margin: 10px 0; color: var(--muted); font: inherit; }
.reviewlist { margin-top: 28px; max-width: 860px; }
.reviewlist h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin: 8px 0 14px; }
.rev { background: var(--surface); border: 1px solid var(--border); border-left: 2px solid var(--no); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 10px; }
.rev.ok { border-left-color: var(--ok); color: var(--ok); font-weight: 600; }
.rev-q { font-weight: 600; margin-bottom: 6px; }
.rev-a { font-size: 14px; color: var(--text); margin-bottom: 6px; }
.rev-e { font-size: 14px; color: var(--muted); }

/* ---- exam chrome ---- */
.examtop { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.examlabel { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); }
.clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; color: var(--accent); background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius-sm); padding: 2px 10px; }
.clock.low { color: var(--no); border-color: var(--no); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.examfoot { display: flex; justify-content: space-between; gap: 10px; }

/* ---- arcade ---- */
.arcbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.hearts { font-size: 16px; letter-spacing: 3px; }
.hearts .alive { color: var(--no); } .hearts .lost { color: var(--faint); opacity: .4; }
.arcscore { font-weight: 800; font-size: 20px; color: var(--accent); font-variant-numeric: tabular-nums; }
.arcscore small { font-size: 11px; color: var(--muted); font-weight: 500; }
.arccombo { font-weight: 700; font-size: 14px; color: var(--muted); min-width: 90px; text-align: right; }
.arccombo.hot { color: var(--accent); }
.qbarwrap { height: 6px; background: var(--surface2); border-radius: 99px; overflow: hidden; margin-bottom: 16px; }
.qbarwrap i { display: block; height: 100%; background: var(--accent); transition: width .09s linear; }
.flash { position: fixed; top: 30%; left: 50%; transform: translateX(-50%); font-size: 32px; font-weight: 800; font-family: var(--font-head); padding: 8px 22px; border-radius: var(--radius-sm); pointer-events: none; z-index: 50; animation: flashpop .85s ease-out forwards; border: 1px solid var(--border2); }
.flash.good { color: var(--ok); background: color-mix(in srgb, var(--ok) 20%, var(--bg)); }
.flash.bad { color: var(--no); background: color-mix(in srgb, var(--no) 18%, var(--bg)); }
@keyframes flashpop { 0% { opacity: 0; transform: translateX(-50%) scale(.6); } 25% { opacity: 1; transform: translateX(-50%) scale(1.1); } 70% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) translateY(-24px) scale(1); } }

.foot { max-width: none; margin: 0; text-align: left; color: var(--faint); font-size: 12px; padding: 16px clamp(16px, 3.5vw, 56px); border-top: 1px solid var(--border); }

/* ---- responsive ---- */
/* desktop: fixed shell, header + footer always visible, nav and content each scroll on their own */
@media (min-width: 861px) {
  /* non-learn: the document scrolls naturally (scrollbar at the window edge); header sticky;
     footer sits after the content, and the home centers itself when it fits */
  #root:not(:has(> .learnwrap)) > .top { position: sticky; top: 0; z-index: 20; }
  /* learn: viewport-locked app-shell, nav + content scroll on their own */
  #root:has(> .learnwrap) { height: 100dvh; }
  #root:has(> .learnwrap) > .learnwrap { flex: 1 1 auto; min-height: 0; overflow: hidden; padding-bottom: 0; }
  .learnwrap .sidebar { position: static; top: auto; height: 100%; display: flex; flex-direction: column; overflow: hidden; padding-bottom: 12px; } /* search fixed top, button fixed bottom */
  .learnwrap .navscroll { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; } /* only the list scrolls */
  .learnwrap .sidebar .sidebottom { flex: 0 0 auto; border-top: 1px solid var(--border); padding: 12px 0 0; }
  .learnwrap .sidebar .btn.full { margin: 0; flex: 0 0 auto; }
  .learnwrap .learnmain { height: 100%; min-height: 0; overflow: hidden; padding-bottom: 12px; }
  .learnwrap .learnscroll { overflow-y: auto; overscroll-behavior: contain; padding-right: 8px; padding-bottom: 28px; }
}
@media (max-width: 860px) {
  .parts { grid-template-columns: 1fr; }
  .partcard.bonus { width: 100%; grid-column: auto; justify-self: stretch; }
  .hero h1 { font-size: clamp(26px, 7vw, 34px); }
  .wrap { padding: 18px 16px 48px;
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right)); }
  .foot { padding: 20px 16px; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .top { gap: 10px; }
  .brand { font-size: 17px; }
  .xpbar { width: 84px; }

  /* Learn: single column; the module list slides in as an off-canvas drawer */
  .learnwrap { display: block; }
  .learnmain { min-height: 0; }
  .learntop { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
  .drawerbtn { display: inline-flex; align-items: center; gap: 6px; }
  .lessontools { position: static; margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
  .lessontools .btn { box-shadow: none; background: transparent; }

  .sidebar { position: fixed; z-index: 60; top: 0; left: 0; bottom: 0;
    width: min(84vw, 330px); background: var(--bg2); border-right: 1px solid var(--border);
    transform: translateX(-100%); transition: transform .24s ease;
    display: flex; flex-direction: column; gap: 6px;
    padding: 16px; overflow: hidden;
    padding-top: calc(16px + env(safe-area-inset-top));
    padding-left: calc(16px + env(safe-area-inset-left)); }
  .sidebar .navscroll { flex: 1 1 auto; max-height: none; min-height: 0; overflow-y: auto; }
  .sidebar .sidebottom { flex: 0 0 auto; border-top: 1px solid var(--border); padding-top: 12px; }
  .learnwrap.draweropen .sidebar { transform: none; box-shadow: 0 0 48px #000a; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: #0009;
    opacity: 0; pointer-events: none; transition: opacity .22s; }
  .learnwrap.draweropen .scrim { opacity: 1; pointer-events: auto; }
}
/* bigger touch targets on real touch screens */
@media (max-width: 860px) and (pointer: coarse) {
  .btn { min-height: 44px; }
  .opt { padding: 15px 16px; }
  .navitem { padding-top: 11px; padding-bottom: 11px; }
  .navchap { padding-top: 12px; padding-bottom: 12px; }
}
