/* Hallmark · custom: "student lab notebook, teacher's red pen" · genre: playful
 * paper oklch(97% 0.018 92) · accent (teacher red) oklch(52% 0.19 27)
 * fonts: Sarabun (printed worksheet) + Sriracha (handwriting) · motion: write-in · stamp-press
 */
:root {
  /* paper & rules */
  --paper: oklch(97% 0.018 92);
  --card: oklch(99.2% 0.006 92);
  --grid: oklch(84% 0.045 235 / 0.35);
  --margin: oklch(62% 0.17 25 / 0.55);
  --rule: oklch(78% 0.03 235);
  --line: oklch(82% 0.04 235 / 0.7);
  --tape: oklch(91% 0.035 85 / 0.78);
  --cover: oklch(40% 0.075 228);
  --cover-weave: oklch(36% 0.07 228);
  /* who wrote it */
  --print: oklch(24% 0.02 262);        /* printed worksheet text */
  --print-soft: oklch(45% 0.02 262);
  --pencil: oklch(34% 0.012 260);      /* the student */
  --pencil-soft: oklch(56% 0.01 260);
  --red: oklch(52% 0.19 27);           /* the teacher */
  --blue: oklch(42% 0.14 262);         /* ballpoint: buttons, links, signature */
  --highlight: oklch(91% 0.16 102);
  --highlight-soft: oklch(95% 0.08 102 / 0.7);
  --amber: oklch(72% 0.17 65);
  --leaf: oklch(72% 0.13 145);
  --bark: oklch(55% 0.07 60);
  /* colored pencils for the sketches (js/sketches.js) */
  --c-metal: oklch(84% 0.015 250);
  --c-gold: oklch(82% 0.12 85);
  --c-wood: oklch(77% 0.09 65);
  --c-wooddark: oklch(63% 0.09 55);
  --c-yellow: oklch(89% 0.15 95);
  --c-pink: oklch(82% 0.09 10);
  --c-blue: oklch(70% 0.11 245);
  --c-glassblue: oklch(86% 0.06 230);
  --c-red: oklch(62% 0.18 25);
  --c-green: oklch(77% 0.12 150);
  --c-glass: oklch(94% 0.03 220);
  --c-water: oklch(80% 0.08 230);
  --c-wax: oklch(94% 0.035 90);
  --c-frost: oklch(90% 0.012 250);
  --c-bag: oklch(96% 0.01 250);
  --c-cardboard: oklch(72% 0.08 70);
  --c-graphite: oklch(35% 0.01 260);
  --chalk: oklch(96% 0.01 230 / 0.85);
  --c-clay: oklch(66% 0.11 45);
  --c-dark: oklch(30% 0.02 260);
  --c-pale: oklch(90% 0.11 100);
  --c-wilt: oklch(64% 0.07 80);
  --c-soil: oklch(42% 0.05 55);
  --c-cork: oklch(74% 0.07 70);
  --c-stone: oklch(66% 0.02 60);
  --c-plasticine: oklch(70% 0.14 40);
  --c-coffee: oklch(45% 0.07 55);
  --c-syrup: oklch(60% 0.2 20);
  --c-sand: oklch(82% 0.07 85);
  --c-oil: oklch(87% 0.13 95);
  --c-orange: oklch(74% 0.15 55);
  --c-purple: oklch(78% 0.09 310);
  --c-night: oklch(30% 0.06 265);
  --c-bone: oklch(95% 0.02 90);
  --c-butter: oklch(91% 0.12 95);
  --c-mold: oklch(58% 0.07 150);
  --c-copper: oklch(62% 0.13 45);
  --c-skin: oklch(86% 0.06 60);
  --c-rust: oklch(52% 0.13 40);
  --c-sky: oklch(93% 0.035 230);
  --focus: oklch(55% 0.18 262);

  --font-print: 'Sarabun', 'Thonburi', system-ui, sans-serif;
  --font-hand: 'Sriracha', 'Sarabun', cursive;

  --space-2xs: 4px; --space-xs: 8px; --space-sm: 12px; --space-md: 16px; --space-lg: 24px; --space-xl: 36px;
  --grid-size: 24px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --hand-box: 255px 15px 225px 15px / 15px 225px 15px 255px; /* wobbly hand-drawn box */
}

