:root{color-scheme:dark;--ink:#f8f2e8;--muted:#d0c8d6;--quiet:#b9b2c4;--gold:#f3c382;--blue:#adcafa;--night:#141322;--line:#b6a3d12f;--panel:#211d32;--sans:"Malgun Gothic","Apple SD Gothic Neo","Noto Sans KR",system-ui,sans-serif;--serif:"Nanum Myeongjo","Batang","AppleMyungjo",Georgia,serif;font-family:var(--sans);background:var(--night);color:var(--ink);font-synthesis:none}
*,*::before,*::after{box-sizing:border-box}body{margin:0;min-width:0}button,input{font:inherit}button{cursor:pointer}button:disabled{cursor:default;opacity:.55}button,input,a{touch-action:manipulation}button:focus-visible,input:focus-visible,a:focus-visible{outline:3px solid #f8d99c;outline-offset:4px}h1,p{margin:0}h1:focus{outline:none}strong{color:#fff0cb}.sr,.skip:not(:focus){position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.skip:focus{position:fixed;z-index:9;top:8px;left:8px;background:#fff0cb;color:#1a1526;padding:12px;border-radius:6px}
.topbar{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:12px max(24px,env(safe-area-inset-right)) 12px max(24px,env(safe-area-inset-left));border-bottom:1px solid var(--line);min-height:72px;background:#171523}
.brand{display:flex;align-items:center;gap:12px;font-weight:800;letter-spacing:-.04em;line-height:1.3}.brand small{display:block;color:var(--quiet);font-size:.78rem;font-weight:500;letter-spacing:0;margin-top:3px}.sigil{flex:0 0 38px;width:38px;height:38px;display:grid;place-items:center;color:var(--gold);font:700 24px Georgia,serif;border:1px solid #a27850;border-radius:5px;background:radial-gradient(ellipse at top,#54384b,#211a30 80%);box-shadow:inset 0 0 0 3px #1b1928}
.primary,.secondary,.quiet{display:inline-flex;align-items:center;justify-content:center;gap:10px;min-height:46px;max-width:100%;border-radius:7px;padding:10px 17px;font-size:.97rem;font-weight:800;line-height:1.4;white-space:normal;text-align:center;transition:background .18s,border-color .18s,color .18s}.primary{border:1px solid #ffe1aa;background:linear-gradient(180deg,#ffdb9d,#eab172);color:#25172a;box-shadow:0 3px 12px #0b080937}.primary:hover{background:#ffe5b9}.primary span{font-size:1.16em;line-height:1}.secondary{border:1px solid #a699b6;background:#28233a;color:var(--ink)}.secondary:hover:not(:disabled){background:#423650}.quiet{border:1px solid transparent;background:none;color:var(--muted)}.quiet:hover,.quiet[aria-pressed=true]{background:#362f49;border-color:#8b799f}.motion{flex:none;font-size:.85rem;padding-inline:10px}
.scene{position:relative;isolation:isolate;overflow:hidden;display:grid;align-items:center;min-height:clamp(550px,calc(100svh - 72px),900px);padding:clamp(24px,6vw,90px);background:#211a34}.scene-art,.scene-shade,.travel-edge,.door-light{position:absolute;inset:0;width:100%;height:100%;z-index:-2;pointer-events:none}.scene-art{object-fit:cover;object-position:center}.scene-shade{z-index:-1;background:linear-gradient(90deg,#10101bf5 0%,#141323e3 24%,#14132395 45%,#11102310 73%),linear-gradient(0deg,#10101b99 0%,transparent 30%)}.hall .scene-art{object-position:58% 52%}.gallery .scene-art,.restore .scene-art{object-position:68% 50%}.scene-copy,.restore-copy{position:relative;max-width:34rem}.eyebrow{color:var(--gold);font-size:.86rem;letter-spacing:.085em;font-weight:800;line-height:1.55;margin-bottom:12px}.eyebrow span{padding-inline:4px;color:var(--muted)}
.scene h1{font-size:clamp(2.6rem,5.6vw,5.5rem);line-height:1.08;letter-spacing:-.08em;font-family:var(--serif);font-weight:800;text-wrap:balance;text-shadow:0 3px 18px #14101a90}.hall h1{max-width:9ch;line-height:1.07}.title-piece{display:block;white-space:nowrap}.title-gold{color:#ffd99b}.lede{color:#eee6e9;line-height:1.75;font-size:clamp(1rem,1.5vw,1.22rem);margin:18px 0 25px;max-width:31rem;word-break:keep-all}.scene-index{position:absolute;bottom:clamp(18px,3vw,36px);right:clamp(18px,3vw,42px);background:#171321e8;color:#fff4e0;padding:10px 14px;border:1px solid #af9064a8;border-radius:4px;font-weight:700;font-size:.89rem}.scene-index span{color:var(--gold);padding-right:6px;font:700 1.08rem Georgia,serif}.gallery h1,.restore h1,.corridor h1{font-size:clamp(2.25rem,4.8vw,4.3rem)}.gallery .scene-shade,.restore .scene-shade{background:linear-gradient(90deg,#11101deb 0%,#181523d4 30%,#16132465 61%,#16132421 100%),linear-gradient(0deg,#10101bd9 0%,transparent 47%)}
.corridor{align-items:end}.corridor .scene-shade{background:linear-gradient(0deg,#11101cf5 2%,#141321cf 22%,transparent 64%),linear-gradient(90deg,#11101c50,transparent 65%)}.corridor .scene-copy{max-width:40rem}
.world-stage { position: absolute; inset: 0; z-index: -1; visibility: hidden; }
.world-stage[data-ready] { visibility: visible; }
.world-stage canvas { display: block; touch-action: pan-y; }
.walk-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.walk-counter { color: #ffe0ab; font-weight: 750; }
.walk-controls [aria-disabled="true"] { opacity: .7; cursor: default; }
.signal-board{display:inline-block;border:1px solid #a8896e9c;border-radius:7px;background:#161322ed;padding:10px 14px;margin:0 0 20px;max-width:100%}.signal-board>span{font-size:.78rem;color:#e9d6b7;font-weight:750}.signal-board ol{display:flex;gap:8px;list-style:none;padding:0;margin:8px 0 0}.signal-board li{display:grid;gap:3px;justify-items:center;min-width:22px;font-size:.78rem;color:#f6e4cb}.signal-board li>span:first-child{width:12px;height:12px;border:1px solid #ffe7b1;background:#ffce83;box-shadow:0 0 7px #ffbe66b0;border-radius:50%}.signal-board .unlit{color:#fff;font-weight:900}.signal-board .unlit>span:first-child{background:#181425;border:2px dashed #c5bed7;box-shadow:none}.gallery .primary{display:flex;width:max-content}
.lesson-open .topbar {
  min-height: 54px;
  padding-block: 3px;
}
.topbar { flex-wrap: wrap; }
.topbar-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-inline-start: auto; }
.topbar-tools [hidden] { display: none; }
.topbar .course-return { min-height: 44px; text-decoration: none; color: inherit; }
.topbar .course-return:hover { color: var(--gold); }
.fullscreen { font-size: .85rem; padding-inline: 10px; }
@media (max-width: 410px) { .fullscreen { font-size: .76rem; padding-inline: 5px; } }
.entrance-scene .scene-copy { width: min(100%, 34rem); }
.entrance-scene .scene-art { object-position: 68% center; }
.entrance-scene h1 { font-size: clamp(2.15rem, 4.3vw, 4.4rem); word-break: keep-all; overflow-wrap: anywhere; }
.entrance-before { opacity: 0; }
.story-paper {
  position: relative;
  color: #382524;
  background: #f8e8c9;
  border: 1px solid #d4a775;
  border-radius: 7px;
  padding: 16px clamp(13px, 2.7vw, 26px);
  margin-block: 17px 20px;
  line-height: 1.65;
  font-weight: 700;
  box-shadow: 0 8px 30px #10101d8c;
  overflow-wrap: anywhere;
}
.sealed-envelope {
  display: grid;
  justify-items: center;
  gap: 2px;
  width: min(100%, 22rem);
  padding: 0;
  background: none;
  border: 0;
  border-radius: 8px;
}
.envelope-art { position: relative; width: 100%; }
.envelope-art img { display: block; width: 100%; height: auto; filter: drop-shadow(0 6px 12px #0c081abc); transition: transform .18s; }
.seal-number { position: absolute; top: 56%; left: 49.7%; translate: -50% -50%; color: #fff0c8; font: 700 clamp(1.25rem, 2.5vw, 1.65rem)/1 Georgia,serif; }
.envelope-action { display: flex; align-items: center; gap: .55em; min-height: 44px; padding-inline: 18px; border: 1px solid #c59c70; border-radius: 7px; background: #261c2e; color: #ffe3b9; font-weight: 800; }
.sealed-envelope:hover .envelope-art img { transform: translateY(-3px); }
.sealed-envelope:hover .envelope-action { background: #3e2a3b; }
.letter-sign { margin-top: 8px; color: #624748; font-size: .9rem; }
.paper-clues { margin: 8px 0 0; padding-inline-start: 1.55em; }
.paper-clues li + li { margin-top: 4px; }
.gate-notes { display: grid; gap: 4px; padding: 0; margin: 0; list-style: none; }
.gate-notes li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 12px;
  border: 1px solid #8c735f;
  border-radius: 5px;
  background: #231d30f2;
  line-height: 1.4;
}
.gate-notes b { color: var(--gold); font: 700 1.65rem Georgia, serif; }
.gate-clue { margin-block: 4px 10px; color: #f4dfba; }
.gate-clue summary { display: list-item; align-content: center; min-height: 44px; width: fit-content; cursor: pointer; font-weight: 750; }
.gate-clue[open] { background: #201c2bf2; border-radius: 6px; padding-inline: 10px; padding-bottom: 8px; }
.gate-form { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
.gate-form .entry { flex: 0 1 175px; }
.gate-form input { border-color: #d7b083; font-size: 1.45rem; letter-spacing: .36em; text-align: center; }
.gate-form .primary { min-height: 48px; }
.gate-form .feedback:not(:empty) { flex-basis: 100%; margin: 0; }
.safe-panel {
  position: relative;
  isolation: isolate;
  width: 100%;
  border: 1px solid #be9868;
  border-radius: 10px;
  background: #302238;
  overflow: hidden;
}
.safe-door { display: block; width: 100%; height: 100%; object-fit: fill; }
.safe-panel .safe-door { position: absolute; inset: 0; z-index: -1; }
.safe-bench { display: grid; align-items: start; gap: 12px; }
.safe-bench > * { min-width: 0; }
.safe-form .feedback:empty { display: none; }
.safe-controls {
  display: grid;
  gap: 8px;
  width: min(70%, 19rem);
  margin-left: auto;
  padding: 14px;
  background: #1b1425e8;
}
.safe-controls input { background: #101319; color: #fff0bb; }
.safe-keys { display: grid; grid-template-columns: repeat(3,minmax(44px,1fr)); gap: 5px; }
.safe-keys button { padding: 4px; min-height: 44px; font-size: 1.125rem; }
.safe-keys [data-safe-key="0"] { grid-column: 2; }
.safe-delete { grid-column: 3; }
.safe-reveal {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  max-width: 25rem;
  aspect-ratio: 2 / 1;
  margin-bottom: 12px;
  border: 3px double #c69b62;
  border-radius: 9px;
  background: radial-gradient(ellipse,#6f4a30,#221827 73%);
  perspective: 600px;
}
.safe-reveal .safe-door { position: absolute; inset: 0; transform-origin: right center; transform: rotateY(-86deg); opacity: .15; }
.safe-key { position: relative; width: 43%; height: 8%; border-radius: 4px; background: #f5ce87; box-shadow: 0 0 20px #f4a5548c; }
.safe-key::before, .safe-key::after { position: absolute; content: ''; }
.safe-key::before { width: 30%; aspect-ratio: 1; inset: 50% auto auto 0; translate: -25% -50%; border: clamp(5px,1vw,9px) solid #f5ce87; border-radius: 50%; background: #60422f; }
.safe-key::after { right: 4%; top: 65%; width: 18%; height: 160%; border-inline: 6px solid #f5ce87; }
.museum-prop {
  position: relative;
  display: grid;
  justify-items: center;
  width: min(100%, 20rem);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff0d4;
}
.museum-prop img { display: block; width: 100%; height: auto; filter: drop-shadow(0 7px 14px #0b0814be); }
.museum-prop span { position: absolute; top: 45%; left: 50%; translate: -50% -50%; width: 67%; font-size: 1rem; font-weight: 800; text-shadow: 0 2px 5px #0b0814; }
.museum-prop:hover img { filter: brightness(1.16) drop-shadow(0 7px 14px #0b0814be); }
.record-ledger span { top: 50%; }
.chapter2 .reader-workspace .map-diagram {
  border-color: #8ab6ab;
  background-color: #15272bec;
  box-shadow: inset 0 0 0 4px #5c79773b, inset 0 0 22px #67c6ab28;
}
.chapter2 .reader-workspace .interaction { border-color: #8b7760; background-color: #271f2cee; }
.reader-startup .map-diagram { animation: reader-wake .45s ease-out both; }
@keyframes reader-wake { from { filter: brightness(.5); } to { filter: brightness(1); } }
.ledger-workspace { position: relative; }
.chapter3 .ledger-workspace .archive-diagram {
  border-color: #b38e68;
  background: linear-gradient(90deg,#351e2d 0 6px,#b58b67 6px 7px,#281b2be8 7px 100%);
  box-shadow: inset 0 -4px #a97a5b55, inset 0 -7px #302132;
}
.ledger-opening { perspective: 1050px; }
.ledger-opening::after {
  content: '';
  position: absolute;
  z-index: 2;
  inset: 0 auto 0 0;
  width: calc((100% - 12px) * .65);
  pointer-events: none;
  background: url('./media/archive-cover.webp') center / 100% 100% no-repeat;
  transform-origin: left;
  animation: ledger-open .48s ease-out both;
}
@keyframes ledger-open {
  from { transform: rotateY(0); opacity: 1; }
  to { transform: rotateY(-110deg); opacity: 0; visibility: hidden; }
}
:root[data-reduced] .ledger-opening::after { display: none; }
@media (min-width: 821px) {
  .entrance-scene.entrance-safe .scene-copy { width: 100%; max-width: 64rem; }
  .safe-bench { grid-template-columns: minmax(230px,.88fr) minmax(0,1.12fr); gap: 16px; }
}
@media (max-width: 819px) {
  .ledger-opening::after { width: 100%; }
}
@media (max-width: 420px) {
  .safe-controls { width: min(78%, 19rem); padding: 9px; }
}
@media (max-width: 340px) {
  .safe-controls { width: 100%; }
}
.gate-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.gate-mechanism {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: 0 0 78px;
  height: 48px;
  border: 1px solid #e9ba79;
  border-radius: 8px;
  background: linear-gradient(145deg,#503329,#211a28);
}
.gate-wheel {
  position: relative;
  width: 28px;
  height: 28px;
  border: 3px double #f7d399;
  border-radius: 50%;
  background: radial-gradient(circle,#ba8150,#704126);
}
.gate-wheel::after { content: ''; position: absolute; inset: 7px 2px; border-radius: 2px; background: #ffd990; }
.gate-bolt { position: absolute; top: 20px; height: 6px; width: 35px; border-radius: 3px; background: #d7a363; }
.gate-bolt.left { left: 3px; }
.gate-bolt.right { right: 3px; }
.gate-open .gate-wheel { transform: rotate(75deg); }
.gate-open .gate-bolt.left { transform: translateX(-13px); }
.gate-open .gate-bolt.right { transform: translateX(13px); }
.task-clue { margin-top: 5px; color: #f3ca97; line-height: 1.45; }
.task-evidence { display: flex; align-items: center; flex-wrap: wrap; gap: 3px 12px; margin-top: 4px; }
.task-evidence .task-clue { margin-top: 0; }
.clue-digits { display: flex; gap: 5px; margin: 0; padding: 0; list-style: none; }
.clue-digits li { display: grid; place-items: center; min-width: 1.7em; padding-inline: 3px; border: 1px solid #c89769; border-radius: 4px; color: #ffe1b4; font-weight: 800; line-height: 1.5; }
.clue-digits .pending { color: var(--muted); border-style: dashed; border-color: #8f7aa3; }
.lesson-open .brand small { display: none; }
.lesson-open .sigil { width: 31px; height: 33px; flex-basis: 31px; font-size: 21px; }
#app[data-lesson-backdrop] {
  min-height: calc(100svh - 54px);
  background-color: #181324;
  background-image: linear-gradient(180deg, #151122e8, #1b14246b 36%, #151122df), var(--lesson-art);
  background-size: cover;
  background-position: 62% center;
}
#app[data-lesson-backdrop="entrance"] { --lesson-art: url('./media/lesson-gate-workbench.webp'); background-position: center; }
#app[data-lesson-backdrop="gallery"] { --lesson-art: url('./media/lesson-gallery-workbench.webp'); background-position: center; }
#app[data-lesson-backdrop="map"] {
  --lesson-art: url('./media/map-room-v2.webp');
  background-image: linear-gradient(180deg, #151122f2, #1b14248c 44%, #151122e8), var(--lesson-art);
}
#app[data-lesson-backdrop="archive"] {
  --lesson-art: url('./media/archive-room-v2.webp');
  background-image: linear-gradient(180deg, #151122f2, #20172b95 42%, #151122ef), var(--lesson-art);
}
.restore-copy .primary { margin-top: 12px; }
.map-scene .scene-art { object-position: 65% center; }
.map-scene h1 { font-size: clamp(2.1rem,5.2vw,4.5rem); word-break: keep-all; }
.map-scene .scene-shade { background: linear-gradient(90deg,#141124f5,#141124b0 42%,#14112420 85%), linear-gradient(0deg,#141124d6,transparent 60%); }
.map-answer { display: flex; align-items: end; gap: 9px; margin-bottom: 10px; }
.map-answer .entry { flex: 0 1 145px; }
.map-answer > span { font-size: 1.5rem; padding-bottom: 8px; }
.map-record { padding: 12px; margin-bottom: 12px; border: 1px solid #aa8662; border-radius: 7px; background: #241a2ceb; color: #ffe1ab; }
@media (max-width: 750px) {
  .map-scene .scene-shade { background: linear-gradient(0deg,#141124fa 0%,#141124d6 39%,#14112432 78%); }
}

.lesson {
  width: 100%;
  max-width: 1680px;
  margin-inline: auto;
  padding: 14px clamp(12px, 3vw, 44px) 18px;
}
.task { margin-bottom: 12px; }
.task-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 12px; flex-wrap: wrap; }
.task h1, .teacher h1 {
  font-size: clamp(1.25rem, 2.4vw, 1.75rem);
  line-height: 1.25;
  letter-spacing: -.04em;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.lesson-progress { color: var(--gold); font-size: .875rem; font-weight: 750; }
.prompt {
  margin-top: 6px;
  font-size: clamp(1.0625rem, 1.75vw, 1.1875rem);
  line-height: 1.55;
  color: #f5eef5;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.lesson-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}
.diagram {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: clamp(11px, 1.6vw, 22px);
  background: #1b172bb8;
  border: 1px solid #665672;
  border-radius: 9px;
}
.model-content { flex: 1; display: grid; align-content: center; gap: 12px; min-width: 0; }
.visual-head { margin-bottom: 12px; }
.diagram[data-mode="compare"] .visual-head { display: flex; align-items: center; justify-content: space-between; gap: 4px 12px; flex-wrap: wrap; }
.compare-control { min-height: 44px; border: 1px solid #847094; }
.compare-control[aria-pressed="true"] { background: #493652; border-color: var(--gold); color: #ffe2b1; }
.legend { display: flex; gap: 6px 18px; flex-wrap: wrap; }
.legend span { display: flex; align-items: center; gap: 7px; color: #eee4f0; font-weight: 700; }
.legend .mark { width: 16px; height: 16px; }
.rack-caption { display: block; margin-bottom: 4px; color: var(--muted); font-weight: 700; }
.bundles { display: flex; flex-wrap: wrap; gap: 8px; }
.diagram[data-mode="copy"] .bundles { justify-content: center; }
:is(.bundle,.drop-slot) {
  --preferred-tile: clamp(16px, 4.3cqw, 33px);
  --available-width: 100cqw;
  --size-count: var(--row-max);
  --mark-gap: 4px;
  --tile-size: max(2px, min(var(--preferred-tile), calc((var(--available-width) - 18px) / var(--size-count) - var(--mark-gap))));
  width: min(100%, calc(18px + var(--row-max) * (var(--tile-size) + var(--mark-gap))));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  min-width: 0;
  padding: 8px;
  border: 1px solid #8f7aa3;
  border-radius: 7px;
  background: #302740ed;
}
.diagram[data-mode="copy"] :is(.bundle,.drop-slot) {
  --preferred-tile: clamp(16px, 5.6cqw, 35px);
  padding-block: 12px;
}
.drop-slot {
  align-items: center;
  min-height: 64px;
  color: #efdbbf;
  border: 2px dashed #a98771;
  background: #211b30dc;
  line-height: 1.3;
  font-weight: 750;
  text-align: center;
}
.drop-slot span { color: var(--gold); font-size: 1.35rem; }
.drop-slot:hover, .drop-ready { border-color: #ffdc9f; background: #473346; }
.model-tip { color: var(--muted); margin-top: 5px; line-height: 1.45; }
[data-pickup] { touch-action: none; user-select: none; cursor: grab; }
[data-dragging] { cursor: grabbing; opacity: .55; }
.drag-shadow {
  position: fixed;
  bottom: auto;
  margin: 0;
  z-index: 15;
  transform: none;
  pointer-events: none;
  opacity: .9;
}
.diagram[data-mode="split"] .bundle, .diagram[data-mode="repair"] .bundle {
  --size-count: 25;
  --preferred-tile: clamp(11px, 3cqw, 27px);
  --mark-gap: clamp(1px, .4cqw, 3px);
}
.diagram[data-mode="split"] .bundle { --preferred-tile: clamp(12px, 3.25cqw, 29px); }
.diagram[data-mode="repair"] .bundle { --size-count: 30; }
.diagram[data-mode="compare"] .bundle {
  --size-count: 14;
  --preferred-tile: clamp(13px, 3.3cqw, 27px);
}
.bundle.lit { border-color: #e5b181; background: #48354b; }
.dim .bundle { border-style: dashed; }
.rail { display: flex; gap: var(--mark-gap); }
.mark { display: inline-block; border-radius: 2px; border: 1px solid #f1cf96; background-position: center; background-size: cover; }
.mark.gold { background-color: #efb66e; background-image: url('./media/tile-gold.webp'); }
.mark.blue { background-color: #b6cff3; background-image: url('./media/tile-blue.webp'); border-color: #c6d7f5; }
.mark.ghost { background: transparent; border: 1px dashed #e4cfea; }
.mark.just-added { border: 2px solid #ffe1a6; box-shadow: inset 0 0 0 1px #473a64; }
.added-count { display: flex; align-items: center; gap: 7px; }
.added-count .mark { width: 16px; height: 16px; }
.rail .mark { flex: 0 0 var(--tile-size); width: var(--tile-size); height: var(--tile-size); }
.lesson-tools { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 12px; }
.calculation, .interaction {
  min-width: 0;
  padding: clamp(11px, 1.4vw, 18px);
  border: 1px solid #665672;
  border-radius: 9px;
  background: #201a2aee;
}
.calculation { display: flex; flex-direction: column; justify-content: center; gap: 8px; container-type: inline-size; }
.calculation:empty { display: none; }
.calculation:empty + .interaction { grid-column: 1 / -1; }
.equation {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  color: #e5d9ec;
}
.copy-counts { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 0; }
.copy-counts div, .copy-counts dt { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.copy-counts dd { margin: 0; color: var(--ink); font-weight: 750; font-variant-numeric: tabular-nums; }
.copy-counts dt { color: var(--muted); }
.copy-counts .mark { width: 16px; height: 16px; }
.ratio{display:inline-flex;gap:.15em;align-items:baseline;font:700 clamp(1.5rem,3vw,2.25rem)/1.1 Georgia,serif;font-variant-numeric:lining-nums tabular-nums;color:#ffdda1;white-space:nowrap}.ratio .colon{color:#d2bfdc}
.equation .ratio { font-size: clamp(2.25rem, 8cqw, 3.5rem); }
.check-diagram .ratio { font-size: clamp(2.25rem, 8cqw, 6rem); }
.ratio-operation { color: var(--gold); font-size: 1.125rem; font-weight: 750; }
.check-diagram { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 8px 20px; min-height: 90px; color: var(--muted); }
.records { width: 100%; border-collapse: collapse; text-align: center; margin-bottom: 12px; line-height: 1.45; }
.records td, .records th { padding: 7px 4px; border-bottom: 1px solid #6e5b80; }
.records td { font-size: 1.1875rem; color: #ffdda1; font-weight: 800; }
.records th { font-weight: 700; color: #f5eaf6; }
.records.check-mapping { max-width: 640px; margin: 0 auto; }
.check-mapping td { font-variant-numeric: tabular-nums; }
.check-mapping tbody td:nth-child(3) { background: #493652; }

.choice-set { padding: 0; border: 0; margin: 0 0 12px; min-width: 0; }
.choice-set legend, .entry>span { color: #f0e6ee; margin-bottom: 7px; font-weight: 700; }
.options { display: flex; gap: 7px; flex-wrap: wrap; }
.options label { display: flex; align-items: center; gap: 7px; min-height: 46px; padding: 8px 10px; border: 1px solid #847094; border-radius: 7px; background: #2b243c; cursor: pointer; line-height: 1.4; font-weight: 700; }
.options label:has(input:checked) { background: #493652; border-color: #ffcf8f; color: #ffe2b1; }
.options label:focus-within { outline: 2px solid #ffe2b1; outline-offset: 2px; }
.options input { margin: 0; accent-color: #f3c382; flex: none; }
.entries { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.entry { display: grid; flex: 1 1 130px; max-width: 100%; min-width: 0; }
.entry>span { display: block; line-height: 1.45; }
.entry input { min-width: 0; width: 100%; height: 48px; background: #121120; color: #fff1d8; border: 1px solid #a48aac; border-radius: 6px; padding: 7px 10px; font-size: 1.19rem; }
.stepper { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.stepper button { min-width: 52px; min-height: 50px; font-size: 1.4rem; padding: 4px; }
.stepper output { min-width: 3.8em; text-align: center; color: #ffe0af; font-size: 1.125rem; font-weight: 800; }
.actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.feedback { color: #ffdcab; line-height: 1.55; word-break: keep-all; }
.feedback:not(:empty) { margin-top: 9px; }
.success { background: #2b3635; border: 1px solid #658676; border-left: 4px solid #b5d5a6; padding: 11px 13px; border-radius: 6px; color: #f1f3e9; line-height: 1.55; margin-bottom: 12px; }
.success b { display: block; color: #d7efcb; }
.teacher .lede { margin-bottom: 0; }
.restore{grid-template-columns:minmax(0,1fr) minmax(0,.88fr);gap:clamp(12px,4vw,68px)}.restore-copy{z-index:1}.next-room{color:#f9e7ca;font-size:.91rem;line-height:1.6;background:#171422ec;border:1px solid #8e748d;border-radius:7px;padding:8px 10px;max-width:32rem}.next-room b{color:var(--gold);margin-right:4px}.next-room span{color:#d8cbdf}.plinth-stage{position:relative;display:grid;place-items:center;align-content:end;min-height:clamp(270px,33vw,415px);padding:15px 10px 14px;border:1px solid #a8896e9c;border-radius:9px;background:radial-gradient(ellipse at 50% 52%,#47314bbb,#181324ed 75%);box-shadow:0 12px 40px #0b06139c}.plinth{display:grid;place-items:center;position:relative;width:min(68%,250px);height:60px;margin-top:111px;border:1px solid #c19a6d;border-top:5px solid #e7b480;border-radius:8px 8px 3px 3px;background:linear-gradient(145deg,#614355,#29233d);color:#f9d5a1;font-size:.72rem;font-weight:800;letter-spacing:.06em}.plinth::before{position:absolute;bottom:100%;left:22%;width:56%;height:11px;content:"";border:1px dashed #f0ba7d;border-radius:6px 6px 0 0}.artifact{position:absolute;z-index:1;display:grid;align-content:center;text-align:center;width:min(38%,150px);min-width:103px;min-height:76px;border:3px double #a16d49;border-radius:7px;background:linear-gradient(155deg,#f6d39f,#b97751);color:#271b2c;font-weight:800;box-shadow:0 8px 16px #110e20a8;left:6%;bottom:124px;transform:rotate(-10deg);padding:6px 4px}.artifact span{font-size:.78rem}.artifact i{font-size:1.62rem;font-style:normal}.artifact .ratio{color:#2a1730;justify-content:center}.artifact .ratio span{font-size:1em}.artifact .colon{color:#4b3046}.done .artifact{left:50%;bottom:119px;transform:translateX(-50%)}.done .plinth::before{display:none}.plinth-light{position:absolute;pointer-events:none;inset:3% 12% 12%;background:radial-gradient(ellipse at 50% 59%,#ffbf695e,transparent 69%);opacity:0}.done .plinth-light{opacity:1}.plinth-stage .primary,.plinth-status{margin:12px 0 0;min-height:46px}.plinth-status{display:grid;place-items:center;color:#e9f5d6;font-size:.9rem;font-weight:800}
@media (min-width: 741px) and (min-height: 600px) {
  .lesson-open { display: flex; flex-direction: column; min-height: 100svh; }
  .lesson-open #app { display: flex; flex: 1; }
  .lesson:has(.lesson-workspace) { display: flex; flex-direction: column; }
  .lesson-workspace { flex: 1; grid-template-rows: minmax(min-content, 1fr) auto; }
  .diagram[data-mode="copy"] :is(.bundle,.drop-slot) {
    /* Two complete groups fit on each row with room for the group boundaries. */
    --available-width: 48cqw;
    --preferred-tile: clamp(36px, min(6cqw, 8svh), 68px);
    gap: 10px;
  }
  .diagram[data-mode="split"] .bundles { justify-content: center; }
  .diagram[data-mode="split"] .rack-caption { text-align: center; }
  .diagram[data-mode="compare"] .model-content { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .diagram[data-mode="compare"] .bundle { --available-width: calc(50cqw - 32px); }
  .diagram[data-mode="compare"] .model-content:has(.rack:nth-child(3)) > .rack:first-child { grid-column: 1 / -1; }
}
@media (min-width: 801px) {
  .calculation:empty + .interaction form:has(.entries) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 8px 14px;
  }
  .calculation:empty + .interaction form :is(.choice-set, .feedback) { grid-column: 1 / -1; }
  .calculation:empty + .interaction form :is(.choice-set, .entries) { margin-bottom: 0; }
}
@media (max-width: 800px) {
  .lesson-tools { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 750px) {
  .scene.entrance-scene { padding-block: clamp(92px, 20svh, 170px) 24px; }
  .entrance-scene .scene-art { object-position: 72% center; }
  .entrance-scene .scene-shade { background: linear-gradient(0deg, #11101dfa 8%, #141321d9 56%, #17132429 100%); }
}
@media(max-width:750px){.topbar{min-height:63px;padding-inline:max(12px,env(safe-area-inset-left)) max(12px,env(safe-area-inset-right))}.scene{padding:20px;min-height:calc(100svh - 63px)}.scene:not(.restore){align-items:end;padding-bottom:68px}.scene-shade,.gallery .scene-shade,.restore .scene-shade{background:linear-gradient(0deg,#11101dfa 0%,#13111fed 24%,#171324ac 47%,#17132410 83%)}.hall .scene-art{object-position:68% 45%}.gallery .scene-art,.restore .scene-art{object-position:72% 47%}.scene-index{bottom:15px;right:18px}.gallery .scene-copy{max-width:32rem}.scene .lede{margin-block:12px 18px}.scene h1{letter-spacing:-.06em}.restore{grid-template-columns:1fr;align-content:end;gap:10px;min-height:calc(100svh - 63px)}.restore .plinth-stage{min-height:230px}.restore .scene-art{object-fit:cover}.signal-board{margin-bottom:12px}}
@media(max-width:410px){.brand{font-size:.88rem;gap:8px}.brand small{font-size:.68rem}.sigil{width:31px;height:33px;flex-basis:31px;font-size:21px}.motion{padding-inline:5px;font-size:.76rem}.scene{padding-inline:14px}.signal-board ol{gap:4px}.signal-board li{min-width:20px}}
@media(max-height:500px) and (min-width:751px){.scene{min-height:calc(100svh - 72px);padding:22px 34px}.scene h1{font-size:clamp(2rem,5vw,3.4rem)}.scene .lede{margin:9px 0 13px}.plinth-stage{min-height:225px}.lesson{padding-block:10px 18px}}
.restore h1{word-break:keep-all;overflow-wrap:break-word;text-wrap:pretty}.artifact .ratio{font-size:clamp(1.55rem,3vw,2.45rem);line-height:1.1}
.artifact {
  isolation: isolate;
  width: clamp(106px, 41%, 220px);
  min-height: 0;
  aspect-ratio: 2 / 1;
  border: 0;
  background: none;
  box-shadow: none;
  color: #fff0ca;
}
.artifact-art { position: absolute; z-index: -1; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; filter: drop-shadow(0 5px 6px #100b1eb3); }
.artifact .ratio, .artifact .colon { color: #fff0ca; }
.artifact .ratio { font-size: clamp(1.25rem, 2.75vw, 2.2rem); }
.artifact i { line-height: 1; }
:root[data-reduced] *,:root[data-reduced] *::before,:root[data-reduced] *::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}

.museum-map-toggle { border-color: #a1806b; color: #ffdfa6; }
.museum-map {
  width: min(920px, calc(100% - 28px));
  max-width: none;
  max-height: calc(100dvh - 28px);
  margin: auto;
  padding: clamp(12px, 2.7vw, 28px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #a98770;
  border-radius: 12px;
  background: #201a2b;
  color: #fff2dc;
  box-shadow: 0 24px 80px #090613b3;
}
.museum-map::backdrop { background: #0c0916cb; }
.museum-map-header { display: flex; flex-wrap: wrap; align-items: start; justify-content: space-between; gap: 8px; }
.museum-map-header h2 { margin: 0 0 4px; font-size: clamp(1.35rem, 3vw, 1.875rem); }
.museum-map-header p { color: #ddd0e4; }
.museum-map-close { border-color: #957b99; }
.museum-floors { display: grid; gap: 10px; margin-block: 14px; }
.museum-floor {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid #775f7e;
  border-radius: 7px;
  background: #151120;
}
.museum-floor h3 { margin: 0; text-align: center; color: #ffdb9f; font-size: 1.2rem; }
.museum-floor-plan { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 12px; }
.museum-landmark, .museum-passage { grid-column: 1 / -1; }
.museum-landmark { color: #e9d4b5; font-weight: 700; }
.museum-passage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 28px;
  border-block: 1px dashed #977f98;
  background: repeating-linear-gradient(90deg, #252034 0 14px, #2b2338 14px 28px);
  color: #e2d4e8;
}
.museum-room {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0,1fr);
  gap: 4px 8px;
  align-items: baseline;
  min-height: 76px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #a08aab;
  border-radius: 5px;
  background: #2b2337;
  color: #f3ebf4;
  text-align: start;
  overflow-wrap: anywhere;
}
.museum-room::before { content: ''; position: absolute; inset: -8px auto auto 50%; width: 13px; height: 8px; border-inline: 1px solid #a08aab; background: #332942; }
.museum-room-number, .museum-room-object { color: #e2d4e8; }
.museum-room strong { font-size: 1.08rem; }
.museum-room-object, .museum-room-status { grid-column: 1 / -1; }
.museum-room-status { font-weight: 750; }
.museum-room[data-status="ready"] { border-color: #edba77; background: #503844; }
.museum-room[data-status="ready"] .museum-room-status { color: #ffdd9d; }
.museum-room[data-status="ready"] .museum-room-status::before { content: '→ '; }
.museum-room[data-status="current"] { border-color: #a9d6c1; background: #273a40; }
.museum-room[data-status="done"] .museum-room-status, .museum-room[data-status="current"] .museum-room-status { color: #c8eddb; }
.museum-room[data-status="locked"] { border-style: dashed; }
.museum-room:hover { box-shadow: inset 0 0 0 1px #e4b688; }
.museum-map-message { position: sticky; bottom: 0; padding-block: 6px; background: #201a2b; color: #ffdfa7; line-height: 1.5; }
.museum-journey .scene-copy { max-width: 100%; }
.museum-journey h1 { font-size: clamp(1.65rem, 3.5vw, 3.1rem); overflow-wrap: anywhere; }
.museum-journey .eyebrow { margin-bottom: 6px; }
.journey-location { margin: 9px 0 14px; color: #ffe4b6; font-size: 1.125rem; font-weight: 750; }
.museum-journey .walk-counter { color: #dfcbdc; font-weight: 600; }
.museum-journey .scene-art { object-position: center; }
.journey-trail {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  width: min(100%,30rem);
  padding: 9px 8px;
  margin: 10px 0;
  list-style: none;
  background: #141424e8;
  border: 1px solid #8c715d;
  border-radius: 8px;
}
.journey-trail li { display: grid; grid-template-rows: 14px auto; justify-items: center; gap: 5px; text-align: center; color: #dbcfde; position: relative; line-height: 1.3; }
.journey-trail li:not(:last-child)::before { content: ''; position: absolute; top: 6px; left: 50%; width: 100%; border-top: 1px solid #a68e7b; }
.journey-trail li > span { z-index: 1; width: 13px; height: 13px; border: 2px solid #beaa93; border-radius: 50%; background: #212234; }
.journey-trail li[aria-current] { color: #ffe0a3; }
.journey-trail li[aria-current] > span { border-color: #fff0bf; background: #ffd18a; box-shadow: 0 0 10px #f8bc63; }
.museum-seals {
  display: grid;
  grid-template-columns: repeat(6,minmax(0,1fr));
  gap: 5px;
  padding: 0;
  margin: 10px 0;
  list-style: none;
}
.museum-seals li { display: grid; justify-items: center; text-align: center; padding: 4px 2px; border: 1px dashed #7c6c83; border-radius: 6px; color: #e0cfe0; overflow-wrap: anywhere; line-height: 1.3; }
.museum-seals li > span:first-child { color: #cbb8a5; }
.museum-seals .earned { border-style: solid; border-color: #a87e53; background: #3a2d35; color: #ffe4a7; }
.museum-seals .earned > span:first-child { color: #ffcd77; }
@media (max-width:480px) { .museum-seals { grid-template-columns: repeat(3,minmax(0,1fr)); } }
@media (min-width:768px) and (max-height:800px) {
  .museum-map { padding-block: 14px; }
  .museum-floors { gap: 7px; margin-block: 8px; }
  .museum-floor { padding-block: 6px; }
  .museum-room { min-height: 65px; padding-block: 5px; }
  .museum-passage { min-height: 23px; }
}
@media (max-width: 750px) {
  .scene.museum-journey:not(.restore) { padding-bottom: 20px; }
}
@media (max-width: 460px) {
  .topbar-tools { gap: 2px; }
  .museum-map-toggle { padding-inline: 6px; font-size: .76rem; }
}
@media (max-width: 620px) {
  .museum-floor { grid-template-columns: minmax(0,1fr); gap: 6px; }
  .museum-floor h3 { text-align: start; }
  .museum-room { grid-template-columns: minmax(0,1fr); padding-inline: 8px; }
}

/* Lesson 1 puts the tile board beside the calculation and response when there is room. */
#app:is([data-lesson-backdrop="entrance"], [data-lesson-backdrop="gallery"]) {
  .lesson {
    padding-inline: max(clamp(12px, 2vw, 32px), env(safe-area-inset-left)) max(clamp(12px, 2vw, 32px), env(safe-area-inset-right));
  }

  .lesson-workspace {
    flex: 0 0 auto;
    grid-template-rows: auto;
    align-items: start;
  }

  .lesson-tools { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .task h1 { font-size: clamp(1.25rem, 2.25vw, 1.75rem); }
  .lesson-progress { font-size: 1rem; }
  .diagram { padding: clamp(12px, 1.4vw, 20px); background: #1b172bed; }
  .model-content { flex: 0 1 auto; align-content: start; }
  .model-tip { color: #e7ddec; }
  .records { margin-bottom: 0; }

  :is(.bundle, .drop-slot) {
    --mark-gap: 3px;
    --tile-size: clamp(20px, 5cqw, 38px);
    --rail-count: var(--row-max);
    --bundle-padding: 8px;
    width: min(100%, calc(2 * (var(--bundle-padding) + 1px) + var(--rail-count) * (var(--tile-size) + var(--mark-gap)) - var(--mark-gap)));
    padding-inline: var(--bundle-padding);
  }

  .diagram[data-mode="copy"] :is(.bundle, .drop-slot) {
    --tile-size: clamp(22px, min(7cqw, calc((50cqw - 22px) / var(--row-max) - var(--mark-gap))), 52px);
    min-width: 44px;
  }

  .diagram[data-mode="compare"] .model-content { grid-template-columns: minmax(0, 1fr); }
  .diagram[data-mode="compare"] .bundle { --tile-size: clamp(20px, 4.5cqw, 32px); }
  .diagram[data-mode="split"] .bundles { justify-content: start; }
  .diagram[data-mode="split"] .rack-caption { text-align: start; }
  .diagram[data-mode="table"] .bundle {
    --tile-size: clamp(20px, 4cqw, 34px);
    --bundle-padding: 5px;
  }

  .rail { flex-wrap: wrap; }
  .rail:empty { display: none; }
  .rail:not(:empty) + .rail:not(:empty) { border-top: 1px solid #b49bc34f; padding-top: 7px; }

  /* Keep longer rails countable in rows of ten on narrow boards. */
  @container (max-width: 600px) {
    .bundle:has(.rail > .mark:nth-child(16)) { --rail-count: 10; }
  }

  .interaction :is(button, .options label), .compare-control { min-width: 44px; font-size: 1rem; }
  .interaction :is(.options, .actions) { gap: 8px; }
  .calculation:empty + .interaction form:has(.entries) { display: block; }
  .calculation:empty + .interaction form :is(.choice-set, .entries) { margin-bottom: 10px; }
  .interaction form:has(.stepper) { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
  .interaction form:has(.stepper) .stepper { margin: 0; }
  .interaction form:has(.stepper) .feedback { flex-basis: 100%; margin: 0; }
  .interaction form:has(.stepper) .feedback:empty { position: absolute; }

  @media (min-width: 820px) and (min-height: 540px) {
    .lesson-workspace { grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); }
    .prompt { font-size: clamp(1.1875rem, 1.6vw, 1.3125rem); }
    .diagram[data-mode="copy"] { padding: 22px; }
    .diagram[data-mode="copy"] .visual-head { margin-bottom: 15px; }
    .diagram[data-mode="copy"] .bundles { gap: 12px; }
    .diagram[data-mode="copy"] :is(.bundle, .drop-slot) {
      --tile-size: clamp(22px, min(9cqw, calc((50cqw - 22px) / var(--row-max) - var(--mark-gap))), 60px);
      min-height: clamp(164px, 29svh, 224px);
      gap: 16px;
    }
    .diagram[data-mode="copy"] .rail + .rail { padding-top: 11px; }
    .diagram[data-mode="copy"] .drop-slot { font-size: 1.125rem; }
    .diagram[data-mode="copy"] .drop-slot span { font-size: 2rem; }
    .diagram[data-mode="copy"] + .lesson-tools .equation .ratio { font-size: clamp(2.75rem, 15cqw, 3.75rem); }

    .diagram[data-mode="support"] .rack-caption { text-align: center; }
    .diagram[data-mode="support"] .bundles { justify-content: center; }
    .diagram[data-mode="support"] .bundle {
      --tile-size: clamp(36px, min(8.5cqw, 8svh), 64px);
      --bundle-padding: 18px;
      min-height: clamp(144px, 24svh, 185px);
      gap: 16px;
    }

    .diagram[data-mode="table"] .records:not(:has(+ .rack)) :is(th, td),
    .records.check-mapping :is(th, td) { padding-block: clamp(14px, 3svh, 24px); }
    .diagram[data-mode="table"] .records:not(:has(+ .rack)) td,
    .records.check-mapping td { font-size: clamp(1.375rem, 4.7cqw, 2.15rem); }
    .check-diagram { min-height: clamp(145px, 24svh, 196px); }
    .check-diagram .ratio { font-size: clamp(3rem, 10cqw, 5.5rem); }
  }

  @media (orientation: landscape) and (max-height: 539px) {
    .lesson:has(.diagram[data-mode="copy"]) { padding-block-start: 6px; }
    .lesson:has(.diagram[data-mode="copy"]) .task { margin-bottom: 8px; }
    .lesson:has(.diagram[data-mode="copy"]) .prompt { margin-top: 4px; }
    .lesson-workspace:has(.diagram[data-mode="copy"]) { gap: 6px; }
    .diagram[data-mode="copy"] { padding: 9px; }
    .diagram[data-mode="copy"] .visual-head { margin-bottom: 7px; }
    .diagram[data-mode="copy"] .model-tip { margin-top: 3px; }
    .diagram[data-mode="copy"] :is(.bundle, .drop-slot) {
      --tile-size: clamp(24px, 4.25cqw, 32px);
      padding-block: 7px;
    }
    .diagram[data-mode="copy"] + .lesson-tools .calculation { padding: 6px 10px; }
    .diagram[data-mode="copy"] + .lesson-tools .equation .ratio { font-size: 2.25rem; }
  }
}

.lesson.chapter2 {
  padding-inline: max(clamp(12px, 2.5vw, 36px), env(safe-area-inset-left)) max(clamp(12px, 2.5vw, 36px), env(safe-area-inset-right));
  padding-bottom: max(18px, env(safe-area-inset-bottom));

  .lesson-workspace {
    flex: 0 0 auto;
    grid-template-rows: auto;
    align-items: start;
  }

  .task { margin-bottom: 12px; }
  .lesson-progress { font-size: 1rem; }
  .prompt { font-size: clamp(1.0625rem, 1.7vw, 1.25rem); }
  :is(.map-diagram, .interaction) {
    gap: 16px;
    padding: clamp(12px, 1.7vw, 24px);
    border-color: #806b80;
    background: #201a2bee;
    word-break: keep-all;
    overflow-wrap: anywhere;
  }

  .map-ruler {
    --ruler-line: #b7a59db3;
    display: grid;
    gap: clamp(12px, 2.5svh, 22px);
    padding-inline: clamp(7px, 2cqw, 14px);
    font-variant-numeric: tabular-nums;
  }

  .map-scale-axis {
    position: relative;
    height: 1.75rem;
    border-bottom: 1px solid var(--ruler-line);
    color: #f2e2ca;
    font-size: 1rem;
    line-height: 1.1;
  }

  .map-scale-axis > span {
    position: absolute;
    inset-inline-start: var(--at);
    top: 0;
    translate: -50% 0;
    white-space: nowrap;
  }

  .map-scale-axis > span::after {
    content: '';
    position: absolute;
    inset-inline-start: 50%;
    top: 1.3rem;
    height: .45rem;
    border-inline-start: 1px solid var(--ruler-line);
  }

  .map-scale-axis > span:first-child { translate: 0 0; }
  .map-scale-axis > span:first-child::after { inset-inline-start: 0; }
  .map-scale-axis > span:last-child { translate: -100% 0; }
  .map-scale-axis > span:last-child::after { inset-inline-start: auto; inset-inline-end: 0; }

  .map-measure-label {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 3px 12px;
    margin-bottom: 7px;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
  }

  .map-measure-label strong {
    color: #ffe2b1;
    font-size: clamp(1.25rem, 4cqw, 1.875rem);
  }

  .map-measure + .map-measure .map-measure-label strong { color: #cbe6ff; }
  .map-quantity { margin-inline-start: auto; font-weight: 700; font-size: 1rem; }
  .map-group-count {
    flex-basis: 100%;
    font-size: 1rem;
    color: #ffe9bf;
  }

  .map-track {
    min-width: 0;
    border-radius: 0 5px 5px 0;
    background: #14101d;
    box-shadow: 0 0 0 1px #8c788777, -2px 0 #edd5b2;
  }

  .map-bar {
    position: relative;
    width: var(--width);
    height: clamp(40px, 7.5svh, 70px);
    border-radius: 0 4px 4px 0;
    background: #eab470;
    box-shadow: inset 0 0 0 1px #ffdfab;
  }

  .map-bar.blue { background: #9cc9ef; box-shadow: inset 0 0 0 1px #d2ebff; }

  .map-bar[data-ticks]::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(to right, #33253a 0 1px, transparent 1px var(--tick));
  }

  .map-remainder {
    position: absolute;
    z-index: 1;
    inset: 0 0 0 var(--start);
    border-inline-start: 1px solid #33253a;
    border-radius: 0 4px 4px 0;
    background: repeating-linear-gradient(135deg, #33253a80 0 2px, transparent 2px 6px);
  }

  .map-group-bands {
    position: absolute;
    z-index: 1;
    inset: 0;
    border: 3px solid #fff2d6;
    border-radius: inherit;
    background: linear-gradient(to right, transparent calc(100% - 2px), #fff2d6 calc(100% - 2px));
    background-origin: border-box;
    background-size: var(--group) 100%;
  }

  .map-steps {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin: 14px 0 0;
    padding: 12px;
    list-style: none;
    border: 1px solid #806b80;
    border-radius: 7px;
    background: #181323;
  }
  .map-steps li { display: grid; gap: 2px; }
  .map-steps li > span { color: #e7d4dc; }
  .map-steps strong { color: #ffdda4; font: 700 clamp(1.35rem, 3.8cqw, 1.95rem)/1.2 Georgia,serif; white-space: nowrap; }
  .map-steps .map-step-operation { display: flex; gap: 5px; flex-wrap: wrap; color: #f3c382; font-weight: 750; }
  .map-bridge { padding-inline-start: 9px; border-inline-start: 3px solid #edbd80; }
  .map-grouping { align-self: start; min-height: 44px; font-size: 1rem; }
  .map-grouping[hidden] { display: none; }
  .map-grouping[aria-pressed="true"] { border-color: #ffdda4; background: #4c3648; }

  :is(.map-reading, .map-note, .map-mismatch) { font-size: 1rem; line-height: 1.5; }
  .map-reading {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 8px;
    margin-bottom: clamp(9px, 1.5svh, 14px);
    color: #ffe4bd;
  }
  .map-note { margin-top: 8px; color: #eee5f4; }
  .map-mismatch { margin-bottom: 13px; color: #ffe0ac; }
  .map-scale-key {
    display: inline-block;
    padding: .18em .5em;
    border: 1px solid #b4976b;
    border-radius: 4px;
    background: #34253a;
    color: #ffe4b2;
    font-weight: 800;
  }

  .map-form { display: grid; gap: 12px; }
  .map-form :is(.choice-set, .map-answer, .feedback) { margin: 0; }
  .map-form .feedback:empty { position: absolute; }
  .map-answer .entry { flex: 1 1 0; }
  .map-answer > span { padding-bottom: 10px; }
  .interaction > .feedback { margin-bottom: 10px; }
  .interaction :is(button, .options label) { min-width: 44px; min-height: 44px; font-size: 1rem; }
  .interaction .options { gap: 8px; }

  .map-placement {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .map-glass { position: relative; }
  .map-slot { border: 2px dashed #bb9dab; background: #1a142a; color: #ffe3bc; }
  .map-slot.drop-ready { background: #4d3753; border-color: #ffdc9f; }

  @media (min-width: 820px) {
    .lesson-workspace { grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr); }
  }

  @media (orientation: landscape) and (max-height: 500px) {
    padding-block-start: 8px;
    .task { margin-bottom: 8px; }
    .prompt { margin-top: 4px; }
    .lesson-workspace { gap: 8px; }
    :is(.map-diagram, .interaction) { padding: 10px; }
    .map-ruler { gap: 8px; }
    .map-measure-label strong { font-size: 1.25rem; }
    .map-form { gap: 8px; }
  }

  @media (max-width: 340px) {
    .map-placement { grid-template-columns: minmax(0, 1fr); }
  }
}

.lesson.chapter2 :is(.map-glass, .map-slot), .map-glass.drag-shadow {
  display: grid;
  place-content: center;
  justify-items: center;
  min-height: clamp(85px, 13svh, 112px);
  padding: 8px;
  border-radius: 7px;
  text-align: center;
}

/* The dragged copy lives under body while it follows the pointer. */
:is(.lesson.chapter2 .map-glass, .map-glass.drag-shadow) {
  isolation: isolate;
  border: 1px solid #98bdd6;
  background: #25263b;
  color: #fff1d7;

  .map-glass-art {
    position: absolute;
    inset: 0;
    z-index: -1;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: .78;
    pointer-events: none;
  }

  :is(b, strong) { padding-inline: 6px; background: #181325ed; border-radius: 4px; }
  strong { font-size: 1.625rem; }
}

.map-scene:not(.archive-scene) {
  .scene-copy { min-width: 0; }
  .scene-art { object-position: 62% center; }
  .scene-shade {
    background: linear-gradient(90deg, #141124f2, #141124bd 37%, #14112422 76%),
      linear-gradient(0deg, #141124de, transparent 43%);
  }
  h1 { overflow-wrap: anywhere; }
  :is(.map-record, .map-case-clue) {
    width: fit-content;
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  .map-case-clue {
    padding: 7px 10px;
    margin-block: 0 10px;
    border: 1px solid #927057;
    border-radius: 6px;
    background: #241a2cf0;
    color: #ffdda9;
    font-weight: 700;
  }
  :is(.primary, .quiet) { min-width: 44px; margin-block-end: 4px; }

  @media (max-width: 750px) {
    &.scene { padding-block: clamp(120px, 27svh, 260px) max(24px, env(safe-area-inset-bottom)); }
    .scene-art { object-position: 66% 40%; }
    .scene-shade { background: linear-gradient(0deg, #141124fc 9%, #141124e6 40%, #14112426 87%); }
  }

  @media (max-height: 500px) {
    &.scene { padding-block: 20px; }
  }
}

.lesson.chapter3 {
  padding-inline: max(clamp(12px, 2.5vw, 36px), env(safe-area-inset-left)) max(clamp(12px, 2.5vw, 36px), env(safe-area-inset-right));
  padding-bottom: max(18px, env(safe-area-inset-bottom));

  .lesson-workspace {
    flex: 0 0 auto;
    grid-template-rows: auto;
    align-items: start;
  }

  .lesson-progress { font-size: 1rem; }
  .prompt { font-size: clamp(1.0625rem, 1.7vw, 1.25rem); }
  :is(.archive-diagram, .interaction) {
    border-color: #8c7184;
    background: #20182aef;
    word-break: keep-all;
    overflow-wrap: anywhere;
  }
  .archive-diagram { gap: 12px; }

  .archive-equation {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: clamp(6px, 2cqw, 16px);
  }
  .archive-card {
    display: grid;
    align-content: center;
    justify-items: center;
    min-width: 0;
    gap: 3px;
    padding: clamp(8px, 2cqw, 16px);
    border: 1px solid #d0a470;
    border-radius: 7px;
    color: #342238;
    background: #f1deb7;
    text-align: center;
  }
  .archive-card small { font-size: 1rem; font-weight: 700; }
  .archive-ratio {
    display: inline-flex;
    align-items: baseline;
    gap: .12em;
    color: inherit;
    font: 700 clamp(1.5rem, 6.3cqw, 3.5rem)/1.1 Georgia, serif;
    font-variant-numeric: lining-nums tabular-nums;
    white-space: nowrap;
  }
  .archive-symbol { color: #ffdfa0; font-size: clamp(1.6rem, 6cqw, 2.65rem); font-weight: 800; }
  .archive-diagram:has(:is(.archive-lines, .archive-table, .archive-film)) {
    .archive-equation .archive-card {
      gap: 2px;
      padding: 6px 4px;
      border-color: #ad896a;
      background: #362536;
      color: #fff0d1;
    }
    .archive-equation .archive-ratio { font-size: clamp(1.5rem, 4.5cqw, 2.25rem); }
    .archive-equation small { color: #eedbc8; }
  }

  .archive-lines {
    display: grid;
    gap: clamp(12px, 2.8cqw, 24px);
    padding: clamp(10px, 2.5cqw, 20px) clamp(7px, 2cqw, 16px);
    border: 1px solid #866c7b;
    border-radius: 7px;
    background: #171220;
  }
  .archive-line {
    --axis-ink: #c7985c;
    --axis-active: #ffcf85;
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: start;
    gap: clamp(4px, 2cqw, 12px);
  }
  .archive-line + .archive-line { --axis-ink: #759dc6; --axis-active: #b4dcff; }
  .archive-line > b {
    min-inline-size: 3em;
    color: var(--axis-active);
    font-size: clamp(1rem, 3cqw, 1.25rem);
    line-height: 1.4;
  }
  .archive-line ol {
    --ticks: 4;
    --end-inset: calc(50% / var(--ticks));
    --tick-spacing: calc(100% / var(--ticks));
    display: grid;
    grid-template-columns: repeat(var(--ticks), minmax(0, 1fr));
    position: relative;
    isolation: isolate;
    margin: 0;
    padding: 0;
    list-style: none;
    text-align: center;
  }
  .archive-line ol:has([data-step="1"]:last-child) { --ticks: 2; }
  .archive-line ol:has([data-step="2"]:last-child) { --ticks: 3; }
  .archive-line ol::before,
  .archive-line ol::after {
    content: '';
    position: absolute;
    z-index: -1;
    inset-inline-start: var(--end-inset);
    top: 10px;
    height: 2px;
    background: var(--axis-ink);
  }
  .archive-line ol::before { inset-inline-end: var(--end-inset); }
  .archive-line ol::after {
    width: calc(var(--step) * var(--tick-spacing));
    top: 9px;
    height: 4px;
    background: var(--axis-active);
  }
  .archive-line li {
    position: relative;
    padding: 24px 0 0;
    color: #eee4ed;
    font-size: clamp(1.125rem, 4.8cqw, 1.9rem);
    font-variant-numeric: tabular-nums;
    font-weight: 750;
    line-height: 1.15;
  }
  .archive-line li::before {
    content: '';
    position: absolute;
    inset-inline-start: 50%;
    top: 5px;
    width: 2px;
    height: 12px;
    translate: -50% 0;
    background: var(--axis-active);
  }
  .archive-line li.is-current { color: var(--axis-active); font-weight: 900; }
  .archive-line li.is-current::before {
    top: 2px;
    width: 18px;
    height: 18px;
    border: 2px solid #171220;
    border-radius: 50%;
    box-shadow: 0 0 0 1px var(--axis-active);
  }

  .archive-scrub {
    display: grid;
    grid-template-columns: auto minmax(44px, 1fr) auto;
    align-items: center;
    gap: 0 12px;
    font-weight: 750;
  }
  .archive-scrub input {
    width: 100%;
    min-height: 44px;
    margin: 0;
    accent-color: #ffcf85;
  }
  #archive-value { color: #ffdfa6; font-variant-numeric: tabular-nums; font-weight: 750; }
  .archive-jump {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 64px), 1fr));
    gap: 8px;
  }
  .archive-jump button { min-height: 44px; padding: 4px; font-size: 1rem; }
  .archive-jump .is-current { border-color: #ffcf85; background: #543849; color: #fff0cd; }

  .archive-table {
    table-layout: fixed;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid #967983;
    border-radius: 7px;
    background: #21182b;
  }
  .archive-table thead th { padding: 8px 4px; background: #34263a; color: #f6e6d7; }
  .archive-table thead th:first-child { border-radius: 6px 0 0; }
  .archive-table thead th:last-child { border-radius: 0 6px 0 0; }
  .archive-table :is(th, td) { border-color: #816677; }
  .archive-table :is(th, td) + :is(th, td) { border-inline-start: 1px solid #816677; }
  .archive-table tbody th { padding: 0; }
  .archive-table tbody td {
    padding: clamp(5px, 1.9cqw, 12px) 3px;
    font-size: clamp(1.375rem, 5.7cqw, 2.2rem);
    font-variant-numeric: tabular-nums;
    color: #ffdc9e;
  }
  .archive-table tbody td:last-child { color: #bcdfff; }
  .archive-table tbody tr:last-child > * { border-bottom: 0; }
  .archive-table tbody tr:last-child th { border-radius: 0 0 0 6px; }
  .archive-table tbody tr:last-child td:last-child { border-radius: 0 0 6px; }
  .archive-table tr:has(input) { cursor: pointer; }
  .archive-table tbody tr:is([data-selected], :has(input:checked)) > * {
    background: #53364a;
    box-shadow: inset 0 2px #ffcf85, inset 0 -2px #ffcf85;
  }
  .archive-row-pick {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    min-width: 44px;
    padding: 4px;
    border-radius: 5px;
    cursor: pointer;
  }
  .archive-row-pick input { flex: none; margin: 0; accent-color: #ffcf85; }
  .archive-row-pick:has(input:focus-visible) { outline: 2px solid #ffda9a; outline-offset: -3px; }
  .archive-table-evidence:not(:empty) {
    display: grid;
    grid-template-columns: repeat(4, auto);
    justify-content: start;
    gap: 7px clamp(5px, 2cqw, 16px);
    padding: 10px;
    border: 1px solid #997a71;
    border-radius: 6px;
    background: #261c30;
    line-height: 1.35;
  }
  .archive-proof-row {
    display: grid;
    grid-template-columns: subgrid;
    grid-column: 1 / -1;
    align-items: center;
  }
  .archive-proof-row .archive-ratio { color: #ffe1a9; font-size: clamp(1.125rem, 3.6cqw, 1.65rem); }
  .archive-proof-result { grid-column: 1 / -1; color: #f7e0ae; font-weight: 750; }

  .archive-bars { display: grid; gap: 10px; }
  .archive-bar {
    display: grid;
    grid-template-columns: var(--split) 1fr;
    margin-top: 5px;
    overflow: hidden;
    border-radius: 6px;
  }
  .archive-bar span { padding: 9px 0; text-align: center; color: #241b2a; font-size: 1.125rem; font-weight: 800; background: #e7ac64; }
  .archive-bar span + span { background: #9ec8ec; }
  .archive-film {
    --film-tile: clamp(16px, 3.6cqw, 30px);
    display: grid;
    gap: 8px;
    font-size: 1rem;
  }
  .film-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
  .film-controls b { margin-inline-end: 4px; }
  .film-guide { font-size: 1rem; line-height: 1.55; color: #e8d9ea; }
  .film-guide b { display: block; color: #ffda94; }
  .film-controls button, .film-overlap { min-width: 44px; min-height: 44px; font-size: 1rem; }
  .archive-film button[aria-pressed="true"] { border-color: #f6c481; color: #ffe4ad; background: #493348; }
  .film-records { display: grid; gap: 6px; }
  .film-row { min-width: 0; border-top: 1px solid #745c73; padding-top: 6px; }
  .film-row p { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 9px; margin-bottom: 4px; }
  .film-row p span { color: #e4d4e5; }
  .film-tiles { display: flex; flex-wrap: wrap; gap: 4px; }
  .film-tray { display: grid; grid-template-rows: repeat(2,var(--film-tile)); gap: 2px; width: max-content; padding: 3px; border: 1px solid #e4af73; border-radius: 5px; background: #58445b; }
  .film-tray > span { display: flex; flex-wrap: wrap; gap: 1px; }
  .film-tray .mark { flex: 0 0 var(--film-tile); width: var(--film-tile); height: var(--film-tile); }
  .film-raw { width: 100%; grid-template-rows: auto auto; background: none; border-color: transparent; }
  .film-leftover { border: 1px dashed #edb2ca; background: repeating-linear-gradient(135deg,#2b253b 0 5px,#3b2a42 5px 10px); }
  .film-overlap { justify-self: start; }
  .film-proof { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 8px; border: 1px solid #b89980; border-radius: 6px; background: #2b2236; }
  .film-proof p { flex-basis: 100%; }
  .film-overlay { display: grid; grid-template-areas: 'overlay'; }
  .film-overlay .film-tray { grid-area: overlay; }
  .film-overlay .film-top { border: 2px dashed #faf1bf; padding: 2px; background: transparent; }
  .film-top .mark { opacity: .65; }
  .film-equations { display: grid; gap: 2px; }
  .film-equations b { color: #ffda94; }
  .archive-file-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .archive-file-cards label { min-height: 76px; cursor: pointer; }
  .archive-file-cards label:has(input:checked) { background: #ffe4a5; outline: 2px solid #986441; outline-offset: -4px; }
  .archive-file-cards label:has(input:focus-visible) { box-shadow: 0 0 0 3px #eab470; }
  .archive-file-cards input { margin: 2px 0; accent-color: #754624; }
  .archive-file-cards .archive-ratio { font-size: clamp(1.125rem, 5.9cqw, 3rem); }

  .interaction :is(button, .options label) { min-width: 44px; min-height: 44px; font-size: 1rem; }
  .interaction .options { gap: 8px; }
  .interaction .map-answer .entry { flex: 1 1 0; }
  .interaction > .feedback { margin-bottom: 10px; }

  @media (min-width: 820px) {
    .lesson-workspace { grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr); }
  }
  @container (max-width: 410px) {
    .archive-scrub { grid-template-columns: auto minmax(44px, 1fr); }
    .archive-scrub output { grid-column: 1 / -1; }
  }
  @container (max-width: 255px) {
    .archive-table-evidence:not(:empty) { padding: 7px; }
    .archive-file-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
  @media (orientation: landscape) and (max-height: 500px) {
    padding-block-start: 7px;
    .task { margin-bottom: 8px; }
    .prompt { margin-top: 4px; }
    .lesson-workspace { gap: 8px; }
    :is(.archive-diagram, .interaction) { padding: 10px; }
    .archive-diagram { gap: 8px; }
    .archive-lines { gap: 8px; padding-block: 8px; }
    .archive-line li { padding-block-start: 21px; font-size: 1.1875rem; }
    .archive-equation small { line-height: 1.3; }
    .archive-table tbody td { padding-block: 6px; }
  }
  @media (orientation: landscape) and (min-width: 820px) and (max-height: 500px) {
    .archive-diagram:has(.archive-jump) {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
      align-items: center;
    }
    :is(.archive-equation, .archive-lines) { grid-column: 1 / -1; }
    .archive-diagram:has(.archive-lines) .archive-card {
      grid-template-columns: auto auto;
      column-gap: 6px;
      justify-content: center;
      align-items: baseline;
    }
    .archive-diagram:has(.archive-lines) .archive-card > span { grid-column: 1 / -1; }
    .archive-scrub { grid-template-columns: auto minmax(44px, 1fr); }
    .archive-scrub output { grid-column: 1 / -1; }
    .archive-jump { grid-template-columns: repeat(4, minmax(44px, 1fr)); }
  }
}

.plate-options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

#app[data-lesson-backdrop="balcony"] { --lesson-art: url('./media/balcony-room.webp'); background-position: 73% center; }
.balcony-scene .scene-art { object-position: 64% center; }
.balcony-scene .balcony-before { pointer-events: none; }
.balcony-scene .scene-shade { background: linear-gradient(90deg,#102127f2,#102127b0 43%,#10212715 85%); }
.balcony-scene h1 { word-break: keep-all; }
.balcony-summary { color: #f9e3b2; font-size: 1.125rem; line-height: 1.5; margin-bottom: 10px; }
.balcony-lit .signal-board li:last-child > span:first-child {
  background: #ffdc78;
  box-shadow: 0 0 8px 4px #ffbf57a8, 0 0 28px 8px #ffaa4a66;
}
.lesson.chapter6 {
  .lesson-progress { font-size: 1rem; }
  .prompt { font-size: clamp(1.0625rem,1.7vw,1.25rem); }
  .lesson-workspace { grid-template-rows: auto; align-items: start; gap: clamp(8px,1.3vw,16px); }
  :is(.share-diagram,.interaction) {
    display: grid;
    align-content: start;
    gap: 9px;
    padding: clamp(10px,1.5vw,17px);
    min-width: 0;
    background: #17252af2;
    border-color: #708c80;
  }
  :is(button,.options label,.share-inspect summary) { min-width: 44px; min-height: 44px; font-size: 1rem; }
  .share-tape { display: grid; gap: 8px; }
  .share-whole { color: #f9e4b2; }
  .share-whole strong { font-size: clamp(1.3rem,4cqw,2.1rem); margin-inline-start: 6px; }
  .share-bar {
    display: grid;
    grid-template-columns: minmax(0,1fr);
    min-height: clamp(50px,9svh,82px);
    border-radius: 8px;
    border: 1px solid #dfc693;
    background: #354644;
    overflow: hidden;
  }
  .share-bar.divided { grid-template-columns: repeat(var(--cells),minmax(0,1fr)); }
  .share-bar > span { display: grid; place-items: center; min-width: 0; font-size: clamp(1rem,4cqw,1.8rem); font-weight: 800; overflow-wrap: anywhere; }
  .share-bar .undivided { color: #fff0c8; }
  .share-bar .part-north { background: #eec67c; color: #342719; border-inline-end: 1px solid #70552e; }
  .share-bar .part-south {
    background: repeating-linear-gradient(135deg,#a4ded1 0 10px,#95d2c5 10px 16px);
    color: #203631;
    border-inline-end: 1px solid #3c766d;
  }
  .share-bar .part-north+.part-south { border-inline-start: 3px solid #fff5ce; }
  .share-bar[data-highlight="north"] .part-south,
  .share-bar[data-highlight="south"] .part-north { filter: brightness(.57); }
  .share-labels, .share-picks { display: flex; flex-wrap: wrap; gap: 6px 12px; }
  .share-labels b:first-child { color: #ffdb97; }
  .share-labels b:last-child { color: #b6f3e5; }
  .share-picks [aria-pressed="true"] { outline: 2px solid #ffc475; }
  .share-inspect summary { align-content: center; color: #ffdf9f; cursor: pointer; }
  .share-candidate-bar { display: flex; margin-bottom: 6px; }
  .share-candidate-bar span {
    flex: 0 0 var(--width);
    min-width: 0;
    min-height: 34px;
    display: grid;
    place-items: center;
    color: #342719;
    background: #eec67c;
    font-weight: 800;
    border-inline-end: 1px solid #17252a;
  }
  .share-candidate-bar span:nth-child(2) { background: #a4ded1; color: #203631; }
  .share-candidate-bar .reserve { color: #fff0cc; background: #253633; outline: 1px dashed #e4caa1; outline-offset: -1px; }
  .share-remainder { color: #ffce9e; }
  .share-remainder > div { display: flex; gap: 5px; margin-top: 6px; }
  .share-remainder i { width: 23px; height: 23px; border: 1px solid #ffda9d; border-radius: 4px; background: #be8150; }
  .share-checks, .share-inputs, .share-plates, .share-slots { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; }
  .share-checks > div { display: grid; gap: 2px; padding: 6px 8px; border: 1px solid #acb68c; border-radius: 6px; overflow-wrap: anywhere; }
  .share-checks .pass { background: #203e36; color: #d6f6db; }
  .share-checks .miss { background: #4c332d; color: #ffdac1; border-style: dashed; }
  .share-proof { display: grid; gap: 4px; padding: 7px 10px; border: 1px solid #85a191; border-radius: 6px; line-height: 1.45; }
  .share-proof b, .share-spec b { color: #ffe2a2; }
  .share-spec,.share-candidate { line-height: 1.45; }
  [data-chapter6] .entry { margin-bottom: 7px; }
  [data-chapter6] .entry input { min-height: 44px; width: 100%; }
  .share-slot {
    min-height: clamp(62px,12svh,112px);
    padding: 6px;
    border: 2px dashed #8fbcad;
    border-radius: 7px;
    background: #213934;
    color: #d7f4d9;
    font-weight: 750;
    overflow-wrap: anywhere;
  }
  .share-slot.drop-ready, .share-slot.installed { border-style: solid; border-color: #c3ebad; background: #33564a; }
  .share-slot.installed { display: grid; place-items: center; }
  .share-slot img { width: min(100%,12rem); display: block; }
  .share-install-status { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 11px; }
  .share-install-status .signal-board { margin: 0; padding: 6px 9px; }
  .share-install-status p { color: #e5f6d4; font-weight: 750; }
  @media (min-width:820px) {
    .lesson-workspace { grid-template-columns: minmax(0,1.85fr) minmax(0,1fr); }
  }
}
.share-plate {
  display: grid;
  align-content: end;
  justify-items: center;
  min-height: 62px;
  padding: 4px;
  border: 1px solid #729f8c;
  border-radius: 8px;
  background: #192d2c;
  color: #f7e9c2;
  font-weight: 750;
}
.share-plate[aria-pressed="true"] { border-color: #ffd283; outline: 2px solid #ffd283; outline-offset: -3px; }
.share-plates [data-plate="south"] { grid-column: 2; }
.share-plate img { display: block; width: min(100%,13rem); pointer-events: none; }
@media (max-width:750px) {
  .balcony-scene .scene-shade { background: linear-gradient(0deg,#102127fa,#102127d5 49%,#10212720 100%); }
}

#app[data-lesson-backdrop="storage"] {
  --lesson-art: url('./media/storage-room.webp');
  background-position: 72% center;
}
.storage-scene .scene-art { object-position: 70% center; }
.storage-scene .scene-shade { background: linear-gradient(90deg,#101b20f5,#101b20ba 49%,#101b201a 90%); }
.storage-scene h1 { word-break: keep-all; }
.receipt-clue {
  width: fit-content;
  max-width: 100%;
  margin-block: 8px 13px;
  padding: 9px 13px;
  border: 1px solid #9c8761;
  border-radius: 8px;
  color: #ffedc5;
  background: #25302cee;
}
.receipt-clue dl { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 5px; }
.receipt-clue dt { color: #dce8da; }
.receipt-clue dd { margin: 0; font-size: 1.125rem; font-weight: 800; }
.storage-plates {
  position: relative;
  width: min(100%, 17rem);
  padding: 52px 12px 7px;
  margin-block: 8px;
  border: 1px solid #8ca491;
  border-radius: 8px;
  background: #172522e0;
  text-align: center;
}
.storage-plates span {
  position: absolute;
  top: 14px;
  left: calc(50% - 48px);
  width: 96px;
  height: 26px;
  transform: skewX(-28deg);
  border: 2px solid #b8f0c5;
  border-radius: 3px;
  background: #3b805f95;
}
.storage-plates span+span { top: 22px; left: calc(50% - 38px); border-style: dashed; }

.lesson.chapter5 {
  .lesson-progress { font-size: 1rem; }
  .prompt { font-size: clamp(1.0625rem,1.7vw,1.25rem); }
  .lesson-workspace { grid-template-rows: auto; align-items: start; gap: clamp(8px,1.3vw,16px); }
  :is(.store-diagram,.interaction) {
    display: grid;
    align-content: start;
    gap: 10px;
    padding: clamp(10px,1.5vw,17px);
    min-width: 0;
    background: #172526f2;
    border-color: #62887b;
  }
  :is(button,.options label) { min-width: 44px; min-height: 44px; font-size: 1rem; }
  .store-card {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px 12px;
    padding: 6px 10px;
    border: 1px solid #a18a62;
    border-radius: 6px;
    background: #312f27;
  }
  .store-card strong { color: #ffdb8d; font-size: clamp(1.3rem,3cqw,1.75rem); }
  .store-table { width: 100%; table-layout: fixed; border-collapse: collapse; text-align: center; }
  .store-table th, .store-table td { padding: 5px 3px; border: 1px solid #68897e; overflow-wrap: anywhere; }
  .store-table th { color: #f5eedc; background: #233a37; }
  .store-table td { font-size: clamp(1.05rem,3.4cqw,1.45rem); font-weight: 750; }
  .store-slot {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 48px;
    border: 1px dashed #a5b9a3;
    border-radius: 5px;
    cursor: pointer;
  }
  .store-slot input { position: absolute; opacity: 0; }
  .store-slot:has(input:checked) { border: 2px solid #ffd486; background: #4d3c2b; color: #ffe5a9; }
  .store-slot:focus-within { outline: 2px solid #fff0b0; outline-offset: 2px; }
  .store-equation {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px 15px;
    padding: 5px;
    font-size: clamp(1.35rem,5.1cqw,2.65rem);
    font-variant-numeric: tabular-nums;
    color: #ffdb91;
  }
  .store-proof { display: grid; gap: 4px; padding: 8px 11px; border: 1px solid #7ca797; border-radius: 6px; line-height: 1.45; }
  .store-proof b { color: #ffe0a0; }
  .store-scale { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; }
  .store-scale p { display: grid; gap: 3px; padding: 5px 8px; background: #243c35; border-radius: 5px; overflow-wrap: anywhere; }
  .store-scale strong { font-size: clamp(1rem,3cqw,1.3rem); }
  .store-scale em { color: #b4e7cc; font-style: normal; white-space: nowrap; }
  #store-form .entry input { width: 100%; min-height: 44px; }
  #store-form .entry { margin-block: 8px; }
  .store-instruction { margin-bottom: 6px; }
  .store-hint summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; color: #ffe0a0; }
  .store-hint summary::before { content: '▸'; margin-inline-end: 6px; }
  .store-hint[open] summary::before { content: '▾'; }
  .store-group, .store-stops, .store-marks { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
  .store-group { margin-top: 6px; }
  .store-group i { display: block; width: 22px; height: 22px; border-radius: 4px; background: #edb879; }
  .store-group i:nth-of-type(n+4) { background: #8ed8d1; border-radius: 50%; }
  .store-stops [aria-pressed="true"] { background: #665134; color: #ffedba; border-color: #ffd58d; }
  .store-count { display: grid; gap: 8px; }
  .store-marks span { padding: 5px 8px; border: 1px dashed #8de0ca; border-radius: 5px; background: #233d37; }
  .store-marks .fixed { border-style: solid; border-color: #ebbc77; background: #533e2c; }
  .store-marks i { display: flex; gap: 3px; margin-top: 4px; }
  .store-marks em { width: 16px; height: 16px; border-radius: 50%; background: #8de0ca; }
  .store-marks .fixed em { border-radius: 3px; background: #ebbc77; }
  .receipt-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .receipt-card {
    display: grid;
    gap: 2px;
    padding: 7px;
    min-width: 0;
    border: 1px solid #b0a67e;
    border-radius: 7px;
    background: #e9d7a7;
    color: #29342d;
    overflow-wrap: anywhere;
  }
  .receipt-card strong { color: #30261a; font-size: clamp(1.25rem,4cqw,2rem); }
  .receipt-card[aria-pressed="true"] { background: #ffe5a6; outline: 2px solid #be753d; outline-offset: -4px; }
  .receipt-table caption { text-align: left; margin-bottom: 3px; }
  .receipt-table td { font-size: 1rem; }
  .receipt-match { color: #b6f0c8; }
  .receipt-miss { color: #ffc59c; }
  @media (min-width:820px) {
    .lesson-workspace { grid-template-columns: minmax(0,1.85fr) minmax(0,1fr); }
    .receipt-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
  }
}
@media (max-width:750px) {
  .storage-scene .scene-shade { background: linear-gradient(0deg,#101b20fa,#101b20d1 52%,#101b2021 100%); }
}

#app[data-lesson-backdrop="machine"] { --lesson-art: url('./media/machine-room.webp'); background-position: 72% center; }
.machine-scene .scene-art { object-position: 68% center; }
.machine-scene .scene-shade { background: linear-gradient(90deg,#111520f5,#121720c2 43%,#10151b30 90%); }
.machine-scene h1 { word-break: keep-all; }
:is(.bench-clue,.bench-schedule) {
  display: grid;
  gap: 3px;
  width: fit-content;
  padding: 10px 15px;
  margin-block: 10px;
  border: 1px solid #ab8f66;
  border-radius: 7px;
  background: #242824eb;
  color: #ffe5b8;
}
.bench-clue strong { font-size: clamp(1.35rem,4vw,2.25rem); }
.restored-ink { display: inline-block; font-style: normal; color: #a7f1d3; }
.bench-schedule span { color: #e5ebdc; }
.lesson.chapter4 {
  .lesson-progress { font-size: 1rem; }
  .lesson-workspace { grid-template-rows: auto; align-items: start; gap: clamp(8px,1.3vw,16px); }
  .prompt { font-size: clamp(1.0625rem,1.7vw,1.25rem); }
  :is(.bench-diagram,.interaction) { background: #19232aed; border-color: #687d73; min-width: 0; }
  .bench-diagram { display: grid; gap: 10px; padding: clamp(10px,1.6vw,18px); align-content: start; }
  .interaction { padding: clamp(10px,1.6vw,18px); }
  .interaction button, .bench-diagram button, .options label { min-width: 44px; min-height: 44px; font-size: 1rem; }
  .bench-formula {
    position: relative;
    display: grid;
    grid-template-columns: 16fr 12fr 16fr 12fr 16fr 12fr 16fr;
    align-items: center;
    text-align: center;
    padding-bottom: 12px;
  }
  .bench-formula.wired { padding-bottom: 50px; }
  .bench-formula b { font-size: clamp(1.1rem,3vw,1.75rem); color: #e3d2ad; }
  .bench-formula .bench-equals { color: #ffce7f; }
  .bench-formula .bench-term {
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 48px;
    padding: 4px;
    border: 1px solid #a58c66;
    border-radius: 7px;
    background: linear-gradient(#384342,#242e30);
    color: #ffebbc;
    font: 700 clamp(1.375rem,4.3vw,3rem)/1.1 Georgia,serif;
  }
  .bench-formula .bench-term[aria-pressed="true"] { background: #704b31; outline: 2px solid #ffd291; outline-offset: -3px; }
  .bench-wires { display: none; width: 100%; height: 50px; position: absolute; bottom: 0; pointer-events: none; }
  .wired .bench-wires { display: block; }
  .bench-wires path { fill: none; stroke-width: 3; vector-effect: non-scaling-stroke; }
  .wire-outer { stroke: #ffc779; }
  .wire-inner { stroke: #9ce3d7; stroke-dasharray: 7 4; }
  .bench-strips { display: grid; gap: 9px; }
  .bench-strip p { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 12px; margin-bottom: 3px; }
  .bench-strip p span { color: #e5e7d9; }
  .bench-strip svg { display: block; width: 100%; height: clamp(32px,6svh,52px); }
  .bench-strip .track { fill: #30404a; }
  .bench-strip .shade.gold { fill: #efb568; }
  .bench-strip .shade.blue { fill: #87d9da; }
  .bench-strip line { stroke: #212d33; stroke-width: 2; vector-effect: non-scaling-stroke; }
  .bench-strip line.fine { stroke-width: 1; opacity: .72; }
  .bench-strip .outline { fill: none; stroke: #bcceb7; vector-effect: non-scaling-stroke; }
  .bench-note, .bench-pair-readout { color: #edf0e5; font-size: 1rem; line-height: 1.45; }
  .bench-proof { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; }
  .bench-proof p { display: grid; gap: 2px; padding: 5px 8px; border: 1px solid #b28d5a; border-radius: 6px; }
  .bench-proof p+p { border: 1px dashed #9ce3d7; }
  .bench-proof b { font-size: 1rem; }
  .bench-proof strong { font-size: clamp(1.05rem,2.1vw,1.45rem); }
  .bench-inputs { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-bottom: 8px; }
  .bench-form > .entry { margin-bottom: 8px; }
  .bench-form .entry input { width: 100%; min-width: 44px; min-height: 44px; }
  .bench-circuits { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0; }
  .bench-circuits li { min-width: 36px; padding: 3px 8px; text-align: center; border: 1px solid #718477; border-radius: 5px; }
  .bench-circuits .lit { background: #ffd186; color: #28231d; font-weight: 800; }
  @media (min-width:820px) {
    .lesson-workspace { grid-template-columns: minmax(0,1.85fr) minmax(0,1fr); }
  }
}
@media (max-width:750px) {
  .machine-scene .scene-shade { background: linear-gradient(0deg,#121720f8,#121720d9 48%,#10151b30 100%); }
}

.archive-scene.scene {
  .scene-copy { min-width: 0; }
  .scene-art { object-position: 63% center; }
  .scene-shade { background: linear-gradient(90deg, #141124a8, #1411247d 36%, transparent 72%), linear-gradient(0deg, #141124ab, transparent 46%); }
  h1 { overflow-wrap: anywhere; }
  .archive-case-clue {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 2px 8px;
    width: fit-content;
    max-width: 100%;
    margin-bottom: 8px;
    padding: 7px 10px;
    border: 1px solid #aa815a;
    border-radius: 6px;
    background: #2a1c2cf2;
    color: #fae6c6;
    line-height: 1.45;
  }
  .archive-case-clue b { color: var(--gold); }
  .archive-cabinet {
    display: grid;
    grid-template-columns: repeat(3,minmax(0,1fr));
    gap: 5px;
    width: min(100%,36rem);
    margin-block: 5px;
  }
  .archive-drawer {
    display: grid;
    justify-items: center;
    width: 100%;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: none;
  }
  .archive-drawer-face { display: block; position: relative; width: 100%; }
  .archive-drawer-art { display: block; width: 100%; height: auto; filter: drop-shadow(0 5px 10px #0f0813b0); }
  .archive-drawer-number {
    position: absolute;
    top: 36.5%;
    left: 50%;
    translate: -50% -50%;
    color: #552c19;
    font: 700 clamp(1rem, 2.65vw, 2.125rem)/1 Georgia, serif;
  }
  .archive-drawer:hover .archive-drawer-face { filter: brightness(1.14); }
  .archive-drawer:focus-visible { outline: 2px solid #f0bc7c; outline-offset: 2px; }
  .archive-drawer-status { color: #ffcc9b; font-size: 1rem; }
  .archive-drawer-status:empty { margin: 0; }
  .archive-damaged { border-style: dashed; }
  .quiet { min-width: 44px; }

  @media (max-width: 750px) {
    align-items: end;
    padding-block: clamp(95px, 20svh, 175px) max(22px, env(safe-area-inset-bottom));
    .scene-art { object-position: 81% center; }
    .scene-shade { background: linear-gradient(0deg, #141124fc 8%, #141124eb 53%, #14112424 100%); }
  }
  @media (orientation: landscape) and (max-height: 500px) {
    padding-block: 16px;
  }
  @media (orientation: landscape) and (min-width: 640px) and (max-height: 500px) {
    .scene-copy:has(.archive-cabinet) {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(0, 48%);
      align-items: start;
      column-gap: 14px;
      max-width: 48rem;
    }
    .archive-cabinet { grid-column: 2; grid-row: 1 / span 5; align-self: center; }
    .archive-drawer-status { grid-column: 1; }
  }
}
