/* Learning pages (learn.html). Builds on style.css: same tokens, fonts,
   track colors and dark mode. Everything here is additive, so the
   dictionary page is unaffected. */

/* ---------- shared bits ---------- */
/* Headings that receive focus when a view opens (for screen readers) are not controls: no focus ring. */
main [tabindex="-1"]:focus, main:focus { outline: none; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--ink); color: var(--on-ink); padding: 10px 16px; border-radius: 8px; font-weight: 700; text-decoration: none; }
.skip-link:focus { top: 10px; }
.learn-body .site-nav { margin-left: auto; }
.learn-body { display: block; height: auto; }
.learn-body .top { position: sticky; top: 0; z-index: 10; }
.wrap { max-width: 1040px; margin: 0 auto; box-sizing: border-box; padding: 24px max(16px, env(safe-area-inset-left, 0px)) 64px max(16px, env(safe-area-inset-right, 0px)); }
.crumbs { font-size: 0.88rem; color: var(--muted); margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs a { color: var(--muted); }
.page-h { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: -0.025em; line-height: 1.08; margin: 0 0 10px; text-wrap: balance; }
.lede { color: var(--muted); font-size: 1.06rem; max-width: 68ch; margin: 0 0 22px; }
.h2 { font-family: var(--font-display); font-size: 1.3rem; margin: 32px 0 12px; }
.btn.secondary { background: var(--surface); color: var(--fg); border-color: var(--line); }
.btn.secondary:hover { border-color: var(--faint); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn.big { height: 46px; padding: 0 22px; border-radius: 23px; font-size: 1rem; }
a.btn { text-decoration: none; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.chip-s { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px; font-size: 0.8rem; font-weight: 700; background: var(--sunk); color: var(--fg); white-space: nowrap; }
.chip-s.ok { background: color-mix(in srgb, var(--ok) 16%, var(--surface)); color: color-mix(in srgb, var(--ok) 75%, var(--fg)); }
.chip-s.plan { background: transparent; border: 1.5px dashed var(--line); color: var(--muted); }
.chip-s.warn { background: color-mix(in srgb, var(--c-S) 15%, var(--surface)); }
.notice { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 18px; font-size: 0.93rem; }
.notice.sim { border-left: 4px solid var(--c-A); }
.notice.bad { border-left: 4px solid var(--bad); }

/* ---------- study paths ---------- */
.paths { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.path-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 12px; border-top: 4px solid var(--tc); min-width: 0; }
.path-card h3 { font-family: var(--font-display); font-size: 1.2rem; margin: 0 0 4px; }
.path-card > p { color: var(--muted); font-size: 0.92rem; margin: 0 0 12px; }
.lvl { margin: 0 0 10px; }
.lvl h4 { font-size: 0.75rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; display: flex; align-items: center; gap: 6px; }
.mods { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mods li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 9px; background: var(--bg); }
.mods li a { font-weight: 700; }
.mods li .pre { display: block; font-size: 0.78rem; color: var(--muted); }
.mods li.planned span.t { color: var(--muted); }

/* ---------- module overview ---------- */
.hero { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin: 0 0 18px; }
.hero .meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.objectives { margin: 8px 0 0; padding-left: 20px; }
.objectives li { margin: 4px 0; }
.steps { list-style: none; padding: 0; margin: 0 0 22px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; counter-reset: step; }
.steps a { display: grid; gap: 4px; height: 100%; box-sizing: border-box; padding: 14px 14px 12px; border-radius: var(--radius); border: 1.5px solid var(--line); background: var(--surface); text-decoration: none; color: var(--fg); }
.steps a:hover { border-color: var(--tc); }
.steps a[aria-current="page"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; }
.steps .n { font-size: 0.75rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.steps b { font-family: var(--font-display); font-size: 1.05rem; }
.steps .st { font-size: 0.82rem; color: var(--muted); }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; }
.tick { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: inline-grid; place-items: center; font-size: 13px; font-weight: 800; margin-top: 1px; }
.tick.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.tick.on::after { content: "\2713"; }

/* ---------- lesson ---------- */
.lesson-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
.lesson-grid > * { min-width: 0; } /* Firefox and WebKit otherwise size grid items to their content */
.toc { position: sticky; top: 90px; font-size: 0.92rem; }
.toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.toc a { display: flex; gap: 8px; align-items: center; padding: 7px 10px; border-radius: 8px; color: var(--fg); text-decoration: none; }
.toc a:hover { background: var(--surface); }
.toc a[aria-current="page"] { background: var(--surface); font-weight: 700; box-shadow: inset 3px 0 0 var(--tc); }
.toc .tick { width: 18px; height: 18px; font-size: 11px; }
.prose { max-width: 72ch; }
.prose h1, .prose h2 { font-family: var(--font-display); font-size: clamp(1.6rem, 3.4vw, 2.2rem); letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 14px; }
.prose p, .prose li { font-size: 1.04rem; }
.prose p { margin: 0 0 14px; }
.prose ul { margin: 0 0 14px; padding-left: 22px; }
.prose a.tl { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--tc) 70%, transparent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.tbl-wrap { overflow-x: auto; margin: 0 0 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.tbl { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
.tbl th, .tbl td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); background: var(--bg); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td:first-child { white-space: nowrap; }
.callout { border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; border: 1px solid var(--line); background: var(--surface); }
.callout.tip { border-left: 4px solid var(--ok); }
.callout.warn { border-left: 4px solid var(--bad); }
.callout > b:first-child { display: block; font-size: 0.75rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
details.aside { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin: 0 0 16px; }
details.aside > summary { cursor: pointer; padding: 12px 16px; font-weight: 700; }
details.aside > div { padding: 0 16px 6px; }
.prose figure.viz { margin-bottom: 18px; }
.check-box { margin: 28px 0 8px; border: 1.5px solid var(--tc); border-radius: var(--radius); padding: 4px 18px 16px; background: color-mix(in srgb, var(--tc) 4%, var(--surface)); }
.check-box > h2 { font-size: 0.75rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); margin: 14px 0 0; }
.pager-l { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }
.refs { font-size: 0.85rem; color: var(--muted); margin-top: 26px; }
.refs ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- term cards ---------- */
/* two columns only when each card can show its diagram at 480 px or more */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 490px), 1fr)); gap: 14px; }
.tcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.tcard .viz-scroll { padding: 10px 4px 2px; background: var(--bg); border-bottom: 1px solid var(--line); }
.tcard .body { padding: 14px 16px 16px; display: grid; gap: 8px; }
.tcard h2, .tcard h3 { font-family: var(--font-display); font-size: 1.15rem; margin: 0; }
.tcard p { margin: 0; font-size: 0.95rem; }
.tcard .ex { color: var(--muted); font-size: 0.9rem; }
.tcard .row { margin-top: 4px; }
.bm { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 17px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; font-size: 0.86rem; font-weight: 700; }
.bm[aria-pressed="true"] { border-color: var(--c-S); background: color-mix(in srgb, var(--c-S) 12%, var(--surface)); }
.src-list { font-size: 0.82rem; color: var(--muted); margin: 0; padding-left: 16px; }
dialog.pop { border: 1px solid var(--line); border-radius: 16px; padding: 0; max-width: min(640px, calc(100vw - 32px)); width: 100%; background: var(--surface); color: var(--fg); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
dialog.pop::backdrop { background: rgba(10, 14, 20, 0.5); }
dialog.pop .tcard { border: 0; border-radius: 0; }
dialog.pop .x { position: absolute; top: 10px; right: 10px; z-index: 2; }

/* ---------- quiz ---------- */
.builder { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.builder fieldset { border: 0; padding: 0; margin: 0; min-width: 0; } /* fieldsets keep their content width by default, which breaks reflow at 400% zoom */
.builder legend { font-weight: 700; margin-bottom: 8px; }
.picks { display: flex; flex-wrap: wrap; gap: 8px; }
.pick { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; max-width: 100%; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 20px; cursor: pointer; background: var(--bg); } /* max-width: long labels wrap at 400% zoom */
.pick:has(input:checked) { border-color: var(--ink); background: var(--surface); }
.pick input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); }
.qbar { height: 8px; border-radius: 4px; background: var(--sunk); overflow: hidden; margin: 0 0 18px; }
.qbar > i { display: block; height: 100%; background: var(--tc); border-radius: 4px; }
.q { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.q-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.q h2, .q .qt { font-size: 1.2rem; line-height: 1.4; margin: 0 0 14px; font-family: var(--font-body); font-weight: 700; max-width: 60ch; }
.opts { border: 0; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.opt { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--bg); }
.opt:hover { border-color: var(--faint); }
.opt:has(input:checked) { border-color: var(--ink); background: var(--surface); }
.opt input { margin: 3px 0 0; width: 18px; height: 18px; flex: none; accent-color: var(--ink); }
.opt.was-wrong { border-style: dashed; }
.opt.is-right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--surface)); }
.transcript { background: var(--tbg); color: var(--tfg); font-family: var(--font-mono); font-size: 0.86rem; line-height: 1.5; padding: 12px 14px; border-radius: 10px; margin: 0 0 14px; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.transcript .c { color: var(--tcmd); }
.cmd-in { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin: 0 0 14px; }
.cmd-in > * { min-width: 0; }
.cmd-in label { font-weight: 700; }
.cmd-in .ctx { color: var(--muted); font-size: 0.92rem; }
.cmd-line { display: flex; flex-wrap: wrap; align-items: center; background: var(--tbg); border-radius: 10px; padding: 0 12px; }
.cmd-line span { color: var(--tcmd); font-family: var(--font-mono); font-size: 0.9rem; min-width: 0; overflow-wrap: anywhere; padding-block: 6px; }
.cmd-line input { flex: 1 1 20ch; min-width: 20ch; height: 46px; border: 0; background: transparent; color: var(--tfg); font-family: var(--font-mono); font-size: 0.95rem; padding: 0 8px; }
.cmd-line input:focus { outline: none; }
.cmd-line:focus-within { outline: 2.5px solid var(--ink); outline-offset: 2px; }
.q-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 0; }
.fb { margin: 14px 0 0; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); }
.fb:empty { display: none; }
.fb.good { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 9%, var(--surface)); }
.fb.bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 7%, var(--surface)); }
.fb.info { border-color: var(--line); background: var(--bg); }
.fb > b:first-child { display: block; margin-bottom: 3px; }
.fb .transcript { margin: 10px 0 0; }
.hints { margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.hints:empty { display: none; }
.hints li { padding: 10px 14px; border-radius: 10px; background: color-mix(in srgb, var(--c-S) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c-S) 35%, var(--line)); }
.explain { margin: 14px 0 0; padding: 14px 16px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.explain h3 { font-size: 0.75rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.explain p { margin: 0 0 8px; }
.q-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.tally { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 0 0 18px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile b { display: block; font-family: var(--font-display); font-size: 1.9rem; line-height: 1.05; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: 0.86rem; }
.tag-bars { display: grid; gap: 10px; margin: 0 0 18px; }
.tag-bar { display: grid; grid-template-columns: 170px minmax(0, 1fr) auto; gap: 12px; align-items: center; font-size: 0.92rem; }
.tag-bar .track { height: 12px; border-radius: 6px; background: var(--sunk); overflow: hidden; display: flex; }
.tag-bar .track i { display: block; height: 100%; }
.tag-bar .m { background: var(--ok); } .tag-bar .p { background: color-mix(in srgb, var(--ok) 45%, var(--sunk)); } .tag-bar .r { background: var(--c-S); }
.legend-s { display: flex; flex-wrap: wrap; gap: 14px; font-size: 0.85rem; color: var(--muted); margin: 0 0 12px; }
.legend-s i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; }

/* ---------- practice ---------- */
.task-grid { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 20px; align-items: start; }
.task-grid > * { min-width: 0; } /* a long path in the side panel must not widen the page */
.task-side { display: grid; gap: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.panel h2, .panel h3 { font-size: 0.78rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; font-family: var(--font-body); }
.goals { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.goals li { display: flex; gap: 10px; align-items: flex-start; font-size: 0.95rem; }
.goals .gh { display: block; color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.task-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.task-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 6px; }
.task-card h3 { font-family: var(--font-display); margin: 0; font-size: 1.15rem; }
.task-card p { margin: 0; color: var(--muted); font-size: 0.93rem; }

/* ---------- terminal ---------- */
.term { --tdir: #7DB7FF; --texe: #8BE38B; --tlnk: #6FDCDC; background: var(--tbg); color: var(--tfg); border-radius: 12px; overflow: hidden; border: 1px solid color-mix(in srgb, var(--tbg) 70%, var(--line)); display: flex; flex-direction: column; }
.term-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 12px; background: var(--tbar); color: var(--tmuted); font-size: 0.82rem; }
.term-bar .dots { display: inline-flex; gap: 6px; }
.term-bar .dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--tmuted); opacity: 0.55; }
.term-bar .ttl { position: relative; flex: 1 1 8rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* relative: keeps its hidden screen-reader text inside the clipped title */
.term-bar button { height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid color-mix(in srgb, var(--tmuted) 50%, transparent); background: transparent; color: var(--tfg); cursor: pointer; font-size: 0.82rem; }
.term-bar button:hover { border-color: var(--tfg); }
.term-out { font-family: var(--font-mono); font-size: 0.88rem; line-height: 1.45; padding: 12px 14px 4px; min-height: 280px; max-height: 60vh; max-height: 60dvh; overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.term-out:focus-visible { outline: 2px solid var(--tfg); outline-offset: -2px; }
.term-out .ln { display: block; }
.term-out .pr { color: var(--tcmd); }
.term-out .pr .path { color: var(--tdir); }
.term-out .dir { color: var(--tdir); font-weight: 700; }
.term-out .exe { color: var(--texe); font-weight: 700; }
.term-out .lnk { color: var(--tlnk); font-weight: 700; }
.term-out .tw { color: #111; background: #57B05A; }
.term-out .comp { color: var(--tmuted); }
.tnote { display: block; margin: 6px 0 10px; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--tnote) 12%, var(--tbg)); border: 1px solid color-mix(in srgb, var(--tnote) 40%, transparent); color: var(--tfg); font-family: var(--font-body); font-size: 0.88rem; white-space: normal; }
.tnote .tag { display: inline-block; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--tbg); background: var(--tnote); border-radius: 4px; padding: 1px 6px; margin-right: 8px; }
.tnote code { background: color-mix(in srgb, var(--tfg) 14%, transparent); color: var(--tfg); }
.tnote.sim { background: color-mix(in srgb, var(--tdir) 10%, var(--tbg)); border-color: color-mix(in srgb, var(--tdir) 45%, transparent); }
.tnote.sim .tag { background: var(--tdir); }
.term-in { display: flex; flex-wrap: wrap; align-items: center; gap: 0; padding: 4px 14px 12px; font-family: var(--font-mono); font-size: 0.88rem; }
/* A long prompt wraps, as in a real terminal, and the command line moves below it instead of being squeezed. */
.term-in label { color: var(--tcmd); min-width: 0; overflow-wrap: anywhere; }
.term-in label .path { color: var(--tdir); }
.term-in input { flex: 1 1 20ch; min-width: 20ch; border: 0; background: transparent; color: var(--tfg); font: inherit; padding: 6px 0 6px 0.6ch; caret-color: var(--tcmd); }
.term-in input:focus { outline: none; }
.term:focus-within { box-shadow: 0 0 0 2.5px var(--ink); }
.term-keys { display: none; gap: 6px; padding: 0 12px 12px; flex-wrap: wrap; }
.term-keys button { min-width: 44px; height: 40px; padding: 0 10px; border-radius: 8px; border: 1px solid color-mix(in srgb, var(--tmuted) 45%, transparent); background: var(--tbar); color: var(--tfg); font-family: var(--font-mono); font-size: 0.9rem; cursor: pointer; }
.term-help { font-size: 0.84rem; color: var(--muted); margin: 8px 2px 0; }
.term-help code { font-size: 0.9em; }
.fsmap { font-family: var(--font-mono); font-size: 0.84rem; }
.fsmap ul { list-style: none; margin: 0; padding-left: 16px; }
.fsmap > ul { padding-left: 0; }
.fsmap li { margin: 1px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fsmap .d { color: var(--c-I); font-weight: 700; }
.fsmap .here { background: color-mix(in srgb, var(--c-A) 18%, transparent); border-radius: 4px; padding: 0 4px; outline: 1.5px solid var(--c-A); }
.fsmap .crumb { font-family: var(--font-body); font-size: 0.86rem; margin: 0 0 8px; color: var(--muted); }
.fsmap .crumb b { color: var(--fg); font-family: var(--font-mono); font-weight: 700; overflow-wrap: anywhere; }

/* ---------- progress ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0 0 18px; }
.list-plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.list-plain li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); flex-wrap: wrap; }
.limits { font-size: 0.93rem; }
.limits li { margin: 4px 0; }

/* ---------- narrow screens ---------- */
@media (max-width: 880px) {
  /* minmax(0, 1fr), not 1fr: a plain 1fr column grows to fit wide content and pushes text off screen */
  .paths, .cards, .task-cards { grid-template-columns: minmax(0, 1fr); }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .steps a { padding: 10px 12px; }
  .lesson-grid { grid-template-columns: minmax(0, 1fr); }
  .toc { position: static; }
  /* position: relative keeps the hidden screen-reader labels inside the scrolling strip */
  .toc ol { position: relative; grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; max-width: 100%; padding-bottom: 4px; }
  .task-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .term-keys { display: flex; }
  .term-out { min-height: 220px; max-height: 50vh; max-height: 50dvh; }
  .tiles, .tally { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tag-bar { grid-template-columns: 1fr auto; }
  .tag-bar .track { grid-column: 1 / -1; }
  .learn-body .site-nav { margin-left: 0; }
}

/* ---------- question types: typed answers, ordering, categories, HTML ---------- */
.ans-in label, .html-in label { display: block; font-weight: 700; margin: 0 0 6px; }
.ans-in .ans { width: 100%; max-width: 28rem; height: 46px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); font-family: var(--font-mono); font-size: 1rem; }
.ans-in .ans:focus { outline: 2.5px solid var(--ink); outline-offset: 2px; }
.ord { list-style: decimal; margin: 0 0 14px; padding-left: 1.8em; display: grid; gap: 8px; }
.ord li { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); }
.ord-t { min-width: 0; overflow-wrap: anywhere; }
.ord-b { display: flex; gap: 6px; flex: none; }
.btn.sm { min-height: 40px; min-width: 44px; padding: 0 10px; }
code.cl { white-space: pre; font-family: var(--font-mono); background: none; }
.ord li code.cl { white-space: pre-wrap; }
.cls { display: grid; gap: 10px; margin: 0 0 14px; }
.cls-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(9rem, 14rem); gap: 10px; align-items: center; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); }
.cls-row select { min-height: 44px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); padding: 0 8px; font: inherit; max-width: 100%; }
@media (max-width: 560px) { .cls-row { grid-template-columns: minmax(0, 1fr); } }
.code-in { width: 100%; box-sizing: border-box; min-height: 14rem; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--tbg); color: var(--tfg); font-family: var(--font-mono); font-size: 0.9rem; line-height: 1.5; tab-size: 2; }
.html-prev { width: 100%; min-height: 220px; margin-top: 10px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; }
pre.code { background: var(--tbg); color: var(--tfg); font-family: var(--font-mono); font-size: 0.88rem; line-height: 1.55; padding: 12px 14px; border-radius: 10px; margin: 0 0 14px; overflow-x: auto; white-space: pre; tab-size: 4; }
pre.code:focus-visible { outline: 2.5px solid var(--ink); outline-offset: 2px; }
.ord-key, .cls-key { margin: 0 0 10px; }
.ex-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.ex-item { border: 1px solid var(--line); border-radius: 14px; padding: 4px 16px 12px; background: var(--surface); }