* { box-sizing: border-box; }
html, body { overflow-x: clip; }
html { -webkit-text-size-adjust: 100%; font-size: clamp(16px, min(1.2vw, 2.05vh), 24px); } /* every rem grows on big screens, stays 16px on phones */
body {
  margin: 0; min-height: 100vh; color: var(--print);
  font-family: var(--font-print); line-height: 1.55;
  font-size: clamp(.875rem, 1.1vh + .375rem, 1.0625rem); /* text follows screen height so each page fits one screen */
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  background-attachment: fixed;
}
#app { width: 100%; }
h1, h2 { font-weight: 700; line-height: 1.3; margin: var(--space-2xs) 0 var(--space-sm); overflow-wrap: anywhere; min-width: 0; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.15rem; margin-top: var(--space-lg); }
p { margin: 0 0 var(--space-sm); }
a { color: var(--blue); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.hand { font-family: var(--font-hand); color: var(--pencil); font-weight: 400; }
.teacher { font-family: var(--font-hand); color: var(--red); font-size: 1.05rem; line-height: 1.5; }
.label { font-size: .88rem; color: var(--print-soft); margin: 0; letter-spacing: .01em; }

/* a notebook page: red margin line down the left, content to its right */
.page { position: relative; margin-left: var(--space-md); padding: var(--space-sm) var(--space-md) 0 var(--space-md); border-left: 2px solid var(--margin); min-height: 100dvh; }
.runhead { display: flex; justify-content: space-between; gap: var(--space-sm); font-size: .88rem; color: var(--print-soft); padding-bottom: var(--space-xs); margin-bottom: var(--space-md); border-bottom: 1px dashed var(--rule); }
.runhead a { white-space: nowrap; }

/* buttons: ballpoint boxes, drawn by hand */
.btn {
  display: inline-block; white-space: nowrap; text-decoration: none; text-align: center;
  font-weight: 600; padding: 10px 18px; min-height: 46px; line-height: 1.5;
  color: var(--blue); background: transparent; border: 2px solid var(--blue); border-radius: var(--hand-box);
  transition: background-color .15s var(--ease-out);
}
.btn:hover { background: var(--highlight-soft); }
.btn:active { transform: translate(1px, 1px); }
.btn.primary { background: var(--blue); color: var(--card); }
.btn.primary:hover { background: var(--print); border-color: var(--print); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn:disabled:hover { background: var(--blue); border-color: var(--blue); }

.pager {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs) var(--space-sm);
  margin-top: var(--space-lg); padding: var(--space-sm) 0; border-top: 1px dashed var(--rule);
  background: var(--paper);
}
.pager > span { flex: 1 1 12em; min-width: 0; margin: 0; }
.pager .btn { margin-left: auto; }

/* write-in: handwriting appears left to right, once */
.write { animation: write .32s var(--ease-out) both; }
@keyframes write { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

/* ---------- cover ---------- */
.cover {
  min-height: 100vh; display: grid; place-items: center; padding: var(--space-lg) var(--space-md);
  background-color: var(--cover);
  background-image: repeating-linear-gradient(0deg, var(--cover-weave) 0 1px, transparent 1px 4px), repeating-linear-gradient(90deg, var(--cover-weave) 0 1px, transparent 1px 4px);
}
.cover-label { width: min(100%, 340px); background: var(--card); padding: var(--space-lg); border: 1px solid var(--rule); outline: 1px solid var(--rule); outline-offset: -6px; border-radius: 10px; transform: rotate(-1deg); }
.cover-label h1 { font-size: 2.1rem; margin: 0; }
.cover-sub { color: var(--print-soft); }
.cover-label form { display: grid; gap: var(--space-sm); margin-top: var(--space-md); }
.cover-label label { font-weight: 600; }
.line { font-size: 1.5rem; border: 0; border-bottom: 2px dotted var(--print); background: transparent; padding: 2px 4px; width: 100%; border-radius: 0; }
.line:focus-visible { outline: none; border-bottom-color: var(--focus); border-bottom-style: solid; }

/* ---------- table of contents ---------- */
.owner { margin-bottom: var(--space-md); }
.owner .hand { font-size: 1.3rem; }
.owner .chip { margin-left: var(--space-xs); }
.toc { list-style: none; padding: 0; margin: 0 0 var(--space-lg); }
.toc a { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-md) 0; color: var(--print); text-decoration: none; border-bottom: 1px solid var(--rule); }
.toc a:hover .toc-text { color: var(--blue); }
.toc-pic { width: 48px; height: 48px; flex: none; }
.toc-no { font-family: var(--font-hand); font-size: 1.6rem; color: var(--pencil-soft); width: 1.2em; flex: none; }
.toc-text { flex: 0 1 auto; min-width: 0; font-weight: 600; font-size: 1.1rem; line-height: 1.35; }
.toc-text small { display: block; font-weight: 400; font-size: .88rem; color: var(--print-soft); }
.leader { flex: 1 1 16px; min-width: 16px; align-self: flex-end; margin-bottom: .55em; border-bottom: 2px dotted var(--rule); }
.count { font-size: 1.1rem; flex: none; }

/* ---------- teacher stamps ---------- */
.stamp { display: inline-grid; flex: none; transform: rotate(-10deg); }
.stamp svg { width: 100%; height: 100%; overflow: visible; fill: none; stroke: var(--red); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.stamp .st-ring2 { stroke-width: 1.2; stroke-dasharray: 3 3; }
.stamp .st-fill { fill: var(--red); }
.stamp .stamp-word { fill: var(--red); stroke: none; font-family: var(--font-hand); font-size: 13px; text-anchor: middle; }
.stamp.lvl-0 { transform: none; }
.stamp.lvl-0 svg { stroke: var(--pencil-soft); stroke-width: 1.6; }
.stamp.lvl-0 .st-ring { stroke-dasharray: 4 4; }
.stamp.lvl-3 svg { stroke-width: 2.8; }
.stamp.small { width: 52px; height: 52px; }
.stamp.big { --sz: clamp(110px, 24vh, 180px); width: var(--sz); height: calc(var(--sz) * 1.25); }
.press { animation: press .28s var(--ease-out) both; }
@keyframes press { from { transform: rotate(-10deg) scale(1.35); opacity: 0; } to { transform: rotate(-10deg) scale(1); opacity: 1; } }

/* ---------- experiment page ---------- */
.equip { font-size: .95rem; }
.equip b { margin-right: var(--space-xs); }
.stage { flex: 1; min-height: 0; margin: 0; display: flex; flex-direction: column; justify-content: center; container-type: size; }
/* drawings scale to whatever box the stage gets: as wide as possible, never taller than the stage minus the caption */
.circuit-wrap, .light-wrap { position: relative; margin: 0 auto; container-type: inline-size; flex: none; }
.circuit-wrap { width: min(100cqw, calc((100cqh - 3.4em) * 300 / 190)); aspect-ratio: 300 / 190; }
.light-wrap { width: min(100cqw, calc((100cqh - 3.4em) * 2)); aspect-ratio: 320 / 160; }
.sketch { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.sketch .ink { fill: none; stroke: var(--pencil); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sketch .wire { stroke-width: 2.6; }
.sketch .gap { stroke: var(--pencil-soft); stroke-dasharray: 5 4; }
.sketch text { font-family: var(--font-hand); fill: var(--pencil); font-size: 12px; }
.sketch .note { fill: var(--pencil-soft); font-size: 11px; }
.glow { fill: var(--highlight); opacity: 0; mix-blend-mode: multiply; transition: opacity .25s var(--ease-out); }
.rays { opacity: 0; stroke: var(--amber); transition: opacity .25s var(--ease-out); }
.lit .glow, .lit .rays { opacity: 1; }
.lit .filament { stroke: var(--amber); }
.slot { position: absolute; transform: translate(-50%, -50%); display: grid; place-items: center; }
.circuit-wrap .slot { left: 50%; top: 84.2%; width: 23.3%; height: 23.2%; }
.light-wrap .slot { left: 46.9%; top: 50%; width: 15.6%; height: 32.5%; border: 1.5px dashed var(--pencil-soft); border-radius: 4px; }
.slot-hint { font-family: var(--font-hand); color: var(--pencil-soft); font-size: 3.4cqw; text-align: center; line-height: 1.2; }
.slot .tag-name { font-size: 3.6cqw; padding: .25em .5em; }
.slot .photo, .slot .sk { width: 82%; height: 82%; object-fit: contain; }
.slot:has(.photo) { mix-blend-mode: multiply; } /* the slot's transform isolates it; blend the whole slot so the photo's white melts into the paper */
.verdict { flex: none; text-align: center; font-family: var(--font-hand); color: var(--pencil); height: 2.8em; margin-top: var(--space-2xs); line-height: 1.4; overflow: hidden; }
.verdict.no { color: var(--pencil-soft); }

/* light scene */
.beam { fill: var(--highlight); opacity: .8; mix-blend-mode: multiply; transition: opacity .3s var(--ease-out); }
.beam-short { opacity: 0; }
.screen-fill { fill: var(--card); transition: fill .3s; }
.crown { fill: var(--leaf); stroke: var(--pencil); stroke-width: 1.5; }
.trunk { fill: var(--bark); stroke: var(--pencil); stroke-width: 1.5; }
.pic { transition: opacity .3s; }
.shade { fill: var(--pencil); opacity: 0; transition: opacity .3s; }
.hatch-line { stroke: var(--pencil-soft); stroke-width: 1.4; }
.light.blur .beam-full { opacity: .4; }
.light.blur .pic { filter: url(#soft); }
.light.dark .beam-full { opacity: 0; }
.light.dark .beam-short { opacity: .8; }
.light.dark .screen-fill { fill: url(#hatch); }
.light.dark .pic { opacity: .12; }
.light.dark .shade { opacity: .75; }

/* plant scene: setup → 7 days → seedling */
.plant-wrap, .flow-wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: var(--space-sm); height: calc(100cqh - 3.4em); width: min(100cqw, calc((100cqh - 3.4em) * 2.4)); margin: 0 auto; flex: none; }
.setup { display: grid; place-items: center; height: 100%; }
.setup .sk { width: 100%; max-width: 150px; height: auto; max-height: 100%; }
.days { text-align: center; line-height: 1.3; color: var(--pencil-soft); }
.plant { position: static; width: 100%; height: 100%; }
.plant .ink-sk .o { fill: none; stroke: var(--pencil); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
/* same specificity as the outline rule above, declared after it, so the colored-pencil fills win */
.plant .ink-sk .f-green { fill: var(--c-green); } .plant .ink-sk .f-pale { fill: var(--c-pale); } .plant .ink-sk .f-wilt { fill: var(--c-wilt); }
.plant .ink-sk .f-clay { fill: var(--c-clay); } .plant .ink-sk .f-soil { fill: var(--c-soil); }
.plant .p { display: none; transform-box: fill-box; transform-origin: 50% 100%; }
.plant.sprout .p-sprout, .plant.grow .p-grow, .plant.lean .p-lean, .plant.pale .p-pale, .plant.wilt .p-wilt { display: inline; }
.plant.growing .p { animation: grow .6s var(--ease-out) both; }
@keyframes grow { from { transform: scaleY(.25); opacity: .3; } }
.glass-scene, .wave-scene { position: static; width: 100%; height: 100%; }

/* sink or float: tub drawing 200×150, the object drops to the surface or the bottom */
.tank-wrap { position: relative; margin: 0 auto; flex: none; width: min(100cqw, calc((100cqh - 3.4em) * 4 / 3)); aspect-ratio: 4 / 3; }
.water { fill: var(--c-water); fill-opacity: .45; }
.drop { position: absolute; left: 50%; top: -2%; width: 24%; aspect-ratio: 1; transform: translateX(-50%); display: grid; place-items: center; }
.drop .sk, .drop .photo { width: 100%; height: 100%; object-fit: contain; }
.tank-wrap.float .drop { top: 29%; transition: top .9s var(--ease-out); }
.tank-wrap.sink .drop { top: 61%; transition: top 1.1s cubic-bezier(.45, 0, .55, 1); }

/* dissolving: glass 120×150 with water / oil layer / sediment, plus a stirring spoon */
.g-water { fill: var(--c-water); fill-opacity: .3; }
.coffee .g-water { fill: var(--c-coffee); fill-opacity: .45; }
.syrup .g-water { fill: var(--c-syrup); fill-opacity: .4; }
.chalk .g-water { fill: var(--card); fill-opacity: .9; }
.g-oil { fill: var(--c-oil); fill-opacity: .9; opacity: 0; }
.oil .g-oil { opacity: 1; }
.g-sed { opacity: 0; stroke: var(--pencil-soft); stroke-width: .8; }
.sand .g-sed, .rice .g-sed, .chalk .g-sed { opacity: 1; }
.sand .g-sed { fill: var(--c-sand); }
.rice .g-sed, .chalk .g-sed { fill: var(--card); }
.glass-scene .spoon { stroke: var(--print-soft); stroke-width: 3; }
.stirring .spoon { transform-box: view-box; animation: stir .5s ease-in-out 3; }
@keyframes stir { 50% { transform: translateX(-14px); } }

/* magnet: 2:1 scene, horseshoe on the left facing right, object slides in when pulled */
.magnet-wrap { position: relative; margin: 0 auto; flex: none; width: min(100cqw, calc((100cqh - 3.4em) * 2)); aspect-ratio: 2 / 1; }
.mag { position: absolute; left: 2%; top: 50%; width: 26%; aspect-ratio: 1; transform: translateY(-50%) rotate(90deg); }
.mag .sk { width: 100%; height: 100%; }
.obj { position: absolute; left: 64%; top: 50%; width: 22%; aspect-ratio: 1; transform: translateY(-50%); display: grid; place-items: center; }
.obj .sk, .obj .photo { width: 100%; height: 100%; object-fit: contain; }
.magnet-wrap.pull .obj { left: 27%; transition: left .7s cubic-bezier(.55, 0, .9, .4); }
.field path { fill: none; stroke: var(--c-red); stroke-width: 1.4; stroke-dasharray: 3 4; opacity: 0; }
.pull .field path { opacity: .55; transition: opacity .4s; }
.ink-line { stroke: var(--pencil); stroke-width: 2; }

/* sound: vibration wave, dense = high, sparse = low */
.wave-box { display: grid; grid-template-rows: minmax(0, 1fr) auto; justify-items: center; align-items: center; gap: 4px; height: 100%; min-height: 0; }
.wave-scene { overflow: hidden; height: auto; max-height: 100%; aspect-ratio: 2 / 1; }
.axis { stroke: var(--rule); stroke-dasharray: 4 4; }
.wave-line { fill: none; stroke: var(--blue); stroke-width: 2.5; stroke-linejoin: round; }
.buzzing .wave-line { animation: buzz .22s linear infinite; }
@keyframes buzz { to { transform: translateX(var(--wl)); } }
.replay { min-height: 34px; padding: 3px 12px; font-size: .88rem; }

/* ---------- name tags & photos (taped in) ---------- */
.tag-name {
  position: relative; display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-hand); color: var(--pencil); font-size: 1.05rem; line-height: 1.3;
  background: var(--card); border: 1px solid var(--rule); padding: 6px 12px; transform: rotate(var(--r, -1.5deg));
}
.tag-name::before { content: ''; position: absolute; top: -7px; left: 50%; width: 40px; height: 13px; background: var(--tape); transform: translateX(-50%) rotate(-4deg); }
.photo { mix-blend-mode: multiply; }

/* ---------- sort page: worksheet T-chart ---------- */
.tchart { display: grid; grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr)); grid-template-rows: auto 1fr; border: 2px solid var(--print); background: var(--card); }
.col { display: grid; grid-row: span 2; grid-template-rows: subgrid; align-content: start; min-height: 160px; /* subgrid: every header row is the same height */ padding: 0; text-align: left; background: none; border: 0; border-left: 1px solid var(--print); }
.col:first-child { border-left: 0; }
.col:hover, .col:focus-visible { background: var(--highlight-soft); }
.col-head { display: block; padding: var(--space-xs); border-bottom: 2px solid var(--print); font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.col-head small { display: block; font-weight: 400; font-size: .88rem; color: var(--print-soft); }
.col-items { list-style: none; margin: 0; padding: var(--space-xs); }
.col-items li { font-size: 1.02rem; line-height: 1.5; overflow-wrap: anywhere; }
.col-items li + li { margin-top: var(--space-2xs); padding-top: var(--space-2xs); border-top: 1px dashed var(--rule); }
.fix { min-height: 1.6em; margin-top: var(--space-sm); }
.pool { display: flex; flex-wrap: wrap; gap: var(--space-xs) var(--space-2xs); margin-top: var(--space-xs); }
.tag { padding: var(--space-sm) var(--space-2xs); background: none; border: 0; }
.tag:nth-child(3n) .tag-name { --r: 1.2deg; }
.tag:nth-child(3n+2) .tag-name { --r: .5deg; }
.tag.picked .tag-name { outline: 2px dashed var(--blue); outline-offset: 4px; background: var(--highlight-soft); }

/* ---------- summary: teacher's note on lined paper ---------- */
.lined { --lh: 1.9em; line-height: var(--lh); padding: 0 var(--space-xs); background-color: var(--card); background-image: repeating-linear-gradient(transparent 0 calc(var(--lh) - 1px), var(--line) calc(var(--lh) - 1px) var(--lh)); }
.lined p { margin: 0 0 var(--lh); }
.lined p:last-child { margin-bottom: 0; }
.lined b { font-weight: 600; background: linear-gradient(transparent 50%, var(--highlight) 50%); }
.sum { width: 100%; table-layout: fixed; border-collapse: collapse; margin-top: var(--space-lg); border: 2px solid var(--print); background: var(--card); }
.sum th { padding: var(--space-xs); border-bottom: 2px solid var(--print); text-align: left; line-height: 1.3; overflow-wrap: anywhere; }
.sum th + th, .sum td + td { border-left: 1px solid var(--print); }
.sum td { padding: var(--space-xs); vertical-align: top; font-size: 1.02rem; line-height: 1.7; }

/* ---------- quiz: ก ข ค ง, checked in red ---------- */
.progress { font-size: .9rem; color: var(--print-soft); }
.q { font-weight: 600; font-size: 1.12rem; line-height: 1.45; }
.q-no { margin-right: var(--space-2xs); }
.mark { font-size: 2rem; line-height: 1; margin-left: var(--space-xs); vertical-align: middle; color: var(--red); }
.choices { list-style: none; padding: 0; margin: 0 0 var(--space-sm); }
.choice { position: relative; width: 100%; min-height: 48px; padding: var(--space-xs) var(--space-sm); text-align: left; background: none; border: 0; line-height: 1.45; }
.choice:hover:not(:disabled) { background: var(--highlight-soft); }
.choice:disabled { cursor: default; color: var(--print); }
.letter { font-weight: 600; margin-right: var(--space-2xs); }
/* circles hug the answer text, like a pencil/pen ring on paper */
.ans { position: relative; display: inline-block; padding: 2px 6px; }
.chosen .ans::after, .right .ans::before { content: ''; position: absolute; inset: -4px -10px; border-radius: 50%; pointer-events: none; }
.chosen .ans::after { border: 2px solid var(--pencil); transform: rotate(-2deg); }
.right .ans::before { border: 2.5px solid var(--red); transform: rotate(2deg) scale(1.04, 1.15); }
.choice.wrong { text-decoration: line-through; text-decoration-color: var(--red); text-decoration-thickness: 2px; }

/* ---------- result / certificate ---------- */
.result .owner .hand { font-size: 1.4rem; }
.stamp-zone { display: grid; place-items: center; margin: var(--space-lg) 0; }
.sign { display: grid; justify-items: end; gap: 2px; margin: var(--space-xl) 0 var(--space-md); text-align: right; }
.scribble { width: 120px; height: 36px; fill: none; stroke: var(--blue); stroke-width: 2; stroke-linecap: round; }
.sign span:not(.date) { border-top: 1px dotted var(--print); padding-top: 2px; min-width: 140px; text-align: center; }
.date { font-size: .9rem; color: var(--print-soft); }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-sm); padding-bottom: var(--space-xl); }

/* ---------- appendix: material cards ---------- */

@media (min-width: 700px) {
  .page { margin-left: var(--space-xl); padding-left: var(--space-lg); padding-right: var(--space-lg); }
}
@media (prefers-reduced-motion: reduce) {
  .write, .press, .plant.growing .p, .stirring .spoon, .buzzing .wave-line { animation: none; }
  .tank-wrap .drop, .magnet-wrap .obj { transition: none !important; }
  .glow, .rays, .beam, .pic, .shade, .screen-fill { transition: none; }
}
@media print { .no-print, .runhead { display: none; } body { background: none; } }

/* ---------- sketches: pencil outline + colored-pencil fill ---------- */
.sk { display: block; overflow: visible; }
.sk .o { fill: none; stroke: var(--pencil); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sk .o-soft { stroke: var(--pencil-soft); stroke-width: 1.2; }
.sk .o-metal { stroke: var(--print-soft); stroke-width: 2.6; }
.sk .o-band { stroke: var(--c-red); stroke-width: 4; }
.sk .o-ray { stroke: var(--amber); }
.sk [class*="f-"] { fill-opacity: .9; }
.sk .f-metal { fill: var(--c-metal); }
.sk .f-gold { fill: var(--c-gold); }
.sk .f-wood { fill: var(--c-wood); }
.sk .f-wooddark { fill: var(--c-wooddark); }
.sk .f-yellow { fill: var(--c-yellow); }
.sk .f-pink { fill: var(--c-pink); }
.sk .f-blue { fill: var(--c-blue); }
.sk .f-glassblue { fill: var(--c-glassblue); }
.sk .f-red { fill: var(--c-red); }
.sk .f-green { fill: var(--c-green); }
.sk .f-glass { fill: var(--c-glass); }
.sk .f-water { fill: var(--c-water); fill-opacity: .7; }
.sk .f-wax { fill: var(--c-wax); }
.sk .f-frost { fill: var(--c-frost); }
.sk .f-bag { fill: var(--c-bag); }
.sk .f-cardboard { fill: var(--c-cardboard); }
.sk .f-graphite { fill: var(--c-graphite); }
.sk .f-paper { fill: var(--card); }
.sk .f-beam { fill: var(--highlight); fill-opacity: .8; }
.sk .f-clay { fill: var(--c-clay); }
.sk .f-dark { fill: var(--c-dark); fill-opacity: .7; }
.sk .f-pale { fill: var(--c-pale); }
.sk .f-wilt { fill: var(--c-wilt); }
.sk .f-soil { fill: var(--c-soil); }
.sk .o-cross { stroke: var(--red); stroke-width: 2.4; }
.sk .f-cork { fill: var(--c-cork); }
.sk .f-stone { fill: var(--c-stone); }
.sk .f-plasticine { fill: var(--c-plasticine); }
.sk .f-coffee { fill: var(--c-coffee); }
.sk .f-syrup { fill: var(--c-syrup); }
.sk .f-sand { fill: var(--c-sand); }
.sk .f-oil { fill: var(--c-oil); }
.sk .f-glass-clear { fill: var(--c-glass); fill-opacity: .35; }
.tag-name .sk { width: 36px; height: 36px; flex: none; }
.with-pic { display: flex; align-items: center; gap: var(--space-sm); }
.title-pic { width: 60px; height: 60px; flex: none; }

/* cover: chalk doodles on the cloth, label on top */
.cover { position: relative; overflow: hidden; width: 100vw; margin-left: calc(50% - 50vw); } /* full-bleed past the 720px page column */
.cover-label { position: relative; z-index: 1; }
.doodles .chalk { position: absolute; width: 78px; height: 78px; }
.chalk .o, .chalk .o-soft, .chalk .o-metal { stroke: var(--chalk); }
.chalk [class*="f-"] { fill-opacity: .35; }
.doodles .chalk:nth-child(1) { top: 7%; left: 8%; transform: rotate(-12deg); }
.doodles .chalk:nth-child(2) { top: 9%; right: 7%; transform: rotate(10deg); }
.doodles .chalk:nth-child(3) { top: 22%; left: 38%; transform: rotate(8deg); }
.doodles .chalk:nth-child(4) { top: 30%; right: 9%; transform: rotate(-14deg); }
.doodles .chalk:nth-child(5) { bottom: 9%; left: 12%; transform: rotate(18deg); }
.doodles .chalk:nth-child(6) { bottom: 7%; right: 12%; transform: rotate(-6deg); }

/* ================= one screen per page: no scrolling up and down =================
 * .fit pages are exactly one viewport tall: header rows stay their size, the middle
 * section takes what is left, the pager sits at the bottom. Portrait stacks the parts;
 * landscape puts them side by side, using the full width. */
html, body { height: 100%; }
.page.fit { height: 100dvh; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.fit > * { flex: none; }
.fit > section { flex: 1 1 auto; min-height: 0; overflow-x: hidden; } /* tilted stamps/tags must not add a sideways scroll */
.fit .runhead { margin-bottom: var(--space-xs); }
.fit h1 { font-size: clamp(1.1rem, 2.4vh + .2rem, 1.75rem); margin: 0; }
.fit .pager { margin-top: var(--space-xs); padding: var(--space-xs) 0 var(--space-sm); }
.fit .pager { flex-wrap: nowrap; }
.fit .pager > span { flex: 1 1 0; font-size: .9rem; line-height: 1.3; }
.fit .btn { min-height: 42px; padding: 8px 16px; }
.ttl { display: flex; align-items: center; gap: var(--space-sm); margin-bottom: var(--space-xs); }
.ttl > div { flex: 1 1 auto; min-width: 0; }
.ttl p { margin: 0; }
.title-pic { width: clamp(34px, 6vh, 56px); height: clamp(34px, 6vh, 56px); }
.equip { display: none; flex: 0 1 34%; font-size: .88rem; line-height: 1.4; color: var(--print-soft); }

/* experiment: drawing + record grid */
.lab { display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, 1.1fr); gap: var(--space-sm); }
.lab-sim { display: flex; min-height: 0; border-bottom: 1px dashed var(--rule); padding-bottom: var(--space-2xs); }
.lab-rec { display: flex; flex-direction: column; min-height: 0; }
.rec-title { flex: none; margin: 0 0 var(--space-2xs); font-size: .95rem; }
.rec-title small { font-weight: 400; color: var(--print-soft); }
.picks, .pool { flex: 1; min-height: 0; display: grid; gap: 5px; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows, 4), minmax(0, 1fr)); }
.pick {
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; align-content: center; column-gap: 6px;
  min-height: 0; padding: 2px 6px; overflow: hidden; text-align: left; background: var(--card); border: 1px solid var(--rule); border-radius: 4px; color: var(--blue);
}
.pick .sk, .pick .photo { grid-row: span 2; align-self: center; width: clamp(24px, 4.6vh, 44px); height: clamp(24px, 4.6vh, 44px); object-fit: contain; }
.pick .nm { font-size: .88rem; line-height: 1.2; overflow-wrap: break-word; /* wrap between Thai words, not inside them */ text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.pick .res { font-size: .92rem; line-height: 1.2; min-height: 1.2em; }
.pick.current { background: var(--highlight-soft); border-color: var(--blue); }
.pick:hover { border-color: var(--blue); }

/* sort: T-chart + tag pool */
.sortlay { display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-xs); }
.sortlay .tchart { min-height: 0; height: 100%; }
.sortlay .col { min-height: 0; overflow: auto; }
.col-head { font-size: .92rem; padding: 4px 6px; }
.col-items { padding: 4px 6px; }
.col-items li { font-size: .88rem; line-height: 1.3; }
.ttl .fix { min-height: 1.5em; margin: 0; font-size: .95rem; }
.pool .tag { display: grid; place-items: center; min-height: 0; padding: 6px 4px; }
.pool .tag-name { font-size: clamp(1rem, min(1.6vh, 1.1vw) + .5rem, 1.6rem); padding: .35em .7em; gap: .45em; max-width: 100%; line-height: 1.2; overflow-wrap: break-word; box-shadow: 0 2px 4px rgb(0 0 0 / .12); }
.pool .tag-name .sk { width: clamp(30px, min(6.5vh, 4.4vw), 68px); height: clamp(30px, min(6.5vh, 4.4vw), 68px); }
.pool .tag-name::before { width: 44px; height: 13px; top: -7px; }
/* sorted stickers: the same tag, taped into its column */
.col-items:has(.stuck) { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 10px 4px; padding: 8px 4px; }
.col-items li.stuck { margin: 0; padding: 0; border: 0; }
.stuck .tag-name { font-size: .88rem; padding: .2em .5em; gap: .4em; animation: stick .35s ease-out; }
.stuck .tag-name .sk { width: 22px; height: 22px; }
.stuck:nth-child(3n) .tag-name { --r: 1.5deg; }
.stuck:nth-child(3n+2) .tag-name { --r: -.5deg; }
@keyframes stick { from { transform: scale(1.25) rotate(4deg); opacity: .4; } }
@media (prefers-reduced-motion: reduce) { .stuck .tag-name { animation: none; } }

/* summary: note + table */
.sumlay { display: grid; grid-template-rows: auto auto; align-content: start; gap: var(--space-sm); overflow: auto; }
.sumlay .lined { --lh: 1.65em; font-size: .95rem; }
.sumlay .sum { margin: 0; }
.sum td span { display: block; font-size: .88rem; line-height: 1.35; }
.sum td span + span { margin-top: 2px; }

/* quiz */
.quizlay { display: flex; flex-direction: column; justify-content: center; gap: var(--space-xs); overflow: auto; }
.quizlay .q { margin: 0; font-size: clamp(1.05rem, 1.6vh + .4rem, 1.35rem); }
.quizlay .choice { min-height: clamp(44px, 7.5vh, 68px); font-size: clamp(1rem, 1.2vh + .45rem, 1.2rem); } /* bigger tap targets when the screen has room */
.choices { margin: 0; }
.quizlay .note { min-height: 3em; margin: 0; }
.progress { margin: 0; }

/* result */
.resultlay { display: grid; grid-template-rows: auto minmax(0, 1fr); justify-items: center; align-content: center; gap: var(--space-sm); overflow: auto; }
.stamp-zone { margin: 0; }
.verdict-note { text-align: center; }
.verdict-note p { margin: 0 0 4px; }
.sign { margin: var(--space-sm) 0 0; justify-items: center; text-align: center; }
.actions { padding-bottom: var(--space-sm); }
.fit .pager.actions { flex-wrap: wrap; justify-content: center; gap: 6px var(--space-sm); } /* three buttons do not fit one phone row */
.pager.actions .btn { margin-left: 0; }

/* contents */
.fit .body { overflow-y: auto; }
.toc a { padding: clamp(4px, 2vh, 30px) 0; }
.toc-pic { width: clamp(32px, 6.5vh, 80px); height: clamp(32px, 6.5vh, 80px); }
.toc .stamp.small { --sz: clamp(38px, 6.5vh, 80px); width: var(--sz); height: var(--sz); }
.toc-text { font-size: 1.1rem; line-height: 1.3; }
.foot { margin: var(--space-xs) 0 var(--space-sm); }
.owner { margin: 0; flex: none; }

/* short screens (small phones, phones with browser bars showing): tighten everything so it still fits */
@media (max-height: 700px) {
  .fit .runhead { margin-bottom: 4px; padding-bottom: 4px; font-size: .88rem; }
  .ttl { margin-bottom: 4px; }
  .ttl .label, .fit .progress { display: none; }
  .fit h1 { font-size: 1.05rem; line-height: 1.25; }
  .title-pic { width: 30px; height: 30px; }
  .lab { grid-template-rows: minmax(0, .8fr) minmax(0, 1.2fr); gap: 6px; }
  .verdict { font-size: .88rem; line-height: 1.3; height: 2.6em; }
  .rec-title { font-size: .88rem; margin-bottom: 2px; }
  .picks, .pool { gap: 3px; }
  .pick { padding: 0 5px; column-gap: 5px; }
  /* many short names (.dense): result sits right of the name so each button is one row */
  .dense .pick { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto; }
  .dense .pick .sk, .dense .pick .photo { grid-row: auto; }
  .dense .pick .res { text-align: right; align-self: center; }
  .pick .nm { font-size: .88rem; line-height: 1.05; }
  .pick .res { font-size: .88rem; line-height: 1.05; }
  .pick .sk, .pick .photo { width: 24px; height: 24px; }
  .fit .pager { margin-top: 4px; padding: 4px 0 6px; }
  .fit .pager > span { font-size: .88rem; }
  .fit .btn { min-height: 40px; padding: 6px 12px; font-size: .9rem; }
  .sumlay .lined { --lh: 1.5em; font-size: .88rem; }
  .sumlay .lined p { margin: 0; } /* no blank ruled line between paragraphs: text stays on the rules */
  .sum td span { display: inline; font-size: .88rem; }
  .sum td span + span::before { content: ' · '; }
  .sum th { font-size: .88rem; padding: 4px 6px; }
  .col-head { font-size: .88rem; }
  .col-head small { font-size: .88rem; }
  .pool .tag-name { font-size: .88rem; }
  .pool .tag-name .sk { width: 18px; height: 18px; }
  .toc a { padding: 3px 0; gap: var(--space-xs); }
  .toc-text { font-size: .92rem; }
  .toc-text small { display: none; }
  .toc-no { font-size: 1.2rem; }
  .foot { font-size: .88rem; }
}

/* landscape (tablet / computer / turned phone): parts side by side across the full width */
@media (orientation: landscape) and (min-width: 600px) {
  .equip { display: block; }
  .lab { grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
  .lab-sim { border-bottom: 0; border-right: 1px dashed var(--rule); padding: 0 var(--space-sm) 0 0; }
  .sortlay { grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: var(--space-md); }
  .sortlay .col-head { font-size: clamp(.95rem, 1vh + .5rem, 1.25rem); padding: 8px 10px; }
  .sortlay .col-head small { font-size: clamp(.88rem, .8vh + .45rem, 1.05rem); }
  .sumlay { grid-template-rows: none; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
  .choices { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space-md); }
  .toc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: var(--space-xl); }
  .resultlay { grid-template-rows: none; grid-template-columns: auto minmax(0, 28em); align-items: center; justify-content: center; gap: var(--space-xl); }
  .verdict-note, .sign { text-align: left; justify-items: start; }
}

/* phones held upright: many items = one-line record rows, compact stickers in the narrow sort columns */
@media (orientation: portrait) {
  .dense .pick { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto; }
  .pick { padding-block: 0; } .pick .nm { line-height: 1.12; } /* long English sentences: 3 lines still fit */
  .dense .pick { padding: 0 6px; }
  .dense .pick .sk, .dense .pick .photo { grid-row: auto; width: 28px; height: 28px; }
  .dense .pick .res { text-align: right; align-self: center; }
  .col-items:has(.stuck) { gap: 4px; padding: 4px; }
  .stuck .tag-name { padding: 1px 5px; line-height: 1.2; }
  .stuck .tag-name .sk, .stuck .tag-name::before { display: none; }
}

/* big landscape screens: summary text fills more of the page (short screens keep the compact sizes above) */
@media (orientation: landscape) and (min-width: 600px) and (min-height: 701px) {
  .sumlay .lined { font-size: 1.45rem; }
  .pick .sk, .pick .photo { width: clamp(24px, 6vh, 76px); height: clamp(24px, 6vh, 76px); }
  .pick { column-gap: .6em; padding: 2px .6em; }
  .pick .nm { font-size: 1.05rem; }
  .pick .res { font-size: 1.1rem; }
  .col-items:has(.stuck) { gap: 14px 8px; padding: 12px 8px; }
  .stuck .tag-name { font-size: clamp(.95rem, min(1.4vh, 1vw) + .45rem, 1.45rem); padding: .3em .6em; }
  .stuck .tag-name .sk { width: clamp(26px, min(5.4vh, 3.6vw), 58px); height: clamp(26px, min(5.4vh, 3.6vw), 58px); }
  .sumlay .sum th { font-size: 1.3rem; }
  .sumlay .sum td span { font-size: 1.3rem; }
}

/* contents tabs: paper index tabs along the top of the list, the open one joins the page */
.tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); /* phones: 2 rows of 4 */ gap: 4px; border-bottom: 2px solid var(--print); flex: none; }
.tab { font: inherit; font-weight: 600; font-size: .9rem; line-height: 1.2; color: var(--print-soft); background: var(--paper); border: 1.5px solid var(--rule); border-bottom: 0; border-radius: 8px 8px 0 0; padding: 6px 4px 4px; min-height: 44px; cursor: pointer; overflow-wrap: anywhere; }
.tab small { display: block; font-weight: 400; font-size: .88rem; color: var(--red); }
.tab[aria-selected="true"] { color: var(--print); background: var(--card); border-color: var(--print); border-width: 2px; margin-bottom: -2px; padding-bottom: 6px; box-shadow: inset 0 4px 0 var(--highlight); }
.tab:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (min-width: 700px) { .tabs { grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); } }
@media (max-height: 700px) {
  .tab { min-height: 40px; font-size: .88rem; padding: 4px 2px 2px; }
  .tab small { font-size: .88rem; }
}

