/* Pixel-art HUD over the Phaser shop scene (D29). Frames are wood or paper, edges are hard pixel steps
   (box-shadow rings, no rounded corners). Everything on the scene is sized in backdrop pixels via --u, so
   pins and cards stay glued to the objects painted in the image at any window size.
   Status never relies on colour alone: every tone also has an icon and words. */
@font-face {
  font-family: 'VT323';
  src: url('/vendor/fonts/vt323-vietnamese.woff2') format('woff2');
  font-display: swap;
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'VT323';
  src: url('/vendor/fonts/vt323-latin.woff2') format('woff2');
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --night: #120b07;
  --wood-0: #1a0f08;
  --wood-1: #2a190e;
  --wood-2: #3b2516;
  --wood-3: #6b4426;
  --wood-4: #93603a;
  --paper: #efe0bf;
  --paper-hi: #fff4dc;
  --paper-lo: #c9b28a;
  --ink: #2b1d12;
  --ink-soft: #6a543c;
  --cream: #f6e7c8;
  --amber: #ffd36a;
  --amber-lo: #d79b2e;
  --good: #2f6b34;
  --bad: #a3392b;
  --good-on-dark: #9fe08a;
  --bad-on-dark: #ff9a84;
  --stale: #8a7a66;
  --select: #e0a52e;
  --line: #b59c74;
  --px: 3px;
  color-scheme: light;
}
/* The HUD is diegetic (wood and paper inside the shop), so it keeps the same palette in dark mode;
   only the letterbox around the scene follows the system theme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) { --night: #0b0705; color-scheme: dark; }
}
:root[data-theme='dark'] { --night: #0b0705; color-scheme: dark; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(ellipse at center, #24160d 0%, var(--night) 70%);
  color: var(--cream);
  font: 20px/1.2 'VT323', 'Courier New', monospace;
  display: grid;
  place-items: center;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; }

#stage {
  position: relative;
  width: min(100vw, calc(100vh * 1672 / 941));
  height: min(100vh, calc(100vw * 941 / 1672));
  container-type: size;
  overflow: hidden;
  box-shadow: 0 0 0 var(--px) var(--wood-0), 0 20px 60px rgba(0, 0, 0, 0.6);
}
#world { position: absolute; inset: 0; }
/* The canvas is drawn at the plate's own resolution and only ever scaled down to fit: smooth downscaling keeps
   the pixel art crisp, nearest-neighbour downscaling drops pixels and looks smeared. */
#world canvas { display: block; image-rendering: auto !important; } /* Phaser sets pixelated inline when pixelArt is on */
#app { position: absolute; inset: 0; --u: calc(100cqw / 1672); pointer-events: none; }
#app > * { pointer-events: auto; }
#app > .toast { pointer-events: none; } /* HUY-160: the rule above beat `.toast { pointer-events: none }`, so a faded toast still caught the clicks meant for the buttons under it */
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud > * { pointer-events: auto; }
/* HUY-158 (L1-L3): the click areas (`.hs-area`) come after the cards in the DOM and sat over their buttons. Cards that hold buttons get z-index 1
   (above the areas, which stay auto); `isolation` keeps that z-index inside the HUD so panels and the story, drawn after it, still cover it. */
.hud { isolation: isolate; }
.hud > .task-card, .hud > .cr-board, .hud > .cr-bubble { z-index: 1; }
.loading, .fatal { position: absolute; inset: 0; display: grid; place-content: center; padding: 24px; text-align: center; font-size: 26px; color: var(--cream); }
.fatal ul { text-align: left; }