/* ---------- terminal: grep colours, pager and editor panels ---------- */
.term-out .gm { color: var(--terr, #ff6b6b); font-weight: 700; }
.term-out .gf { color: #d38cf2; }
.term-out .gn { color: var(--texe); }
.term-out .gs { color: var(--tdir); }
.term-out .err { color: var(--terr, #ff8f8f); }
.term { position: relative; }
.term-panel { display: flex; flex-direction: column; background: var(--tbg); color: var(--tfg); border-top: 1px solid color-mix(in srgb, var(--tfg) 20%, transparent); font-family: var(--font-mono); font-size: 0.88rem; }
.pg-top, .ed-top { padding: 6px 12px; background: color-mix(in srgb, var(--tfg) 12%, var(--tbg)); }
.pg-text { margin: 0; padding: 10px 14px; height: 50vh; height: 50dvh; min-height: 220px; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.pg-text:focus-visible, .ed-text:focus-visible { outline: 2px solid var(--tfg); outline-offset: -2px; }
.pg-text mark { background: var(--tfg); color: var(--tbg); }
.pg-bar, .ed-keys { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 6px 12px 10px; }
.pg-keys, .ed-keys { display: flex; flex-wrap: wrap; gap: 6px; }
.term-panel button { min-height: 40px; padding: 0 10px; border-radius: 6px; border: 1px solid color-mix(in srgb, var(--tfg) 35%, transparent); background: transparent; color: var(--tfg); font: inherit; cursor: pointer; }
.pg-find { padding: 0 12px 10px; }
.pg-find input { min-height: 36px; background: var(--tbg); color: var(--tfg); border: 1px solid var(--tfg); border-radius: 6px; font: inherit; padding: 0 8px; }
.ed-text { height: 45vh; height: 45dvh; min-height: 200px; margin: 0; padding: 10px 14px; border: 0; resize: vertical; background: var(--tbg); color: var(--tfg); font: inherit; line-height: 1.45; }
.ed-bar { min-height: 1.6em; padding: 4px 12px; color: var(--tcmd); }
.ed-bar button { margin-left: 6px; }
@media (forced-colors: active) { .term-panel button, .pg-find input { border: 1px solid ButtonText; } .pg-text mark { forced-color-adjust: none; background: Highlight; color: HighlightText; } }
pre.code code, .transcript code { color: inherit; background: none; padding: 0; border: 0; font: inherit; }

/* ---------- breadcrumbs: at least 24 px tall (WCAG 2.5.8) ---------- */
.crumbs a { display: inline-flex; align-items: center; min-height: 24px; }

/* ---------- phones: the command line gets the full width, below the prompt ---------- */
@media (max-width: 480px) {
  .term-in label, .cmd-line span { flex-basis: 100%; }
  .term-in input { padding-left: 0; }
}

/* ---------- short windows (a landscape phone, or 400% zoom) ---------- */
/* The header and the lesson contents scroll away instead of covering the screen,
   and the terminal's output, command line and keys fit together. */
@media (max-height: 500px) {
  .learn-body .top { position: static; }
  .toc { position: static; }
  .term-out, .pg-text, .ed-text { min-height: 7.5rem; }
}

/* ---------- touch screens ---------- */
@media (pointer: coarse) {
  /* controls at least 44 px tall; mouse and keyboard sizes are unchanged */
  .bm, .pick, .btn.sm, .term-bar button, .term-keys button, .term-panel button, .toc a, .crumbs a, .mods li a, .list-plain a { min-height: 44px; }
  .mods li a, .list-plain a { display: inline-flex; align-items: center; }
  .term-in input { min-height: 44px; }
  /* the key bar for Tab, arrows and symbols on every touch screen, not only narrow ones */
  .term-keys { display: flex; }
  /* 16 px or more: iPhone Safari zooms the whole page in when a smaller field gets focus */
  .term-in input, .cmd-line input, .code-in, .pg-find input, .ed-text, .ed-name { font-size: max(16px, 1em); }
}