/* ================= ป.4 scenes ================= */
.sk .f-orange { fill: var(--c-orange); }
.sk .f-purple { fill: var(--c-purple); }
.sk .f-night { fill: var(--c-night); }
.sk .f-bone { fill: var(--c-bone); }
.sk .f-butter { fill: var(--c-butter); }
.sk .f-mold { fill: var(--c-mold); }
.sk .f-milk { fill: var(--card); fill-opacity: 1; }
.sk .o-body { fill: none; stroke: var(--c-green); stroke-width: 8; stroke-linecap: round; }
.sk .o-worm { fill: none; stroke: var(--c-pink); stroke-width: 7; stroke-linecap: round; }
.sk .o-copper { stroke: var(--c-copper); stroke-width: 3.2; }
.sk .o-air { stroke: var(--c-blue); stroke-width: 2; }
.sk .o-leaf { stroke: var(--c-green); stroke-width: 3; }
/* right-hand result drawing inside a .flow-wrap (like the dissolving glass) */
.scene-r { position: static; width: 100%; height: 100%; }

/* backbone x-ray: dark screen, a scan bar sweeps down, then the bones (or a soft outline) show */
.xr-screen { fill: var(--c-night); stroke: var(--pencil); stroke-width: 2; }
.xr-bones, .xr-ribs { fill: var(--c-bone); stroke: var(--c-bone); stroke-width: 1; opacity: 0; }
.xr-ribs { fill: none; stroke-width: 2; stroke-linecap: round; }
.xr-soft { fill: none; stroke: var(--chalk); stroke-width: 1.5; stroke-dasharray: 4 4; opacity: 0; }
.sketch .xr-label { font-family: var(--font-hand); font-size: 10px; fill: var(--c-bone); opacity: 0; }
.xr-scan { fill: var(--c-green); opacity: 0; }
.scanning .xr-scan { animation: scan .7s linear both; }
@keyframes scan { 0% { opacity: .7; transform: translateY(0); } 100% { opacity: 0; transform: translateY(78px); } }
.xray.has .xr-bones, .xray.has .xr-ribs, .xray.none .xr-soft, .scanning .xr-label { opacity: 1; transition: opacity .3s .6s; }

