/* =====================================================================
   Gjeometria 6 — interactive edition
   Screen-oriented: every lesson is a deck of slides (prev / next).
   ===================================================================== */

@font-face { font-family: "Atkinson"; src: url(../fonts/AtkinsonHyperlegibleNext-VariableFont_wght.ttf) format("truetype"); font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url(../fonts/AtkinsonHyperlegibleNext-Italic-VariableFont_wght.ttf) format("truetype"); font-weight: 200 800; font-style: italic; font-display: swap; }
/* GeoGebra draws labels with the family "geogebra-sans-serif" (not shipped by
   GeoGebra itself, so the browser would fall back to its default sans-serif).
   Point it at Atkinson Hyperlegible Next: l, I and 1 stay distinct. */
@font-face { font-family: "geogebra-sans-serif"; src: url(../fonts/AtkinsonHyperlegibleNext-VariableFont_wght.ttf) format("truetype"); font-weight: 200 800; font-style: normal; }
@font-face { font-family: "geogebra-sans-serif"; src: url(../fonts/AtkinsonHyperlegibleNext-Italic-VariableFont_wght.ttf) format("truetype"); font-weight: 200 800; font-style: italic; }
@font-face { font-family: "Source Serif"; src: url(../fonts/SourceSerif4-Semibold.otf) format("opentype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Source Serif"; src: url(../fonts/SourceSerif4-Bold.otf) format("opentype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Source Serif"; src: url(../fonts/SourceSerif4-It.otf) format("opentype"); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  --paper: #fbf8f2;
  --card: #ffffff;
  --ink: #1d2433;
  --ink-2: #4a5468;
  --ink-3: #7a8396;
  --line: #e4dfd4;
  --line-2: #d3ccbd;
  --accent: #2456c9;       /* draggable / primary */
  --accent-soft: #e8eefc;
  --warm: #c2531b;         /* highlights, part colour */
  --warm-soft: #fbece3;
  --ok: #18794e;
  --ok-soft: #e3f4ea;
  --bad: #b42318;
  --bad-soft: #fde8e6;
  --def: #2456c9;  --def-bg: #eef3fd;
  --prop: #7a4fc0; --prop-bg: #f3effb;
  --thm: #b5480f;  --thm-bg: #fdf1e9;
  --note: #6b6250; --note-bg: #f5f1e8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(29,36,51,.06), 0 8px 24px rgba(29,36,51,.07);
  --bar-h: 58px;
  --nav-h: 68px;
  --body-font: "Atkinson", system-ui, -apple-system, "Segoe UI", sans-serif;
  --head-font: "Source Serif", Georgia, serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body-font);
  font-size: 18px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--head-font); font-weight: 600; line-height: 1.2; margin: 0; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; border-radius: 6px; }

/* ---------- math-ish markup ---------- */
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: .82em; line-height: 1.05; margin: 0 .08em; }
.frac > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 .18em .05em; }
.frac > span:last-child { padding: .05em .18em 0; }
.mixed { white-space: nowrap; }
.hat, .arc { position: relative; display: inline-block; padding-top: .18em; line-height: 1; white-space: nowrap; }
.hat::before, .arc::before {
  content: ""; position: absolute; left: 4%; right: 4%; top: -.12em; height: .36em;
  background: currentColor;
  -webkit-mask: no-repeat center / 100% 100%; mask: no-repeat center / 100% 100%;
}
.hat::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'%3E%3Cpath d='M2 18 L50 3 L98 18' fill='none' stroke='black' stroke-width='5' stroke-linejoin='round'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'%3E%3Cpath d='M2 18 L50 3 L98 18' fill='none' stroke='black' stroke-width='5' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.arc::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'%3E%3Cpath d='M3 18 Q50 -6 97 18' fill='none' stroke='black' stroke-width='5'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'%3E%3Cpath d='M3 18 Q50 -6 97 18' fill='none' stroke='black' stroke-width='5'/%3E%3C/svg%3E"); }
i.dd { font-family: var(--head-font); font-style: italic; }
.mathline { text-align: center; font-size: 1.08em; margin: .55em 0; letter-spacing: .01em; }
.nowrap { white-space: nowrap; }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--bar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: color-mix(in srgb, var(--paper) 92%, white);
  border-bottom: 1px solid var(--line); z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--head-font); font-weight: 700; font-size: 20px; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.crumb { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.15; }