/* ---------- frames ---------- */
.wood {
  background: linear-gradient(180deg, var(--wood-2), #33200f);
  color: var(--cream);
  box-shadow: 0 0 0 var(--px) var(--wood-0), inset 0 0 0 var(--px) var(--wood-3), inset 0 0 0 calc(var(--px) * 2) var(--wood-1), 0 calc(var(--px) * 2) 0 var(--px) rgba(0, 0, 0, 0.35);
}
.paper {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 0 0 var(--px) var(--wood-1), inset 0 0 0 var(--px) var(--paper-hi), inset 0 0 0 calc(var(--px) * 2) var(--paper-lo), calc(var(--px) * 2) calc(var(--px) * 2) 0 var(--px) rgba(0, 0, 0, 0.35);
}

/* ---------- buttons ---------- */
.px-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  background: var(--cream);
  color: var(--ink);
  padding: 4px 12px 5px;
  min-height: 34px;
  font-size: 22px;
  line-height: 1.05;
  box-shadow: 0 0 0 2px var(--wood-1), inset -2px -3px 0 var(--paper-lo), inset 2px 2px 0 var(--paper-hi);
  transition: transform 60ms;
}
.px-btn:hover:not(:disabled) { background: #fff2cf; }
.px-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 0 0 2px var(--wood-1), inset 2px 2px 0 var(--paper-lo); }
.px-btn:focus-visible { outline: 3px dashed var(--select); outline-offset: 3px; }
.px-btn.primary { background: var(--amber); box-shadow: 0 0 0 2px var(--wood-1), inset -2px -3px 0 var(--amber-lo), inset 2px 2px 0 #fff0b8; }
.px-btn.primary:hover:not(:disabled) { background: #ffe08a; }
.px-btn[aria-pressed='true'] { background: #2f5d7c; color: #fff; box-shadow: 0 0 0 2px var(--wood-1), inset -2px -3px 0 #1d3e55, inset 2px 2px 0 #5d8fb3; }
.px-btn:disabled { opacity: 0.45; cursor: not-allowed; }
/* Pixel-art tool icons (B2) sit left of the label; they are drawn larger than the scene's pixels, so scale smoothly. */
.px-btn.has-icon { display: inline-flex; align-items: center; gap: 8px; text-align: left; }
.act-icon { flex: none; width: 60px; height: 52px; object-fit: contain; image-rendering: auto; margin: -4px 0; }
.file-btn { display: inline-flex; align-items: center; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-btn:focus-within { outline: 3px dashed var(--select); outline-offset: 3px; }

/* ---------- HUD cards ---------- */
.title-card { position: absolute; padding: calc(var(--u) * 10) calc(var(--u) * 22); display: grid; align-content: center; }
.title-card h1 { margin: 0; font-size: calc(var(--u) * 58); line-height: 0.95; font-weight: 400; color: var(--amber); text-shadow: calc(var(--u) * 3) calc(var(--u) * 3) 0 var(--wood-0); letter-spacing: 0.02em; }
.title-card .sub { margin: calc(var(--u) * 4) 0 0; font-size: max(18px, calc(var(--u) * 25)); color: var(--cream); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats { position: absolute; display: flex; gap: calc(var(--u) * 8); }
.chip { background: rgba(26, 15, 8, 0.86); color: var(--cream); padding: calc(var(--u) * 2) calc(var(--u) * 10); font-size: max(18px, calc(var(--u) * 24)); box-shadow: 0 0 0 2px var(--wood-0), inset 0 0 0 2px var(--wood-3); }

.task-card { position: absolute; padding: calc(var(--u) * 12) calc(var(--u) * 14) calc(var(--u) * 12) calc(var(--u) * 18); overflow: hidden; font-size: max(18px, calc(var(--u) * 24)); line-height: 1.02; }
.task-card::before { content: ''; position: absolute; left: calc(var(--u) * 6); top: calc(var(--u) * 14); bottom: calc(var(--u) * 14); width: calc(var(--u) * 6);
  background: repeating-linear-gradient(180deg, var(--wood-1) 0 calc(var(--u) * 6), transparent calc(var(--u) * 6) calc(var(--u) * 16)); }
.task-card p { margin: 0 0 calc(var(--u) * 6) calc(var(--u) * 6); }
.task-title { font-size: calc(var(--u) * 32); color: var(--ink); border-bottom: 2px solid var(--paper-lo); padding-bottom: calc(var(--u) * 4); }
.task-head { color: var(--ink-soft); }
.task-quote { font-style: italic; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-next { color: #7a3a14; }

/* Pins sit where the concept image had its painted labels; they stay opaque and still. */
.pin {
  position: absolute;
  height: calc(var(--u) * 38);
  margin-top: calc(var(--u) * -1);
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 8);
  padding: 0 calc(var(--u) * 10) 0 calc(var(--u) * 5);
  border: 0;
  cursor: pointer;
  background: #1d140e;
  color: var(--cream);
  font-size: calc(var(--u) * 26);
  white-space: nowrap;
  box-shadow: 0 0 0 calc(var(--u) * 3) #0e0905, inset 0 0 0 calc(var(--u) * 2) #4a3524;
}
.pin .px-icon { width: calc(var(--u) * 28); height: calc(var(--u) * 28); flex: none; background: var(--cream); fill: #1d140e; padding: calc(var(--u) * 4); }
.pin:hover:not(:disabled), .pin:focus-visible { background: #3a2716; color: var(--amber); box-shadow: 0 0 0 calc(var(--u) * 3) var(--amber), inset 0 0 0 calc(var(--u) * 2) #4a3524; outline: none; }
.pin:hover .px-icon, .pin:focus-visible .px-icon { background: var(--amber); }
.pin.is-suggested { animation: pin-pulse 1.1s steps(2, jump-none) infinite; }
.pin.is-suggested .px-icon { background: var(--amber); }
.pin:disabled { cursor: default; }
@keyframes pin-pulse {
  from { box-shadow: 0 0 0 calc(var(--u) * 3) #0e0905, inset 0 0 0 calc(var(--u) * 2) #4a3524; }
  to { box-shadow: 0 0 0 calc(var(--u) * 3) var(--amber), 0 0 0 calc(var(--u) * 7) rgba(255, 211, 106, 0.35), inset 0 0 0 calc(var(--u) * 2) #4a3524; }
}
.hs-area { position: absolute; background: transparent; border: 0; padding: 0; cursor: pointer; }
.hs-area:disabled { cursor: default; }

.bubble { position: absolute; transform: translateY(-100%); padding: calc(var(--u) * 14) calc(var(--u) * 18); font-size: calc(var(--u) * 26); line-height: 1.05; }
.bubble::after { content: ''; position: absolute; left: calc(var(--u) * 130); bottom: calc(var(--u) * -18); width: calc(var(--u) * 18); height: calc(var(--u) * 18);
  background: var(--paper); box-shadow: 3px 3px 0 var(--wood-1); clip-path: polygon(0 0, 100% 0, 0 100%); }
/* Peeking customer (HUY-79): the bubble sits right of the door post, its tail pointing left at the face. */
.bubble.from-left { transform: none; }
.bubble.arriving.from-left { animation-name: pop-top; }
.bubble.from-left::after { left: calc(var(--u) * -18); top: calc(var(--u) * 70); bottom: auto; clip-path: polygon(100% 0, 100% 100%, 0 0); box-shadow: none; }
.bubble p { margin: 0 0 calc(var(--u) * 8); }
.bubble-who { color: var(--ink-soft); }
.bubble-text { font-size: calc(var(--u) * 26); }
.bubble.arriving { animation: pop 0.25s steps(3) 2s both; }
@keyframes pop-top { from { opacity: 0; transform: translateY(-8%); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(-90%); } to { opacity: 1; transform: translateY(-100%); } }

/* System buttons sit along the top edge, left of the task card: clear of the pins and the story box. */
.corner { position: absolute; right: calc(var(--u) * 340); top: calc(var(--u) * 16); display: flex; gap: 8px; }
.corner .px-btn { font-size: max(18px, calc(var(--u) * 24)); }
.concept-note { position: absolute; left: calc(var(--u) * 12); bottom: calc(var(--u) * 8); margin: 0; font-size: max(18px, calc(var(--u) * 18)); color: rgba(246, 231, 200, 0.85); background: rgba(14, 9, 5, 0.7); padding: 0 8px; }

/* ---------- story ---------- */
.hud.is-story .pin, .hud.is-story .task-card, .hud.is-story .stats { filter: saturate(0.6) brightness(0.8); }
/* The chapter's title card sits over the middle of the scene for the first 4.2 s of a story (`chapter` above); the pins wait until it is gone,
   then come back in 0.4 s, so the two are never on screen together (HUY-137, Q17). */
.hud.has-card .pin, .hud.has-card .hs-area { animation: card-pins 0.4s steps(4) 4.2s both; }
@keyframes card-pins { from { opacity: 0; } to { opacity: 1; } }
.narration {
  position: absolute;
  left: 50%;
  bottom: calc(var(--u) * 26);
  transform: translateX(-50%);
  width: min(calc(var(--u) * 1180), calc(100% - 24px));
  padding: calc(var(--u) * 18) calc(var(--u) * 28) calc(var(--u) * 16);
  font-size: max(20px, calc(var(--u) * 33));
  line-height: 1.1;
  animation: rise 0.2s steps(3);
}
.narration .prov { margin: 0 0 6px; font-size: max(18px, calc(var(--u) * 20)); color: var(--amber); opacity: 0.85; }
.narration .speaker { margin: 0; color: var(--amber); }
.narration-text { margin: 4px 0 10px; min-height: 2.2em; }
.narration.kind-placeholder { background: repeating-linear-gradient(135deg, #3b2516 0 14px, #44291a 14px 28px); }
.narration.kind-placeholder .narration-text { color: #ffe7b0; }
.ending-art { position: absolute; inset: 0; background: #1c120c center / cover no-repeat; }
.ending-art::after { content: ''; position: absolute; inset: 0; background: var(--tint, #000); opacity: var(--dim, 0); pointer-events: none; }
.ending-pending { position: absolute; top: calc(var(--u) * 180); left: 50%; transform: translateX(-50%); margin: 0; font-size: max(16px, calc(var(--u) * 22)); }
.chapter-card { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; animation: chapter 4.2s steps(12) both; }
.chapter-card p { margin: 0; font-size: calc(var(--u) * 34); color: var(--cream); text-shadow: 3px 3px 0 #000; }
.chapter-card h2 { margin: 0; font-size: calc(var(--u) * 96); font-weight: 400; color: var(--amber); text-shadow: calc(var(--u) * 5) calc(var(--u) * 5) 0 #000; }
@keyframes chapter { 0% { opacity: 0; } 15%, 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes rise { from { transform: translate(-50%, 12px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ---------- modal panels ---------- */
.scrim { position: absolute; inset: 0; background: rgba(12, 7, 4, 0.5); }
.modal {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(calc(var(--u) * 980), calc(100% - 24px));
  max-height: calc(100% - 24px);
  display: flex;
  flex-direction: column;
  font-size: clamp(19px, calc(var(--u) * 26), 26px);
  line-height: 1.12;
  animation: open 0.16s steps(3);
}
.modal.wide { width: min(calc(var(--u) * 1440), calc(100% - 24px)); }
@keyframes open { from { transform: translate(-50%, -46%); opacity: 0; } to { transform: translate(-50%, -50%); opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px 6px 20px; }
.modal-head h2 { margin: 0; font-size: 1.45em; font-weight: 400; outline: none; }
.modal-head .status { color: var(--ink-soft); font-size: 0.8em; }
.modal-body { overflow: auto; padding: 4px 20px 18px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 8px; border-bottom: 3px solid var(--paper-lo); }
.tab { appearance: none; border: 0; cursor: pointer; background: var(--paper-lo); color: var(--ink); padding: 3px 12px; font-size: 0.95em; box-shadow: 0 0 0 2px var(--wood-1); }
.tab.is-active { background: var(--paper-hi); }
.tab.is-suggested::after { content: ' ●'; color: #c0472f; }
.tab:focus-visible { outline: 3px dashed var(--select); outline-offset: 2px; }

.modal h3 { margin: 14px 0 6px; font-size: 0.95em; font-weight: 400; color: #7a3a14; letter-spacing: 0.02em; }
.modal p { margin: 4px 0; }
.modal ul { margin: 4px 0; padding-left: 1.2em; }
.plain { list-style: none; margin: 0; padding: 0 !important; display: grid; gap: 8px; }
.row { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.label { color: var(--ink-soft); }
.seg { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.85em; }
.modal.paper .small { font-size: max(18px, 0.85em); } /* HUY-137, Q15: the 18 px floor outside the bench too */
.tag { display: inline-block; font-size: max(18px, 0.8em); padding: 0 6px; background: var(--wood-2); color: var(--cream); margin-right: 4px; }
.notice { background: #fff3c4; box-shadow: 0 0 0 2px var(--amber-lo); padding: 8px 12px; margin: 8px 0; }
.safety { margin-top: 14px !important; font-size: 0.85em; color: var(--ink-soft); border-top: 2px dashed var(--paper-lo); padding-top: 8px; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.cols3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.checks { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.checks li.hint .px-btn { background: var(--amber); }
.jobs .px-btn, .checks .px-btn { width: 100%; text-align: left; }
.history { font-size: 0.9em; }
.check { cursor: pointer; }
.q-art { display: none; }
.check input { width: 18px; height: 18px; vertical-align: -2px; accent-color: #2f5d7c; }
.qa-state { display: inline-block; min-width: 12ch; }
.parts li { display: flex; gap: 8px; align-items: center; }
.drawer { width: 22px; height: 16px; background: var(--wood-4); box-shadow: 0 0 0 2px var(--wood-1), inset 0 -4px 0 var(--wood-3); flex: none; }
.outcome { font-size: 1.1em; }
.principle { background: #fff3c4; padding: 8px 12px; box-shadow: 0 0 0 2px var(--amber-lo); }
.page { border-bottom: 2px dashed var(--paper-lo); padding-bottom: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 0.9em; }
th, td { text-align: left; padding: 3px 6px; border-bottom: 2px solid var(--paper-lo); }
th { color: var(--ink-soft); font-weight: 400; }
tr.stale td { color: var(--stale); }
.badge { white-space: nowrap; }
.badge.tone-good { color: var(--good); }
.badge.tone-bad { color: var(--bad); }
.badge.tone-stale { color: var(--stale); }
.hints li { margin-bottom: 6px; }
.hyp-form { display: grid; gap: 6px; margin-top: 6px; }
.hyp-form label { display: grid; gap: 2px; color: var(--ink-soft); }
.hyp-form input, .hyp-form select { background: var(--paper-hi); color: var(--ink); border: 0; box-shadow: 0 0 0 2px var(--wood-1); padding: 3px 8px; font-size: 1em; }
.hyp-form button { justify-self: start; }

/* TV close-up and the diagram sheet. */
.inspect { display: grid; grid-template-columns: minmax(260px, 0.8fr) 1.2fr; gap: 18px; align-items: start; }
.crt { margin: 0; text-align: center; }
.crt canvas { width: 100%; height: auto; image-rendering: pixelated; display: block; background: #2a1a10; box-shadow: 0 0 0 3px var(--wood-1); }
.crt figcaption { margin-top: 6px; }
/* TV cabinet as an image (brief B1): the screen canvas covers the measured glass, rounded like the tube; the sound
   marks sit just right of the speaker grille. */
.crt-art { position: relative; width: 100%; margin: 0 auto; background: center / 100% 100% no-repeat; }
.crt .crt-art canvas { position: absolute; box-shadow: none; background: none; image-rendering: pixelated; }
.crt .crt-art canvas[data-crt] { border-radius: 8% / 10%; }
.crt .crt-art canvas[data-crt-sound] { left: 100%; top: 52%; width: 9%; height: auto; }
.sheet { background: var(--paper-hi); box-shadow: 0 0 0 2px var(--paper-lo), 4px 4px 0 2px rgba(0, 0, 0, 0.15); padding: 8px 10px; }
.caption { font-size: 0.85em; color: var(--ink-soft); }
svg.diagram { width: 100%; height: auto; display: block; font-family: 'VT323', monospace; }
.diagram text { fill: var(--ink); font-size: 20px; }
.diagram .small { font-size: 18px; }
.wire, .cable { fill: none; stroke: var(--ink-soft); stroke-width: 3; }
.cable-drop { stroke: var(--ink-soft); stroke-width: 2; stroke-dasharray: 3 3; }
.arrow-head { fill: var(--ink-soft); }
.block rect, .link-hit { fill: #fffaf0; stroke: var(--wood-1); stroke-width: 3; }
.block, .link { cursor: pointer; }
.block:hover rect, .link:hover .link-hit { fill: #fff3c4; }
.block.is-selected rect, .link.is-selected .link-hit { fill: #ffe7a0; stroke: var(--select); stroke-width: 5; }
.block:focus-visible, .link:focus-visible { outline: none; }
.block:focus-visible rect, .link:focus-visible .link-hit { stroke: var(--select); stroke-width: 5; stroke-dasharray: 6 3; }
.tone-good .block-status, .output-status.tone-good { fill: var(--good); }
.tone-bad .block-status, .output-status.tone-bad { fill: var(--bad); }
.tone-bad .cable { stroke: var(--bad); stroke-dasharray: 6 5; }
.tone-stale .block-status, .output-status.tone-stale { fill: var(--stale); }
.tone-unknown .block-status, .output-status.tone-unknown { fill: var(--ink-soft); }
.output rect { fill: none; stroke: var(--ink-soft); stroke-width: 2; stroke-dasharray: 4 4; }
.output text { fill: var(--ink-soft); }

/* ---------- working day (D31) ---------- */
.clock { display: inline-flex; align-items: center; gap: calc(var(--u) * 8); }
.clock-sun { width: calc(var(--u) * 14); height: calc(var(--u) * 14); background: var(--amber); box-shadow: 0 0 0 calc(var(--u) * 2) #7a4a14; }
.clock-bar { position: relative; width: calc(var(--u) * 120); height: calc(var(--u) * 12); background: #3a2516; box-shadow: inset 0 0 0 calc(var(--u) * 2) #0e0905; }
.clock-bar > span { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #ffd36a, #ff9a4a 70%, #c0472f); box-shadow: inset 0 0 0 calc(var(--u) * 2) #0e0905; }
.clock.late .clock-text { color: #ffcf7a; }
.clock.over { box-shadow: 0 0 0 2px var(--wood-0), inset 0 0 0 2px var(--bad-on-dark); }
.clock.over .clock-sun { background: #6a5a8a; box-shadow: 0 0 0 calc(var(--u) * 2) #2a2040; }
.clock.over .clock-text { color: var(--bad-on-dark); }
.modal-clock { padding: 0 16px 6px; }
.modal-clock .chip { font-size: 0.9em; }
.modal-clock .clock-bar { width: 140px; height: 10px; }
.modal-clock .clock-sun { width: 12px; height: 12px; }
.door-chip { cursor: pointer; border: 0; font-size: max(18px, 0.85em); animation: pin-pulse 1.1s steps(2, jump-none) infinite; }
.door-chip.late { color: var(--bad-on-dark); }
.bubble-wait { color: var(--ink-soft); font-size: max(18px, calc(var(--u) * 22)); }
.bubble-wait.late { color: var(--bad); }
.task-warn { color: var(--bad); }
.task-card .px-btn { font-size: max(18px, calc(var(--u) * 24)); margin-left: calc(var(--u) * 6); }
.modal ul.warn { list-style: none; padding: 6px 12px; background: #fde3d8; box-shadow: 0 0 0 2px var(--bad); }
.modal ul.warn li::before { content: '! '; color: var(--bad); }

/* ---------- first-job walkthrough (D33) ---------- */
.father-tip { position: absolute; padding: calc(var(--u) * 12) calc(var(--u) * 16); font-size: max(18px, calc(var(--u) * 25)); line-height: 1.05; animation: pop-in 0.25s steps(3) both;
  box-shadow: 0 0 0 calc(var(--u) * 3) var(--wood-0), inset 0 0 0 calc(var(--u) * 3) var(--amber), calc(var(--u) * 6) calc(var(--u) * 6) 0 rgba(0, 0, 0, 0.35); }
.father-tip p { margin: 0 0 calc(var(--u) * 8); }
.father-tip .tip-who { color: #7a3a14; }
.father-tip .tag { font-size: max(18px, calc(var(--u) * 18)); }
.father-tip .px-btn { font-size: max(18px, calc(var(--u) * 22)); } /* HUY-137 (Q15): 18 px floor for the HUD too (tip, wait line, door chip, task button) */
@keyframes pop-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.tip-strip { color: var(--ink); margin: 0 16px 6px; padding: 6px 12px; background: #fff3c4; box-shadow: 0 0 0 2px var(--amber-lo), inset 0 0 0 2px #fff8dc; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.tip-strip p { margin: 0; flex: 1 1 22em; }
.tip-strip .row { display: flex; gap: 8px; }
.pin.is-guided, .px-btn.is-guided, .tab.is-guided { animation: guided 0.9s steps(2, jump-none) infinite; }
.pin.is-guided::after { content: '▼'; position: absolute; left: 50%; top: calc(var(--u) * -34); transform: translateX(-50%); color: var(--amber); font-size: calc(var(--u) * 30); text-shadow: calc(var(--u) * 2) calc(var(--u) * 2) 0 #0e0905; }
@keyframes guided {
  from { box-shadow: 0 0 0 calc(var(--u) * 3) #0e0905; }
  to { box-shadow: 0 0 0 calc(var(--u) * 3) var(--amber), 0 0 0 calc(var(--u) * 9) rgba(255, 211, 106, 0.45); }
}

/* ---------- toast, busy ---------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--u) * 28);
  transform: translateX(-50%);
  max-width: min(calc(var(--u) * 900), calc(100% - 24px));
  margin: 0;
  padding: 8px 18px;
  font-size: max(19px, calc(var(--u) * 27));
  background: rgba(26, 15, 8, 0.94);
  color: var(--cream);
  box-shadow: 0 0 0 3px var(--wood-0), inset 0 0 0 2px var(--good-on-dark);
  animation: toast 6s steps(30) both;
  pointer-events: none;
}
.toast.error { box-shadow: 0 0 0 3px var(--wood-0), inset 0 0 0 2px var(--bad-on-dark); }
@keyframes toast { 0% { opacity: 0; } 4%, 85% { opacity: 1; } 100% { opacity: 0; } }
.busy { position: absolute; inset: 0; cursor: wait; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; }
  /* HUY-142: the 1ms rule above ran the toast's whole life in 1ms and left it at opacity 0. Reduced motion means no
     fade, not no message: it stands still for the same 6 seconds, then goes (a step, not a fade). The resume delay
     (inline, `!important`) still applies. */
  .toast { animation-name: toast-still; animation-duration: 6s !important; animation-timing-function: step-end; }
  @keyframes toast-still { 0% { opacity: 1; } 100% { opacity: 0; } }
}

/* Narrow or short screens: the scene stays on top, panels and story take the whole viewport. */
@media (max-width: 760px), (max-height: 460px) {
  body { place-items: start center; overflow: auto; }
  .modal, .modal.wide { position: fixed; inset: 8px; transform: none; width: auto; max-height: none; animation: none; }
  .narration { position: fixed; bottom: 8px; width: calc(100vw - 16px); }
  .scrim { position: fixed; }
  .inspect, .cols2, .cols3 { grid-template-columns: 1fr; }
  .corner { position: fixed; right: 8px; bottom: 8px; }
  .toast { position: fixed; bottom: 8px; }
}

/* Hand-over cutscene (HUY-79): pixel-block wipe over the page, a framed close-up, the customer's words typed out. */
.cutscene { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; cursor: pointer; }
.cut-blocks { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; pointer-events: none; }
.cut-frame { position: relative; margin: 0; width: min(86vw, 140vh); aspect-ratio: 16 / 9; padding: 10px; background: #1c120c; box-shadow: 0 0 0 4px var(--wood-1), 0 0 0 9999px #1c120c; }
.cut-frame[hidden] { display: none; }
.cut-art { width: 100%; height: 100%; background-repeat: no-repeat; image-rendering: pixelated; }
.cut-tag { position: absolute; top: 18px; right: 18px; padding: 2px 8px; background: #1c120cd0; color: var(--cream); font-size: 18px; }
.cut-say { position: absolute; left: 6%; right: 6%; bottom: 6%; padding: 12px 18px; font-size: clamp(20px, 2.4vw, 30px); line-height: 1.15; min-height: 3.2em; }
.cut-who { display: block; font-size: 0.75em; color: #7a3a14; margin-bottom: 2px; }
.cut-hint { position: absolute; bottom: 10px; right: 16px; margin: 0; color: #f6e7c880; font-size: 18px; pointer-events: none; }

/* Parts chest (HUY-79): RPG-style inventory. Drawers on the left, the picked part on the right. */
.inv { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 1.2fr); gap: 18px; align-items: start; }
.inv-grid { list-style: none; margin: 0; padding: 12px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; background: var(--wood-3, #6b4527); box-shadow: 0 0 0 3px var(--wood-1), inset 3px 3px 0 #8a5d36, inset -3px -3px 0 #3d2715; }
.slot { aspect-ratio: 1; position: relative; }
.slot > button, .slot.is-empty { width: 100%; height: 100%; display: grid; place-items: center; padding: 6px; border: 0; cursor: pointer; background: #2e1d10; box-shadow: inset 3px 3px 0 #1a0f08, inset -2px -2px 0 #5a3b22; }
.slot.is-empty { cursor: default; opacity: 0.7; }
.slot img { width: 100%; height: 100%; object-fit: contain; image-rendering: auto; pointer-events: none; }
.slot-glyph { font-size: clamp(28px, 3vw, 44px); color: #e8c48a; text-shadow: 2px 2px 0 #1a0f08; }
.slot-count { position: absolute; right: 6px; bottom: 2px; font-size: 24px; color: #fff4dc; text-shadow: 2px 0 0 #1a0f08, -2px 0 0 #1a0f08, 0 2px 0 #1a0f08, 0 -2px 0 #1a0f08; }
.slot-held { position: absolute; left: 4px; top: 4px; padding: 0 5px; font-size: 16px; background: var(--cream); color: var(--ink); box-shadow: 0 0 0 2px var(--wood-1); }
.slot-coming { position: absolute; right: 5px; top: 3px; font-size: 20px; color: #ffd36a; text-shadow: 2px 2px 0 #1a0f08; }
.slot.is-out img, .slot.is-out .slot-glyph { opacity: 0.4; filter: grayscale(0.6); }
.slot.is-picked > button { box-shadow: inset 0 0 0 3px var(--amber, #ffd36a), inset 5px 5px 0 #1a0f08; background: #3a2616; }
.slot.is-missing > button { animation: slot-missing 1s steps(2, jump-none) infinite; }
@keyframes slot-missing { 50% { box-shadow: inset 0 0 0 3px #e0533b, inset 3px 3px 0 #1a0f08; } }
.slot > button:hover { background: #3a2616; }
.slot > button:focus-visible { outline: 3px dashed var(--select); outline-offset: 2px; }
/* B8 detailed parts not used in chapter 1 (D45): greyed out, labelled in words, not a button; name on hover/focus. */
.slot.is-spare img { opacity: 0.45; filter: grayscale(0.7); }
.slot.is-spare.is-tool img { opacity: 0.8; filter: grayscale(0.3); }
.slot-unused { position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%); padding: 0 5px; white-space: nowrap; font-size: 16px; line-height: 1.1;
  background: var(--paper-lo); color: var(--ink); box-shadow: 0 0 0 2px var(--wood-1); pointer-events: none; }
.inv-pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0 0 8px; }
.inv-pager .px-btn { min-width: 2.2em; }
.inv-pager [aria-disabled='true'] { opacity: 0.45; cursor: default; }
.inv-spare-note { margin: 4px 0 8px; }
.inv-big.is-spare img { opacity: 0.6; filter: grayscale(0.5); }
.inv-detail { padding: 14px 16px; grid-row: span 2; }
.inv-note { margin: 0; }
.inv-detail h3 { margin: 6px 0 8px; }
.inv-big { width: 120px; height: 120px; display: grid; place-items: center; margin: 0 auto; background: #2e1d10; box-shadow: 0 0 0 3px var(--wood-1), inset 3px 3px 0 #1a0f08, inset -2px -2px 0 #5a3b22; padding: 10px; }
.inv-big img { width: 100%; height: 100%; object-fit: contain; }
.inv-stats { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0 0 10px; }
.inv-stats dt { color: #7a3a14; }
.inv-stats dd { margin: 0; }
.inv-about { border-top: 2px dashed #c9a877; margin-top: 10px; padding-top: 8px; }
.inv-about h4 { margin: 0 0 6px; font-size: 1em; }
.inv-about p { margin: 0 0 8px; }
@media (max-width: 760px) { .inv { grid-template-columns: 1fr; } }


/* Panels on pixel-art objects (HUY-79, D39): each job panel is written straight onto an image of a real object in the
   shop (open notebook, repair bench, counter slips, tool roll, parts box), all on the same desk. The image fills
   .panel-art at its own aspect ratio; every zone is placed in % of that image, measured on the image with sharp
   (never by eye), and sized in cqw/cqh so it scales with it. On paper (.leaf, .on-paper) text is ink and buttons are
   handwritten underlined words; on wood, felt or rubber the buttons stay paper tags. */
.modal.art, .modal.art.wide { width: min(calc(var(--u) * 1080), calc(100% - 24px)); color: var(--cream); background: var(--wood-1);
  box-shadow: 0 0 0 var(--px) var(--wood-0), inset 0 0 0 var(--px) var(--wood-3), calc(var(--px) * 2) calc(var(--px) * 2) 0 var(--px) rgba(0, 0, 0, 0.35); }
.modal.art .modal-head .status { color: var(--paper-lo); }
.modal.art .tabs { border-bottom: 0; }
.modal.art .modal-body { padding: 0; }
.panel-art { position: relative; background: center / 100% 100% no-repeat; container-type: size; image-rendering: auto;
  font-size: max(18px, calc(var(--u) * 23)); line-height: 1.15; } /* cq units inside, --u here: .panel-art is its own size container */
.panel-art[data-art='notebook'] { aspect-ratio: 2400 / 1606; }
.panel-art[data-panel='notebook_student'] { aspect-ratio: 2400 / 1602; }
.panel-art[data-art='parts'], .panel-art[data-art='inspect'] { aspect-ratio: 2400 / 1474; }
.panel-art[data-panel='parts_hanel'] { aspect-ratio: 2400 / 1470; }
/* Small windows (D87): the parts shelf takes the height the window has (the art keeps its ratio, so it grows to about 1040 px wide at
   1280×720), so the card on the clipboard has room for 18 px text without scrolling. 1672×941 keeps the 1080 px modal. */
@media (max-width: 1579px), (max-height: 890px) {
  /* The head (title + clock), the tabs and the tutorial strip are packed into the fewest rows, and the art is sized from the height
     that is really left (--ov = those rows), so the shelf never needs an outer scroll. Capped at 1060 px (the card sizes below are for it). */
  .modal.art:has(.panel-art[data-art='parts']) { --ov: 74px; --col: 0px; width: min(calc(100% - 24px), calc(1060px + var(--col)), calc((100cqh - 12px - var(--ov)) * 2400 / 1474 + var(--col))); max-height: calc(100% - 12px);
    display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto auto auto; }
  /* HUY-160 (D112): with father's strip the shelf used to lose its 58 px row (the art shrank from 1032 to 931 px wide at 1280×720 and the card
     with it, so the long text scrolled). The strip now stands in a side column to the right of the shelf, which uses the width the window has
     left (232 px; the shelf is as tall as without the strip), and the clock moves up beside the title. */
  .modal.art:has(.panel-art[data-art='parts']):has(.tip-strip) { --col: 232px; grid-template-columns: minmax(0, 1fr) var(--col); grid-template-rows: auto auto auto 1fr; }
  .modal.art:has(.panel-art[data-art='parts']):has(.tip-strip) .modal-head { justify-self: start; }
  .modal.art:has(.panel-art[data-art='parts']):has(.tip-strip) .modal-clock { grid-area: 3 / 2 / 4 / 3; align-self: start; padding: 0 0 6px 6px; }
  .modal.art:has(.panel-art[data-art='parts']):has(.tip-strip) .modal-clock .chip { white-space: normal; }
  .modal.art:has(.panel-art[data-art='parts']):has(.tip-strip) .modal-clock .clock-bar { display: none; }
  .modal.art:has(.panel-art[data-art='parts']):has(.tip-strip) .tip-strip { grid-area: 4 / 2 / 5 / 3; align-self: start; margin: 0 0 0 6px; padding: 8px 10px; flex-direction: column; align-items: stretch; flex-wrap: nowrap; }
  .modal.art:has(.panel-art[data-art='parts']):has(.tip-strip) .tip-strip p { flex: none; }
  .modal.art:has(.panel-art[data-art='parts']):has(.tip-strip) .tip-strip .row { flex-wrap: wrap; }
  .modal.art:has(.panel-art[data-art='parts']):has(.tip-strip) .tip-strip .px-btn { white-space: normal; text-align: left; }
  .modal.art:has(.panel-art[data-art='parts']):has(.tip-strip) .modal-body { grid-area: 3 / 1 / 5 / 2; }
  .modal.art:has(.panel-art[data-art='parts']) .modal-head { grid-area: 1 / 1; padding: 4px 12px 2px 20px; }
  .modal.art:has(.panel-art[data-art='parts']) .modal-head h2 { white-space: nowrap; } /* HUY-160: a title on two lines (1024×768, chapter 1) made the head taller than --ov reckons and the art ran past the box, cutting the strip under it */
  .modal.art:has(.panel-art[data-art='parts']) .modal-clock { grid-area: 1 / 2; padding: 0 16px 0 0; }
  .modal.art:has(.panel-art[data-art='parts']) .tabs { grid-area: 2 / 1 / 3 / 3; padding-bottom: 4px; }
  .modal.art:has(.panel-art[data-art='parts']) .tip-strip { grid-area: 3 / 1 / 4 / 3; margin-bottom: 3px; padding-top: 2px; padding-bottom: 2px; }
  .modal.art:has(.panel-art[data-art='parts']) .modal-body { grid-area: 4 / 1 / 5 / 3; min-height: 0; }
}
/* D97, HUY-129: from 1580 px up the shelf also takes the height the window has (it was fixed at 1080 px wide, so the card on the clipboard
   scrolled with every long part at 1672×941). --ov is the rows above the art (head + tabs; with the tip strip, one more); the card keeps
   18 px ink at least (2.5 % of the sheet height above that, was 3 %) on a bigger sheet, so the long "what this part does" text fits without a scrollbar. */
@media (min-width: 1580px) and (min-height: 891px) {
  .modal.art:has(.panel-art[data-art='parts']) { --ov: 112px; width: min(calc(100% - 24px), calc(var(--u) * 1130), calc((100cqh - 12px - var(--ov)) * 2400 / 1474)); max-height: calc(100% - 12px); }
  .modal.art:has(.panel-art[data-art='parts']):has(.tip-strip) { --ov: 236px; }
}
/* D99, HUY-133: low windows (under 700 px tall, e.g. 1366×650 and 1280×600). The shelf is only about 740–820 px wide there, so the head
   (title, close, clock) broke into two rows and the shelf grew past the window. The head keeps one row (smaller title, the clock's bar
   hidden, as the bench header does), and the room reserved above the art (--ov) is what the rows really take, so the shelf never needs
   an outer scroll. The 18 px text stays; the card scrolls inside as before when a long part does not fit. */
@media (max-height: 699px) {
  .modal.art:has(.panel-art[data-art='parts']) .modal-head h2 { font-size: 1.1em; white-space: nowrap; }
  .modal.art:has(.panel-art[data-art='parts']) .modal-head h2 .status { font-size: 0.8em; }
  .modal.art:has(.panel-art[data-art='parts']) .modal-head .px-btn { min-height: 0; padding-top: 2px; padding-bottom: 2px; }
  .modal.art:has(.panel-art[data-art='parts']) .modal-clock .clock-bar { display: none; }
  .modal.art:has(.panel-art[data-art='parts']) { --ov: 84px; }
  .modal.art:has(.panel-art[data-art='parts']) .tabs { gap: 3px; padding-left: 8px; padding-right: 8px; }
  .modal.art:has(.panel-art[data-art='parts']) .tab { padding: 3px 7px; }
}
/* Chapter 2's metal drawer (HUY-106): the note under the rack sits on the grey bench below the frame, in dark ink. */
.panel-art[data-panel='parts_hanel'] .inv-note { top: 95.6%; color: #2a1d12; text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.4); }
.panel-art p, .panel-art ul, .panel-art ol { margin: 0; }
.panel-art li { margin: 0 !important; }
.panel-art .plain { gap: 0; }
/* Ink on paper. --rule is the line pitch: the printed line gap on ruled paper, else just the line height. */
.panel-art :is(.leaf, .on-paper) { --rule: 1.2em; color: #263552; line-height: var(--rule); scrollbar-width: thin; scrollbar-color: var(--paper-lo) transparent; }
.panel-art :is(.leaf, .on-paper) > :first-child { margin-top: 0; }
.panel-art :is(.leaf, .on-paper) h3 { margin: var(--rule) 0 0; font-size: 1em; line-height: var(--rule); color: #7a3a14; }
.panel-art :is(.leaf, .on-paper) h4 { margin: 0; font-size: 1em; font-weight: 400; line-height: var(--rule); color: #7a3a14; }
.panel-art :is(.leaf, .on-paper) .muted { color: #6f6455; }
.panel-art :is(.leaf, .on-paper) .small { font-size: 1em; } /* HUY-106 (D78): 18 px floor, the body is already 18 px */
.panel-art :is(.leaf, .on-paper) .tag { padding: 0 4px; line-height: calc(var(--rule) * 0.8); }
.panel-art :is(.leaf, .on-paper, .inv-detail) .tag { font-size: max(18px, 0.9em); } /* 1672: 0.9em as before; 1280: 18 px floor */
.panel-art :is(.leaf, .on-paper) .principle { background: none; box-shadow: none; padding: 0; color: #7a3a14; }
.panel-art :is(.leaf, .on-paper) .notice { background: none; box-shadow: none; padding: 0; margin: 0; color: #7a3a14; }
.panel-art table { font-size: 1em; }
.panel-art th, .panel-art td { padding: 0 4px 0 0; border: 0; line-height: var(--rule); vertical-align: bottom; }
.panel-art th { color: #7a3a14; }
.panel-art :is(.leaf, .on-paper) .px-btn { background: none; box-shadow: none; padding: 0; color: #263552; line-height: var(--rule); text-align: left;
  text-decoration: underline dotted; text-underline-offset: 0.15em; display: inline-flex; align-items: center; gap: 0.2em; }
.panel-art .on-paper .px-btn { min-height: 0; }
.panel-art :is(.leaf, .on-paper) .px-btn.primary { color: #a3392b; text-decoration-style: solid; }
.panel-art :is(.leaf, .on-paper) .px-btn:hover:not(:disabled) { color: #a3392b; }
.panel-art :is(.leaf, .on-paper) .px-btn:disabled { color: #8a7f70; text-decoration: none; cursor: default; opacity: 1; }
.panel-art :is(.leaf, .on-paper) .px-btn:focus-visible { outline: 2px dashed #a3392b; outline-offset: 1px; }
.panel-art :is(.leaf, .on-paper) .act-icon { width: auto; height: var(--rule); margin: 0; }
/* Paper tags on wood, felt or rubber: the usual pixel button, sized to the image. */
.panel-art .px-btn { font-size: 1em; }
.panel-art .act-icon { height: 1.6em; width: auto; }

/* Notebook: 2400×1606, 22 ruled lines per page; every line of text sits on a printed line. */
.panel-art .spread { position: absolute; inset: 0; display: block; }
.panel-art .leaf { position: absolute; top: 16.65%; height: 69.28%; overflow-y: auto; --rule: 3.149cqh; font-size: max(18px, calc(var(--rule) * 0.95)); padding-right: 0.4em; } /* never below the 18 px body size of the other panels (1280×720: the rule gives about 16 px) */
.panel-art .leaf:first-child { left: 13.25%; width: 33%; }
.panel-art .leaf:last-child { left: 52.5%; width: 34%; }
.panel-art .hyp-form { gap: 0; margin: 0; }
.panel-art .hyp-form label { display: flex; gap: 0.4em; align-items: baseline; color: #6f6455; line-height: var(--rule); }
.panel-art .hyp-form input, .panel-art .hyp-form select { flex: 1; min-width: 0; height: var(--rule); line-height: 1; padding: 0 2px; font-size: 1em; color: #263552;
  background: rgba(255, 248, 225, 0.35); box-shadow: none; border-bottom: 1px dashed #6f6455; }
.panel-art .hyp-form input::placeholder { color: #a39784; }
.book-foot { position: absolute; top: 86.5%; height: 4%; left: 13.25%; right: 13.5%; display: flex; justify-content: space-between; align-items: center;
  font-size: max(18px, calc(3.149cqh * 0.95)); color: #6f6455; }
.book-foot .leaf-foot { display: flex; gap: 1em; align-items: center; }
.book-foot .leaf-foot:last-child { padding-right: 12%; } /* the curled page corner covers the right edge of the foot (HUY-105 QA) */
.book-foot .px-btn { background: none; box-shadow: none; padding: 0; color: #263552; text-decoration: underline dotted; font-size: 1em; }
.book-foot .px-btn:hover { color: #a3392b; }
.book-note { position: absolute; left: 13.25%; right: 13.5%; bottom: 0; height: 6.9%; margin: 0; display: flex; align-items: center;
  font-size: max(18px, 2.6cqh); line-height: 1; color: var(--paper-lo); }

/* Debrief after a job (HUY-79, D50): the same open notebook, one unit per ruled line block. layoutDebrief() measures
   the units and keeps each page within the paper; a section opens one ruled line below the one before it. */
.du { break-inside: avoid; }
.du h3, .du p { margin: 0; }
.du.d-gap { padding-top: 0.6em; }
.panel-art .du.d-gap { padding-top: var(--rule); }
.panel-art .d-book .leaf > .du:first-child { padding-top: 0; }
.panel-art .du h3 { margin: 0; }
.panel-art .d-title { color: #a3392b; }
.panel-art .d-k { color: #7a3a14; }
.d-li { padding-left: 1em; text-indent: -1em; }
.d-li.dot::before { content: '· '; }
.panel-art .d-father { color: #7a3a14; font-style: italic; }
.panel-art .d-src { color: #6f6455; font-size: 0.9em; }
.d-foot[hidden], .book-foot .px-btn[hidden] { display: none; }

/* Parts box: 2400×1474. 12 felt compartments (4×3, column pitch 11.55%, row pitch 26.4%) and a clipped index card. */
.panel-art .inv { display: block; }
.panel-art .inv-grid { position: absolute; left: 9.67%; top: 13.59%; width: 45.35%; height: 77.8%; padding: 0; gap: 1.4cqh 0.85cqw;
  grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(3, 1fr); background: none; box-shadow: none; }
.panel-art .slot { aspect-ratio: auto; }
.panel-art .slot > button, .panel-art .slot.is-empty { background: none; box-shadow: none; padding: 4%; }
.panel-art .slot.is-empty { opacity: 1; }
.panel-art .slot-unused { font-size: max(18px, 2.9cqh); bottom: 6%; }
/* Page arrows sit on the desk above the box, as paper tags. */
.panel-art .inv-pager { position: absolute; left: 9.67%; width: 45.35%; top: 3.2%; height: 6.6%; margin: 0; font-size: max(18px, 3cqh); color: var(--paper-hi, #f4e6c4); text-shadow: 2px 2px 0 #1a0f08; }
.panel-art .slot > button:hover { background: radial-gradient(closest-side, rgba(255, 211, 106, 0.28), transparent); }
.panel-art .slot.is-picked > button { background: radial-gradient(closest-side, rgba(255, 211, 106, 0.42), transparent); box-shadow: inset 0 0 0 3px var(--amber); }
.panel-art .slot-count { font-size: max(18px, 3.4cqh); right: 8%; bottom: 3%; }
.panel-art .slot-held { font-size: max(18px, 2.4cqh); }
.panel-art .inv-detail { position: absolute; left: 61.7%; top: 17.6%; width: 28.3%; height: 73%; padding: 0 0.3em 0 0; overflow-y: auto;
  background: none; box-shadow: none; --rule: 1.1em; font-size: max(18px, 3cqh); }
/* Small windows (1280×720): 18 px text leaves less room, so the icon and the line pitch shrink; 1672×941 keeps the HUY-105 sizes. */
@container (max-width: 900px) { .panel-art .inv-detail { --rule: 1.02em; } .panel-art .inv-detail .inv-big { width: 2.8em; height: 2.8em; margin: 0 0.5em 0.1em 0; } }
/* D87: only in small windows (the shelf is capped at 1060 px there); at 1580 px and up the card is as in HUY-105. */
@media (max-width: 1579px), (max-height: 890px) { .panel-art .inv-detail { --rule: 1em; font-size: 18px; left: 60.6%; top: 16.4%; width: 30.9%; height: 76.6%; padding: 0; } .panel-art .inv-detail .inv-big { width: 2.8em; height: 2.8em; margin: 0 0.5em 0.1em 0; } }
/* D97, HUY-129: 1580 px and up, the card is as big as the sheet. Ink is 18 px at least and grows with the window (2.5 % of the sheet height; HUY-105 had 3 %,
   which made the long "what this part does" text scroll at 1672×941). */
@media (min-width: 1580px) and (min-height: 891px) {
  .panel-art .inv-detail { --rule: 1em; font-size: max(18px, 2.5cqh); left: 60.8%; top: 17%; width: 30.2%; height: 75%; padding: 0; }
  .panel-art .inv-detail .inv-big { width: 2.8em; height: 2.8em; margin: 0 0.5em 0.1em 0; }
}
/* "More below" mark: paper fade and a ▼ at the foot of the card until it is scrolled to the end. */
.panel-art .inv-detail::after { content: '▼'; display: block; position: sticky; bottom: 0; height: 0; margin: 0; text-align: right; line-height: 0; color: #a3392b; pointer-events: none; transform: translateY(-0.9em); text-shadow: 0 0 0.5em #f4e6c4, 0 0 0.5em #f4e6c4, 0 0 0.5em #f4e6c4; box-shadow: 0 -0.9em 0.9em 0.5em #f4e6c4; }
.panel-art .inv-detail.is-end::after { display: none; }
.panel-art .inv-detail .inv-big { float: left; width: 3.6em; height: 3.6em; margin: 0 0.5em 0.2em 0; padding: 0.2em; background: none; box-shadow: none; }
.panel-art .inv-detail h3 { margin: 0; }
.panel-art .inv-stats { display: block; margin: 0; }
.panel-art .inv-stats dt { display: inline; color: #7a3a14; }
.panel-art .inv-stats dt::after { content: ': '; }
.panel-art .inv-stats dd { display: inline; }
.panel-art .inv-stats dd::after { content: ''; display: block; }
.panel-art .inv-about { clear: both; border-top: 2px dashed #c9b28a; margin-top: 0.3em; padding-top: 0.2em; }
.panel-art .inv-about h4 .tag { display: inline-block; }
.panel-art .inv-detail .row { margin: 0.2em 0; gap: 0.8em; }
/* The general rule about reserved parts sits on the desk under the box, like the note under the notebook. */
.panel-art .inv-note { position: absolute; left: 9.67%; top: 94.6%; width: 80.7%; margin: 0; font-size: max(18px, 2.75cqh); line-height: 1; color: var(--paper-lo); }

/* HUY-160 (D112): "waiting for parts" (the notice, the two order buttons) sits on the strip under the box, where the general note stands
   the rest of the time, instead of inside the card: it took 58 px of a card that already scrolls at 1280×720 and 1580×800, and the order
   buttons scrolled out of sight with it. Always visible now. */
.panel-art .inv-order { position: absolute; left: 2%; width: 96%; bottom: 0.6%; font-size: max(18px, 2.75cqh); line-height: 1; }
.panel-art .inv-order .notice { display: flex; flex-wrap: nowrap; align-items: center; gap: 0 14px; margin: 0; padding: 2px 10px; color: var(--ink); }
.panel-art .inv-order .notice p { margin: 0; flex: 1 1 auto; min-width: 0; }
.panel-art .inv-order .row { flex: none; }
.panel-art .inv-order .row { margin: 0; gap: 10px; }
.panel-art .inv-order .px-btn { min-height: 0; padding: 2px 10px; font-size: 1em; }

/* Repair bench: 2400×1474. Teal rubber mat (TV and test conditions), graph paper taped down (block diagram),
   tool tray with a cloth lining (one tag per check, the safety line). */
.panel-art .inspect { display: block; }
.panel-art .bench-tv { position: absolute; left: 9.8%; top: 13.4%; width: 22.8%; height: 45.6%; display: flex; flex-direction: column; gap: 0.6cqh;
  color: var(--cream); text-shadow: 2px 2px 0 rgba(14, 9, 5, 0.85); }
.panel-art .bench-tv .crt > canvas { width: 74%; margin: 0 auto; box-shadow: 0 0.8cqh 0 rgba(10, 6, 3, 0.45); background: none; }
.panel-art .bench-tv .crt-art { width: 82%; margin: 0.6cqh 0 0 2%; filter: drop-shadow(0 0.8cqh 0 rgba(10, 6, 3, 0.45)); }
.panel-art .bench-tv .crt figcaption { margin-top: 0.6cqh; font-size: 0.95em; line-height: 1.1; }
.panel-art .bench-tv .crt strong { font-weight: 400; color: #fff4dc; }
.panel-art .bench-tv .row { margin: 0; flex-direction: column; align-items: stretch; gap: 0.5cqh; }
.panel-art .bench-tv .label { color: #f6e7c8; }
.panel-art .bench-tv .seg { display: grid; gap: 0.8cqh; }
.panel-art .bench-tv .seg .px-btn { padding: 1px 8px; text-shadow: none; white-space: nowrap; }
.panel-art .sheet { position: absolute; left: 39.6%; top: 13.6%; width: 50.8%; height: 45.4%; padding: 0; background: none; box-shadow: none;
  display: flex; flex-direction: column; justify-content: space-between; }
.panel-art .sheet svg.diagram { flex: 1; min-height: 0; }
.panel-art .diagram text { font-size: 22px; }
.panel-art .diagram .small { font-size: 19px; }
/* Generic block sheet (chapter 2, bench.ts genericDiagramSvg): 24-unit text reads ≥ 18 px at 1672×941. */
.panel-art .diagram.generic text, .panel-art .diagram.generic .small { font-size: 24px; }
.panel-art .block rect, .panel-art .link-hit { fill: rgba(255, 250, 236, 0.92); }
.panel-art .sheet .caption { margin: 0; font-size: 0.9em; line-height: 1.1; color: #6f6455; }
.panel-art .tray { position: absolute; left: 11.2%; top: 70.4%; width: 77.6%; height: 19.4%; display: flex; flex-direction: column; justify-content: space-between; }
.panel-art .tray .checks { grid-template-columns: repeat(3, 1fr); gap: 1cqh 1cqw; }
.panel-art .tray .checks { height: 100%; grid-template-columns: repeat(3, auto); grid-template-rows: 1fr 1fr; }
.panel-art .tray .checks .px-btn { height: 100%; padding: 0 0.35em; gap: 0.25em; font-size: 0.95em; line-height: 1.05; white-space: nowrap; }
.panel-art .tray .checks .act-icon { height: 1.25em; }
/* The safety line sits on the desk under the tray, like the note under the notebook. */
.panel-art .tray .safety { position: absolute; top: calc(100% + 4.4cqh); left: 0; right: 0; margin: 0 !important; padding: 0; border-top: 0;
  font-size: max(18px, 2.75cqh); line-height: 1; color: var(--paper-lo); }

/* Counter: 1586×992 (v2, ChatGPT edit of the Gemini v1). Repair order pad ruled every 39.8 px from y 256, red amount
   line at x 928; a pocket calculator; a torn receipt from a stub book ruled every 32.8 px from y 569, with a stamp at the
   lower right. Zones start one line above the first printed line so text sits on lines. */
.panel-art[data-art='customer'] { aspect-ratio: 1586 / 992; }
/* Chapter 2's warranty desk (HUY-99, ui_counter_hanel_v1): same lined pad, the small slip sits a little lower. */
.panel-art[data-panel='customer_hanel'] { aspect-ratio: 1448 / 903; }
.panel-art[data-panel='customer_hanel'] .quote-slip { left: 73%; width: 15.4%; top: 57.5%; height: 19.3%; --rule: 3.1cqh; }
.panel-art .quote-pad { position: absolute; left: 9.2%; width: 55.3%; top: 21.8%; height: 64.2%; --rule: 4.012cqh; font-size: max(18px, calc(var(--rule) * 0.86)); overflow-y: auto; }
.panel-art .quote-items label { position: relative; display: block; padding: 0 12% 0 1.1em; text-indent: -1.1em; line-height: var(--rule); }
.panel-art .quote-items input { width: 0.8em; height: 0.8em; margin: 0 0.25em 0 0; vertical-align: -0.05em; accent-color: #263552; }
.panel-art .q-detail { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.panel-art .q-art { display: inline; }
.panel-art .q-time { position: absolute; left: 89.2%; top: 0; white-space: nowrap; text-indent: 0; padding-left: 0.3em; }
.panel-art .q-part { margin-left: 0.3em; display: inline-block; text-indent: 0; white-space: nowrap; }
.panel-art .quote-pad .history { margin: 0; padding: 0; list-style: none; font-size: 0.95em; }
.panel-art .quote-pad .history li { line-height: var(--rule); }
.panel-art .quote-pad .history em { font-style: normal; color: #7a3a14; }
.panel-art .quote-slip { position: absolute; left: 72.4%; width: 15.6%; top: 54.0%; height: 20.6%; --rule: 3.306cqh; font-size: max(18px, calc(var(--rule) * 0.86)); }
.panel-art .quote-slip .row { display: block; margin: 0; }
.panel-art .quote-slip .px-btn { display: flex; }

/* Tool roll: 1536×1024 (ChatGPT; v2 swaps the tools for electronics repair ones, same geometry). Plain canvas under the tool pockets (the work the quote allows,
   as paper tags) and a clipboard sheet ruled every 29.25 px from y 248 (the after-repair tests, in ink). */
.panel-art[data-art='repair'] { aspect-ratio: 1536 / 1024; }
.panel-art .roll { position: absolute; left: 7.2%; top: 46.6%; width: 50.6%; height: 38%; color: #3b2516; overflow-y: auto; }
.panel-art .roll h3 { margin: 0 0 0.4em; font-size: 1em; color: #7a3a14; }
.panel-art .roll .row { margin: 0; gap: 1.2cqh 1cqw; }
.panel-art .roll .notice { margin: 0 0 0.6em; }
.panel-art .qa-sheet { position: absolute; left: 67%; width: 27.2%; top: 21.36%; height: 62.8%; --rule: 2.856cqh; font-size: max(18px, var(--rule)); overflow-y: auto; }
.panel-art .qa-sheet .small { font-size: 1em; }
/* Two printed lines per test: "state · required/recommended", then the test itself as a handwritten link. */
.panel-art .qa-list li { display: grid; grid-template-columns: auto 1fr; grid-template-rows: var(--rule) auto; column-gap: 0.3em; }
.panel-art .qa-list .qa-state { min-width: 0; grid-area: 1 / 1; }
.panel-art .qa-list .tag { grid-area: 1 / 2; line-height: var(--rule); }
.panel-art .qa-list .px-btn { grid-area: 2 / 1 / 3 / 3; display: block; line-height: var(--rule); text-align: left; } /* 18 px text no longer fits one line: wraps onto the next printed line (HUY-106) */
.panel-art .qa-list .act-icon { display: none; }
.panel-art .qa-list .tag { background: none; color: #a3392b; padding: 0; font-size: 1em; }
.panel-art .qa-list .tag::before { content: '· '; }
.panel-art .roll .muted { color: #5a4630; }

@media (max-width: 760px), (max-height: 460px) {
  .panel-art { aspect-ratio: auto !important; background: var(--paper) !important; container-type: normal; color: var(--ink); font-size: 1em; }
  .panel-art .spread { position: static; }
  .panel-art .leaf, .panel-art .leaf:first-child, .panel-art .leaf:last-child { position: static; width: auto; height: auto; --rule: 1.25em; font-size: 1em; padding: 8px 14px; }
  .book-foot, .book-note { position: static; padding: 4px 14px; font-size: 1em; color: var(--ink-soft); }
  .modal.art, .modal.art.wide { width: auto; }
  .panel-art :is(.leaf, .on-paper) { --rule: 1.25em; }
  .panel-art :is(.quote-pad, .quote-slip, .qa-sheet, .inv-detail, .roll) { font-size: 1em; overflow: visible; }
  .panel-art :is(.inv-grid, .tray .checks, .bench-tv, .bench-tv .seg, .roll .row) { gap: 8px; }
  .panel-art .bench-tv .crt canvas { width: 100%; }
  .panel-art .inv-detail .inv-big { float: none; }
  .panel-art .qa-list li { grid-auto-rows: auto; }
  .panel-art .bench-tv .crt strong { color: inherit; }
  .panel-art .diagram text { font-size: 20px; }
  .panel-art .diagram .small { font-size: 18px; }
  .panel-art .q-art { display: none; }
  .panel-art .q-detail { position: static; width: auto; height: auto; clip-path: none; }
  .panel-art .quote-items label { padding-right: 0; }
  .panel-art :is(.inv-grid, .inv-detail, .inv-note, .inv-order, .bench-tv, .sheet, .tray, .quote-pad, .quote-slip, .roll, .qa-sheet) { position: static; width: auto; height: auto; margin: 8px 14px; font-size: 1em; }
  .panel-art .inv-grid { grid-template-rows: none; }
  .panel-art .slot { aspect-ratio: 1; }
  .panel-art .slot > button, .panel-art .slot.is-empty { background: #2e1d10; }
  .panel-art .slot-unused { font-size: 16px; bottom: 4px; }
  .panel-art .inv-pager { position: static; height: auto; margin: 8px 14px 0; font-size: 1em; color: var(--ink); text-shadow: none; }
  .panel-art .slot.is-picked > button { background: #3a2616; }
  .panel-art .slot-count, .panel-art .slot-held { font-size: 20px; }
  .panel-art .bench-tv { color: var(--ink); text-shadow: none; }
  .panel-art .bench-tv .label { color: var(--ink-soft); }
  .panel-art .tray .checks { grid-template-columns: 1fr; height: auto; grid-template-rows: none; }
  .panel-art .tray .safety, .panel-art .inv-note { position: static; color: var(--ink-soft); font-size: 0.85em; }
  .panel-art .du.d-gap { padding-top: 0.6em; }
}

/* Volume sliders in the Menu (HUY-80). */
.volumes { display: grid; gap: 6px; max-width: 460px; }
.volume { display: grid; grid-template-columns: 7em 1fr 2.2em; align-items: center; gap: 10px; }
.volume input[type='range'] { width: 100%; accent-color: #7a3a14; }
.volume output { text-align: right; color: var(--ink-soft); }

/* Repair bench close-up (HUY-78, D36, D42): the device on the bench fills the stage, one face at a time; the tools on the
   bench are the buttons. Areas and label corners come from the manifest in % of the image (measured with sharp); here
   only their look. Hover/focus lights an object with a warm glow like the desk lamp, never a frame (D37); labels are
   game UI chips like the shop pins. Text stays ≥ 18 px at 1672×941 (one image pixel = one --u). Narrow or short screens
   never get here: they keep the paper panel. */
.bench-scene { position: absolute; inset: 0; background: var(--night); overflow: hidden; z-index: 5; }
.bench-img { position: absolute; left: 0; top: 0; width: 100%; background: center / 100% 100% no-repeat; }
.bench-img > * { position: absolute; }
.bench-screen, .bench-sound, .bench-needle { image-rendering: pixelated; pointer-events: none; }
.bench-lamp { pointer-events: none; }
/* Light and shade only (D37): the tube's dark rim and the lamp's warm reflection over the code-drawn picture, so it
   sits behind curved glass in the same light as the art instead of looking pasted on. */
.bench-screen { filter: saturate(0.78) brightness(0.9); }
.bench-glass { pointer-events: none; background: radial-gradient(ellipse 72% 68% at 50% 50%, rgba(0, 0, 0, 0) 58%, rgba(10, 8, 6, 0.55) 100%),
  linear-gradient(160deg, rgba(255, 214, 150, 0.16) 0%, rgba(255, 214, 150, 0) 32%); }
/* A flat panel has no curved tube: no rim vignette and no tube filter over the code-drawn light (HUY-100, D73). */
.bench-scene[data-device="lcd_tv_v1"] .bench-glass { display: none; }
.bench-scene[data-device="lcd_tv_v1"] .bench-screen { filter: none; }
.bench-hs { appearance: none; border: 0; padding: 0; margin: 0; cursor: pointer;
  background: radial-gradient(ellipse closest-side, rgba(255, 220, 150, 0.85), rgba(255, 190, 96, 0.42) 58%, rgba(255, 170, 60, 0) 100%);
  mix-blend-mode: screen; opacity: 0; transition: opacity 120ms steps(3); }
.bench-hs:disabled { cursor: not-allowed; }
.bench-hs:hover:not(:disabled), .bench-hs.is-hot:not(:disabled) { opacity: 1; }
.bench-hs.is-picked { opacity: 0.8; }
.bench-hs.is-guided { animation: bench-glow 1s steps(2, jump-none) infinite; }
@keyframes bench-glow { from { opacity: 0.15; } to { opacity: 1; } }
.bench-pin { appearance: none; border: 0; cursor: pointer; display: grid; gap: 0; text-align: left; padding: calc(var(--u) * 3) calc(var(--u) * 10) calc(var(--u) * 4);
  background: rgba(26, 15, 8, 0.88); color: var(--cream); font-size: max(16px, calc(var(--u) * 22)); line-height: 1;
  box-shadow: 0 0 0 calc(var(--u) * 3) #0e0905, inset 0 0 0 calc(var(--u) * 2) #4a3524; white-space: nowrap; }
.bench-pin .pin-name { color: #ffe1a0; }
.bench-pin .pin-name em { font-style: normal; color: var(--amber); }
.bench-pin .pin-state { font-size: 0.92em; margin-top: calc(var(--u) * 2); }
.bench-pin:disabled { cursor: not-allowed; opacity: 0.7; }
.bench-pin:hover:not(:disabled), .bench-pin.is-hot:not(:disabled), .bench-pin:focus-visible { box-shadow: 0 0 0 calc(var(--u) * 3) var(--amber), inset 0 0 0 calc(var(--u) * 2) #4a3524; outline: none; background: #3a2716; }
.bench-pin.is-picked { background: #4a3112; box-shadow: 0 0 0 calc(var(--u) * 3) var(--amber), inset 0 0 0 calc(var(--u) * 2) #7a5320; }
.bench-pin.is-guided, .bench-flip.is-guided, .bench-cond.is-guided { animation: guided 0.9s steps(2, jump-none) infinite; }
.bench-pin.is-guided::after, .bench-flip.is-guided::after { content: '▼'; position: absolute; left: calc(var(--u) * 14); top: calc(var(--u) * -34); color: var(--amber); font-size: calc(var(--u) * 30); text-shadow: calc(var(--u) * 2) calc(var(--u) * 2) 0 #0e0905; }
.pin-state.tone-good { color: var(--good-on-dark); }
.pin-state.tone-bad { color: var(--bad-on-dark); }
.pin-state.tone-stale { color: #c8b79c; }
.pin-state.tone-unknown { color: #d9c8a8; }
.bench-flip { font-size: max(16px, calc(var(--u) * 23)); padding: calc(var(--u) * 4) calc(var(--u) * 14); }
.bench-cond { width: calc(var(--u) * 238); padding: calc(var(--u) * 8) calc(var(--u) * 10); display: grid; gap: calc(var(--u) * 5); font-size: max(16px, calc(var(--u) * 20)); line-height: 1; }
.bench-cond .cond-head { margin: 0; color: #7a3a14; text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.9em; }
.cond-tag { appearance: none; border: 0; cursor: pointer; display: flex; gap: calc(var(--u) * 6); align-items: baseline; text-align: left; padding: calc(var(--u) * 3) calc(var(--u) * 6);
  background: var(--paper-hi); color: var(--ink); font-size: 1em; box-shadow: 0 0 0 2px var(--wood-1), inset -2px -2px 0 var(--paper-lo); }
.cond-tag[aria-checked='true'] { background: #2f5d7c; color: #fff; box-shadow: 0 0 0 2px var(--wood-1), inset -2px -2px 0 #1d3e55; }
.cond-tag .cond-cost { margin-left: auto; opacity: 0.8; }
.cond-tag:focus-visible { outline: 3px dashed var(--select); outline-offset: 2px; }
.cond-tag:disabled { opacity: 0.5; cursor: not-allowed; }
/* The open notebook on the bench: ink on its squared pages. */
.book-spread { left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.book-page { position: absolute; left: var(--l); top: var(--t); width: var(--w); height: var(--h); color: #263552; font-size: max(16px, calc(var(--u) * 19)); line-height: 1.02; overflow: hidden; pointer-events: none; }
.book-page .ink-link { pointer-events: auto; }
.book-title { margin: 0 0 calc(var(--u) * 3); color: #7a3a14; text-decoration: underline; text-underline-offset: 2px; }
.book-page ul { list-style: none; margin: 0; padding: 0 0 0 calc(var(--u) * 14); }
.book-page > ul { padding-left: 0; }
.book-page li { position: relative; }
.book-page li li::before { content: ''; position: absolute; left: calc(var(--u) * -10); top: 0; width: calc(var(--u) * 7); height: 0.55em; border-left: 2px solid #4a5a7a; border-bottom: 2px solid #4a5a7a; }
.book-page .node b { font-weight: 400; }
.book-page .tone-good > .node b { color: var(--good); }
.book-page .tone-bad > .node b { color: var(--bad); }
.book-page .tone-stale > .node b, .book-page .tone-unknown > .node b { color: #6a6a6a; }
.book-page .is-picked > .node { background: rgba(255, 211, 106, 0.55); }
.book-quote { margin: 0; }
.book-count { margin: calc(var(--u) * 4) 0 0; color: #4a5a7a; }
.ink-link { appearance: none; border: 0; background: none; padding: 0; margin-top: calc(var(--u) * 3); cursor: pointer; color: #1d3e8a; font-size: 1em; text-decoration: underline; text-underline-offset: 2px; text-align: left; }
.ink-link:hover, .ink-link.is-hot { color: #a3392b; }
.ink-link:focus-visible { outline: 2px dashed #a3392b; outline-offset: 2px; }
/* Small windows (1280×720, D87): the painted pages are too small for 18 px ink, so the two pages become one paper card on the
   book (same width, same bottom edge) that grows upward with its text. HUY-158 (L4): the same card now at every size (the block was
   `(max-width: 1579px), (max-height: 890px)`): at 1672×941 and 1920×1080 the painted left page was 144–168 px high for 294–337 px of text
   and `overflow: hidden` cut the block tree and the right page's lines. */
@media all {
  .book-spread { left: var(--cl); top: auto; bottom: calc(var(--cb) - 74px); width: calc(var(--cw) + 40px); height: auto; pointer-events: auto; cursor: pointer; display: flex; gap: 12px; padding: 5px 10px 5px; box-sizing: border-box;
    background: var(--paper); box-shadow: 0 0 0 2px var(--wood-1), inset 0 0 0 2px var(--paper-hi), inset 0 0 0 4px var(--paper-lo); }
  .book-page { position: static; font-size: 18px; line-height: 1; overflow: visible; pointer-events: auto; }
  .book-page.left { flex: 1.7 1 0; min-width: 0; }
  .book-page.right { flex: 1 1 0; min-width: 0; }
  .book-page ul { padding-left: 6px; }
  .book-page li li::before { left: -6px; width: 5px; }
  /* D97, HUY-129: the speaker bench (classroom, cases 6–8) can have a three-line footer (64 px); its sheet sits 22 px higher so its foot clears it.
     The LCD and CRT benches keep the sheet where it is: raised, it would reach the backlight label on the LCD back. */
  .bench-scene.cr-bench[data-device="abstract_pc_speaker_v1"] .book-spread { bottom: calc(var(--cb) - 42px); } /* HUY-158 (L5): was -52px; the sheet's foot (640) touched the footer (637) at 1280x720, cases 6-8 */
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Header over the shelf, father's strip under it, hint line and the safety sentence along the bottom edge. */
.bench-head { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: calc(var(--u) * 14); padding: calc(var(--u) * 6) calc(var(--u) * 14); font-size: max(16px, calc(var(--u) * 22)); }
.bench-head h2 { margin: 0; font-size: 1.15em; font-weight: 400; outline: none; white-space: nowrap; color: var(--amber); }
.bench-head h2 .status { color: var(--paper-lo); font-size: 0.85em; }
.bench-head .tabs { border: 0; padding: 0; flex-wrap: nowrap; }
.bench-head .tab { font-size: 0.95em; white-space: nowrap; }
.bench-side { margin-left: auto; display: flex; gap: calc(var(--u) * 10); align-items: center; }
.bench-side .chip { font-size: 0.95em; }
.bench-side .clock-bar { width: calc(var(--u) * 110); height: 10px; }
.bench-side .clock-sun { width: 12px; height: 12px; }
.bench-side .px-btn { font-size: 1em; min-height: 0; }
.bench-tip { position: absolute; right: calc(var(--u) * 12); top: calc(var(--u) * 62); width: calc(var(--u) * 470); font-size: max(16px, calc(var(--u) * 21)); }
.bench-tip .tip-strip { margin: 0; color: var(--ink); }
.bench-foot { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: calc(var(--u) * 18); align-items: center; padding: calc(var(--u) * 5) calc(var(--u) * 16); background: rgba(18, 11, 7, 0.88);
  box-shadow: 0 calc(var(--u) * -3) 0 #0e0905; font-size: max(16px, calc(var(--u) * 20)); line-height: 1.05; }
.bench-foot p { margin: 0; }
.bench-hint { flex: 1 1 auto; color: var(--cream); }
.bench-hint strong { font-weight: 400; color: var(--amber); }
.bench-note { color: var(--amber); flex: 0 1 auto; }
.bench-img-note { background: rgba(18, 11, 7, 0.88); color: var(--amber); padding: calc(var(--u) * 3) calc(var(--u) * 8); font-size: max(18px, calc(var(--u) * 20)); line-height: 1.05; pointer-events: none; }
.bench-safety { flex: 0 0 46%; color: var(--paper-lo); font-size: 0.9em; }
/* Classroom bench (HUY-114): the safety line reads at 18 px or more; at 1280×720 it takes the wider part of the footer so it stays two lines. Chapters 1–2 keep 0.9em (18 px there covers the meter label). */
.cr-bench .bench-hint { flex: 1 1 28%; }
.cr-bench .bench-safety { flex: 1 1 68%; font-size: max(18px, 0.9em); }
.bench-scene[data-device="abstract_pc_speaker_v1"] .bench-pin[data-region="volume"], .bench-scene[data-device="abstract_pc_speaker_v1"] .bench-pin[data-region="amp"] { white-space: normal; max-width: calc(var(--u) * 190); }
.bench-scene[data-device="abstract_pc_speaker_v1"] .bench-pin[data-region="amp"] { translate: -100% 0; }
/* Labels sit over the other objects' hit areas here, so they must take the click themselves (QA 01/11: the volume label picked the amp). */
.bench-scene[data-device="abstract_pc_speaker_v1"] .bench-pin { z-index: 2; }
/* Both grow upward from the pin: the listen label stays over its speaker, the meter label beside the meter and clear of the footer. */
.bench-scene[data-device="abstract_pc_speaker_v1"] .bench-pin[data-region="listen_left"] { white-space: normal; max-width: calc(var(--u) * 225); translate: 0 -100%; }
.bench-scene[data-device="abstract_pc_speaker_v1"] .bench-pin[data-region="meter"] { white-space: normal; max-width: calc(var(--u) * 240); translate: 0 -100%; }
/* Speaker bench (HUY-109): the long result line wraps, so a block's label stays beside its object (QA 31/10). */
.cr-bench .bench-pin[data-key="bench-meter"] { translate: 0 calc(var(--u) * -14); }
.bench-safety.is-short { display: none; }
/* D87, HUY-117: small windows only (1580 px and up keeps the HUY-114 layout). Chapters 1–2 get an 18 px floor on the footer, the
   conditions card and its head; the safety line takes the wider part of the footer so both texts stay at two lines; the meter's label
   rides above the taller footer; and while a hint is shown (pointer or Tab on an object) it takes most of the footer with a short
   warning beside it, so the footer does not grow over the labels and the warning never vanishes. */
@media (max-width: 1579px), (max-height: 890px) {
  .bench-foot { font-size: max(18px, calc(var(--u) * 20)); }
  .bench-hint { flex: 1 1 0; }
  .bench-safety { flex: 0 0 59%; font-size: max(18px, 0.9em); }
  .bench-foot.has-hint .bench-safety:not(.is-short) { display: none; }
  .bench-foot.has-hint .bench-safety.is-short { display: block; flex: 0 0 26%; }
  .bench-pin[data-key="bench-meter"] { translate: 0 -16px; }
  .bench-cond { min-width: calc(var(--u) * 238); width: max-content; font-size: max(18px, calc(var(--u) * 20)); }
  .bench-cond .cond-head { font-size: max(18px, 0.9em); }
  /* D93, HUY-123: the labels, their result line, the flip button, the father's strip and the bench header read at 18 px too. */
  .bench-pin { font-size: max(18px, calc(var(--u) * 22)); }
  .bench-pin .pin-state { font-size: max(18px, 0.92em); }
  .bench-flip { font-size: max(18px, calc(var(--u) * 23)); }
  .bench-tip { font-size: max(18px, calc(var(--u) * 21)); }
  /* The header keeps one row (tighter gaps; the clock keeps its sun and text, its bar is hidden); with the door chip it cannot,
     so the right side drops to a second row without breaking a piece, and the father's strip moves below it. */
  .bench-head { font-size: max(18px, calc(var(--u) * 22)); flex-wrap: wrap; gap: 4px 8px; padding: 4px 8px; }
  .bench-head h2 .status, .bench-head .tab, .bench-side .chip { font-size: max(18px, 0.85em); }
  .bench-head h2, .bench-side > * { white-space: nowrap; }
  .bench-head .tabs { gap: 4px; }
  .bench-head .tab { padding: 3px 8px; }
  .bench-side { gap: 8px; }
  .bench-side .clock-bar { display: none; }
  .bench-scene:has(.door-chip) .bench-tip { top: 76px; }
  /* Labels that the larger text pushed onto a neighbour (measured at 1280×720, D93). LCD (shop and classroom share the boxes):
     the ribbon's label sits over the ribbon, clear of the backlight strip; the stand's label steps right and down, clear of the
     probes and the standby labels. Speaker: the adapter's label goes to the right of the adapter, so the long right-cable result
     keeps one line; the probes' label steps down, clear of the volume label. Classroom: the meter's label rides above its taller footer. */
  .bench-scene[data-device="lcd_tv_v1"] .bench-pin[data-region="cable_lvds"] { translate: -100px 0; max-width: 186px; white-space: normal; }
  .bench-scene[data-device="lcd_tv_v1"] .bench-pin[data-region="stand"] { translate: 32px 8px; }
  /* The back boards' long results ("… chưa kết luận được · cũ") wrap before the notebook sheet on the right. */
  .bench-scene[data-device="abstract_crt_v1"] .bench-pin[data-region="board_audio"] { max-width: 176px; white-space: normal; }
  .bench-scene[data-device="lcd_tv_v1"] .bench-pin[data-region="board_main"] { max-width: 290px; white-space: normal; }
  /* T10 (D100): the adapter label hangs from the scene's right edge (it sits at the far right, so a shift to the right ran out of the window at 1280 and 1366 px); same height as before. The flip button steps left of the listen label, which grows upward over it. */
  .bench-scene[data-device="abstract_pc_speaker_v1"] .bench-pin[data-region="adapter"] { left: auto !important; right: 6px; translate: 0 48px; }
  .bench-scene[data-device="abstract_pc_speaker_v1"] .bench-flip { translate: calc(-100% + 16px) 0; }
  .bench-scene[data-device="abstract_pc_speaker_v1"] .bench-pin[data-region="power_led"] { max-width: 290px; white-space: normal; }
  .bench-scene[data-device="abstract_pc_speaker_v1"] .bench-pin[data-region="probes"] { translate: 0 12px; }
  /* HUY-137 (Q05): the right cable's long result wraps before the father's sheet (it starts at 67 % of the width), and the power lamp's
     result takes 2 lines instead of 3, so it stays clear of the probes' label under it. */
  .bench-scene[data-device="abstract_pc_speaker_v1"] .bench-pin[data-region="right_cable"] { white-space: normal; max-width: calc(var(--u) * 270); }
  .cr-bench .bench-pin[data-key="bench-meter"] { translate: 0 -20px; }
  .modal-clock .chip { font-size: max(18px, 0.9em); }
}
/* D97, HUY-129: 1580 px and up with the "khách chờ" chip: the header was too full, so the clock text, the chip and "Về tiệm/Về xưởng"
   each broke onto two lines (the header grew to 67 px). Same tight gaps as the small-window header (D93), the clock's bar hidden, and no
   piece breaks; the header stays one row (44 px → 40 px) and nothing else on the scene moves. Without the chip the header is as before. */
@media (min-width: 1580px) and (min-height: 891px) {
  .bench-scene:has(.door-chip) .bench-head { gap: 4px 8px; padding: 4px 6px; }
  .bench-scene:has(.door-chip) .bench-head .tabs { gap: 4px; }
  .bench-scene:has(.door-chip) .bench-head .tab { padding: 3px 8px; }
  .bench-scene:has(.door-chip) .bench-side { gap: 8px; }
  .bench-scene:has(.door-chip) .bench-side .clock-bar { display: none; }
  .bench-scene:has(.door-chip) .bench-side > * { white-space: nowrap; }
}
/* HUY-160 (D112): 1580 px and up, three labels that sat on a neighbour or on the footer (measured at 1672×941 and 1920×1080).
   - The meter's label ended exactly on the footer's top edge, and while a hint is shown (hover) the footer grows by 25-29 px over it:
     it rides 34 art px (≈ 34 px at 1672, 39 px at 1920) higher, so it stays clear of the grown footer and of the conditions card.
   - The LCD stand's label steps right and down like in small windows (D93), clear of the probes' long result and the standby label.
   - The speaker bench's right-cable label wraps before the sheet (the sheet starts at 67 % of the width), as in small windows (HUY-137). */
@media (min-width: 1580px) and (min-height: 891px) {
  .bench-pin[data-key="bench-meter"] { translate: 0 calc(var(--u) * -34); }
  .bench-scene[data-device="lcd_tv_v1"] .bench-pin[data-region="stand"] { translate: calc(var(--u) * 32) calc(var(--u) * 8); }
  .bench-scene[data-device="abstract_pc_speaker_v1"] .bench-pin[data-region="right_cable"] { white-space: normal; max-width: calc(var(--u) * 264); }
}
/* D99, HUY-133: low windows (under 700 px tall). The scene is only 600–650 px high there, but the footer keeps its 18 px lines (up to 64 px,
   82 px on the speaker bench), so the meter's label sat on the footer and the conditions card on the label. The label rides above the
   footer by the amount the scene lost: the lift is a straight line in the scene height (10 % of it minus a constant; -41 px at 650,
   -46 px at 600, measured against the footer at 1366×650 and 1280×600), the card rides a little higher than the label (-25 px, -36 px).
   720 px and up are not touched. */
@media (max-height: 699px) {
  .bench-scene .bench-pin[data-key="bench-meter"] { translate: 0 calc(10cqh - 106px); }
  .bench-scene[data-device="abstract_pc_speaker_v1"] .bench-pin[data-region="meter"] { translate: 0 calc(-100% + 10cqh - 80px); }
  .bench-scene .bench-cond { translate: 0 calc(22cqh - 168px); }
  /* Labels that the sheet's new height or the father's strip now touch (measured at 1366×650 and 1280×600): the LCD back's backlight label steps
     left of the sheet and down; the speaker and knob labels step down under the strip; the probes label wraps instead of growing sideways. */
  .bench-scene[data-device="lcd_tv_v1"] .bench-pin[data-region="board_backlight"] { translate: -120px 24px; }
  .bench-scene[data-device="lcd_tv_v1"] .bench-pin[data-region="speaker"] { translate: 0 8px; }
  .bench-scene[data-device="abstract_crt_v1"] .bench-pin[data-region="knob"] { translate: 0 4px; }
  .bench-scene:not([data-device="abstract_pc_speaker_v1"]) .bench-pin[data-region="probes"] { max-width: 150px; white-space: normal; }
  .bench-scene[data-device="abstract_pc_speaker_v1"] .bench-pin[data-region="probes"] { translate: -12px 16px; } /* HUY-137 (Q05): clear of the volume label's long result and of the sheet */
  /* The notebook sheet keeps its 18 px lines too, so its foot sank into the footer; it rises by the same kind of straight line (25 px at 650,
     33 px at 600; the speaker bench, whose footer is three lines, 18 px and 27 px more than its D97 position). */
  .book-spread { bottom: calc(var(--cb) + 61px - 16cqh); }
  .bench-scene.cr-bench[data-device="abstract_pc_speaker_v1"] .book-spread { bottom: calc(var(--cb) + 89px - 18cqh); }
}
/* HUY-160: above the "waiting for parts" strip under the parts box. The box is centred, so the toast rides the gap under it plus 38 px; the gap is worked
   out from the box's size (art height = its width x 1474/2400, capped by the window height) as styles.css sizes it below. */
#app:has(.panel-art[data-art='parts']) > .toast { bottom: calc((100cqh - 74px - min(100cqh - 86px, min(100cqw - 24px, 1060px) * 0.61417)) / 2 + 38px); }
#app:has(.panel-art[data-art='parts']):has(.tip-strip) > .toast { bottom: calc((100cqh - 74px - min(100cqh - 86px, min(100cqw - 256px, 1060px) * 0.61417)) / 2 + 38px); }
@media (min-width: 1580px) and (min-height: 891px) {
  #app:has(.panel-art[data-art='parts']) > .toast { bottom: calc((100cqh - 112px - min(100cqh - 124px, min(100cqw - 24px, var(--u) * 1130) * 0.61417)) / 2 + 38px); }
  #app:has(.panel-art[data-art='parts']):has(.tip-strip) > .toast { bottom: calc((100cqh - 172px - min(100cqh - 248px, min(100cqw - 24px, var(--u) * 1130) * 0.61417)) / 2 + 38px); }
}
.bench-scene ~ .toast { bottom: calc(var(--u) * 74); z-index: 6; } /* HUY-140: above .bench-scene (z 5), else the bench hid the toast in chapters 1-2 */
.cr-toast { bottom: calc(var(--u) * 100); z-index: 6; } /* above .bench-scene (z 5): the tools answer through this toast (D84) */

/* ---------- title screen and 5-frame opening (HUY-81, D48) ---------- */
/* Title: the shop scene stays behind; only shade over it (D37), the name on a wooden sign like the shop's title card. */
.title-screen {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: 1fr auto auto 1fr auto;
  justify-items: center;
  gap: calc(var(--u) * 26);
  padding: calc(var(--u) * 40) calc(var(--u) * 40) calc(var(--u) * 18);
  background: radial-gradient(ellipse 70% 60% at 50% 46%, rgba(14, 9, 5, 0.35), rgba(14, 9, 5, 0.82) 100%), linear-gradient(180deg, rgba(8, 12, 34, 0.35), rgba(14, 9, 5, 0.25));
}
.title-sign { grid-row: 2; padding: calc(var(--u) * 22) calc(var(--u) * 56) calc(var(--u) * 18); text-align: center; }
.title-sign h1 { margin: 0; font-size: calc(var(--u) * 132); line-height: 0.9; font-weight: 400; color: var(--amber); text-shadow: calc(var(--u) * 6) calc(var(--u) * 6) 0 var(--wood-0); letter-spacing: 0.02em; white-space: nowrap; }
.title-sign .sub { margin: calc(var(--u) * 6) 0 0; font-size: max(20px, calc(var(--u) * 32)); color: var(--cream); }
.title-menu { grid-row: 3; display: flex; flex-wrap: wrap; justify-content: center; gap: calc(var(--u) * 18); }
.title-menu .px-btn { font-size: max(22px, calc(var(--u) * 36)); padding: calc(var(--u) * 8) calc(var(--u) * 30); min-width: calc(var(--u) * 220); }
.title-sound { grid-row: 4; align-self: start; padding: calc(var(--u) * 14) calc(var(--u) * 26); font-size: max(18px, calc(var(--u) * 24)); width: min(calc(var(--u) * 640), 100%); }
.title-sound h3 { margin: 0 0 8px; font-weight: 400; }
.title-note { grid-row: 5; margin: 0; max-width: calc(var(--u) * 1400); text-align: center; font-size: max(18px, calc(var(--u) * 20)); color: rgba(246, 231, 200, 0.85); background: rgba(14, 9, 5, 0.6); padding: 2px 10px; }

/* Opening: full stage, art above, words in a band below, pixel-block wipes between frames. */
.opening { --u: calc(100cqw / 1672); position: absolute; inset: 0; z-index: 80; background: #1c120c; cursor: pointer; }
.op-body { position: absolute; inset: 0; display: grid; grid-template-rows: 1fr auto; }
.op-frame { margin: 0; position: relative; display: grid; place-items: center; padding: calc(var(--u) * 22) calc(var(--u) * 36) 0; min-height: 0; }
.op-art { position: relative; background-repeat: no-repeat; box-shadow: 0 0 0 calc(var(--u) * 4) var(--wood-1), 0 0 0 calc(var(--u) * 7) var(--wood-0); }
/* Dim and tint are light over the picture, never drawn shapes (D37). */
.op-art::after { content: ''; position: absolute; inset: 0; background: var(--tint, #000); opacity: var(--dim, 0); pointer-events: none; }
.op-tag { position: absolute; z-index: 1; top: calc(var(--u) * 10); right: calc(var(--u) * 10); margin: 0; padding: 2px 10px; background: rgba(28, 18, 12, 0.85); color: var(--cream); font-size: max(18px, calc(var(--u) * 20)); }
.op-pending { display: grid; place-content: center; gap: calc(var(--u) * 10); text-align: center; background: #120b07; }
.op-pending-title { margin: 0; font-size: calc(var(--u) * 56); color: rgba(246, 231, 200, 0.55); letter-spacing: 0.04em; }
.op-pending-alt { margin: 0 auto; max-width: calc(var(--u) * 980); font-size: max(18px, calc(var(--u) * 24)); color: rgba(246, 231, 200, 0.5); }
.op-say { margin: calc(var(--u) * 18) calc(var(--u) * 36) calc(var(--u) * 20); padding: calc(var(--u) * 14) calc(var(--u) * 26) calc(var(--u) * 12); min-height: calc(var(--u) * 210); display: grid; grid-template-rows: auto 1fr auto; cursor: default; }
.op-count { margin: 0 0 calc(var(--u) * 4); font-size: max(18px, calc(var(--u) * 20)); color: var(--amber); opacity: 0.85; }
.op-lines { display: grid; align-content: start; gap: calc(var(--u) * 6); }
.op-line { margin: 0; font-size: max(20px, calc(var(--u) * 31)); line-height: 1.1; }
.op-prov { display: inline-block; margin-right: calc(var(--u) * 12); padding: 0 calc(var(--u) * 8); font-size: max(18px, calc(var(--u) * 20)); vertical-align: 0.15em; color: var(--wood-0); background: var(--paper-lo); }
.op-line.kind-fact .op-prov { background: var(--amber); }
.op-line.kind-era .op-prov { background: #b9c4d6; }
.op-line.kind-family_claim .op-prov { background: #e6c79a; }
.op-line.kind-placeholder { color: #ffe7b0; }
.op-line.kind-placeholder .op-prov { background: repeating-linear-gradient(135deg, #ffe7b0 0 8px, #e9c98a 8px 16px); }
.op-line.kind-placeholder .op-text::before { content: 'Chỗ này chờ bạn kể: '; color: var(--amber); }
.op-buttons { display: flex; justify-content: flex-end; gap: calc(var(--u) * 14); margin-top: calc(var(--u) * 8); }
.op-buttons .px-btn { font-size: max(18px, calc(var(--u) * 26)); }
.op-buttons small { font-size: max(18px, 0.75em); opacity: 0.75; }

/* Chapter chooser on the title screen (HUY-87, D56): smaller than the play buttons, under them. */
.title-menu.title-chapters { grid-row: 4; align-self: start; gap: calc(var(--u) * 12); }
.title-menu.title-chapters .px-btn { font-size: max(18px, calc(var(--u) * 26)); min-width: 0; padding: calc(var(--u) * 4) calc(var(--u) * 18); }
.title-menu.title-chapters .px-btn[aria-pressed="true"] { color: var(--amber); }

/* Inspect panel for a device with no bench drawing yet (chapter 2 LCD, D58): a labelled stand-in note. */
.look-card { text-align: left; padding: 0.5em 0.7em; line-height: 1.15; background: rgba(246, 231, 200, 0.92); color: var(--ink, #2a1a10); text-shadow: none; }
.diagram .block.is-link rect { stroke-dasharray: 6 4; }
/* Filled column by column: block checks in the first two columns, looks from outside in the last two; the long labels
   ("Kiểm tra đèn nền và inverter", "Nhìn kỹ mặt màn (đã rút điện)") then share a column and the tray still fits at 1280×720. */
.panel-art .tray.generic .checks { grid-template-columns: repeat(4, auto); grid-template-rows: repeat(3, 1fr); grid-auto-flow: column; gap: 0.6cqh 0.6cqw; }
.panel-art .tray.generic .checks .px-btn { font-size: 0.82em; }
@media (max-width: 760px), (max-height: 460px) {
  /* Narrow screens: the generic tray follows the one-column paper layout too (the four-column rule above outranks it). */
  .panel-art .tray.generic .checks { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-flow: row; }
  .panel-art .tray.generic .checks .px-btn { white-space: normal; }
}
.panel-art .bench-tv .look-card { font-size: 0.9em; }
.panel-art .bench-tv .look-card p { margin: 0 0 0.3em; }

/* ---------- classroom, chapter 3 (HUY-113, D84) ----------
   Chalk words go straight onto the blank board of the plate (area measured with sharp, rows slanted like the board);
   the student is a cut-out figure drawn 1:1 (never a code sprite); everything else reuses the shop's wood and paper. */
/* Board type: never below 18 px (D77/D78). */
.cr-board { position: absolute; transform-origin: 0 0; color: rgba(236, 240, 226, 0.92); font-size: max(18px, calc(var(--u) * 22)); line-height: 1.02; overflow: hidden; }
.cr-board p { margin: 0; }
/* The board sits over its own click area: only its buttons take clicks, the rest still falls through to "Bảng phấn". */
.hud > .cr-board { pointer-events: none; }
.cr-board button { pointer-events: auto; }
.chalk-corner { font-size: max(18px, calc(var(--u) * 18)); color: rgba(236, 240, 226, 0.6); margin-bottom: calc(var(--u) * 6) !important; }
.chalk-big { font-size: max(20px, calc(var(--u) * 30)); }
.chalk-pager { margin: 0; white-space: nowrap; }
.chalk-pager[hidden], .chalk-list li[hidden], .chalk-pager button[hidden] { display: none; }
.chalk-list { margin: 0; padding: 0; list-style: none; }
.chalk-list li { margin: 0 0 calc(var(--u) * 7); padding-left: 1.3em; }
.chalk-list li .chalk { display: block; width: 100%; }
.chalk-list li .chalk-no { display: inline-block; width: 1.3em; margin-left: -1.3em; }
.chalk-no { color: rgba(236, 240, 226, 0.6); }
.chalk { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; text-shadow: 0 0 1px rgba(255, 255, 255, 0.4); }
.chalk:hover, .chalk:focus-visible { color: #fff2b0; text-decoration: underline dotted; outline: none; }
.cr-board-under { overflow: visible; }
.chalk-tell { font-size: max(18px, calc(var(--u) * 19)); color: rgba(236, 240, 226, 0.55); text-shadow: 0 0 2px #000, 1px 1px 0 #1d140e; }
.cr-student { position: absolute; pointer-events: none; }
.cr-bubble { transform: none; font-size: max(18px, calc(var(--u) * 22)); }
/* Only the inner body scrolls (when the lines are long), so the tail outside the paper is never clipped (QA Q1). */
.cr-bubble-body { max-height: calc(var(--u) * 380); overflow-x: hidden; overflow-y: auto; }
.cr-bubble-body::-webkit-scrollbar { width: 0; height: 0; }
.cr-note { font-size: max(18px, 0.85em); }
.cr-bubble .bubble-text { font-size: max(18px, calc(var(--u) * 22)); }
.cr-bubble::after { left: auto; right: calc(var(--u) * -18); bottom: auto; top: calc(var(--u) * 110); clip-path: polygon(0 0, 100% 0, 0 100%); box-shadow: none; }
.cr-bubble .px-btn.ink { background: none; box-shadow: none; padding: 0; color: #a3392b; text-decoration: underline dotted; font-size: 1em; }
.cr-remark { color: #7a3a14; }
.cr-task { font-size: max(18px, calc(var(--u) * 22)); overflow: auto; }
.cr-task .px-btn { font-size: max(18px, calc(var(--u) * 22)); }
.cr-hud .pin { gap: 0; padding: 0 calc(var(--u) * 12); }
.cr-pending { background: #1c120c; display: grid; place-content: center; }
.cr-book .leaf h4 { margin-top: var(--rule) !important; }
.cr-book .cr-lines, .cr-book .cr-plan, .cr-book .cr-rows { list-style: none; padding: 0; margin: 0; }
.cr-book .mark-bad { color: #a3392b; }
.cr-book .mark-good { color: #2f6b34; }
.cr-book .mark-unknown { color: #7a3a14; }
.cr-book .mark-stale { color: #8a7f70; }
.cr-book .cr-said { color: #7a3a14; }
.cr-book .cr-by { color: #8a7f70; }
.cr-book .cr-chips { display: flex; flex-wrap: wrap; gap: 0 0.8em; }
.cr-book .leaf .px-btn { min-height: 0; }
.cr-book .cr-chip[aria-pressed='true'] { color: #a3392b; background: rgba(224, 165, 46, 0.25); }
.cr-book .cr-cond[aria-pressed='true'] { color: #a3392b; font-weight: 700; }
.cr-book .cr-moves { display: flex; flex-direction: column; align-items: flex-start; }
.cr-book .cr-tell:not(:disabled) { color: #8a7f70; }
.cr-book .cr-legend { margin-top: 0; }
/* D91: the student's notebook is paged like the father's (units measured on the paper, a page turner); nothing scrolls. */
.cr-book .du h4 { margin-top: 0 !important; }
.cr-book .vo-book .leaf { overflow: hidden; }
.cr-book .vo-foot[hidden] { display: none; }
/* HUY-145: the student's exercise book has a ballpoint and an eraser lying over the top-right corner of the right page (measured on
   ui_student_notebook_v1.webp: the pen's left edge runs from x 77 % at y 16.7 % to x 86.6 % at y 33 % of the image). The right leaf wraps its text
   around them with a float shaped like that edge, so no word is printed over the pen. The page corner does not curl in this image. */
.cr-book[data-panel='notebook_student'] .leaf:last-child::before { content: ''; float: right; width: 30%; height: 40%; shape-outside: polygon(7% 0, 100% 0, 100% 59%, 92% 52%, 75% 41%, 56% 30%, 43.3% 19%, 23.7% 8.5%); shape-margin: 0.5em; }
.cr-diagram li { margin: 6px 0; }
.cr-diagram .cr-chip { padding: 2px 8px; }
.cr-chip.mark-bad { color: #a3392b; }
.cr-chip.mark-good { color: #2f6b34; }
.cr-bench .bench-head .cr-bench-note { margin: 0; font-size: max(18px, calc(var(--u) * 20)); color: var(--cream); }