/* magnifier */
.lens-rim { fill: none; stroke: var(--pencil); stroke-width: 2.4; }
.sketch .lens-label { font-family: var(--font-hand); font-size: 10px; fill: var(--pencil); }
.lens-scene.zoom .lens-art { transform-box: fill-box; transform-origin: center; animation: zoom .5s var(--ease-out) both; }
@keyframes zoom { from { transform: scale(.3); opacity: 0; } }

/* plant / animal / neither: picture + three food questions */
.living-wrap { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.5fr); align-items: center; gap: var(--space-sm); height: calc(100cqh - 3.4em); width: min(100cqw, calc((100cqh - 3.4em) * 2.6)); margin: 0 auto; flex: none; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.checks li { display: flex; align-items: center; gap: var(--space-xs); padding: 2px 6px; border-bottom: 1px dashed var(--rule); font-size: .9rem; line-height: 1.25; }
.checks li.hit { background: var(--highlight-soft); font-weight: 600; }
.checks .tick { flex: none; width: 1.2em; font-size: 1.2rem; text-align: center; }
.checks .tick.ok { color: var(--red); }
.checks .tick.bad { color: var(--pencil-soft); }

/* plant parts: highlighter behind the part, one cue for the job */
.parts-wrap { position: relative; margin: 0 auto; flex: none; width: min(100cqw, calc((100cqh - 3.4em) * 4 / 3)); aspect-ratio: 4 / 3; }
.parts-scene .soil { fill: var(--c-soil); opacity: .25; }
.parts-scene .hl { fill: var(--highlight); opacity: 0; }
.hl-root .hl-root, .hl-stem .hl-stem, .hl-leaf .hl-leaf, .hl-flower .hl-flower { opacity: .75; transition: opacity .3s; }
.parts-scene .cue, .parts-scene .fruit { display: none; }
.cue-up .cue-up, .cue-wind .cue-wind, .cue-hold .cue-hold, .cue-sun .cue-sun, .cue-vapor .cue-vapor, .cue-bee .cue-bee, .cue-fruit .fruit { display: inline; }
.cue-fruit .petals { display: none; }
.cue-fruit .fruit { transform-box: fill-box; transform-origin: center; animation: zoom .6s var(--ease-out) both; }
.flow { fill: var(--c-water); stroke: var(--blue); stroke-width: .8; animation: rise 1s linear infinite; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } 50% { opacity: 1; } to { transform: translateY(-14px); opacity: 0; } }
.cue-wind path { animation: blow 1.2s ease-in-out infinite; }
@keyframes blow { 50% { transform: translateX(8px); } }
.vapor { animation: rise 1.6s ease-out infinite; }

/* elastic: after letting go */
.after { display: grid; justify-items: center; align-content: center; gap: 2px; height: 100%; min-height: 0; }
.bend-obj { width: 100%; max-width: 150px; min-height: 0; aspect-ratio: 1; display: grid; place-items: center; }
.bend-obj .sk, .bend-obj .photo { width: 80%; height: 80%; object-fit: contain; transform-origin: center; }
.after-note { color: var(--pencil-soft); font-size: .88rem; }
.act-stretch.back .sk { animation: stretch-back 1.3s ease-in-out both; }
.act-squeeze.back .sk { animation: squeeze-back 1.3s ease-in-out both; }
.act-squeeze.stay .sk { animation: squeeze-stay 1.3s ease-in-out both; }
.act-bend.stay .sk { animation: bend-stay 1.3s ease-in-out both; }
@keyframes stretch-back { 40%, 55% { transform: scale(1.5, .8); } 75% { transform: scale(.92, 1.05); } 100% { transform: none; } }
@keyframes squeeze-back { 40%, 55% { transform: scale(1.2, .5); } 75% { transform: scale(.95, 1.08); } 100% { transform: none; } }
@keyframes squeeze-stay { 40%, 55% { transform: scale(1.2, .5); } 100% { transform: scale(.85, .62) rotate(-6deg); } }
@keyframes bend-stay { 40%, 100% { transform: rotate(40deg) skewX(-18deg) scale(.9); } }

/* heat: hot water, a rod, butter on top */
.heat-wrap { position: relative; margin: 0 auto; flex: none; width: min(100cqw, calc((100cqh - 3.4em) * 4 / 3)); aspect-ratio: 4 / 3; }
.hot-water { fill: var(--c-water); fill-opacity: .5; }
.steam { fill: none; stroke: var(--pencil-soft); stroke-width: 1.4; animation: rise 1.8s ease-out infinite; }
.rod-edge { stroke: var(--pencil); stroke-width: 9; stroke-linecap: round; }
.rod { stroke: var(--c-metal); stroke-width: 6; stroke-linecap: round; }
.rod-copper .rod { stroke: var(--c-copper); }
.rod-wood .rod { stroke: var(--c-wood); }
.rod-plastic .rod { stroke: var(--c-blue); }
.rod-glass .rod { stroke: var(--c-glass); }
.heat-line { stroke: var(--c-red); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 127; stroke-dashoffset: 127; opacity: 0; }
.heating.good .heat-line { opacity: .85; animation: heat-up 1.4s ease-in both; }
.heating.poor .heat-line { opacity: .85; animation: heat-low 1.4s ease-out both; }
@keyframes heat-up { from { stroke-dashoffset: 127; } to { stroke-dashoffset: 0; } }
@keyframes heat-low { from { stroke-dashoffset: 127; } to { stroke-dashoffset: 112; } }
.butter-g { transform-box: fill-box; transform-origin: 50% 100%; }
.drip { fill: none; stroke: var(--c-butter); stroke-width: 4; stroke-linecap: round; opacity: 0; }
.heating.good .butter { transform-box: fill-box; transform-origin: 50% 100%; animation: melt .7s 1.4s ease-in both; }
.heating.good .drip { animation: drip .7s 1.6s ease-in both; }
@keyframes melt { to { transform: scale(1.25, .4); } }
@keyframes drip { from { opacity: 0; stroke-dasharray: 0 30; } to { opacity: 1; stroke-dasharray: 30 0; } }

/* states of matter: tall bottle → wide box */
.state-wrap { position: relative; margin: 0 auto; flex: none; width: min(100cqw, calc((100cqh - 3.4em) * 220 / 120)); aspect-ratio: 220 / 120; }
.state-scene .liq { fill: var(--c-water); fill-opacity: .6; opacity: 0; transform-box: fill-box; transform-origin: 50% 100%; }
.st-milk .liq { fill: var(--c-bone); fill-opacity: 1; stroke: var(--pencil-soft); stroke-width: 1; }
.st-oil .liq { fill: var(--c-oil); fill-opacity: .9; }
.gas circle { fill: var(--c-blue); opacity: .7; }
.gas { opacity: 0; }
.moving.st-liquid .liq { opacity: 1; }
.moving.st-liquid .liq-l { animation: drain .9s ease-in both; }
.moving.st-liquid .liq-r { animation: fill-up .9s .3s ease-out both; }
@keyframes drain { to { transform: scaleY(0); } }
@keyframes fill-up { from { transform: scaleY(0); } }
.moving.st-gas .gas-l { animation: fade-out .8s ease-in both; }
.moving.st-gas .gas-r { animation: fade-in .8s .4s ease-out both; }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: none; } }
.gas-r { transform-box: fill-box; transform-origin: center; }
.solid-obj { position: absolute; left: 20%; top: 77%; width: 15%; aspect-ratio: 1; transform: translate(-50%, -50%); display: grid; place-items: center; }
.solid-obj .sk, .solid-obj .photo { width: 100%; height: 100%; object-fit: contain; }
.moving.st-solid .solid-obj { animation: carry 1s ease-in-out both; }
@keyframes carry { 0% { left: 20%; top: 77%; } 50% { top: 30%; } 100% { left: 75.5%; top: 77%; } }

/* moon: night sky */
.moon-wrap { position: relative; margin: 0 auto; flex: none; width: min(100cqw, calc((100cqh - 3.4em) * 2)); aspect-ratio: 2 / 1; }
.night { fill: var(--c-night); }
.stars circle { fill: var(--c-bone); }
.hills { fill: oklch(24% 0.04 265); }
.sketch .sky-day { font-family: var(--font-hand); font-size: 13px; fill: var(--c-bone); }
.sketch .sky-when { font-family: var(--font-hand); font-size: 8.5px; fill: var(--chalk); }
.moon-big { position: absolute; left: 70%; top: 44%; width: 36%; aspect-ratio: 1; transform: translate(-50%, -50%); }
.moon-big .sk { width: 100%; height: 100%; }
.moon-big.chalk [class*="f-"] { fill-opacity: 1; }
.moon-big .f-dark { fill: oklch(40% 0.03 265); }
.rise .moon-big { animation: appear .6s ease-out both; }
@keyframes appear { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .scanning .xr-scan, .lens-scene.zoom .lens-art, .flow, .cue-wind path, .vapor, .steam, .bend-obj .sk,
  .heating .heat-line, .heating .butter, .heating .drip, .moving .liq, .moving .gas, .moving .solid-obj, .rise .moon-big, .cue-fruit .fruit { animation-duration: .01s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; }
}

/* ================= ป.5 scenes ================= */
.sk .f-skin { fill: var(--c-skin); }
.sk .f-rust { fill: var(--c-rust); }
.sk .o-arrow { stroke: var(--red); stroke-width: 2.4; }
.sk .o-fog { stroke: var(--pencil-soft); stroke-width: 3.5; opacity: .6; }
.sk .o-frost { stroke: var(--c-bone); stroke-width: 1.6; }
.sk .sk-num { font: 700 10px var(--font-print); fill: var(--red); stroke: none; }

/* friction: ramp + floor, the car rolls down and stops at --end */
.friction-wrap { position: relative; margin: 0 auto; flex: none; width: min(100cqw, calc((100cqh - 3.4em) * 2.2)); aspect-ratio: 220 / 100; }
.floor { fill: var(--card); stroke: var(--pencil); stroke-width: 1; }
.car { position: absolute; left: 7%; top: 28%; width: 13%; aspect-ratio: 1; transform: translate(-50%, -50%) rotate(48deg); }
.car .sk { width: 100%; height: 100%; }
.rolling .car { animation: roll-down .5s ease-in forwards, roll-on var(--dur, 1.5s) .5s cubic-bezier(.2, .7, .3, 1) forwards; }
@keyframes roll-down { to { left: 24%; top: 69%; transform: translate(-50%, -50%) rotate(0); } }
@keyframes roll-on { from { left: 24%; top: 69%; transform: translate(-50%, -50%); } to { left: var(--end); top: 69%; transform: translate(-50%, -50%); } }