.crumb small { color: var(--ink-3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb b { font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid transparent; background: transparent; display: grid; place-items: center; color: var(--ink-2); flex: none; }
.iconbtn:hover { background: #fff; border-color: var(--line); }
.iconbtn svg { width: 22px; height: 22px; }

.dots { display: flex; gap: 4px; align-items: center; flex-wrap: nowrap; max-width: 38vw; overflow: hidden; }
.dots button { width: 22px; height: 8px; border-radius: 4px; border: 0; padding: 0; background: var(--line-2); flex: 1 1 22px; min-width: 6px; }
.dots button.seen { background: color-mix(in srgb, var(--accent) 45%, var(--line-2)); }
.dots button.ex { background: var(--line-2); box-shadow: inset 0 0 0 1.5px var(--warm); }
.dots button.ex.seen { background: color-mix(in srgb, var(--warm) 45%, var(--line-2)); }
.dots button.ex.done { background: var(--ok); box-shadow: none; }
.dots button.cur { background: var(--accent); height: 12px; }

/* ---------- stage & slide ---------- */
.stage {
  position: fixed; inset: var(--bar-h) 0 var(--nav-h) 0;
  display: flex; align-items: stretch; justify-content: center;
  padding: 18px 20px;
}
.slide {
  width: 100%; max-width: 1280px; height: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
  animation: slidein .28s ease both;
}
.slide.back { animation-name: slideback; }
@keyframes slidein { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes slideback { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .slide { animation: none; } }

.slide-head { padding: 20px 28px 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.slide-head h2 { font-size: clamp(22px, 2.3vw, 30px); flex-basis: 100%; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.chip.warm { background: var(--warm-soft); color: var(--warm); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.prop { background: var(--prop-bg); color: var(--prop); }
.chip.thm { background: var(--thm-bg); color: var(--thm); }
.chip.note { background: var(--note-bg); color: var(--note); }
.stars { color: var(--warm); letter-spacing: 1px; font-size: 14px; }

.slide-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; padding: 8px 28px 22px; overflow: auto; }
.slide-main.has-media { grid-template-columns: minmax(300px, 0.95fr) minmax(320px, 1.15fr); }
.slide-main.media-wide { grid-template-columns: minmax(280px, 0.75fr) minmax(320px, 1.4fr); }
.slide-main.narrow-body .body { max-width: 760px; margin: 0 auto; width: 100%; }
.body { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.body > p { margin: 0; }
.body ul, .body ol { margin: 0; padding-left: 1.3em; }
.body li + li { margin-top: .3em; }
.media { min-width: 0; min-height: 300px; display: flex; flex-direction: column; gap: 10px; }
/* a long exercise list scrolls; the figure stays in view beside it */
.slide-main.has-media { container-type: size; }
.slide-main.has-media > .media { position: sticky; top: 0; align-self: start; height: calc(100cqh - 30px); }

/* boxes */
.box { border-radius: 12px; padding: 12px 16px 12px 16px; border-left: 5px solid; }
.box .box-label { display: block; font-size: 12.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 2px; }
.box.def { background: var(--def-bg); border-color: var(--def); } .box.def .box-label { color: var(--def); }
.box.prop { background: var(--prop-bg); border-color: var(--prop); } .box.prop .box-label { color: var(--prop); }
.box.thm { background: var(--thm-bg); border-color: var(--thm); } .box.thm .box-label { color: var(--thm); }
.box.note { background: var(--note-bg); border-color: #b9ad94; } .box.note .box-label { color: var(--note); }
/* two theorems side by side: the same statement keeps its colour in both rows */
.thm-pair { overflow-x: auto; }
.thm-pair table { border-collapse: separate; border-spacing: 6px; margin: 4px -6px; }
.thm-pair th { font-weight: 800; font-size: 13px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); text-align: left; padding: 2px 8px; white-space: nowrap; }
.thm-pair tbody th { text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--ink); }
.thm-pair td { padding: 8px 14px; border-radius: 10px; border: 1.5px solid var(--line); background: #faf8f3; white-space: nowrap; }
.thm-pair td.tone-accent { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.thm-pair td.tone-warm { background: var(--warm-soft); border-color: var(--warm); color: var(--warm); }
.box.tip { background: var(--ok-soft); border-color: var(--ok); } .box.tip .box-label { color: var(--ok); }
.box p { margin: 0; } .box p + p { margin-top: .4em; }
/* logic box: what we did, in terms of logic — a glowing lamp */
.box.logic { background: #fff8e3; border-color: #d99a00; display: grid; grid-template-columns: 34px 1fr; gap: 0 10px; align-items: start; }
.box.logic .box-label { color: #9a6a00; }
.box.logic .lamp { grid-row: span 2; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #b87f00; background: radial-gradient(circle, #ffe9a8 0%, #fff4cf 55%, rgba(255,244,207,0) 72%); animation: lampglow 2.6s ease-in-out infinite; }
.box.logic .lamp svg { width: 22px; height: 22px; fill: #ffd34d; }
@keyframes lampglow { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 196, 40, 0); } 50% { box-shadow: 0 0 14px 4px rgba(255, 196, 40, .55); } }
@media (prefers-reduced-motion: reduce) { .box.logic .lamp { animation: none; box-shadow: 0 0 10px 2px rgba(255, 196, 40, .45); } }
.sol .box.logic { margin-top: 10px; }

.given { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; background: #faf8f3; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.given dt { font-weight: 800; font-size: 13px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); padding-top: 3px; }
.given dd { margin: 0; }

/* step reveal */
.steps { display: flex; flex-direction: column; gap: 8px; }
.steps .steps-label { font-weight: 800; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--thm); }
.step { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; padding: 8px 10px; border-radius: 10px; background: #faf8f3; border: 1px solid var(--line); animation: stepin .25s ease both; }
.step .n { width: 26px; height: 26px; border-radius: 50%; background: var(--thm); color: #fff; font-weight: 800; font-size: 14px; display: grid; place-items: center; }
.step.cur { border-color: var(--thm); box-shadow: 0 0 0 2px color-mix(in srgb, var(--thm) 18%, transparent); }
@keyframes stepin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.steps-ctrl { display: flex; gap: 8px; flex-wrap: wrap; }

.reveal { border: 1px dashed var(--line-2); border-radius: 12px; padding: 10px 14px; }
.reveal .a { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; font-weight: 650; font-size: 16px; color: var(--ink); text-decoration: none; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn.warm { background: var(--warm); border-color: var(--warm); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: #f3f0ea; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14.5px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn svg { width: 18px; height: 18px; }

/* ---------- media: figures and GeoGebra ---------- */
.figure { position: relative; flex: 1; min-height: 260px; border-radius: 12px; background: #fff; border: 1px solid var(--line); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.figure.static { padding: 18px; }
.figure.static img { max-width: 100%; max-height: 100%; object-fit: contain; }
.figure.static img.svgfig { width: min(100%, var(--w, 100%)); height: auto; max-height: 100%; }
.figcap { font-size: 14px; color: var(--ink-3); text-align: center; }
.ggb-host { position: absolute; inset: 0; }
.ggb-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); font-size: 15px; background: #fff; }
.ggb-loading .spin { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; margin: 0 auto 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
.ggb-tools { position: absolute; right: 8px; top: 8px; display: flex; gap: 6px; z-index: 3; }
.figure.has-tools .ggb-tools { top: auto; bottom: 8px; }
.ggb-tools .iconbtn { background: rgba(255,255,255,.92); border-color: var(--line); width: 34px; height: 34px; }
.ggb-tools .iconbtn svg { width: 18px; height: 18px; }
.stepper { display: flex; align-items: center; gap: 10px; font-size: 14.5px; color: var(--ink-2); }
.stepper .btn { min-width: 38px; justify-content: center; font-size: 18px; padding-top: 2px; padding-bottom: 2px; }
.stepper b { min-width: 1.4em; text-align: center; font-size: 18px; color: var(--ink); }
/* compass toggle: the compass's own steel colour */
.ggb-tools .compass-toggle { height: 34px; background: rgba(255,255,255,.92); color: #3c5864; border-color: #b4c8d0; }
.ggb-tools .compass-toggle.on { background: #eaf1f3; border-color: #5d8190; }
.fallback-note { position: absolute; left: 10px; bottom: 8px; font-size: 12.5px; color: var(--ink-3); background: rgba(255,255,255,.9); padding: 2px 8px; border-radius: 6px; }
.media-hint { font-size: 14.5px; color: var(--ink-2); display: flex; gap: 8px; align-items: flex-start; }
.media-hint .hand { flex: none; width: 20px; height: 20px; color: var(--accent); margin-top: 1px; }

.readouts { display: flex; flex-wrap: wrap; gap: 8px; }
.readout { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 10px; border-radius: 8px; background: #f4f2ec; font-variant-numeric: tabular-nums; font-size: 16px; }
.readout b { font-weight: 700; }
.readout.hl { background: var(--ok-soft); color: var(--ok); }

.task { border-radius: 12px; padding: 10px 14px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); display: flex; gap: 10px; align-items: flex-start; }
.task .ico { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 800; font-size: 14px; margin-top: 1px; }
.task.done { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.task.done .ico { background: var(--ok); }

/* ---------- exercises ---------- */
.ex { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; background: #fff; display: flex; flex-direction: column; gap: 10px; }
.exlist { display: flex; flex-direction: column; gap: 12px; }
.exgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); gap: 14px; align-items: start; }
.slide-main.ex-wide .body { max-width: 1180px; }
.ex-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--ink-3); }
.lvl { font-weight: 800; letter-spacing: .04em; color: var(--warm); }
.badge { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #f1ede4; color: var(--ink-2); }
.ex-q { margin: 0; }
.ex-q p { margin: 0 0 .4em; }
.ex-body { display: flex; flex-direction: column; gap: 8px; }
.ex-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ex.ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.ex.bad { border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.fb { border-radius: 10px; padding: 8px 12px; font-size: 16px; display: none; }
.fb.show { display: block; animation: stepin .2s ease both; }
.fb.ok { background: var(--ok-soft); color: var(--ok); }
.fb.bad { background: var(--bad-soft); color: var(--bad); }
.fb.info { background: var(--note-bg); color: var(--ink-2); }
.sol { border-radius: 10px; padding: 10px 14px; background: #faf8f3; border: 1px solid var(--line); display: none; }
.sol.show { display: block; animation: stepin .2s ease both; }
.sol .box-label { font-size: 12.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ok); display: block; margin-bottom: 2px; }

.opts { display: flex; flex-direction: column; gap: 8px; }
.opts.row { flex-direction: row; flex-wrap: wrap; }
.opt { text-align: left; display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 10px; border: 1.5px solid var(--line-2); background: #fff; min-height: 44px; }
.opt .mk { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 2px solid var(--line-2); display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.opt.multi .mk { border-radius: 6px; }
.opt:hover { border-color: var(--ink-3); }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt.sel .mk { border-color: var(--accent); background: var(--accent); color: #fff; }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.right .mk { border-color: var(--ok); background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .mk { border-color: var(--bad); background: var(--bad); color: #fff; }

.fill { line-height: 2.3; }
.blank { display: inline-block; vertical-align: middle; min-width: 3.2em; height: 38px; padding: 0 8px; border: 1.5px solid var(--line-2); border-radius: 8px; background: #fffef9; text-align: center; font-size: 17px; }
.blank:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input.blank { width: 4.6em; }
select.blank { padding: 0 4px; min-width: 3.4em; }
.blank.w2 { width: 5.5em; } .blank.w3 { width: 8em; } .blank.w4 { width: 12em; }
.blank.right { border-color: var(--ok); background: var(--ok-soft); }
.blank.wrong { border-color: var(--bad); background: var(--bad-soft); }
.unit { color: var(--ink-2); margin-left: 4px; }
.num-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.listin { width: 100%; height: 44px; border: 1.5px solid var(--line-2); border-radius: 10px; padding: 0 12px; background: #fffef9; font-size: 17px; letter-spacing: .03em; }
.listin:focus { border-color: var(--accent); outline: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips .c { padding: 2px 10px; border-radius: 999px; font-size: 15px; background: #f1ede4; }
.chips .c.right { background: var(--ok-soft); color: var(--ok); }
.chips .c.wrong { background: var(--bad-soft); color: var(--bad); text-decoration: line-through; }
.chips .c.miss { background: #fff; border: 1px dashed var(--ok); color: var(--ok); }
.kbd-hint { font-size: 13.5px; color: var(--ink-3); }

.order { display: flex; flex-direction: column; gap: 6px; }
.order-item { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1.5px solid var(--line-2); border-radius: 10px; background: #fff; }
.order-item .n { font-weight: 800; color: var(--ink-3); text-align: center; }
.order-item .mv { display: flex; gap: 4px; }
.order-item .mv button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: #faf8f3; display: grid; place-items: center; }
.order-item.right { border-color: var(--ok); background: var(--ok-soft); }
.order-item.wrong { border-color: var(--bad); background: var(--bad-soft); }

.proof { display: flex; flex-direction: column; gap: 6px; }
.proof-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) minmax(170px, 0.9fr); gap: 10px; align-items: center; padding: 6px 8px; border-radius: 10px; background: #faf8f3; border: 1px solid var(--line); }
.proof-row .n { font-weight: 800; color: var(--ink-3); text-align: center; }
.proof-row select { width: 100%; height: 38px; border-radius: 8px; border: 1.5px solid var(--line-2); background: #fff; padding: 0 6px; font-size: 15px; }
.proof-row select.right { border-color: var(--ok); background: var(--ok-soft); }
.proof-row select.wrong { border-color: var(--bad); background: var(--bad-soft); }
.proof-head { display: grid; grid-template-columns: 26px minmax(0,1fr) minmax(170px,0.9fr); gap: 10px; font-size: 12.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); padding: 0 8px; }

.match { display: grid; grid-template-columns: minmax(0,1fr) minmax(160px, 0.9fr); gap: 6px 12px; align-items: center; }
.match select { height: 40px; border-radius: 8px; border: 1.5px solid var(--line-2); background: #fff; padding: 0 6px; }
.match select.right { border-color: var(--ok); background: var(--ok-soft); }
.match select.wrong { border-color: var(--bad); background: var(--bad-soft); }

.selfcheck { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hintlist { display: grid; gap: 6px; }
.hintlist:empty { display: none; }
.hint { display: grid; grid-template-columns: 26px 1fr; gap: 8px; align-items: start; padding: 7px 10px; border-radius: 10px; background: #fff8e3; border: 1px solid #ecd28a; font-size: 16px; animation: stepin .25s ease both; }
.hint .n { width: 22px; height: 22px; border-radius: 50%; background: #d99a00; color: #fff; font-weight: 800; font-size: 13px; display: grid; place-items: center; margin-top: 1px; }

/* ---------- lesson cover & end ---------- */
.cover { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(260px, .8fr); gap: 28px; align-items: center; height: 100%; padding: 12px 8px; }
.cover .kicker { color: var(--warm); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; font-size: 14px; }
.cover h1 { font-size: clamp(30px, 4vw, 48px); margin: 6px 0 14px; }
.cover .goals { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.cover .goals li { display: flex; gap: 10px; align-items: flex-start; }
.cover .goals li::before { content: ""; flex: none; width: 10px; height: 10px; margin-top: 8px; border-radius: 50%; background: var(--warm); }
.cover-art { width: 100%; max-height: 340px; }
.cover-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--ink-3); font-size: 15px; margin-top: 16px; }
.endcard { text-align: center; max-width: 640px; margin: auto; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.endcard .big-stars { font-size: 44px; color: var(--warm); letter-spacing: 6px; }
.endcard .big-stars .off { color: var(--line-2); }
.summary { text-align: left; width: 100%; }

/* ---------- bottom nav ---------- */
.navbar {
  position: fixed; inset: auto 0 0 0; height: var(--nav-h);
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 0 16px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 92%, white); z-index: 20;
}
.navbar .counter { min-width: 84px; text-align: center; color: var(--ink-2); font-variant-numeric: tabular-nums; font-size: 15px; }
.navbar .btn { min-width: 140px; min-height: 46px; }
.kbd { font-size: 12px; color: var(--ink-3); border: 1px solid var(--line-2); border-radius: 5px; padding: 0 5px; margin-left: 4px; }

/* ---------- home ---------- */
.home { position: fixed; inset: var(--bar-h) 0 0 0; overflow: auto; }
.home-inner { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }
.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(260px, .75fr); gap: 32px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 32px; box-shadow: var(--shadow); }
.hero h1 { font-size: clamp(34px, 5vw, 58px); margin: 4px 0 8px; }
.hero .sub { color: var(--ink-2); font-size: 19px; margin: 0 0 18px; max-width: 46ch; }
.hero .meta { color: var(--ink-3); font-size: 14px; margin-top: 14px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.progress-ring { display: flex; align-items: center; gap: 14px; margin-top: 18px; color: var(--ink-2); font-size: 15px; }
.bar { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; flex: 1; max-width: 320px; }
.bar > i { display: block; height: 100%; background: var(--ok); border-radius: 5px; }

.part { margin-top: 34px; }
.part-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.part-num { font-family: var(--head-font); font-weight: 700; color: var(--warm); font-size: 18px; }
.part-head h2 { font-size: 28px; }
.part-head .pp { color: var(--ink-3); font-size: 14px; margin-left: auto; }
.module { margin: 14px 0 6px; font-size: 14px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.tile { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); text-decoration: none; color: var(--ink); min-height: 86px; transition: transform .12s ease, box-shadow .12s ease; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-2); }
.tile .tn { font-size: 13px; color: var(--ink-3); font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
.tile .tt { font-weight: 650; line-height: 1.25; }
.tile .tbar { margin-top: auto; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.tile .tbar i { display: block; height: 100%; background: var(--accent); }
.tile.done .tbar i { background: var(--ok); }
.tile.review { background: #fffaf3; border-style: dashed; }
.tile.reading { background: #f8f6ff; }

/* ---------- TOC drawer & dialogs ---------- */
.scrim { position: fixed; inset: 0; background: rgba(20, 24, 33, .35); z-index: 40; animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; } }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(420px, 92vw); background: var(--paper); z-index: 41; box-shadow: 8px 0 30px rgba(0,0,0,.15); display: flex; flex-direction: column; animation: drawin .22s ease both; }
@keyframes drawin { from { transform: translateX(-30px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { flex: 1; font-size: 20px; }
.drawer-body { overflow: auto; padding: 8px 10px 30px; }
.toc-part { margin-top: 14px; padding: 0 6px; font-family: var(--head-font); font-weight: 700; color: var(--warm); }
.toc-mod { margin: 8px 6px 4px; font-size: 12.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.toc-l { display: flex; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 8px; text-decoration: none; color: var(--ink); font-size: 16px; }
.toc-l:hover { background: #fff; }
.toc-l.cur { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.toc-l .st { width: 18px; height: 18px; flex: none; border-radius: 50%; border: 2px solid var(--line-2); }
.toc-l .st.part { border-color: var(--accent); background: conic-gradient(var(--accent) var(--p), transparent 0); }
.toc-l .st.done { border-color: var(--ok); background: var(--ok); }
.dialog { position: fixed; z-index: 41; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(520px, 92vw); background: var(--card); border-radius: 16px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 12px; animation: fade .2s ease both; }
.dialog h3 { font-size: 22px; }
.dialog .row { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* glossary */
.gloss { display: flex; flex-direction: column; gap: 10px; }
.gloss-item { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.gloss-item b { display: block; }
.gloss-search { width: 100%; height: 42px; border-radius: 10px; border: 1.5px solid var(--line-2); padding: 0 12px; background: #fff; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 14px); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 15px; z-index: 50; animation: fade .2s ease both; box-shadow: var(--shadow); }

/* ---------- custom widgets ---------- */
.wsvg { width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }
.wsvg text { font-family: var(--body-font); }
.handle { cursor: grab; }
.handle:active { cursor: grabbing; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .slide-main.has-media, .slide-main.media-wide { grid-template-columns: minmax(0, 1fr); }
  .slide-main.has-media { container-type: normal; }
  .slide-main.has-media > .media { position: static; height: auto; }
  .media { min-height: 340px; }
  .figure { min-height: 320px; }
  .cover, .hero { grid-template-columns: minmax(0,1fr); }
  .cover-art { max-height: 200px; }
  .dots { display: none; }
}
@media (max-width: 640px) {
  body { font-size: 17px; }
  :root { --bar-h: 54px; --nav-h: 62px; }
  .stage { padding: 8px; }
  .slide-head { padding: 14px 16px 4px; }
  .slide-main { padding: 6px 16px 16px; }
  .brand span { display: none; }
  .navbar .btn { min-width: 0; flex: 1; }
  .navbar .btn .lbl-long { display: none; }
  .proof-row, .proof-head { grid-template-columns: 22px minmax(0,1fr); }
  .proof-row select { grid-column: 2; }
  .proof-head span:last-child { display: none; }
  .match { grid-template-columns: minmax(0,1fr); }
  .hero { padding: 20px; }
}

/* SVG figures: their labels are part of the drawing, not selectable text */
svg text { -webkit-user-select: none; user-select: none; }
.wsvg, .svgfig { -webkit-user-select: none; user-select: none; }
/* the movable protractor (protractorMeasure) */
.ex-widget { position: relative; margin: 6px 0 4px; }
.ex-widget .wsvg { width: 100%; height: auto; display: block; background: #fffdf8; border: 1px solid var(--line); border-radius: 12px; }
.pro-tools { position: absolute; top: 8px; right: 8px; }
.pro-toggle { height: 32px; background: rgba(255,255,255,.92); color: #3e5a9b; border-color: #9db4e6; }
.pro-toggle.on { background: #eef4ff; border-color: #5b77b8; }
/* lesson 3.7 widgets: the row of choices / goal under the drawing */
.split-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.split-bar .btn { min-width: 38px; justify-content: center; }
/* a widget with its controls under the drawing */
.figure.stack { flex-direction: column; justify-content: flex-start; padding: 12px; gap: 4px; }
.figure.stack .wsvg { height: auto; max-height: 62vh; min-height: 0; flex: 0 1 auto; }
.figure.stack .split-bar, .figure.stack .readouts { align-self: stretch; justify-content: center; }
