/* STM 탐침: '종이 위 그림' (studio/DESIGN.md, 2026-10-17)
   - 틀(위 막대·판·단추·창)은 공용 묶음 kit/paper.css(빌드가 studio/_kit에서 복사)의 토큰과 부품을 그대로 쓴다:
     .k-btn·.k-primary(단추), .k-seg·.k-on(고른 상태), .k-range(슬라이더), .k-w(범례 낱말), .k-link(진행 지우기),
     .k-dark(어두운 그림 위 초점 링), [hidden] !important. 이 파일에는 배치와 이 작품의 대상 색만 둔다.
   - 어두운 그림은 둘이다: 3D 장면(#fig)과 그래프·STM 영상(#view2d). 둘 다 흰 종이 위에 놓인다.
   - 같은 대상은 같은 색(어두운 그림 위 / 종이 위): 전자의 확률 파동·터널 전류 = 청록, 장벽 = 주황, 공과 확대해 그린 건너편 파동 = 보라(호박은 경고에만),
     빈자리·맞힘 = 초록, 다른 원자 = 분홍. 3D 이름표, 글 속 범례 낱말, 읽음값, 그래프가 같은 색을 쓴다.
   - 반경: 단추·입력·세그먼트 var(--k-r), 판·그림·꼬리표·창 0, 원자·점·손잡이만 원. */
:root {
  --wave-d: #52dcff; --wave-p: #0b7285;
  --bar-d: #ff7a45;  --bar-p: #d9480f;
  --ball-d: #c4b5fd; --ball-p: #6741d9;
  --ok-d: #5fe39a;   --ok-p: #237032;
  --pink-d: #ff7ad9; --pink-p: #c2255c;
  --bad-p: #c92a2a;
  --scene: #0b1222;
  --hdr: 52px;
  --sideW: clamp(300px, 35%, 450px);
  --sceneH: 44%;
  --tap: 40px;
  font-family: var(--k-font);
  color: var(--k-ink);
  -webkit-text-size-adjust: 100%;
}
@media (max-height: 560px) { :root { --tap: 36px; } }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; color: var(--k-ink); font-family: var(--k-font); background: var(--k-paper);
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation; font-size: 14px; line-height: 1.45; }
/* 줄바꿈은 낱말 경계에서만: 한국어는 어절, 영어는 단어(하이픈 분철 없음), 일본어는 구절(크롬)과 금칙.
   화면을 넘칠 만큼 긴 낱말만 끊는다. 가운뎃점·괄호·숫자 단위는 i18n.js의 wrapText·keepWords가 맡는다 */
html { overflow-wrap: break-word; -webkit-hyphens: none; hyphens: none; }
html:lang(ko) { word-break: keep-all; }
html:lang(ja) { word-break: auto-phrase; line-break: strict; }
/* 사파리(auto-phrase 없음): 문구에 넣은 U+200B(구절 경계, i18n.js는 이때만 넣는다)에서만 줄을 바꾼다 */
@supports not (word-break: auto-phrase) { html:lang(ja) { word-break: keep-all; } }
.nb { white-space: nowrap; }
button { font-family: inherit; font-size: 14px; color: inherit; cursor: pointer; }
button:focus-visible, canvas:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--k-ink); outline-offset: 2px; }
button:disabled { cursor: default; opacity: 0.45; }
b, strong { font-weight: 750; }
i.v { font-family: "Times New Roman", Georgia, serif; font-style: italic; font-size: 1.08em; }
sup { font-size: max(12px, 0.74em); line-height: 0; }
.k-w.wave { --w: var(--wave-p); }
.k-w.bar { --w: var(--bar-p); }
.k-w.ball { --w: var(--ball-p); }
.k-w.ok { --w: var(--ok-p); }
.k-w.pink { --w: var(--pink-p); }