/* net force: pushes as red arrows, then the net force, then the box slides */
.netforce-wrap { position: relative; margin: 0 auto; flex: none; width: min(100cqw, calc((100cqh - 3.4em) * 2.2)); aspect-ratio: 220 / 100; }
.push { fill: none; stroke: var(--red); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.sketch .nf-num { font: 700 8.5px var(--font-print); fill: var(--red); }
.net-arrow { fill: none; stroke: var(--blue); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 5 3; }
.sketch .net-text { font-family: var(--font-hand); font-size: 10px; fill: var(--blue); }
#net { opacity: 0; }
.pushing #net { animation: appear .4s .4s both; opacity: 1; }
.pushing #movers { transform-box: view-box; }
.go-left #movers { animation: slide-l 1s .8s ease-in-out both; }
.go-right #movers { animation: slide-r 1s .8s ease-in-out both; }
@keyframes slide-l { to { transform: translateX(-34px); } }
@keyframes slide-r { to { transform: translateX(34px); } }

/* change of state: the state ladder */
.phase-scene .pill rect { fill: var(--card); stroke: var(--pencil-soft); stroke-width: 1.4; }
.phase-scene .pill text { font-family: var(--font-print); font-size: 11px; fill: var(--print); }
.phase-scene .pill.from rect { stroke-dasharray: 3 3; stroke: var(--pencil); }
.phase-scene .pill.to rect { fill: var(--highlight); stroke: var(--pencil); }
.phase-arrow { fill: none; stroke: var(--red); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 90; stroke-dashoffset: 0; }
.drawing .phase-arrow { animation: draw-in .7s ease-out both; }
@keyframes draw-in { from { stroke-dashoffset: 90; } }
.days.hot { color: var(--red); }
.days.cold { color: var(--blue); }

/* chemical change: observation sheet reuses .checks */
.checks .seen { font-family: var(--font-hand); color: var(--pencil); border-bottom-style: solid; }

/* heredity: family tree with trait pictures */
.family-wrap { position: relative; margin: 0 auto; flex: none; width: min(100cqw, calc((100cqh - 3.4em) * 200 / 120)); aspect-ratio: 200 / 120; }
.trait { position: absolute; width: 17%; aspect-ratio: 1; transform: translate(-50%, -50%); display: grid; place-items: center; }
.trait .sk { width: 100%; height: 100%; }
.t-parent { left: 17%; top: 22%; }
.t-child { left: 30%; top: 77%; }
.pass { fill: none; stroke: var(--red); stroke-width: 2.2; stroke-dasharray: 4 3; opacity: 0; }
.sketch .later { font-family: var(--font-hand); font-size: 10px; fill: var(--pencil-soft); opacity: 0; }
.inherit .pass, .gained .later { opacity: 1; }
.shown .trait { animation: appear .5s ease-out both; }
.shown .t-child { animation-delay: .4s; }

/* clouds and precipitation */
.precip-wrap { position: relative; margin: 0 auto; flex: none; width: min(100cqw, calc((100cqh - 3.4em) * 200 / 120)); aspect-ratio: 200 / 120; }
.air { fill: var(--c-sky); }
.lk { display: none; }
.show-rain .lk-rain, .show-hail .lk-hail, .show-snow .lk-snow, .show-cloud .lk-cloud, .show-fog .lk-fog, .show-dew .lk-dew, .show-frost .lk-frost { display: inline; }
.drop-l { stroke: var(--blue); stroke-width: 1.8; stroke-linecap: round; }
.hail { fill: var(--c-glassblue); stroke: var(--pencil); stroke-width: 1; }
.flake { stroke: var(--blue); stroke-width: 1.2; stroke-linecap: round; fill: none; }
.fall > * { animation: fall 1.1s linear 3 both; }
.fall.slow > * { animation-duration: 2.2s; animation-iteration-count: 2; }
@keyframes fall { from { transform: translateY(-6px); opacity: 0; } 15% { opacity: 1; } to { transform: translateY(56px); opacity: .9; } }
.mark { fill: var(--highlight); opacity: .45; }
.sketch .mark-t { font-family: var(--font-hand); font-size: 10px; fill: var(--pencil); }
.fog-band { stroke: var(--card); stroke-width: 7; stroke-linecap: round; opacity: .85; }
.dew { fill: var(--c-water); stroke: var(--blue); stroke-width: .8; }
.frost-x { stroke: var(--card); stroke-width: 2; stroke-linecap: round; }

/* stars and planets */
.stars-wrap { position: relative; margin: 0 auto; flex: none; width: min(100cqw, calc((100cqh - 3.4em) * 2)); aspect-ratio: 2 / 1; }
.sun-dot { fill: var(--c-yellow); }
.sketch .sky-label { font-family: var(--font-hand); font-size: 8.5px; fill: var(--c-bone); }
.beam-in, .beam-out { stroke: var(--c-yellow); stroke-width: 2.4; stroke-dasharray: 4 3; opacity: 0; }
.earth circle { fill: var(--c-blue); }
.earth, .sun-src { opacity: .35; }
.own-glow { fill: var(--c-yellow); opacity: 0; }
.lit .beam-in, .lit .beam-out { opacity: 1; animation: appear .6s both; }
.lit .beam-out { animation-delay: .5s; }
.lit .earth, .lit .sun-src { opacity: 1; }
.own .own-glow { opacity: .35; animation: glow 1.2s ease-in-out 3 alternate; transform-box: fill-box; transform-origin: center; }
.is-sun .sun-src { opacity: 0; }
@keyframes glow { to { transform: scale(1.25); opacity: .15; } }
.star-obj { position: absolute; left: 51%; top: 48%; width: 22%; aspect-ratio: 1; transform: translate(-50%, -50%); }
.star-obj .sk { width: 100%; height: 100%; }
.star-obj.chalk [class*="f-"] { fill-opacity: 1; }

/* food chain */
.fc-wrap { display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, .8fr); gap: 4px; height: calc(100cqh - 3.4em); width: min(100cqw, calc((100cqh - 3.4em) * 2.2)); margin: 0 auto; flex: none; }
.fc-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 4px; min-height: 0; }
.fc-down { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); }
.fc-slot { display: grid; grid-template-rows: minmax(0, 1fr) auto; justify-items: center; height: 100%; min-height: 0; padding: 2px; border: 1.5px dashed var(--rule); border-radius: 8px; }
.fc-slot.hit { border: 2px solid var(--pencil); background: var(--highlight-soft); }
.fc-pic { width: 100%; height: 100%; min-height: 0; min-width: 0; display: grid; place-items: center; }
.fc-pic .sk, .fc-pic .photo { width: 100%; height: 100%; object-fit: contain; }
.fc-slot:not(.hit) .fc-pic { opacity: .45; }
.fc-name { font-size: .88rem; font-weight: 600; line-height: 1.2; text-align: center; }
.fc-arrow { color: var(--red); font-size: 1.3rem; }
.fc-note { font-size: .88rem; color: var(--pencil-soft); text-align: center; line-height: 1.2; }

@media (prefers-reduced-motion: reduce) {
  .rolling .car, .pushing #net, .go-left #movers, .go-right #movers, .drawing .phase-arrow, .shown .trait, .fall > *, .lit .beam-in, .lit .beam-out, .own .own-glow { animation-duration: .01s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; }
}

/* ================= ป.6 scenes ================= */
.sk .o-band-dark { stroke: var(--c-dark); stroke-width: 4; }
.sk .f-sky { fill: var(--c-sky); }

/* result card on the right of a .flow-wrap (nutrients, separating) */
.result-card { display: grid; grid-template-rows: minmax(0, 1fr) auto; justify-items: center; gap: 4px; height: 100%; min-height: 0; text-align: center; }
.result-card .test-art { width: 100%; max-width: 150px; height: 100%; min-height: 0; }
.result-card .hand { font-size: .88rem; line-height: 1.25; color: var(--pencil); }
.spot { transition: none; }
.testing.r-carb .spot { animation: iodine .8s .5s both; }
@keyframes iodine { to { fill: oklch(38% 0.12 300); } }
.drip { fill: oklch(55% 0.12 60); opacity: 0; }
.testing.r-carb .drip { animation: drop .5s both; }
@keyframes drop { from { opacity: 1; transform: translateY(-12px); } to { opacity: 0; transform: translateY(10px); } }
.greasy { fill: var(--c-glass); opacity: 0; stroke: var(--pencil-soft); stroke-dasharray: 2 2; }
.testing.r-fat .greasy { animation: appear .8s .3s both; opacity: .9; }
.working.use-sieve .test-art { animation: shake .25s ease-in-out 4; }
.working.use-magnet .test-art { animation: lift .6s ease-out both; }
.working.use-filter .test-art, .working.use-pick .test-art { animation: appear .6s both; }
@keyframes shake { 50% { transform: translateX(8px); } }
@keyframes lift { from { transform: translateY(20px); } }

/* digestion: body outline with organs */
.body-wrap { position: relative; margin: 0 auto; flex: none; width: min(100cqw, calc((100cqh - 3.4em) * 120 / 150)); aspect-ratio: 120 / 150; }
.body-scene .hl { fill: var(--highlight); opacity: 0; }
.hl-line { fill: none; stroke: var(--highlight); stroke-width: 12; stroke-linejoin: round; opacity: 0; }
.hl-mouth .hl-mouth, .hl-stomach .hl-stomach, .hl-small .hl-small, .hl-large .hl-large { opacity: .8; transition: opacity .3s; }
.sk .gut { stroke: var(--c-pink); stroke-width: 4; }
.sk .colon { stroke: var(--c-wood); stroke-width: 6; }
.sketch .organ-label { font-family: var(--font-hand); font-size: 11px; fill: var(--red); }

/* series / parallel */
.circuit2-wrap { position: relative; margin: 0 auto; flex: none; width: min(100cqw, calc((100cqh - 3.4em) * 64 / 60)); aspect-ratio: 64 / 60; }
.wire2 { fill: none; stroke: var(--pencil); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.bulb-c { fill: var(--c-yellow); stroke: var(--pencil); stroke-width: 1; }
.glow2 { fill: var(--highlight); opacity: .7; }
.sketch .bat-t { font-family: var(--font-hand); font-size: 4px; fill: var(--pencil-soft); }
.sketch .out-t { font-family: var(--font-hand); font-size: 4px; fill: var(--red); opacity: 0; }
.run.series .glow2 { animation: fade-out .3s .9s both; }
.run.series .bulb-c { animation: go-dark .3s .9s both; }
.run .b0 .glow2 { animation: fade-out .2s .5s both; }
.run .b0 .bulb-c { animation: take-out .3s .5s both; }
.run .out-t { animation: appear .3s .5s both; opacity: 1; }
@keyframes go-dark { to { fill: var(--card); } }
@keyframes take-out { to { fill: transparent; stroke-dasharray: 1.5 1.5; } }

/* static electricity: two objects swing together or apart */
.static-wrap { position: relative; margin: 0 auto; flex: none; width: min(100cqw, calc((100cqh - 3.4em) * 2)); aspect-ratio: 2 / 1; }
.charged { position: absolute; top: 45%; width: 26%; transform: translate(-50%, -50%); display: grid; justify-items: center; text-align: center; transition: left .8s cubic-bezier(.5, 0, .3, 1.3); }
.charged .sk { width: 100%; aspect-ratio: 1; height: auto; }
.charged .q { font: 700 1rem var(--font-print); letter-spacing: .05em; }
.charged .qn { color: var(--blue); }
.charged .qp { color: var(--red); }
.charged .qz { color: var(--pencil-soft); }
.charged small { font-size: .88rem; color: var(--print-soft); }
.ca { left: 30%; } .cb { left: 70%; }
.together .ca { left: 40%; } .together .cb { left: 60%; }
.apart .ca { left: 15%; } .apart .cb { left: 85%; }

/* eclipses */
.eclipse-wrap { position: relative; margin: 0 auto; flex: none; width: min(100cqw, calc((100cqh - 3.4em) * 2.2)); aspect-ratio: 220 / 100; }
.sun-big { fill: var(--c-yellow); }
.sunray { stroke: var(--c-yellow); stroke-width: .8; opacity: .35; stroke-dasharray: 3 3; }
.earth-big { fill: var(--c-blue); }
.moon-small { fill: var(--c-stone); }
.moon-small.red { fill: var(--c-rust); }
.shadow-cone { fill: oklch(10% 0.02 265); opacity: .75; }
.umbra-spot { fill: oklch(12% 0.02 265); opacity: .8; }
.sketch .ecl-title { font-family: var(--font-hand); font-size: 10px; fill: var(--c-yellow); }
.lined-up .shadow-cone, .lined-up .umbra-spot, .lined-up .ecl-title { animation: appear .6s .3s both; }

/* land and sea breeze */
.breeze-wrap { position: relative; margin: 0 auto; flex: none; width: min(100cqw, calc((100cqh - 3.4em) * 2)); aspect-ratio: 220 / 110; }
.moon-c { fill: var(--c-yellow); }
.wind { fill: none; stroke: var(--blue); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 6 4; }
.night-t .wind { stroke: var(--c-bone); }
.blowing .wind { animation: flow 1s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -20; } }
.sketch .temp { font-family: var(--font-hand); font-size: 9px; }
.sketch .temp.hot { fill: var(--red); }
.sketch .temp.cold { fill: var(--blue); }
.sketch .wind-t { font-family: var(--font-hand); font-size: 9px; fill: var(--blue); }
.sketch .wind-t.on-night { fill: var(--c-bone); }

