/* Layout: one calm column on squared notebook paper. Figures sit straight on the grid; the lab is the only framed object. */
:root {
  --bg: #F6F8FC;
  --grid: rgba(52, 94, 190, .085);
  --surface: #FFFFFF;
  --ink: #1B2140;
  --ink-soft: #56607F;
  --line: #C9D2E6;
  --accent: #3646C4;
  --accent-soft: #E5E9FB;
  --shape: #E9EDF9;
  --shadow: rgba(27, 33, 64, .28);
  --ok: #157A47;
  --no: #A2560F;
  --m-red: #E0473C;
  --m-blue: #2D7BE0;
  --m-green: #1FA463;
  --m-yellow: #F5BB1B;
  --m-purple: #8D55DA;
  --leaf: #BFE6CD;
  --font-display: "Frank Ruhl Libre", "David Libre", "Times New Roman", serif;
  --font-body: "Heebo", "Arial Hebrew", "Noto Sans Hebrew", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}
@media screen and (prefers-color-scheme: dark) {
  :root {
    --bg: #11152A; --grid: rgba(140, 165, 255, .06); --surface: #1A2040; --ink: #E9ECF8; --ink-soft: #A4ADCB;
    --line: #333C60; --accent: #96A1FF; --accent-soft: #262E57; --shape: #2B3360; --shadow: rgba(0, 0, 0, .5);
    --ok: #55C990; --no: #E5A65A;
    --m-red: #EC5F54; --m-blue: #4C93EE; --m-green: #34B877; --m-yellow: #F7C63A; --m-purple: #A374E8; --leaf: #2F6B4D;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 26px 26px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}
.page {
  max-width: 47rem;
  margin-inline: auto;
  padding-block: 2.75rem 4.5rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- type ---- */
.eyebrow { margin: 0 0 .5rem; font-size: .9rem; font-weight: 500; color: var(--accent); }
h1 { margin: 0; font-family: var(--font-display); font-weight: 900; font-size: clamp(2.4rem, 8vw, 3.75rem); line-height: 1.1; text-wrap: balance; }
.lede { margin: 1rem 0 0; max-width: 34rem; font-size: 1.15rem; color: var(--ink-soft); }
h2 { margin: 4rem 0 1rem; padding-top: 2rem; border-top: 1px solid var(--line); font-family: var(--font-display); font-weight: 700; font-size: 2rem; line-height: 1.2; text-wrap: balance; }
h3 { margin: 2.25rem 0 .5rem; font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; line-height: 1.3; text-wrap: balance; }
p { margin: 0 0 .9rem; max-width: 38rem; }
.fine { font-size: .88rem; color: var(--ink-soft); }
.term { font-weight: 500; background: var(--accent-soft); padding: .05em .4em; border-radius: 4px; white-space: nowrap; }
.star { color: var(--accent); font-weight: 700; }
.print-only { display: none; }

/* ---- figures ---- */
.figbox { display: inline-block; vertical-align: middle; line-height: 0; width: 6rem; flex: none; }
.fig { display: block; width: 100%; height: auto; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.fig .paper { fill: var(--shape); }
/* outlines of shapes that move are in drawing units, so a zoomed copy looks exactly like the original */
.fig .edge { fill: none; stroke: var(--ink); stroke-linejoin: round; }
.fig .ghost { fill: none; stroke: var(--ink-soft); stroke-width: 1.25px; vector-effect: non-scaling-stroke; stroke-dasharray: 5 5; }
.fig .axis { stroke: var(--accent); stroke-width: 1.75px; vector-effect: non-scaling-stroke; stroke-dasharray: 7 6; stroke-linecap: round; }
.fig .vlabel { font-family: var(--font-body); font-weight: 700; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.fig .axis-name { font-family: var(--font-body); font-weight: 500; font-size: 17px; fill: var(--accent); text-anchor: middle; dominant-baseline: central; }
.fig.nocolor .wedge, .fig.nocolor .vlabel { display: none; }
.fig .solid { fill: var(--shape); stroke: var(--ink); stroke-width: 1.75px; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.fig .pin { fill: var(--ink); }
.fig .glyph { fill: none; stroke: var(--ink); stroke-width: 17; stroke-linecap: round; stroke-linejoin: round; }
.fig .heart { fill: var(--m-red); stroke: var(--ink); stroke-width: 1.75px; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.fig .tad path { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.fig .tad circle { fill: var(--ink); }
.fig .tad.hot path { stroke: var(--m-red); }
.fig .tad.hot circle { fill: var(--m-red); stroke: var(--ink); stroke-width: 1.5; }
.fig.nocolor .tad.hot path { stroke: var(--ink); }
.fig.nocolor .tad.hot circle { fill: var(--ink); stroke: none; }
.fig .homemark { fill: var(--ink-soft); }
.fig .ring { fill: var(--m-red); }
.fig .frame { fill: none; stroke: var(--ink-soft); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.fig .arm { fill: none; stroke: var(--ink); stroke-width: 13; stroke-linecap: round; stroke-linejoin: round; }
.fig .arm.sq { stroke-width: 14; stroke-linecap: square; stroke-linejoin: miter; }
.fig .arm.thin { stroke-width: 8; }
.fig .arm.fat { stroke-width: 19; }
.fig .blob { fill: var(--shape); stroke: var(--ink); stroke-width: 2.6; stroke-linejoin: round; }
.fig .ghost-art .blob { fill: none; stroke: var(--ink-soft); opacity: .4; }
.fig .ghost-art .arm { stroke: var(--ink-soft); opacity: .28; }
.fig .leaf { fill: var(--leaf); stroke: var(--ink); stroke-width: .014; stroke-linejoin: round; }
.fig .leaf.hot { fill: var(--m-red); }
.fig.nocolor .leaf.hot { fill: var(--leaf); }
.fig .stem { fill: var(--ink); }
.fig .branch { fill: none; stroke: var(--ink); stroke-linecap: round; }
.fig .gen { font-family: var(--font-body); font-weight: 700; font-size: 15px; fill: var(--accent); text-anchor: middle; dominant-baseline: central; }
.treebox { display: block; width: min(100%, 17rem); line-height: 0; }
.w { font-weight: 500; white-space: nowrap; }
sup { font-size: .7em; line-height: 0; }
a { color: var(--accent); text-underline-offset: .2em; }
.stripbox { display: block; width: 100%; max-width: 30rem; line-height: 0; }
.strip-demo { display: grid; gap: .9rem; margin: 1.25rem 0 1.5rem; }
.strip-cap { display: block; margin-bottom: .2rem; font-size: .85rem; line-height: 1.4; color: var(--ink-soft); }
.ico { width: 1.6rem; height: 1.6rem; flex: none; color: var(--accent); }
@keyframes nudge { 40% { transform: scale(1.045); } }
.mover.nudge { animation: nudge .35s ease; }

.demo { display: grid; gap: 1.1rem; margin: 1.25rem 0 1.5rem; }
.demo-row { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem 1rem; }
.step { display: inline-flex; flex-direction: column; align-items: center; gap: .1rem; font-size: .85rem; color: var(--ink-soft); line-height: 1.3; }
.step svg { width: 4.25rem; height: .75rem; }
.verdict { flex: 1 1 12rem; min-width: 0; font-size: .95rem; font-weight: 500; }
.verdict.yes { color: var(--ok); }
.verdict.nope { color: var(--no); }

.sym8 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.4rem 1rem; margin: 1.4rem 0 1rem; }
.sym8 figure { margin: 0; display: grid; gap: .45rem; justify-items: center; align-content: start; text-align: center; }
.sym8 .fig { width: min(100%, 6rem); }
.sym8 figcaption { display: flex; flex-direction: column; align-items: center; gap: .1rem; font-size: .85rem; line-height: 1.35; }
.sym8 .ico { width: 1.35rem; height: 1.35rem; }

/* ---- lab ---- */
.lab-card { margin-top: 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 1.1rem; box-shadow: 0 22px 44px -32px var(--shadow); }
.lab-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .6rem 1rem; margin-bottom: 1rem; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.seg button { border: 0; background: transparent; color: var(--ink-soft); font-size: .92rem; font-weight: 500; padding: .3rem .8rem; border-radius: 7px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.lab-main { display: grid; grid-template-columns: minmax(0, 19rem) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.stage {
  position: relative; aspect-ratio: 1; max-width: 100%; overflow: hidden;
  border: 1px solid var(--line); border-radius: 12px;
  background-color: var(--bg);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 26px 26px;
}
.stage .fig { position: absolute; inset: 0; width: 100%; height: 100%; }
.lids { position: absolute; inset: 0; pointer-events: none; }
.lid { position: absolute; left: -10%; right: -10%; height: 58%; background: var(--ink); transition: transform .5s cubic-bezier(.6, 0, .3, 1); }
.lid-top { top: 0; border-radius: 0 0 50% 50% / 0 0 26% 26%; transform: translateY(-102%); }
.lid-bottom { bottom: 0; border-radius: 50% 50% 0 0 / 26% 26% 0 0; transform: translateY(102%); }
.stage.shut .lid { transform: none; }
.lids-text { position: absolute; inset: 0; display: grid; place-items: center; color: var(--bg); font-weight: 500; opacity: 0; transition: opacity .2s; }
.stage.shut .lids-text { opacity: 1; transition-delay: .35s; }
.home { display: flex; align-items: center; gap: .6rem; margin-top: .6rem; font-size: .85rem; color: var(--ink-soft); }
.home .figbox { width: 3.6rem; }
.lab-side { min-width: 0; }
.lab-prompt { margin: 0 0 .6rem; min-height: 3.4em; font-weight: 500; }
.lab-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .7rem; }
.lab-actions:empty { display: none; }
.btn { padding: .45rem 1.1rem; border: 1px solid var(--ink); border-radius: 10px; background: var(--surface); color: var(--ink); font-weight: 500; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn-quiet { padding: .2rem 0; border: 0; background: none; color: var(--accent); font-size: .92rem; text-decoration: underline; text-underline-offset: .2em; cursor: pointer; }
.sym-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.25rem, 1fr)); gap: .45rem; }
.sym { display: flex; align-items: center; gap: .5rem; min-width: 0; padding: .4rem .6rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font-size: .95rem; line-height: 1.3; text-align: start; cursor: pointer; }
.sym:hover:not(:disabled) { border-color: var(--accent); }
.sym:active:not(:disabled) { transform: translateY(1px); }
.sym:disabled { opacity: .5; cursor: default; }
.sym.right { opacity: 1; border-color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok); }
.sym.wrong { text-decoration: line-through; }
.lab-side .fine { margin: .5rem 0 0; }
.lab-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; margin-top: .9rem; }
.switch { display: inline-flex; align-items: center; gap: .45rem; font-size: .95rem; cursor: pointer; }
.switch input { width: 1.1em; height: 1.1em; accent-color: var(--accent); }
.lab-log { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .4rem; min-height: 2rem; margin-top: .8rem; font-size: .88rem; color: var(--ink-soft); }
.chip { display: inline-flex; align-items: center; gap: .25rem; padding: .05rem .35rem .05rem .6rem; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--ink); }
.chip .ico { width: 1.1rem; height: 1.1rem; }

/* lab, multiplication table: a grid of icon buttons; green is back at the start, yellow is a reflection */
.lab-table { margin: 0 0 .9rem; }
.lab-table .table-wrap { margin: 0; padding: 2px; }
.lab-table .fine { margin: .5rem 0 0; }
.ltable { border-collapse: collapse; }
.ltable th, .ltable td { padding: 0; border: 1px solid var(--line); background: var(--surface); }
.ltable th { background: var(--accent-soft); }
.ltable .corner, .ltable .etc { border: 0; background: none; }
.ltable .more { display: grid; place-items: center; width: var(--cell); height: var(--cell); }
.ltable .more .ico { color: var(--ink-soft); }
.ltable button { display: grid; place-items: center; width: var(--cell); height: var(--cell); padding: 0; border: 0; background: none; color: var(--ink); cursor: pointer; }
.ltable .ico { display: block; width: calc(var(--cell) * .74); height: calc(var(--cell) * .74); }
.ltable.big { --cell: 2.9rem; }
.ltable.mid { --cell: 2.15rem; }
.ltable.small { --cell: 1.72rem; }
.ltable td.is-id { background: var(--bg); background: color-mix(in srgb, var(--m-green) 24%, var(--surface)); }
.ltable td.is-ref { background: var(--bg); background: color-mix(in srgb, var(--m-yellow) 26%, var(--surface)); }
.ltable td.is-new .ico { color: var(--ink-soft); }
.ltable button:hover, .ltable button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ltable th.hot { background: var(--accent); }
.ltable th.hot .ico { color: var(--surface); }
.ltable td.on { box-shadow: inset 0 0 0 2.5px var(--accent); }

/* ---- exercises ---- */
.part { display: flex; align-items: baseline; gap: .6rem; margin: 3rem 0 1.4rem; padding-bottom: .4rem; border-bottom: 2px solid var(--ink); font-size: 1.45rem; }
.part span { font-family: var(--font-body); font-size: .85rem; font-weight: 700; color: var(--accent); white-space: nowrap; }
.ex { display: grid; grid-template-columns: 2.6rem minmax(0, 1fr); gap: 0 .75rem; margin-bottom: 2.5rem; }
.ex-num { font-family: var(--font-display); font-weight: 900; font-size: 2.1rem; line-height: 1.3; color: var(--accent); }
.ex-body { min-width: 0; }
.ex-body > :last-child { margin-bottom: 0; }
.sub { display: grid; gap: 1rem; margin: .6rem 0 1rem; padding-inline-start: 1.7rem; list-style: hebrew; max-width: 38rem; }
.sub > li { min-width: 0; }
.sub > li::marker { font-weight: 700; color: var(--ink-soft); }
.sub p { margin-bottom: .5rem; }

.shape-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.5rem 1rem; margin: 1.1rem 0 1.25rem; }
.shape-cell { display: grid; justify-items: center; align-content: start; gap: .3rem; text-align: center; font-size: .88rem; line-height: 1.35; }
.shape-cell .figbox { width: 5.25rem; }
.shape-name { display: flex; align-items: center; min-height: 2.7em; }
.ans { display: inline-flex; flex-direction: column; align-items: center; gap: .1rem; min-height: 3.7em; }
.ans .mark { margin: 0; }

.num { width: 3.4em; padding: .15em .2em; border: 1px solid var(--line); border-bottom: 2px solid var(--ink-soft); border-radius: 6px 6px 2px 2px; background: var(--surface); color: var(--ink); font-size: 1.05rem; font-weight: 700; text-align: center; -moz-appearance: textfield; appearance: textfield; }
.num::-webkit-outer-spin-button, .num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sel { max-width: 100%; padding: .3em .5em; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.num.ok, .sel.ok { border-color: var(--ok); color: var(--ok); }
.num.no, .sel.no { border-color: var(--no); }
.mark { margin-inline-start: .4em; font-size: .88rem; font-weight: 500; }
.mark:empty { display: none; }
.mark.ok { color: var(--ok); }
.mark.no { color: var(--no); }
/* the check button: sticks to the bottom of the screen while the exercises scroll by, and rests at their end */
.checkbar { position: sticky; bottom: max(.75rem, env(safe-area-inset-bottom)); z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .9rem; width: fit-content; max-width: 100%; margin: 2.5rem 0 0; padding: .5rem .6rem; padding-inline-end: 1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 12px 30px -16px var(--shadow); }
.check-status { font-size: .92rem; font-weight: 500; color: var(--ink-soft); }
.check-status:empty { display: none; }

/* ---- account: who is signed in, handing a page in, and the teacher's banner over a submission ---- */
.gate-pending .page > *, .gated .page > :not(.gate) { visibility: hidden !important; height: 0 !important; min-height: 0 !important; overflow: hidden !important; margin: 0 !important; padding: 0 !important; border: 0 !important; }
.gate { display: none; }
.gated .gate { display: block; padding-top: 12vh; }
.gate .btn { margin-top: 1.25rem; }
.gate-note { min-height: 1.5em; margin: 1rem 0 0; font-size: .92rem; color: var(--no); }
.account { display: flex; justify-content: flex-end; align-items: center; gap: .75rem; min-height: 2.2rem; margin-bottom: .75rem; font-size: .92rem; }
.account .btn { padding: .3rem .9rem; font-size: .92rem; }
.account .who { font-weight: 500; color: var(--ink-soft); }
.submitbar { display: grid; gap: .7rem; max-width: 38rem; margin: 3rem 0 0; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.submit-status { margin: 0; font-weight: 500; }
.submit-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; }
.btn:disabled { opacity: .5; cursor: default; }
.review-banner { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem 1.1rem; margin-bottom: 1.25rem; padding: .7rem 1rem; border: 1px solid var(--accent); border-radius: 12px; background: var(--accent-soft); font-size: .95rem; }
.review-banner a { margin-inline-start: auto; }
.checkbar:has(.check-status:empty) { padding-inline-end: .6rem; }
.choices { display: inline-flex; flex-wrap: wrap; gap: .4rem; vertical-align: middle; }
.choices button { padding: .2em .85em; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); cursor: pointer; }
.choices button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.note {
  display: block; width: 100%; max-width: 38rem; min-height: 3.8em; padding: 0 .2em; border: 0; border-radius: 0; resize: vertical;
  background: repeating-linear-gradient(transparent 0 calc(1.9em - 1px), var(--line) calc(1.9em - 1px) 1.9em);
  color: var(--ink); line-height: 1.9em;
}
.line { width: min(100%, 17rem); padding: .1em .2em; border: 0; border-bottom: 1.5px solid var(--ink-soft); border-radius: 0; background: transparent; color: var(--ink); }
.hint { margin-top: .7rem; max-width: 38rem; }
.hint summary { display: inline-block; list-style: none; color: var(--accent); font-size: .9rem; font-weight: 500; border-bottom: 1px dashed currentColor; cursor: pointer; }
.hint summary::-webkit-details-marker { display: none; }
.hint > div { margin-top: .5rem; padding: .6rem .9rem; border-radius: 8px; background: var(--accent-soft); font-size: .95rem; }

.ex3 { display: grid; grid-template-columns: minmax(0, 15rem) minmax(0, 1fr); gap: 1.25rem; align-items: start; margin: 1rem 0; }
.legend { margin: 0; }
.legend .figbox { width: 100%; }
.legend figcaption { font-size: .85rem; line-height: 1.4; color: var(--ink-soft); text-align: center; }
.cases { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem 1rem; }
.case { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: .3rem .5rem; }
.case-tag { font-weight: 700; color: var(--ink-soft); }
.case .figbox { width: 5.5rem; }
.case .sel { grid-column: 1 / -1; width: 100%; }
.case .mark { grid-column: 1 / -1; margin: 0; }
.solo-fig { margin: .6rem 0 1rem; }
.solo-fig .figbox { width: 6.5rem; }
.figbox.zoombox { width: 9rem; }
.figbox.branchbox { width: 11rem; }
/* a question with its drawing beside it; on a narrow screen the drawing drops below */
.with-fig { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .5rem 1.25rem; }
.with-fig > p { flex: 1 1 16rem; margin: 0; }
.with-fig .figbox.branchbox { width: 9rem; }
.shape-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#exercises { counter-reset: ex; }
.ex-num::before { counter-increment: ex; content: counter(ex); }

.table-wrap { overflow-x: auto; margin: 1rem 0 .4rem; }
.cayley { border-collapse: collapse; font: inherit; font-size: .9rem; line-height: 1.35; }
.cayley th, .cayley td { padding: .45rem .5rem; border: 1px solid var(--line); text-align: center; white-space: nowrap; }
.cayley th { background: var(--accent-soft); font-weight: 500; }
.cayley th .ico { display: block; width: 1.4rem; height: 1.4rem; margin: 0 auto .1rem; }
.cayley .corner { background: transparent; font-size: .75rem; color: var(--ink-soft); }
.cayley .corner span { display: block; }
.cayley td { background: var(--surface); }
.cayley td.given { color: var(--ink-soft); }
.cayley .sel { min-width: 7.4em; padding: .25em .3em; }
.cayley .mark { display: none; }

.bye { display: flex; align-items: center; gap: .5rem; margin: 4rem 0 0; padding-top: 1.25rem; border-top: 1px solid var(--line); font-family: var(--font-display); font-size: 1.25rem; color: var(--ink-soft); }
.bye svg { width: 1.1rem; height: 1.1rem; }
.export { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1.5rem 0 0; }
.export .btn { text-decoration: none; }

@media (max-width: 40rem) {
  .lab-main, .ex3 { grid-template-columns: minmax(0, 1fr); }
  .stage-col { width: 100%; max-width: 21rem; margin-inline: auto; }
  .legend { max-width: 15rem; margin-inline: auto; }
  .lab-prompt { min-height: 0; }
}
@media (max-width: 34rem) {
  .sym8, .shape-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ex { grid-template-columns: 1.8rem minmax(0, 1fr); gap: 0 .5rem; }
  .ex-num { font-size: 1.6rem; line-height: 1.6; }
  .sub { padding-inline-start: 1.4rem; }
  h2 { font-size: 1.7rem; }
}
@media (prefers-reduced-motion: reduce) {
  .lid, .lids-text { transition: none; }
  .mover.nudge { animation: none; }
}

@page { size: A4; margin: 14mm 15mm 15mm; }
@media print {
  :root { --bg: #fff; }
  body { background: #fff; font-size: 10.5pt; line-height: 1.55; }
  .page { max-width: none; padding: 0; }
  .screen-only, .mark, .hint:not([open]) { display: none !important; }
  .print-only { display: block; }
  h1 { font-size: 30pt; }
  h2 { margin-top: 1.4rem; padding-top: 1rem; font-size: 19pt; }
  h3 { margin-top: 1.1rem; }
  h2, h3, .part, .part + p, .ex-body > p:first-child { break-after: avoid; }
  .demo-row, .strip-demo, .solo-fig, .sym8 figure, .shape-grid, .ex3, .cayley, .sub > li { break-inside: avoid; }
  p, .part { break-inside: avoid; }
  .term { padding-block: 0; }
  .note { resize: none; }
  #exercises { break-before: page; }
  #exercises h2 { margin-top: 0; padding-top: 0; border-top: 0; }
  .ex { margin-bottom: 1.5rem; }
  .part { margin: 1.6rem 0 1rem; }
  .num, .sel { color: #000 !important; border-color: #666 !important; }
  .sel { -webkit-appearance: none; appearance: none; min-width: 11em; border-width: 0 0 1px !important; border-radius: 0; background: none; }
  .sel:invalid { color: transparent !important; }
  .cayley .sel { min-width: 7em; border: 0 !important; }
  .note { min-height: 5.7em; }
  .bye { margin-top: 2rem; }
}