#app {
  position: fixed; inset: 0; display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sideW);
  grid-template-rows: var(--hdr) minmax(0, 1fr);
  grid-template-areas: "top top" "view side";
  background: var(--k-paper);
}
#app > * { min-width: 0; min-height: 0; }
/* 시작 화면: 판 자리(데스크톱 오른쪽) */
body.starting #side { display: none !important; }
body.starting #app { grid-template-areas: "top top" "view start"; }
#app > .k-start { grid-area: start; min-height: 0; padding: 14px 14px 12px 6px; }
.k-start.x-tiny { gap: 6px; }
.k-start.x-tiny .k-q { font-size: 14px; line-height: 1.25; }
body.thumb #app > :not(#view) { display: none !important; }
body.thumb #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: 1fr; grid-template-areas: "view"; }
body.thumb #view { padding: 0; }
body.thumb #tools, body.thumb #labels, body.thumb #hud, body.thumb #mag { display: none !important; }

/* ── 위 막대 ── */
#top { grid-area: top; display: flex; align-items: center; gap: 6px; padding: 6px 10px 6px 6px; min-width: 0; }
.icon { flex: none; width: var(--tap); height: var(--tap); border: 0; border-radius: var(--k-r); background: none; display: grid; place-items: center; padding: 0; color: var(--k-ink); }
@media (hover: hover) { .icon:hover { background: var(--k-wash); } }
#chap { flex: 1; min-width: 0; display: flex; align-items: center; padding: 0 6px; font-size: 15px; line-height: 1.3; }
#chap .in { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; min-width: 0; }
#chTag { font-weight: 800; margin-right: 0.45em; }
#chTag:empty { display: none; }
#chName { font-weight: 500; color: var(--k-ink-2); }
body.starting #chap { font-size: 17px; }
body.starting #chName { font-weight: 800; color: var(--k-ink); }
body.starting #bMenu { visibility: hidden; }
body.starting #tabs { display: none; }
html.phone body:not(.starting) #chName, html.micro body:not(.starting) #chName { display: none; }
#tabs { display: flex; align-items: center; gap: 2px; flex: none; min-width: 0; overflow: hidden; }
#tabs .lb { flex: none; font-size: 15px; font-weight: 800; margin: 0 8px 0 4px; white-space: nowrap; }
#tabs button {
  flex: none; position: relative; height: var(--tap); min-width: 34px; padding: 0 8px; border: 0; border-radius: 0; background: none;
  color: var(--k-sub); font-size: 15px; font-weight: 650; white-space: nowrap; display: flex; align-items: center; justify-content: center; gap: 5px;
}
#tabs button .n { font-variant-numeric: tabular-nums; }
#tabs button .t { display: none; }
#tabs .pip { position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); display: flex; gap: 2px; }
#tabs .pip i { width: 5px; height: 5px; box-shadow: inset 0 0 0 1px var(--k-ctl); }
#tabs .pip i.on { background: var(--k-ink); box-shadow: none; }
#tabs.story button { padding-bottom: 8px; }
@media (hover: hover) { #tabs button:not(.k-on):hover { background: var(--k-wash); color: var(--k-ink); } }
html.free:not(.tabsHidden) #chap { display: none; }
html.tabsHidden #tabs { display: none; }
html.free #tabs { flex: 1; }
html.free #tabs button .t { display: inline; }
html.free #tabs.nolb .lb { display: none; }
html.free #tabs.num button:not(.k-on) .t, html.free #tabs.min button .t { display: none; }
html.free #tabs.min { gap: 0; }
html.free #tabs.min button { min-width: 32px; padding: 0 4px; }
/* 스토리 모드 단계 탭: 좁은 화면에서는 접는다(미션 줄의 점과 메뉴가 대신한다) */
@media (max-width: 820px) { html:not(.free) #tabs { display: none; } }

/* ── 3D 그림 ── */
#view { grid-area: view; display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 0 10px 12px 12px; }
#fig { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--scene); }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
/* 장면 이름표: 반경 0, 장면과 같은 불투명 바탕, 글자색으로 대상을 가른다 */
.lbl { position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 12.5px; line-height: 1.25; padding: 2px 7px 3px; background: var(--scene); color: #e6edf8; font-weight: 650; }
.lbl small { display: block; color: #b4c0d6; font-size: 12px; font-weight: 600; }
.lbl b { color: #ffffff; }
.lbl.wave, .lbl.wave b { color: var(--wave-d); }
.lbl.bar, .lbl.bar b { color: var(--bar-d); }
.lbl.ball, .lbl.ball b { color: var(--ball-d); }
.lbl.rul, .lbl.rul b { color: #ffffff; } /* 파장 자 이름표: 흰색 */
.lbl.ok, .lbl.ok b { color: var(--ok-d); }
.lbl.mag, .lbl.mag b { color: var(--ball-d); font-weight: 800; }
.lbl.dim { color: #b4c0d6; }
.lbl.big { font-size: 14px; font-weight: 750; }
.lbl.cell { font-size: 15px; padding: 2px 6px; font-weight: 750; }
.lbl.pink, .lbl.pink b { color: var(--pink-d); font-weight: 750; }
#tools { position: absolute; left: 8px; bottom: 8px; z-index: 3; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; max-width: calc(100% - 16px); }
#toolsX { display: contents; }
#tools .k-btn { height: var(--tap); }
#tools .k-btn.ico { width: var(--tap); padding: 0; }
/* 장벽 근처 확대경(1단계): 그림 위쪽 띠 창, 테두리 한 줄 */
#mag { position: absolute; z-index: 1; border: 1px solid #5c6b85; pointer-events: none; }
#magTag, #magR { position: absolute; top: 0; font-size: 12px; font-weight: 750; background: var(--scene); padding: 2px 7px; }
#magTag { left: 0; color: #e6edf8; }
#magR { right: 0; color: var(--ball-d); }
#magR:empty { display: none; }
#hud { position: absolute; right: 8px; top: 8px; z-index: 3; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; pointer-events: none; }
.meter { width: 210px; padding: 6px 10px 18px; background: var(--scene); color: #e6edf8; }
.mHead { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; color: #b4c0d6; margin-bottom: 5px; }
.mHead b { color: var(--wave-d); font-size: 15px; font-variant-numeric: tabular-nums; }
.mBar { position: relative; height: 8px; background: #26324a; }
.mBar span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--wave-d); }
.mBar i { position: absolute; top: -3px; width: 1px; height: 14px; background: #b4c0d6; }
.mBar em { position: absolute; top: 11px; transform: translateX(-30%); font-style: normal; font-size: 12px; color: #b4c0d6; white-space: nowrap; }
#toast {
  position: absolute; left: 50%; bottom: 10px; transform: translate(-50%, 8px); z-index: 5; opacity: 0; pointer-events: none;
  background: var(--k-paper); color: var(--k-ink); padding: 7px 12px; font-size: 14px; font-weight: 600; line-height: 1.45;
  width: max-content; max-width: min(calc(100% - 24px), 520px); text-align: center; transition: opacity 0.2s, transform 0.2s;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#noGL { position: absolute; inset: 20px; display: grid; place-items: center; text-align: center; color: #e6edf8; }

/* ── 오른쪽(아래) 판: 미션, 그래프, 읽음값, 조작 ── */
#side { grid-area: side; display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; padding: 4px 14px 12px 4px; }
#mission { flex: none; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
#mHead { display: flex; align-items: center; gap: 8px; min-width: 0; }
#mDots { display: flex; gap: 4px; flex: none; }
#mDots i { width: 10px; height: 10px; display: block; box-shadow: inset 0 0 0 1.5px var(--k-ctl); }
#mDots i.on { background: var(--k-ink); box-shadow: none; }
#mDots i.cur { box-shadow: inset 0 0 0 2.5px var(--k-ink); }
#mDots i.on.cur { box-shadow: none; }
#mGoal { font-size: 15px; font-weight: 800; line-height: 1.3; min-width: 0; }
#mText { margin: 0; font-size: 14px; line-height: 1.5; }
#mText:empty, #mProg:empty { display: none; }
#mProg { margin: 0; font-size: 14px; font-weight: 700; line-height: 1.4; }
#mActs { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
#mActs:empty { display: none; }
#mActs .k-btn { height: var(--tap); }
.pr { font-weight: 800; }
.pr.ok { color: var(--ok-p); }
.pr.no { color: var(--bad-p); }
html.free #mHead, html.free #mProg { display: none; }
#view2d { position: relative; flex: 1 1 auto; min-height: 64px; overflow: hidden; background: var(--scene); }
#g { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#gNote { position: absolute; left: 10px; right: 10px; top: 5px; font-size: 12px; color: #b4c0d6; pointer-events: none; text-align: right; }
#read { flex: none; display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 13.5px; color: var(--k-sub); align-items: baseline; }
#read:empty { display: none; }
#read b { color: var(--k-ink); font-variant-numeric: tabular-nums; }
#read .wv b { color: var(--wave-p); }
#read .okc b { color: var(--ok-p); }
#read small { color: var(--k-sub); font-size: 12px; }
#ctl { flex: none; display: flex; flex-direction: column; gap: 7px; }
#ctl:empty { display: none; }
/* 예측 전 잠금(스토리 모드): 조작은 흐리게, 할 일 한 줄(막 없이) */
#ctl.locked > * { opacity: 0.45; }
#ctl.locked::before { content: attr(data-lock-msg); font-size: 14px; font-weight: 700; color: var(--k-ink); }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.row > .k-btn { flex: 1 1 auto; min-width: 0; height: var(--tap); padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; gap: 6px; } /* 폭은 글 길이에 맞춰 나눈다(같은 폭이면 긴 이름이 말줄임된다) */
.row > .k-btn.narrow { flex: 0 0 auto; }
.k-btn svg { flex: none; }
.sl { display: grid; grid-template-columns: auto minmax(60px, 1fr) auto; gap: 8px; align-items: center; font-size: 13.5px; }
.sl label { color: var(--k-ink); font-weight: 700; white-space: nowrap; }
.sl.lock label, .sl.lock output { color: var(--k-sub); }
.sl output { min-width: 66px; text-align: right; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* 플래시 칸 8개: 저장된 전자 = 청록 점, 목표 = 잉크 점 */
.cells { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.cells button { height: 40px; border: 1.5px solid var(--k-ctl); border-radius: var(--k-r); background: var(--k-paper); display: grid; place-items: center; padding: 0; position: relative; }
.cells button .dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--wave-p); }
.cells button.full .dot { background: var(--wave-p); }
.cells button.want::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: var(--k-ink); }
.cells button.match { border-color: var(--ok-p); border-width: 2.5px; }
.cells.target { pointer-events: none; }
.cells.target div { height: 18px; display: grid; place-items: center; }
.cells.target .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--k-ink); }
.cells.target .dot.f { background: var(--k-ink); }
.tgtRow { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px; align-items: center; font-size: 12.5px; color: var(--k-sub); font-weight: 650; }
.slPair { display: flex; flex-direction: column; gap: 7px; }

/* ── 옆 창(예측·결과): 판 맨 위(미션 줄·조작 자리). 그래프는 그 아래 그대로 보인다.
   다 들어가지 않으면 그래프도 접고(cardOnly), 그래도 넘치면 그림까지 접는다(cardFull, main.js fitSide) ── */
#sheet { flex: none; display: flex; flex-direction: column; min-width: 0; min-height: 0; max-height: 100%; background: var(--k-paper); }
html.carded #mission, html.carded #ctl, html.carded #read { display: none; }
html.cardOnly #view2d { display: none; }
html.noGraph #view2d { display: none; }
html.cardOnly #sheet { flex: 1 1 auto; }
html.cardFull #view { display: none; }
html.cardFull #side { grid-column: 1 / -1; }
#sheet .ctx { color: var(--k-sub); font-size: 14px; line-height: 1.5; margin: 0 0 6px; }
/* 알아 둘 것(예측 창 맨 위): 이 미션에서 처음 나오는 낱말과 단위의 뜻. 접히지 않는다 */
#sheet .know { color: var(--k-ink); font-size: 14px; line-height: 1.5; margin: 0 0 8px; }
#sheet h2 { font-size: 18px; line-height: 1.4; margin: 0 0 8px; }
#sheet .acts { margin-top: 12px; }
.res { margin-bottom: 8px; }
.res .hd { font-size: 16px; font-weight: 800; margin: 0 0 2px; line-height: 1.4; }
.res .hd.ok { color: var(--ok-p); }
.res .hd.bad { color: var(--bad-p); }
.res .pk { font-size: 14px; color: var(--k-sub); margin: 0 0 2px; line-height: 1.45; }
.res .rv { font-size: 14.5px; margin: 4px 0 0; line-height: 1.5; }
/* ── 가운데 창 ── */
#modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: var(--k-dim); padding: 12px; }
#modal .card { display: flex; flex-direction: column; width: min(580px, 100%); max-height: calc(100% - 8px); overflow: hidden; background: var(--k-paper); color: var(--k-ink); padding: 20px 22px 18px; }
#modal .card.wide { width: min(700px, 100%); }
.card > .cb { min-height: 0; overflow: auto; }
.card > .acts { flex: none; }
.card [tabindex="-1"]:focus { outline: none; }
.card h2 { font-size: 21px; font-weight: 750; margin: 0 0 10px; line-height: 1.38; }
.card h3 { font-size: 15px; font-weight: 800; margin: 14px 0 4px; }
.card p, .card .body { margin: 8px 0; font-size: 15px; line-height: 1.6; }
.card .note { font-size: 13.5px; color: var(--k-sub); line-height: 1.5; }
.card ul { margin: 6px 0; padding-left: 20px; }
.card li { font-size: 14.5px; line-height: 1.55; margin: 3px 0; }
.card table { border-collapse: collapse; width: 100%; font-size: 13px; margin: 6px 0; }
.card td, .card th { border-bottom: 1px solid var(--k-rule); padding: 4px 6px; text-align: left; }
.opts { display: grid; gap: 8px; margin-top: 12px; grid-template-columns: minmax(0, 1fr); }
#sheet.noCtx .ctx { display: none; }
.opts button {
  min-height: 46px; border: 1.5px solid var(--k-ctl); border-radius: var(--k-r); background: var(--k-paper); color: var(--k-ink);
  font-weight: 650; font-size: 15px; padding: 8px 12px; line-height: 1.35; text-align: left;
}
@media (hover: hover) { .opts button:hover { background: var(--k-wash); border-color: var(--k-ink); } }
.acts { display: flex; gap: 8px 10px; justify-content: flex-end; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.acts .k-btn { height: var(--tap); }
.acts .k-link { margin-right: auto; }
.stList { display: grid; margin-top: 6px; }
.stList > button {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 6px; width: 100%; min-height: 46px; padding: 6px 4px;
  border: 0; border-top: 1px solid var(--k-rule); background: none; text-align: left; color: var(--k-ink); font-size: 16px;
}
.stList > button:last-child { border-bottom: 1px solid var(--k-rule); }
@media (hover: hover) { .stList > button:not(.k-on):hover { background: var(--k-wash); } }
.stList .n { color: var(--k-sub); font-variant-numeric: tabular-nums; font-weight: 650; }
.stList > button.done .n { color: var(--k-ink); font-weight: 800; }
.stList .t { font-weight: 650; display: flex; flex-direction: column; }
.stList .t small { font-size: 13.5px; font-weight: 500; color: var(--k-sub); }
.stList .c { font-size: 14px; color: var(--k-sub); white-space: nowrap; }
.stars { font-size: 24px; letter-spacing: 3px; color: var(--k-ctl); margin: 2px 0 6px; }
.stars .on { color: var(--k-ink); }
.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin: 8px 0; }
.topics .k-btn { justify-content: flex-start; text-align: left; min-height: 40px; height: auto; padding: 6px 10px; white-space: normal; line-height: 1.3; }
.topics .k-btn.seen { border-color: var(--ok-p); }
.topicBox { padding: 8px 0 0; border-top: 1px solid var(--k-rule); font-size: 14px; line-height: 1.55; min-height: 3em; }
.topicBox .acts { margin-top: 8px; justify-content: flex-start; }
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; font-size: 0.86em; line-height: 1.1; margin: 0 2px; }
.frac > span:first-child { border-bottom: 1px solid currentColor; padding: 0 2px; }
.safety { padding: 6px 0; border-top: 1px solid var(--k-rule); border-bottom: 1px solid var(--k-rule); }

/* 낮은 데스크톱 */
@media (max-height: 600px) and (min-aspect-ratio: 21/20) {
  #mText { font-size: 13.5px; line-height: 1.45; }
  #side { gap: 6px; }
}
@media (max-height: 560px) and (min-aspect-ratio: 21/20) {
  :root { --hdr: 46px; }
  #modal .card { padding: 14px 18px; }
  .card h2 { font-size: 18px; margin-bottom: 6px; line-height: 1.35; }
  .card p, .card .body { font-size: 14px; line-height: 1.5; margin: 6px 0; }
  .acts { margin-top: 10px; }
  .opts { margin-top: 8px; gap: 6px; }
  .opts button { min-height: 40px; font-size: 14px; padding: 5px 10px; }
  .stList > button { min-height: 40px; padding: 3px 4px; font-size: 15px; }
  .stList .t small { display: none; }
}

/* ── 휴대폰 세로: 위 그림, 아래 판(미션 글은 '미션 보기'와 예측 창에서) ── */
html.compact { --hdr: 50px; }
html.compact #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--hdr) var(--sceneH) minmax(0, 1fr); grid-template-areas: "top" "view" "side"; }
html.compact body.starting #app { grid-template-rows: var(--hdr) minmax(0, 1fr) minmax(0, 2.4fr); grid-template-areas: "top" "view" "start"; }
html.compact #view { padding: 0 10px 6px; }
html.compact #side { padding: 0 10px 8px; gap: 6px; }
html.compact #mText { display: none; }
html.compact #mGoal { font-size: 14px; }
html.compact #mProg { font-size: 13.5px; }
html.compact #mission { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
html.compact #mHead { flex: 1 1 100%; }
html.compact #mProg { flex: 1 1 50%; }
html.compact #mActs { flex: 0 1 auto; margin-left: auto; }
html.compact #view2d { min-height: 72px; }
html.compact #read { font-size: 12.5px; gap: 2px 10px; }
html.compact #read small { display: none; }
html.compact .sl { gap: 6px; font-size: 12.5px; }
html.compact .sl output { min-width: 58px; }
html.compact .cells button { height: var(--tap); }
html.compact #gNote { display: none; }
html.compact .slPair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
html.compact .slPair.one, html.short .slPair.one, html.micro .slPair.one { grid-template-columns: minmax(0, 1fr); }
html.compact .slPair .sl { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "lab out" "rng rng"; gap: 0 6px; }
html.compact .slPair .sl label { grid-area: lab; }
html.compact .slPair .sl output { grid-area: out; min-width: 0; }
html.compact .slPair .sl input { grid-area: rng; height: var(--tap); }
html.compact #sheet h2 { font-size: 17px; line-height: 1.38; margin-bottom: 6px; }
html.compact #sheet p, html.compact #sheet .body { font-size: 14px; line-height: 1.5; margin: 6px 0; }
html.compact #sheet .opts { gap: 6px; margin-top: 8px; }
html.compact #sheet .opts button { min-height: 40px; font-size: 14.5px; padding: 5px 10px; }
html.compact #sheet .acts { margin-top: 10px; }
html.compact.cardFull #side { grid-row: 2 / -1; }
html.compact #app > .k-start { padding: 10px 10px 6px; }
html.compact #modal { padding: 8px; }
html.compact #modal .card { padding: 16px 16px 14px; }
html.compact .card h2 { font-size: 18px; }
html.compact .stList > button { min-height: 42px; font-size: 15px; }
html.compact .stList .t small { display: none; }
html.compact .topics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; margin: 5px 0; }
html.compact.monBig #read { display: none; }
@media (max-height: 520px) and (max-aspect-ratio: 21/20) {
  html.compact body.starting #app { grid-template-rows: var(--hdr) minmax(0, 1fr) minmax(0, 2.9fr); }
  .card { padding: 12px 14px; }
  .card h2 { font-size: 17px; line-height: 1.35; margin-bottom: 6px; }
  .card p, .card .body { font-size: 13.5px; line-height: 1.5; margin: 6px 0; }
  .acts { margin-top: 10px; }
}

/* ── 낮은 가로 화면(750×280 등): 그림 왼쪽, 오른쪽 판 ── */
html.short { --hdr: 44px; --sideW: min(48vw, 420px); }
html.short body.starting #app { grid-template-columns: minmax(0, 1fr) minmax(0, 60%); }
html.short #top { padding: 2px 6px 2px 4px; gap: 4px; }
html.short #chap { font-size: 13px; }
html.short #chap .in { line-height: 1.22; }
html.short #view { padding: 0 6px 6px 8px; }
html.short #side { padding: 0 8px 6px 2px; gap: 5px; }
html.short #mText { display: none; }
html.short #mission { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 3px 8px; }
html.short #mHead { flex: 1 1 auto; min-width: 0; }
html.short #mGoal { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.short #view2d { min-height: 50px; flex-basis: 0; }
html.short #ctl { gap: 4px; }
html.short #ctl.locked::before { font-size: 13px; }
html.short #mGoal { font-size: 13.5px; }
html.short #mProg { flex: 1 1 50%; font-size: 13px; }
html.short #mActs { flex: 0 1 auto; margin-left: auto; }
html.short #read { font-size: 12px; gap: 1px 10px; }
html.short #read small { display: none; }
html.short .sl { font-size: 12.5px; }
html.short .k-range { height: 36px; }
html.short .cells button { height: 36px; }
html.short #gNote { display: none; }
html.short .slPair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
html.short .slPair .sl { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "lab out" "rng rng"; gap: 0 6px; }
html.short .slPair .sl label { grid-area: lab; }
html.short .slPair .sl output { grid-area: out; min-width: 0; }
html.short .slPair .sl input { grid-area: rng; height: 36px; }
html.short .row > .k-btn { height: 36px; }
html.short #sheet h2 { font-size: 15px; margin-bottom: 4px; }
html.short #sheet p, html.short #sheet .body, html.short #sheet .ctx, html.short #sheet .know { font-size: 13px; line-height: 1.45; margin: 4px 0; }
html.short .res .hd { font-size: 14.5px; }
html.short .res .pk, html.short .res .rv { font-size: 13px; }
html.short #sheet .opts { margin-top: 6px; gap: 5px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
html.short #sheet .opts button { min-height: 36px; font-size: 13px; padding: 3px 8px; }
html.short #sheet .acts { margin-top: 6px; }
html.short.cardOnly:not(.micro) #app { grid-template-columns: minmax(0, 1fr) minmax(0, 64%); }
html.short #app > .k-start { padding: 6px 4px 4px; }
html.short #modal { padding: 4px; }
html.short #modal .card { padding: 10px 14px; }
html.short .card h2 { font-size: 16px; margin-bottom: 4px; }
html.short .card p, html.short .card .body { font-size: 13px; margin: 4px 0; line-height: 1.45; }
html.short .card li { font-size: 13px; margin: 2px 0; }
html.short .acts { margin-top: 8px; }
html.short .stList { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 10px; }
html.short .stList > button { min-height: 36px; padding: 2px; gap: 4px; grid-template-columns: 20px minmax(0, 1fr) auto; font-size: 13.5px; }
html.short .stList > button:nth-last-child(-n+2) { border-bottom: 1px solid var(--k-rule); }
html.short .stList .t small { display: none; }
html.short .topics { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin: 5px 0; }
html.short .topicsLead { display: none; }
html.short .stars { font-size: 20px; margin: 0; }
html.short.monBig #read { display: none; }
html.short .meter, html.compact .meter { display: none; }

/* ── 아주 낮은 화면(320×200 등) ── */
html.micro { --hdr: 40px; }
html.micro #top { gap: 2px; padding: 2px 4px; }
html.micro .icon { width: 36px; height: 36px; }
html.micro #chap { font-size: 12.5px; }
html.micro:not(.free) #tabs { display: none; }
html.micro #view { padding: 0 4px 4px 6px; }
html.micro #side { padding: 0 6px 3px 2px; gap: 3px; }
/* 판(#side)의 칸을 바로 격자에 놓는다: 위 막대, [그림 | 미션 줄], [조작판 가로 전체]. 그래프와 읽음값은 접는다(3D가 결과를 보인다) */
html.micro #app { grid-template-columns: minmax(0, 34%) minmax(0, 66%); grid-template-rows: var(--hdr) minmax(0, 1fr) auto; grid-template-areas: "top top" "view mission" "ctl ctl"; }
html.micro body.starting #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--hdr) minmax(0, 1fr); grid-template-areas: "top" "start"; }
html.micro body.starting #view { display: none; }
html.micro #side { display: contents; }
html.micro #mission { grid-area: mission; min-height: 0; padding: 0 6px 2px 2px; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 2px 6px; align-content: flex-start; }
html.micro #mHead { flex: 1 1 100%; }
html.micro #mDots { display: none; }
html.micro #ctl { grid-area: ctl; padding: 2px 6px 4px; gap: 3px; }
html.micro #ctl.locked::before { font-size: 12.5px; }
html.micro #sheet { grid-area: mission; }
html.micro.cardOnly #sheet { grid-row: 2 / 4; grid-column: 1 / 3; padding: 0 8px 4px; position: relative; z-index: 30; }
html.micro #read, html.micro #view2d { display: none !important; }
html.micro #mProg { font-size: 12px; }
html.micro .slPair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
html.micro .slPair .sl { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "lab out" "rng rng"; gap: 0 4px; }
html.micro .slPair .sl label { grid-area: lab; }
html.micro .slPair .sl output { grid-area: out; min-width: 0; }
html.micro .slPair .sl input { grid-area: rng; height: 36px; }
html.micro .sl { font-size: 12px; }
html.micro #mGoal { font-size: 12.5px; }
html.micro #mission.mNoHead #mHead, html.micro #mission.mNoProg #mProg { display: none; }
html.figTiny #tools { display: none; }
html.micro .sl output { min-width: 50px; }
html.micro .k-range { height: 36px; }
html.micro .row > .k-btn, html.micro #mActs .k-btn { height: 36px; min-height: 36px; padding: 0 7px; font-size: 12.5px; }
html.micro .row > .k-btn { flex: 1 1 auto; padding: 0 5px; gap: 4px; }
html.micro .cells button { height: 36px; }
html.micro #tools { left: 3px; bottom: 3px; }
html.micro #tools .k-btn { height: 36px; min-height: 36px; }
html.micro #tools .k-btn.ico { width: 36px; }
html.micro #tools .k-btn:not(.ico) { padding: 0 6px; font-size: 12px; }
html.micro #tools { flex-wrap: nowrap; gap: 3px; left: 3px; bottom: 3px; }
/* 짧은 이름(.ls)은 아주 작은 틀에서만 */
.k-btn .ls, html.micro .k-btn .lf { display: none; }
html.micro .k-btn .ls { display: inline; }
/* 글이 단추보다 넓은 줄(main.js fitLabels) */
.row.sl .k-btn .lf { display: none; }
.row.sl .k-btn .ls { display: inline; }
/* 자유 모드에는 미션 칸이 없으므로 그림이 가로 전체를 쓴다 */
html.micro.free #app { grid-template-areas: "top top" "view view" "ctl ctl"; }
html.micro.free #mission { display: none; }
html.micro .card h2 { font-size: 14px; margin-bottom: 2px; }
html.micro .acts { margin-top: 4px; }

@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
/* 아주 작은 틀: 메뉴의 단계 목록은 한 줄에 하나(두 칸이면 일본어 가타카나 낱말이 칸보다 길어 갈린다). 창 안 스크롤로 본다 */
html.micro .stList { grid-template-columns: minmax(0, 1fr); }
/* 예측 전: 그래프와 읽음값은 자리만 두고 가린다(답을 미리 보이지 않게). 예측을 고르면 나타난다 */
html.preAns #view2d > *, html.preAns #read { visibility: hidden; }
html.preAns #view2d::after { content: attr(data-pre); position: absolute; inset: 0; display: grid; place-items: center; padding: 8px; text-align: center; color: #c3cde0; font-size: 13.5px; font-weight: 700; }
#sheet small, #card small { font-size: 12.5px; } /* 결과 글의 (모형, 자릿수만): 12px 이상 */