@media (prefers-reduced-motion: reduce) {
  .testing .spot, .testing .drip, .testing .greasy, .working .test-art, .run .glow2, .run .bulb-c, .run .out-t, .lined-up .shadow-cone, .lined-up .umbra-spot, .lined-up .ecl-title, .blowing .wind { animation-duration: .01s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; }
  .charged { transition: none; }
}

/* ---------- reading sheets (#read) ---------- */
.rd-hello { display: flex; gap: var(--space-sm); align-items: center; margin-bottom: var(--space-md); }
.rd-hello img { width: 76px; height: 76px; border-radius: 50%; object-fit: cover; flex: none; border: 2px solid var(--rule); }
.rd-hello p { margin: 0; padding: var(--space-sm) var(--space-md); background: var(--card); border: 2px solid var(--amber); border-radius: 14px; line-height: 1.6; position: relative; }
.rd-hello p::before { content: ""; position: absolute; left: -9px; top: 50%; translate: 0 -50%; border: 8px solid transparent; border-right-color: var(--amber); border-left: 0; }
mark { background: linear-gradient(transparent 45%, var(--highlight) 45% 90%, transparent 90%); color: inherit; padding: 0 .1em; }
.rd-point { margin: var(--space-lg) 0; }
.rd-point > header { display: flex; align-items: center; gap: var(--space-sm); }
.rd-point h2 { margin: 0; flex: 1; }
.rd-no { position: relative; flex: none; width: 46px; height: 46px; display: grid; place-items: center; rotate: -8deg; }
.rd-no svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: var(--highlight); stroke: var(--red); stroke-width: 2.4; stroke-linejoin: round; }
.rd-no b { position: relative; font-weight: 700; font-size: 1.1rem; color: var(--red); margin-top: 3px; }
.rd-tag { font-family: var(--font-hand); color: var(--red); border: 1.5px solid var(--red); border-radius: 999px; padding: 0 10px; font-size: .9rem; white-space: nowrap; rotate: -4deg; }
.rd-fig { position: relative; margin: var(--space-sm) auto; max-width: 480px; }
.rd-fig img { display: block; width: 100%; border-radius: 12px; }
.rd-fig > svg { display: block; width: 50%; margin: 0 auto; }
.rd-label { position: absolute; translate: -50% -50%; background: var(--card); border: 1.5px solid var(--print); border-radius: 8px; padding: 1px 8px; font-weight: 600; font-size: clamp(.85rem, 2.8vw, .95rem); white-space: nowrap; box-shadow: 2px 2px 0 var(--tape); }
.rd-boxes { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-sm); }
.rd-box { background: var(--card); border: 1.5px dashed var(--rule); border-radius: 10px; padding: var(--space-xs) var(--space-sm); }
.rd-box b { color: var(--blue); }
.rd-box p { margin: 2px 0 0; line-height: 1.55; }
.rd-fig > svg ~ .rd-label { display: none; } /* labels belong to the photo, not the fallback sketch */
/* strip: pictures sit side by side at their own size, each caption right under its picture */
.rd-strip { --pic: clamp(56px, 7vw, 88px); display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-sm) var(--space-lg); margin: var(--space-sm) 0; }
.rd-strip figure { flex: 0 1 calc(var(--pic) + 56px); margin: 0; display: grid; justify-items: center; gap: 2px; text-align: center; }
.rd-strip svg { width: var(--pic); height: var(--pic); }
.rd-strip figcaption { font-size: .92rem; line-height: 1.3; color: var(--print); }

/* ---------- front menu (#menu): top bar, greeting, four big cards that fill the screen ---------- */
.hub { position: relative; min-height: 100dvh; overflow: hidden; width: 100vw; margin-left: calc(50% - 50vw); padding: var(--space-xl) var(--space-md); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-lg); }
.hub-doodles { position: absolute; inset: 0; pointer-events: none; }
.hub-doodles .sk { position: absolute; width: clamp(54px, 9vw, 92px); height: auto; opacity: .85; }
.hub-doodles .sk:nth-child(1)  { top: 4%;  left: 5%;   rotate: -14deg; }
.hub-doodles .sk:nth-child(2)  { top: 6%;  right: 6%;  rotate: 12deg; }
.hub-doodles .sk:nth-child(3)  { top: 20%; left: 14%;  rotate: 20deg; }
.hub-doodles .sk:nth-child(4)  { top: 18%; right: 16%; rotate: -8deg; }
.hub-doodles .sk:nth-child(5)  { top: 40%; left: 1%;   rotate: 8deg; width: 48px; }
.hub-doodles .sk:nth-child(6)  { top: 40%; right: 1%;  rotate: -16deg; width: 48px; }
.hub-doodles .sk:nth-child(7)  { bottom: 22%; left: 10%; rotate: -6deg; }
.hub-doodles .sk:nth-child(8)  { bottom: 20%; right: 9%; rotate: 14deg; }
.hub-doodles .sk:nth-child(9)  { bottom: 4%;  left: 4%;  rotate: 10deg; }
.hub-doodles .sk:nth-child(10) { bottom: 5%;  right: 5%; rotate: -12deg; }
.hub-doodles .sk:nth-child(11) { bottom: 3%;  left: 40%; rotate: 6deg; }
.hub-doodles .sk:nth-child(12) { top: 3%;  left: 44%;  rotate: -10deg; }
.hub .cover-label { position: relative; z-index: 1; }
.rd-list { margin: var(--space-xs) 0 var(--space-sm); padding-left: 1.3em; line-height: 1.65; }
.rd-list li::marker { color: var(--red); }
.rd-table { overflow-x: auto; margin: var(--space-sm) 0; }
.rd-table table { border-collapse: collapse; width: 100%; min-width: 460px; background: var(--card); font-size: .92rem; line-height: 1.5; }
.rd-table th, .rd-table td { border: 1px solid var(--rule); padding: 6px 8px; text-align: left; vertical-align: top; }
.rd-table thead th { background: var(--highlight-soft); }
.rd-table tbody th { color: var(--blue); white-space: nowrap; }
.rd-words, .rd-qa { margin: var(--space-lg) 0; padding: var(--space-sm) var(--space-md); background: var(--card); border: 1.5px solid var(--rule); border-radius: 12px; }
.rd-words h2, .rd-qa h2 { margin: 0 0 var(--space-xs); }
.rd-qa h2 small { font-weight: 400; font-size: .88rem; color: var(--pencil-soft); margin-left: var(--space-xs); }
.rd-words dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px var(--space-sm); }
.rd-words dt { font-weight: 700; color: var(--blue); }
.rd-words dd { margin: 0; }
.rd-qa details { border-top: 1px dashed var(--rule); padding: var(--space-xs) 0; }
.rd-qa summary { cursor: pointer; font-weight: 600; }
.rd-qa details p { margin: 4px 0 0; padding-left: 1em; color: var(--red); font-weight: 600; font-size: 1rem; }
@media (max-width: 600px) { .rd-words dl { grid-template-columns: 1fr; } .rd-words dd { margin-bottom: 6px; } }
@media (max-width: 600px) { /* phone: each table row becomes a small card, column name before each value */
  .rd-table table { min-width: 0; }
  .rd-table thead { display: none; }
  .rd-table table, .rd-table tbody, .rd-table tr, .rd-table th, .rd-table td { display: block; width: 100%; }
  .rd-table tr { border: 1px solid var(--rule); border-radius: 8px; margin-bottom: var(--space-xs); background: var(--card); }
  .rd-table th, .rd-table td { border: 0; border-top: 1px dashed var(--rule); }
  .rd-table tbody th { border-top: 0; background: var(--highlight-soft); border-radius: 8px 8px 0 0; }
  .rd-table td[data-h]:not([data-h=""])::before { content: attr(data-h) " · "; color: var(--print-soft); font-size: .88rem; }
}
/* chain: fixed-size pictures packed together; each arrow points from picture to picture, at picture mid-height */
.rd-chain { --pic: clamp(48px, 7vw, 84px); display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: var(--space-xs) 0; margin: var(--space-sm) 0; padding: var(--space-sm); background: var(--card); border: 1.5px dashed var(--rule); border-radius: 12px; }
.rd-chain figure { flex: 0 1 calc(var(--pic) + 44px); min-width: 0; margin: 0; display: grid; justify-items: center; gap: 2px; text-align: center; }
.rd-chain .sk { width: var(--pic); height: var(--pic); }
.rd-chain figcaption { font-weight: 600; font-size: .92rem; line-height: 1.3; }
.rd-chain small { display: block; color: var(--red); font-size: .85rem; line-height: 1.25; }
.rd-arrow { flex: 0 0 auto; width: clamp(22px, 3vw, 36px); height: auto; margin-top: calc(var(--pic) / 2 - 9px); fill: none; stroke: var(--pencil); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 600px) { .rd-chain { --pic: 44px; flex-wrap: nowrap; padding: var(--space-xs) 2px; } .rd-chain figure { flex: 1 1 0; } .rd-chain figcaption, .rd-chain small { font-size: .8rem; overflow-wrap: anywhere; } .rd-arrow { width: 14px; margin-top: calc(var(--pic) / 2 - 4px); } }
/* ข้อสอบชอบหลอก: the selling point of every Short Note — red-pen box near the top */
.rd-traps { margin: var(--space-md) 0 var(--space-lg); padding: var(--space-sm) var(--space-md); background: var(--card); border: 2.5px solid var(--red); border-radius: 14px 10px 16px 12px; box-shadow: 4px 4px 0 oklch(52% 0.19 27 / .18); rotate: -.4deg; }
.rd-traps header { display: flex; align-items: center; gap: var(--space-sm); }
.rd-traps-pic { width: 52px; height: 52px; flex: none; rotate: -12deg; }
.rd-traps h2 { margin: 0; color: var(--red); }
.rd-traps h2 small { font-size: .88rem; font-weight: 600; background: var(--red); color: var(--card); border-radius: 999px; padding: 1px 8px; vertical-align: middle; }
.rd-traps header p { margin: 0; color: var(--pencil); }
.rd-traps ol { margin: var(--space-xs) 0 0; padding-left: 1.4em; }
.rd-traps li { padding: 6px 0; border-top: 1px dashed var(--rule); }
.rd-traps li::marker { color: var(--red); font-weight: 700; }
.rd-traps li p { margin: 0; line-height: 1.55; }
.rd-no-way { color: var(--print-soft); }
.rd-no-way::before { content: "✗ เข้าใจผิด: "; color: var(--red); font-weight: 700; }
.rd-yes-way::before { content: "✓ ที่ถูก: "; color: oklch(50% 0.13 150); font-weight: 700; }
.rd-about { display: block; font-weight: 400; font-size: .95rem; color: var(--print-soft); line-height: 1.45; margin-top: 2px; }


/* mission book (#missions): one row per experiment, stamped once passed */
.missions { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: var(--space-sm); margin: var(--space-md) 0 var(--space-xl); }
.mission { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-sm); background: var(--card); border: 1.5px dashed var(--rule); border-radius: 12px; color: var(--print); text-decoration: none; }
.mission.done { border: 1.5px solid var(--print); box-shadow: 3px 3px 0 var(--tape); }
.mission:hover { translate: 0 -2px; }
.mission-pic { width: 48px; height: 48px; flex: none; }
.mission-name { flex: 1; min-width: 0; font-weight: 600; font-size: 1.05rem; line-height: 1.35; }
.mission-name small { display: block; font-weight: 400; font-size: .9rem; color: var(--print-soft); }
/* paper-tag buttons for the small top links (เมนู / แก้ชื่อ / back) — same look everywhere */
.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 34px; padding: 3px 12px; font-family: var(--font-print); font-weight: 600; font-size: .95rem; line-height: 1.2; color: var(--blue); background: var(--card); border: 1.5px solid var(--blue); border-radius: 8px 10px 8px 12px; box-shadow: 2px 2px 0 var(--tape); text-decoration: none; white-space: nowrap; rotate: -1deg; }
.chip:hover { background: var(--highlight-soft); }
.chip:active { translate: 1px 1px; box-shadow: none; }
.runhead { align-items: center; font-size: .95rem; }
.ttl .chip { margin-bottom: 4px; }
.rd-no-way { font-family: var(--font-hand); font-size: 1.05rem; }
.rd-no-way::before { font-family: var(--font-print); }
.tab small { font-family: var(--font-print); font-weight: 600; }
.toc-text small.rd-about { display: block; }
.rec-title small { font-size: .9rem; }

/* ---------- exam (O-NET ป.6): strand picker, one question per page, score ---------- */
.exam-pick { display: grid; grid-template-columns: 1fr; grid-auto-rows: minmax(0, 1fr); gap: var(--space-sm); padding: var(--space-xs) 0 var(--space-sm); overflow-y: auto; }
@media (min-width: 700px) { .exam-pick { grid-template-columns: 1fr 1fr; gap: var(--space-md); } }
.ex-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: clamp(12px, 2.5vw, 40px); padding: clamp(12px, 3vh, 36px) clamp(12px, 2.5vw, 40px); min-height: 96px; background: var(--card); border: 1.5px solid var(--rule); border-radius: 14px; color: inherit; text-decoration: none; transition: transform .15s var(--ease-out), background .15s; }
.ex-card:hover { background: var(--highlight-soft); transform: rotate(-.4deg); }
.ex-card-pic { width: clamp(56px, 17vh, 190px); height: auto; }
.ex-card-text { display: grid; gap: 2px; line-height: 1.35; }
.ex-card-text small { color: var(--print-soft); font-size: clamp(.9rem, 1vh + .5rem, 1.25rem); }
.ex-card-text b { font-size: clamp(1.15rem, 2.6vh + .4rem, 2.4rem); line-height: 1.25; }
.ex-card-text span { color: var(--print-soft); font-size: clamp(.95rem, 1.3vh + .45rem, 1.45rem); }
.ex-score { text-align: center; color: var(--red); line-height: 1; white-space: nowrap; }
.ex-score b { font-size: clamp(2rem, 8vh, 5.5rem); color: var(--red); }
.ex-score small { font-size: 1rem; }
.ex-score.none { font-family: var(--font-hand); color: var(--pencil-soft); font-size: clamp(1rem, 1.4vh + .5rem, 1.5rem); }

.ex-src { margin: var(--space-2xs) 0 0; font-size: .82rem; color: var(--print-soft); }
.ex-fig { margin: var(--space-xs) 0; padding: var(--space-xs); background: var(--card); border: 1.5px dashed var(--rule); border-radius: 12px; }
.ex-svg { width: 100%; height: auto; max-height: 36vh; }
.ex-svg .ex-t { font-family: var(--font-hand); fill: var(--pencil); font-size: 9px; }
.ex-svg .ex-sm { font-size: 6.5px; }
.ex-svg .ex-red { fill: var(--red); } .ex-svg .ex-blue { fill: var(--blue); }
.ex-svg .ex-line { fill: none; stroke: var(--pencil-soft); stroke-width: .8; }
.ex-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: var(--space-xs) 0; }
.ex-box { font-size: clamp(1rem, 1.6vh + .45rem, 1.5rem); padding: 4px 10px; background: var(--card); border: 1.5px solid var(--pencil); border-radius: 8px; font-family: var(--font-hand); }
.ex-arrow { display: inline-grid; justify-items: center; line-height: 1; color: var(--pencil); font-size: 1.3rem; }
.ex-arrow small { font-size: .78rem; color: var(--print-soft); }
.ex-code { margin: var(--space-xs) 0; padding: var(--space-sm); background: var(--card); border: 1.5px dashed var(--rule); border-radius: 10px; font: clamp(.92rem, 1.4vh + .4rem, 1.35rem)/1.5 var(--font-print); white-space: pre-wrap; }
.ex-figchoices .ans { display: inline-flex; align-items: center; gap: 6px; width: 100%; }
.ex-figchoices .ex-svg { width: min(100%, 260px); max-height: 18vh; }
.ex-note { min-height: 3em; margin: var(--space-xs) 0 0; font-size: clamp(1rem, 1.7vh + .45rem, 1.6rem); }
.ex-note.ok { color: var(--blue); }
.ex-tf { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-xs); }
.ex-tf li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-sm); padding: var(--space-xs) var(--space-sm); background: var(--card); border: 1.5px solid var(--rule); border-radius: 10px; font-size: clamp(1rem, 1.8vh + .45rem, 1.65rem); line-height: 1.45; }
.ex-tf li.bad { border-color: var(--red); background: oklch(96% 0.03 27); }
.ex-tf li.good { border-color: var(--blue); }
.ex-yn { display: flex; gap: 6px; }
.ex-yn .btn { min-height: clamp(40px, 6vh, 60px); padding: 4px clamp(12px, 1.5vw, 24px); font-size: inherit; }
.ex-yn .btn[aria-pressed="true"] { background: var(--blue); color: var(--card); border-color: var(--blue); }
.ex-yn .btn:disabled { opacity: 1; cursor: default; }
@media (max-width: 600px) { .ex-tf li { grid-template-columns: 1fr; gap: 6px; } .ex-card { gap: var(--space-sm); padding: var(--space-sm); } }
.ex-tally { flex: 1 1 0; font-size: .95rem; }
.ex-big { font-size: clamp(1.2rem, 2.6vh, 2.2rem); margin: var(--space-sm) 0; } .ex-big b { font-size: clamp(3rem, 11vh, 8rem); color: var(--red); line-height: 1; }
.result .verdict-note:has(.ex-big) { font-size: clamp(1rem, 1.8vh + .3rem, 1.5rem); }

/* ---------- brand: Kruclick Lab67 (cover wordmark, menu label, strip on every page) ---------- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.cover-hub { gap: var(--space-md); }
.brand { position: relative; z-index: 1; margin: 0; display: flex; flex-direction: column; align-items: center; line-height: .86; }
.brand-k { rotate: -3deg; font-family: var(--font-print); font-weight: 700; font-size: clamp(3.6rem, 19vw, 11rem); letter-spacing: -.03em; color: var(--print); text-shadow: .035em .035em 0 var(--highlight), .07em .07em 0 var(--tape); }
.brand-l { display: flex; align-items: center; gap: .08em; margin-top: -.08em; rotate: 2.5deg; font-family: var(--font-hand); font-size: clamp(4.4rem, 24vw, 14rem); color: var(--red); text-shadow: .03em .03em 0 var(--card); }
.brand-l .n67 { display: inline-block; padding: .02em .14em .06em; color: var(--card); background: var(--blue); border-radius: .16em .2em .14em .22em; rotate: -7deg; text-shadow: none; box-shadow: .05em .06em 0 var(--rule); }
.brand-slogan { position: relative; z-index: 1; margin: var(--space-xs) 0 0; padding: 6px 18px; font-family: var(--font-hand); font-size: clamp(1.3rem, 4.6vw, 2rem); color: var(--pencil); background: var(--card); border: 1.5px solid var(--print); border-radius: 12px 16px 12px 14px; rotate: -1.5deg; box-shadow: 3px 3px 0 var(--tape); text-align: center; }
.brand-slogan mark { color: var(--red); }
.cover-form { position: relative; z-index: 1; display: flex; gap: var(--space-sm); width: min(100%, 480px); margin-top: var(--space-sm); }
.cover-form .line { flex: 1; min-width: 0; width: auto; text-align: center; font-size: 1.4rem; background: var(--card); border: 2px solid var(--print); border-radius: 12px; padding: 10px 12px; }
.cover-form .go { font-size: 1.7rem; font-weight: 700; padding: 8px 30px; rotate: 1.5deg; }
@media (max-width: 420px) { .cover-form { flex-direction: column; } .cover-form .go { rotate: 0deg; } }
.bm b { font-weight: 700; color: var(--print); }
.bm i { font-style: normal; color: var(--red); margin-left: .2em; font-size: 1.1em; }
.brand-strip { display: block; width: fit-content; margin: 0 0 var(--space-2xs) auto; font-size: .95rem; line-height: 1.2; text-decoration: none; rotate: -1.5deg; }

/* menu: fills the whole screen — bar on top, greeting, then a 2×2 grid of cards that takes the rest */
.hub.menu { justify-content: flex-start; align-items: stretch; gap: clamp(10px, 2.2vh, 28px); padding: clamp(12px, 2.5vh, 28px) clamp(14px, 4vw, 64px); }
.menu .hub-doodles .sk { opacity: .35; }
.mn-bar-top, .mn-hi, .mn-cards { position: relative; z-index: 1; }
.mn-bar-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); }
.mn-brand { font-size: clamp(1.1rem, 1.8vw, 1.6rem); }
.mn-exit { font-size: clamp(1rem, 1.4vw, 1.3rem); min-height: 44px; padding: 6px 18px; color: var(--red); border-color: var(--red); }
.mn-hi h1 { margin: 0; font-size: clamp(1.8rem, 5vh, 3.4rem); line-height: 1.15; }
.mn-hi h1 .hand { color: var(--blue); }
.mn-hi p { margin: 2px 0 0; font-size: clamp(1.1rem, 2.4vh, 1.7rem); }
.mn-cards { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 1fr; grid-auto-rows: minmax(120px, 1fr); gap: clamp(12px, 2.4vh, 28px); }
@media (min-width: 760px) { .mn-cards { grid-template-columns: 1fr 1fr; } }
.mn-card { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: clamp(12px, 2.4vw, 36px); padding: clamp(14px, 3vh, 36px) clamp(16px, 2.6vw, 40px); background: var(--card); border: 1.5px solid var(--print); border-radius: 16px 20px 14px 18px; color: var(--print); text-decoration: none; box-shadow: 5px 6px 0 var(--rule); transition: translate .15s, box-shadow .15s; }
.mn-card::before { content: ""; position: absolute; top: -11px; left: 50%; width: 90px; height: 22px; translate: -50% 0; rotate: -3deg; background: var(--tape); }
.mn-card:hover, .mn-card:focus-visible { translate: 0 -4px; box-shadow: 6px 10px 0 var(--rule); }
.mn-pic { display: grid; place-items: center; width: clamp(64px, 17vh, 190px); aspect-ratio: 1; }
.mn-pic .sk, .mn-pic .stamp, .mn-pic .stamp svg { width: 100%; height: 100%; }
.mn-body { display: grid; gap: clamp(2px, .6vh, 8px); min-width: 0; }
.mn-title { font-size: clamp(1.35rem, 4.4vh, 2.8rem); font-weight: 700; line-height: 1.2; }
.mn-note .mn-title, .mn-missions .mn-title { color: var(--blue); } .mn-lab .mn-title { color: var(--red); }
.mn-sub { color: var(--print-soft); font-size: clamp(.95rem, 2.3vh, 1.45rem); line-height: 1.4; }
.mn-quip { font-size: clamp(1rem, 2.3vh, 1.5rem); color: var(--pencil); }
.mn-bar { display: block; height: clamp(10px, 1.4vh, 14px); max-width: 420px; background: var(--paper); border: 1.5px solid var(--print); border-radius: 6px; overflow: hidden; }
.mn-bar i { display: block; height: 100%; background: var(--highlight); }
.mn-count { font-size: clamp(.9rem, 1.9vh, 1.25rem); color: var(--print-soft); } .mn-count b { color: var(--print); }
.mn-go { font-size: clamp(1.6rem, 4vh, 2.8rem); color: var(--blue); line-height: 1; transition: translate .15s; }
.mn-card:hover .mn-go { translate: 4px 0; }
@media (max-width: 759px) { /* phone: four short rows, the whole menu fits one screen */
  .mn-cards { flex: none; grid-auto-rows: auto; align-content: start; gap: 14px; }
  .mn-hi h1 { font-size: 1.9rem; } .mn-hi p { font-size: 1.05rem; }
  .mn-card { grid-template-columns: 64px minmax(0, 1fr); padding: 14px 16px; gap: 14px; }
  .mn-pic { width: 64px; }
  .mn-title { font-size: 1.35rem; } .mn-sub { font-size: .92rem; } .mn-count { font-size: .85rem; }
  .mn-go, .mn-quip { display: none; }
}

/* Short Note list: one heading per O-NET strand */
.rd-strand { display: flex; align-items: baseline; gap: var(--space-xs); margin: var(--space-lg) 0 0; padding-bottom: 4px; border-bottom: 2px solid var(--print); color: var(--blue); }
.rd-strand small { font-weight: 400; font-size: .9rem; color: var(--print-soft); }
@media (max-width: 600px) { .rd-strip { --pic: 48px; gap: var(--space-xs) var(--space-sm); } .rd-strip figure { flex-basis: calc(var(--pic) + 24px); } .rd-strip figcaption { font-size: .8rem; overflow-wrap: anywhere; } }

/* math hands-on scene (js/sims/math.js + js/math/draw.js) */
.msim-wrap { position: relative; margin: 0 auto; flex: none; width: min(100cqw, calc((100cqh - 3.4em) * 220 / 140)); aspect-ratio: 220 / 140; }
.msim .mtxt { font-family: var(--font-hand); font-size: 11px; fill: var(--pencil); }
.msim .mnum { font: 700 13px var(--font-print); fill: var(--red); }
.msim .msmall { font-size: 8px; }
.msim .ray { fill: none; stroke: var(--pencil); stroke-width: 2.4; stroke-linecap: round; }
.msim .ray.red { stroke: var(--red); } .msim .ray.blue { stroke: var(--blue); }
.msim .half { fill: none; stroke: var(--red); stroke-width: 1.4; stroke-dasharray: 4 3; }
.msim .wedge { fill: none; stroke: var(--c-yellow); stroke-width: 56; transition: stroke-dasharray 1.2s var(--ease-out); }
.msim .mv { transform-box: view-box; transform-origin: 110px 122px; transition: transform 1.1s var(--ease-out); }
.msim .cell { animation: m-pop .25s var(--ease-out) both; animation-delay: calc(var(--i) * 70ms); }
.msim .late { animation: m-pop .3s var(--ease-out) 1.1s both; }
.msim .draw { stroke-dasharray: 600; animation: m-draw .9s var(--ease-out) both; }
@keyframes m-pop { from { opacity: 0; } }
@keyframes m-draw { from { stroke-dashoffset: 600; } to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .msim .cell, .msim .late, .msim .draw { animation: none; } .msim .mv, .msim .wedge, .msim .grow { transition: none; } }
/* subject picker + menu chips */
.mn-subjects .mn-card { font: inherit; text-align: left; cursor: pointer; }
.mn-chips { display: flex; gap: var(--space-xs); flex-wrap: wrap; justify-content: flex-end; }
.mn-switch { color: var(--blue); border-color: var(--blue); }

/* ================= notebook polish: summary, quiz, subject picker ================= */
/* summary on big landscape screens: teacher's note across the top, the record table full width under it (shorter laptops keep note | table side by side) */
@media (orientation: landscape) and (min-width: 600px) and (min-height: 860px) {
  .sumlay { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; align-content: start; gap: var(--space-lg); padding: 14px 6px 6px; }
  .sumlay .lined, .sumlay .sum { position: relative; border: 1.5px solid var(--print); border-radius: 14px 18px 12px 16px; box-shadow: 5px 6px 0 var(--rule); }
  .sumlay .lined { padding: .4em 1em; }
  .sumlay .lined::before { content: ''; position: absolute; top: -11px; left: 50%; width: 90px; height: 22px; translate: -50% 0; rotate: -3deg; background: var(--tape); }
  .sumlay .sum { border-collapse: separate; border-spacing: 0; overflow: hidden; }
  .sumlay .sum th { background: var(--highlight-soft); padding: .45em .8em; }
  .sumlay .sum td { padding: .5em .8em; }
  .sumlay .lined { font-size: 1.6rem; }
  .sumlay .sum th, .sumlay .sum td span { font-size: 1.45rem; }
  .sumlay .sum td span { display: inline; } /* items flow across the wide cell, a dot between */
  .sumlay .sum td span + span::before { content: ' · '; color: var(--pencil-soft); }
}

/* quiz: the whole question is one taped worksheet card that fills the page; each choice a hand-drawn answer box */
.quizlay { position: relative; justify-content: center; gap: clamp(10px, 2.6vh, 34px); margin: 14px 6px 8px; padding: clamp(16px, 4vh, 56px) clamp(16px, 3vw, 64px); background: var(--card); border: 1.5px solid var(--print); border-radius: 14px 18px 12px 16px; box-shadow: 5px 6px 0 var(--rule); overflow: auto; }
.quizlay::before { content: ''; position: absolute; top: -11px; left: 50%; width: 90px; height: 22px; translate: -50% 0; rotate: -3deg; background: var(--tape); }
.quizlay .q { padding-bottom: .5em; border-bottom: 2px dashed var(--rule); font-size: 1.9rem; line-height: 1.5; }
.quizlay .q-no { display: inline-grid; place-items: center; width: 1.8em; height: 1.8em; margin-right: .4em; border: 2px solid var(--red); border-radius: 50% 45% 52% 48%; color: var(--red); font-family: var(--font-hand); rotate: -6deg; }
.quizlay .choices { gap: clamp(10px, 2.4vh, 30px) clamp(12px, 2.4vw, 40px); }
.quizlay .choices li { display: flex; }
.quizlay .choice { min-height: clamp(56px, 12vh, 150px); padding: .4em 1em; font-size: 1.6rem; background: var(--card); border: 2px solid var(--blue); border-radius: var(--hand-box); color: var(--print); transition: translate .15s, box-shadow .15s, background .15s; }
.quizlay .choice:hover:not(:disabled) { background: var(--highlight-soft); translate: 0 -2px; box-shadow: 3px 4px 0 var(--rule); }
.quizlay .choice .letter { display: inline-grid; place-items: center; width: 1.7em; height: 1.7em; margin-right: .45em; background: var(--highlight-soft); border-radius: 50%; color: var(--blue); }
.quizlay .choice.right { border-color: var(--red); }
.quizlay .choice.wrong { border-style: dashed; border-color: var(--pencil-soft); }
.quizlay .note { min-height: 2.6em; padding: 0 .4em; font-size: 1.4rem; }
@media (max-height: 700px), (orientation: portrait) {
  .quizlay { padding: 14px 12px; gap: 10px; }
  .quizlay .q { font-size: 1.15rem; }
  .quizlay .choice { min-height: 48px; font-size: 1.02rem; }
  .quizlay .note { font-size: 1rem; }
}
/* ข้อสอบจริง: the same taped card as the chapter quiz; questions are longer and may carry a table or picture, so smaller type and the card scrolls */
.exam-card { justify-content: safe center; }
.exam-card > * { flex-shrink: 0; } /* a long question scrolls inside the card instead of squashing its table */
.exam-card .q { font-size: clamp(1.1rem, 1.4vh + .65rem, 1.65rem); }
.exam-card .choice { min-height: clamp(48px, 8vh, 100px); font-size: clamp(1rem, 1.2vh + .5rem, 1.45rem); }
.exam-card .ex-src { margin: 0; }
.exam-card .rd-table { margin: 0; }
.exam-card .rd-table table { min-width: 0; font-size: clamp(.9rem, 1.2vh + .45rem, 1.3rem); }
.exam-card .ex-tf { font-size: clamp(1rem, 1.2vh + .5rem, 1.4rem); }
.exam-card .ex-fig .ex-svg { max-height: 34vh; }
.exam-card .ex-figchoices .ex-svg { max-height: 16vh; }

/* subject picker: two big notebook buttons, the sketch large on top, the subject name huge */
.mn-subjects { grid-auto-rows: minmax(0, 1fr); }
.mn-subjects .mn-card { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto auto; justify-items: center; align-content: center; text-align: center; gap: clamp(8px, 2vh, 24px); border-width: 2.5px; }
.mn-subjects .mn-lab { border-color: var(--red); box-shadow: 7px 8px 0 oklch(62% 0.17 25 / 0.25); }
.mn-subjects .mn-note { border-color: var(--blue); box-shadow: 7px 8px 0 oklch(42% 0.14 262 / 0.22); }
.mn-subjects .mn-pic { width: clamp(110px, 32vh, 380px); min-height: 0; }
.mn-subjects .mn-title { font-size: clamp(2rem, 8vh, 5.4rem); }
.mn-subjects .mn-body { display: grid; justify-items: center; gap: 6px; width: min(100%, 30em); }
.mn-subjects .mn-bar { width: 100%; }
.mn-subjects .mn-go { font-size: clamp(1rem, 2.4vh, 1.6rem); padding: .3em 1.2em; border: 2px solid currentColor; border-radius: var(--hand-box); font-family: var(--font-hand); }
.mn-subjects .mn-lab .mn-go { color: var(--red); }
.mn-subjects .mn-go::before { content: 'เข้าห้องนี้ '; }
@media (max-width: 759px) {
  .mn-subjects { grid-auto-rows: minmax(0, 1fr); flex: 1 1 auto; }
  .mn-subjects .mn-card { grid-template-columns: 1fr; padding: 16px; }
  .mn-subjects .mn-pic { width: clamp(70px, 13vh, 200px); }
  .mn-subjects .mn-card { gap: 6px; padding: 14px 16px; }
  .mn-subjects .mn-sub { display: none; }
  .mn-deco .sk { width: clamp(34px, 6vh, 64px); }
  .mn-subjects .mn-title { font-size: clamp(1.8rem, 5vh, 3rem); }
  .mn-subjects .mn-go { display: inline-block; }
}
.mn-deco { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; pointer-events: none; } /* clips doodles, not the tape */
.mn-deco .sk { position: absolute; width: clamp(40px, 9vh, 110px); height: auto; opacity: .5; }
.mn-deco .sk:nth-child(1) { top: 7%; left: 5%; rotate: -12deg; }
.mn-deco .sk:nth-child(2) { top: 8%; right: 6%; rotate: 10deg; }
.mn-deco .sk:nth-child(3) { bottom: 8%; left: 6%; rotate: 8deg; }
.mn-deco .sk:nth-child(4) { bottom: 9%; right: 5%; rotate: -10deg; }
.mn-subjects .mn-pic, .mn-subjects .mn-body, .mn-subjects .mn-go { position: relative; }
.msim .grow { transform-box: fill-box; transform-origin: left; transition: transform 1.1s var(--ease-out); }
.msim .grow.up { transform-origin: bottom; }
.msim .f-red-soft { fill: var(--c-red); fill-opacity: .55; }

/* ================= English subject ================= */
.mn-eng .mn-title { color: oklch(48% 0.13 150); }
.mn-subjects .mn-eng { border-color: oklch(52% 0.13 150); box-shadow: 7px 8px 0 oklch(52% 0.13 150 / 0.22); }
.mn-subjects .mn-eng .mn-go { color: oklch(48% 0.13 150); }
@media (min-width: 760px) { .mn-subjects { grid-template-columns: repeat(3, minmax(0, 1fr)); } .mn-subjects .mn-title { font-size: clamp(1.8rem, 6vh, 4.2rem); } }
@media (max-width: 759px) { /* phone: three short side-by-side rows so all subjects fit one screen */
  .mn-subjects .mn-card { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto; justify-items: start; text-align: left; gap: 12px; padding: 10px 14px; }
  .mn-subjects .mn-pic { width: clamp(56px, 10vh, 110px); }
  .mn-subjects .mn-body { justify-items: start; }
  .mn-subjects .mn-title { font-size: clamp(1.5rem, 4vh, 2.4rem); }
  .mn-subjects .mn-go { display: none; }
  .mn-deco .sk:nth-child(n+3) { display: none; }
}

/* English activity scene: the picked card large, Thai meaning, sentence to hear */
.eng-stage { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-sm); width: 100%; min-height: 0; }
.eng-card { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: clamp(10px, 2vw, 32px); width: min(100%, 40em); padding: clamp(12px, 3vh, 36px) clamp(14px, 2.4vw, 40px); background: var(--card); border: 1.5px solid var(--print); border-radius: 14px 18px 12px 16px; box-shadow: 5px 6px 0 var(--rule); }
.eng-card::before { content: ''; position: absolute; top: -11px; left: 50%; width: 90px; height: 22px; translate: -50% 0; rotate: -3deg; background: var(--tape); }
.eng-pic .sk { width: clamp(70px, 20vh, 220px); height: auto; }
.eng-words { display: grid; gap: .3em; min-width: 0; }
.eng-word { font-size: clamp(1.3rem, 3.4vh + .4rem, 2.6rem); line-height: 1.2; color: var(--blue); overflow-wrap: anywhere; }
.eng-th { font-size: clamp(1rem, 1.6vh + .5rem, 1.5rem); color: var(--red); }
.eng-say { font-size: clamp(1rem, 1.6vh + .45rem, 1.5rem); color: var(--print); font-style: italic; }
.eng-speak { min-height: 40px; }
.ex-read { display: block; margin: 0 0 .6em; padding: .6em .9em; font-weight: 400; font-size: .92em; line-height: 1.5; background: var(--paper); border-left: 4px solid var(--rule); border-radius: 4px; max-height: 40vh; overflow-y: auto; }
@media (orientation: portrait), (max-height: 700px) { /* phone: the card shares the top half with the instructions */
  .eng-stage { gap: 4px; }
  .eng-card { padding: 8px 12px; gap: 10px; }
  .eng-card::before { width: 60px; height: 14px; top: -7px; }
  .eng-pic .sk { width: clamp(48px, 9vh, 110px); }
  .eng-word { font-size: clamp(1.05rem, 2.2vh + .3rem, 1.6rem); }
  .eng-th, .eng-say { font-size: clamp(.88rem, 1vh + .4rem, 1.1rem); }
  .eng-speak { min-height: 34px; padding: 2px 12px; }
}
/* exam card: passages and tables need the room, so tighter spacing than the chapter quiz */
.quizlay.exam-card { justify-content: flex-start; gap: clamp(6px, 1.4vh, 18px); padding-block: clamp(12px, 2.4vh, 32px); }
.exam-card .q { font-size: clamp(1.05rem, 1.4vh + .55rem, 1.6rem); padding-bottom: .3em; }
.exam-card .choice { min-height: clamp(44px, 7vh, 90px); font-size: clamp(1rem, 1.2vh + .5rem, 1.4rem); }
.exam-card .ex-read { max-height: 32vh; }
.exam-card .rd-table th, .exam-card .rd-table td { padding: .2em .7em; line-height: 1.3; }
/* wide screens: a table / figure goes left, the choices right, so the answers never drop below the screen */
@media (orientation: landscape) and (min-width: 900px) {
  .quizlay.exam-card:has(> .rd-table, > .ex-fig, > .ex-code, > .ex-flow) { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); grid-template-rows: auto auto auto 1fr; column-gap: clamp(16px, 2.4vw, 40px); align-content: start; }
  .exam-card:has(> .rd-table, > .ex-fig, > .ex-code, > .ex-flow) > .q { grid-column: 1 / -1; }
  .exam-card:has(> .rd-table, > .ex-fig, > .ex-code, > .ex-flow) > :is(.rd-table, .ex-fig, .ex-code, .ex-flow) { grid-column: 1; grid-row: 2 / span 3; align-self: start; }
  .exam-card:has(> .rd-table, > .ex-fig, > .ex-code, > .ex-flow) > :is(.ex-src, .choices, .note) { grid-column: 2; }
  .exam-card:has(> .rd-table, > .ex-fig, > .ex-code, > .ex-flow) > .choices { grid-template-columns: 1fr; }
}
@media (max-height: 820px) {
  .quizlay.exam-card { padding-block: 10px; gap: 6px; margin-top: 10px; }
  .exam-card .q { font-size: 1.05rem; line-height: 1.4; }
  .exam-card .choice { min-height: 40px; padding-block: .2em; font-size: 1rem; }
  .exam-card .note { min-height: 0; font-size: 1rem; line-height: 1.35; }
  .exam-card .choices { gap: 6px 16px; }
}

/* Ranking board (#rank) */
.rk-me { font-size: 1.15rem; margin: 0 0 var(--space-xs); }
.rk-me b { font-size: 1.8rem; color: var(--red); }
.rk-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.rk-list li { display: flex; align-items: center; gap: var(--space-xs); padding: 8px 6px; border-bottom: 1px dashed var(--tape); }
.rk-list li.me { background: var(--card); outline: 2px solid var(--blue); border-radius: 6px; }
.rk-no { width: 2.2em; text-align: center; font-size: 1.3rem; }
.rk-list li:nth-child(-n+3) .rk-no { color: var(--red); font-size: 1.6rem; }
.rk-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.rk-name small { opacity: .55; }
.rk-pt { font-size: 1.15rem; }
