/* 원뿔 자르기: '종이 위 그림' (studio/DESIGN.md, 2026-10-17)
   - 틀(위 막대·조작판·좌표평면 판·단추·창)은 공용 묶음(_kit/paper.css)의 토큰과 부품을 그대로 쓴다:
     .k-btn·.k-primary(단추), .k-seg·.k-on(고른 상태 = 굵은 글자 + 칸 아래 3px 막대), .k-range(슬라이더),
     .k-w(범례 낱말), .k-link(진행 지우기), .k-dark(어두운 그림 위 초점 링), [hidden] !important.
   - 3D 원뿔은 흰 종이 위의 어두운 그림(#v3d), 조작판은 그림 아래 종이 위, 좌표평면은 종이 위 잉크 그래프(#v2d).
   - 같은 대상은 같은 색: 원·타원 주황, 포물선 초록, 쌍곡선 분홍(3D 단면·좌표평면 곡선·이름·글),
     초점 F 파랑·F′ 보라, 접선 청록, 학생이 끄는 손잡이·점 P는 잉크(어두운 장면에서는 흰색).
     어두운 장면용(--*-d)과 흰 종이용(--*-p, 흰 바탕 대비 4.5:1 이상) 두 벌.
   - 반경: 단추·입력 var(--k-r), 판·그림·꼬리표·창 0, 손잡이·색 점만 원. */
@import "kit/paper.css";

:root {
  --ell-d: #ff8c42;  --ell-p: #c2410c;   /* 원·타원 */
  --par-d: #7ee08a;  --par-p: #2b7a35;   /* 포물선 */
  --hyp-d: #ff8fc7;  --hyp-p: #c2255c;   /* 쌍곡선 */
  --F-d: #4cc9f0;    --F-p: #0369a1;     /* 초점 F */
  --F2-d: #c4a1ff;   --F2-p: #6741d9;    /* 초점 F′ */
  --tan-d: #5eead4;  --tan-p: #0f766e;   /* 접선 */
  --ok-p: #237032;
  --bad-p: #c92a2a;
  --scene: #0a1022;  /* 3D 장면 바탕 */
  --lab-ink: #e8eeff;
  --hdr: 52px;
  --pw: clamp(min(300px, 44vw), 39%, 560px);
  --tap: 40px;
  --font: var(--k-font);
}
@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); font-size: 14px;
  background: var(--k-paper); -webkit-text-size-adjust: 100%;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
/* 줄바꿈: 한국어는 어절, 영어는 낱말, 일본어는 구절·금칙. 화면을 넘칠 만큼 긴 낱말만 끊는다 */
html { overflow-wrap: break-word; hyphens: none; }
html:lang(ko) { word-break: keep-all; }
html:lang(ja) { word-break: auto-phrase; line-break: strict; }
/* 사파리(auto-phrase 없음): 문구에 넣은 U+200B(구절 경계, main.js는 이때만 넣는다)에서만 줄을 바꾼다 */
@supports not (word-break: auto-phrase) { html:lang(ja) { word-break: keep-all; } }
.nw { white-space: nowrap; }
button { font-family: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--k-ink); outline-offset: 2px; }
i { font-style: italic; font-family: "Times New Roman", "Cambria Math", Georgia, serif; font-size: 1.08em; }
sup { font-size: max(12px, 0.76em); line-height: 0; vertical-align: 0.5em; }

/* ── 범례 낱말(.k-w)의 대상 색 ── */
.k-w.ell { --w: var(--ell-p); }
.k-w.par { --w: var(--par-p); }
.k-w.hyp { --w: var(--hyp-p); }
.k-w.F { --w: var(--F-p); }
.k-w.F2 { --w: var(--F2-p); }
.k-w.tan { --w: var(--tan-p); }
.k-w.tool { --w: var(--k-ink); }
.k-w { white-space: nowrap; } /* 범례 낱말(짧은 이름·식)은 한 줄로: 밑줄이 두 줄로 갈리지 않게 */

#app {
  position: fixed; inset: 0; display: grid;
  grid-template-columns: minmax(0, 1fr) var(--pw);
  grid-template-rows: var(--hdr) minmax(0, 1fr);
  grid-template-areas: "top top" "view panel";
  background: var(--k-paper);
}
body.wide.f2d { --pw: clamp(300px, 50%, 720px); }

/* ── 위 막대 ── */
#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); } }
#goalBox { flex: 1 1 auto; min-width: 0; position: relative; min-height: var(--tap); display: flex; align-items: center; padding: 0 8px 4px; }
/* 위 여백 3px: 첫 줄 위첨자(n², a²)의 윗부분이 overflow에 잘리지 않게(잘린 만큼 margin으로 되돌린다) */
#goalBox .in { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; min-width: 0; font-size: 15px; line-height: 1.32; padding-top: 3px; margin-top: -3px; }
#goalBox.grow .in { -webkit-line-clamp: 5 !important; } /* main.js fitGoal: 세로 휴대폰에서 위 막대를 키울 때 */
#stepTag { font-weight: 800; margin-right: 0.45em; }
#stepTag:empty, #goalBox.nolead #stepTag { display: none; }
#goal b { font-weight: 800; }
body.starting #goalBox .in { font-size: 17px; font-weight: 800; }
body.starting #bMenu, body.starting #stars { visibility: hidden; }
/* 칠하기·작도 진행: 위 막대 아래쪽의 가는 잉크 막대(색 띠가 아니라 진행 표시) */
#prog { position: absolute; left: 8px; right: 8px; bottom: 0; height: 3px; background: var(--k-rule); }
#prog i { display: block; height: 100%; width: var(--p, 0%); background: var(--k-ink); transition: width 0.2s; }
/* 이 단계의 별(★ = 얻음, ☆ = 아직) */
#stars { display: flex; align-items: center; gap: 1px; padding: 0 4px; font-size: 17px; color: var(--k-ink); white-space: nowrap; flex: none; }
#top.nostars #stars { display: none; } /* 할 일 글이 넘치는 좁은 화면: 별은 메뉴·결과에도 있다 */
body.starting #chips3d { visibility: hidden; } /* 시작 화면 뒤 평면 움직임의 읽음값은 숨긴다(예측의 답을 미리 보여 주지 않게) */
.gp { display: inline-block; width: 1.1em; } /* 읽음값 사이 간격(' · ' 대신) */
.tog[aria-pressed="true"]:focus-visible { box-shadow: inset 0 -3px 0 var(--lab-ink), 0 0 0 2px var(--k-paper); } /* 눌린 토글의 막대가 초점 링을 덮지 않게 */
#h2d .mini[aria-pressed="true"]:focus-visible { box-shadow: inset 0 -3px 0 var(--k-ink), 0 0 0 2px var(--k-paper); }
#stars span { width: 1.05em; text-align: center; }

/* 자유 모드 장면 고르기(공용 .k-on) */
#scenes { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; overflow: hidden; }
#scenes .lb { flex: none; font-size: 15px; font-weight: 800; margin: 0 10px 0 4px; white-space: nowrap; }
#scenes button {
  flex: none; height: var(--tap); min-width: 32px; border: 0; border-radius: 0; background: none; padding: 0 9px;
  font-size: 15px; font-weight: 600; color: var(--k-sub); white-space: nowrap; display: flex; align-items: center; justify-content: center; gap: 5px;
}
#scenes button .n { font-variant-numeric: tabular-nums; }
@media (hover: hover) { #scenes button:not(.k-on):hover { background: var(--k-wash); color: var(--k-ink); } }
#scenes.nolb .lb { display: none; }
#scenes.num button:not(.k-on) .t { display: none; }
#scenes.min button .t { display: none; }
/* 아주 좁으면 지금 장면 하나와 ‹ › 단추만 */
#scenes .stp { display: none; color: var(--k-ink); font-size: 20px; }
#scenes.step .stp { display: flex; }
#scenes.step button[data-f]:not(.k-on) { display: none; }
#scenes.step button.k-on .t { display: inline; }
#scenes.step { gap: 0; }

/* ── 3D 그림: 흰 종이 위의 어두운 그림(.k-dark), 조작판은 그 아래 종이 위 ── */
#view { grid-area: view; display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 0 10px 0 12px; }
#v3d { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--scene); }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#c:focus-visible { outline: 2px solid var(--k-paper); outline-offset: -4px; }
.nogl { position: absolute; inset: 20% 8%; display: grid; place-items: center; text-align: center; color: var(--lab-ink); padding: 16px; }

/* 장면 꼬리표(반경 0, 바탕은 장면색, 글자는 대상색) */
#chips3d { position: absolute; left: 0; top: 0; display: flex; flex-wrap: wrap; gap: 0 2px; align-items: center; pointer-events: none; max-width: calc(100% - 96px); z-index: 3; }
.badge, .chip {
  background: var(--scene); padding: 4px 8px; font-size: 14px; color: var(--lab-ink);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.badge b { font-size: 15px; }
.chip { font-variant-numeric: tabular-nums; color: #c3cde6; }
.chip b { color: var(--lab-ink); }
.chip.eq { color: var(--par-d); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; vertical-align: middle; margin-right: 5px; font-style: normal; }
.badge .sw { margin-right: 0; }
#found { position: absolute; left: 0; bottom: 0; display: flex; flex-wrap: wrap; gap: 0 2px; pointer-events: none; max-width: calc(100% - 140px); z-index: 3; }
.fchip { font-size: 13px; padding: 3px 8px; background: var(--scene); color: #8f9bbd; white-space: nowrap; }
.fchip.on { color: var(--c); font-weight: 800; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
#read3d {
  position: absolute; left: 0; bottom: 0; background: var(--scene); padding: 5px 10px; font-size: 13px; line-height: 1.55;
  font-variant-numeric: tabular-nums; pointer-events: none; color: var(--lab-ink); z-index: 3;
}
#read3d .tot { color: #c3cde6; margin-top: 2px; padding-top: 1px; }
#read3d .qn { display: block; font-size: 12px; line-height: 1.3; color: #a9b5d4; max-width: 200px; white-space: normal; }
#read3d b { color: #fff; }
/* 장면 위 단추(어두운 바탕): 바탕은 장면색, 반경 3px, 고른 것은 칸 아래 흰 막대 */
#tog3d { position: absolute; right: 0; top: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; z-index: 4; padding: 6px; }
.tog {
  min-height: var(--tap); border-radius: var(--k-r); border: 1.5px solid #8a93ad; background: var(--scene); color: var(--lab-ink); padding: 0 12px;
  font-size: 14px; font-weight: 650; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
.tog[aria-pressed="true"] { font-weight: 800; box-shadow: inset 0 -3px 0 var(--lab-ink); }
.tog:disabled { opacity: 0.45; }
#cam3d { position: absolute; right: 0; bottom: 0; display: flex; gap: 6px; z-index: 4; padding: 6px; }
#cam3d .mini { background: var(--scene); color: var(--lab-ink); border-color: #8a93ad; }
@media (hover: hover) { #cam3d .mini:hover, .tog:hover { background: #1a2240; } }
.mini {
  width: var(--tap); height: var(--tap); border-radius: var(--k-r); border: 1.5px solid var(--k-ctl); background: var(--k-paper);
  display: grid; place-items: center; padding: 0; flex: 0 0 auto; color: var(--k-ink);
}
.mini.txt { width: auto; min-width: var(--tap); padding: 0 10px; font-size: 14px; font-weight: 650; }
.mini[aria-pressed="true"] { font-weight: 800; box-shadow: inset 0 -3px 0 var(--k-ink); }
@media (hover: hover) { #h2d .mini:hover { background: var(--k-wash); } }

#toast {
  position: absolute; left: 50%; top: 4px; transform: translate(-50%, -6px); width: max-content; max-width: min(560px, 96%);
  background: var(--k-paper); color: var(--k-ink); padding: 7px 12px; font-size: 14px; font-weight: 600; line-height: 1.4;
  text-align: center; opacity: 0; transition: opacity 0.25s, transform 0.25s; pointer-events: none; z-index: 5;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.good::before { content: "✓ "; font-weight: 800; color: var(--ok-p); }

/* ── 좌표평면(오른쪽 판, 세로 화면에서는 아래) ── */
#v2d { grid-area: panel; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--k-paper); padding: 0 14px 10px 4px; }
#h2d { display: flex; align-items: center; gap: 6px; padding: 4px 0 4px 2px; min-height: 48px; }
#eq { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 9px; font-size: 16px; white-space: nowrap; overflow: hidden; padding-block: 6px; } /* 분수 위 첨자(x²)가 잘리지 않게 위아래 여유 */
#eq .tname { font-weight: 800; font-size: 15px; flex: 0 0 auto; }
#eq .eqn, .eqn { display: inline-block; white-space: nowrap; font-variant-numeric: tabular-nums; }
.eqn b { font-weight: 400; padding: 0 5px; }
#eq .q { font-weight: 800; }
#eq.tight .tname { display: none; }
#eq.tight2 { font-size: 13px; }
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1.12; margin: 0 1px; }
.frac > span:first-child { border-bottom: 1.4px solid currentColor; padding: 0 3px 1px; }
.frac > span:last-child { padding: 1px 3px 0; }
#h2d .tools { display: flex; gap: 5px; flex: 0 0 auto; }
body.wide #bSwap { display: none; }
#gwrap { flex: 1 1 0; min-height: 0; position: relative; }
#g { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#g:focus-visible { outline: 2px solid var(--k-ink); outline-offset: -2px; }
#read2d { padding: 5px 2px 2px; font-size: 14px; line-height: 1.45; min-height: 30px; font-variant-numeric: tabular-nums; color: var(--k-ink); }
#read2d:empty { display: none; }
#read2d .dim, .dim { color: var(--k-sub); }
#read2d .ok { color: var(--ok-p); }
#read2d b { color: var(--k-ink); font-weight: 800; }

/* SVG 그래프: 흰 종이 위 잉크. 곡선·초점·접선 색은 graph.js HEX(종이용 값) */
#g .grid { stroke: #e6e6e6; stroke-width: 1; fill: none; }
#g .axis { stroke: #8a8a8a; stroke-width: 1.3; }
#g .arrow { fill: #8a8a8a; }
#g .axname { fill: var(--k-ink-2); font: italic 15px "Times New Roman", Georgia, serif; }
#g .tick { fill: var(--k-sub); font-size: 12px; font-variant-numeric: tabular-nums; }
#g .tick.o { font: italic 13px "Times New Roman", Georgia, serif; fill: var(--k-ink-2); }
#g .curve { fill: none; stroke-width: 2.8; stroke-linejoin: round; }
#g .curve-glow { display: none; }
#g .paint { fill: none; stroke: var(--k-ink); stroke-width: 4; stroke-linecap: round; opacity: 0.85; }
#g .ink { fill: none; stroke: var(--k-ink-2); stroke-width: 3.5; stroke-linecap: round; }
#g .seg { stroke: #9a9a9a; stroke-width: 1.6; }
#g .seg.minor { stroke-dasharray: 4 3; }
#g .asym { stroke: #8a8a8a; stroke-width: 1.3; stroke-dasharray: 7 5; }
#g .directrix { stroke: var(--F2-p); stroke-width: 2; stroke-dasharray: 8 5; fill: none; }
#g .box { fill: rgba(194, 37, 92, 0.06); stroke: rgba(194, 37, 92, 0.6); stroke-width: 1.2; stroke-dasharray: 3 3; }
#g .tri { stroke: var(--k-ink-2); stroke-width: 1.8; }
#g .tri-fill { fill: rgba(23, 23, 23, 0.05); stroke: #9a9a9a; stroke-width: 1.2; }
#g .tri-l { fill: var(--k-ink); font: italic 15px "Times New Roman", Georgia, serif; }
#g .dist { stroke-width: 2.6; stroke-linecap: round; }
#g .dist.f1, #g .string.f1 { stroke: var(--F-p); }
#g .dist.f2, #g .string.f2 { stroke: var(--F2-p); }
#g .string { stroke: #9a9a9a; stroke-width: 1.8; }
#g .pencil-dot { fill: var(--k-paper); }
#g .phalo { fill: rgba(23, 23, 23, 0.06); stroke: rgba(23, 23, 23, 0.35); stroke-width: 1; }
#g .pdot { fill: var(--k-paper); stroke: var(--k-ink); stroke-width: 2.5; }
#g .fdot { stroke: var(--k-paper); stroke-width: 1.5; }
#g .pin { stroke: var(--k-ink); stroke-width: 2.5; }
#g .hdot { fill: var(--F2-p); }
#g .vdot { fill: var(--k-paper); stroke-width: 2; }
#g .lbl { fill: var(--k-ink); font-size: 14px; font-weight: 700; paint-order: stroke; stroke: var(--k-paper); stroke-width: 3.5px; }
#g .lbl.it { font: italic 700 15px "Times New Roman", Georgia, serif; paint-order: stroke; stroke: var(--k-paper); stroke-width: 3.5px; }
#g .coord { fill: var(--k-ink); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; paint-order: stroke; stroke: var(--k-paper); stroke-width: 3px; }
#g .term { fill: var(--k-ink-2); font-size: 12px; font-weight: 700; paint-order: stroke; stroke: var(--k-paper); stroke-width: 3px; }
#g .tan { stroke-width: 2.2; }
#g .tan.on { stroke-width: 3.4; }
#g .tandot { stroke: var(--k-paper); stroke-width: 2; }
#g .pencil { fill: var(--k-ink-2); stroke: var(--k-ink); stroke-width: 1; }
#g .pencil-tip { fill: var(--k-ink); }

/* ── 조작판(그림 아래 종이 위) ── */
#dock { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 6px 0 10px; min-height: calc(var(--tap) + 16px); }
#dock[inert] { opacity: 0.45; }
body.starting #dock { visibility: hidden; }
.ctl { flex: 1 1 auto; min-width: 0; }
#ctlPlane { display: flex; flex-wrap: wrap; gap: 0 18px; }
#ctlPlane .row { flex: 1 1 0; }
#ctlPlane #rowTh { flex: 1.7 1 0; }
/* θ가 60° 가까이일 때 손잡이가 '60° 모선' 눈금 글자를 덮으므로 글자를 접는다(위 칩에 '모선 60°'가 있다) */
#rowTh.near60 .mark60 span { visibility: hidden; }
/* 힌트(포물선은 60.0°): 학생이 평면을 움직여 보고도 못 찾을 때 막대 아래에 그대로 남는다(사라지는 안내 대신) */
#thHint { flex: 1 1 100%; margin: 4px 0 0; font-size: 13px; line-height: 1.4; color: var(--k-ink-2); }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.lbl { font-size: 14px; color: var(--k-sub); white-space: nowrap; font-weight: 650; }
output { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 54px; white-space: nowrap; color: var(--k-ink); }
#oM { min-width: 34px; text-align: center; }
.rng { position: relative; flex: 1 1 auto; min-width: 70px; display: flex; }
.rng .k-range { flex: 1 1 auto; min-width: 60px; touch-action: none; }
.k-range.tanR { --q: var(--tan-p); }
#oN { color: var(--tan-p); }
/* 모선 60° 눈금(가는 잉크 눈금과 이름) */
.mark60 { position: absolute; left: calc(11px + (100% - 22px) * 0.73171); top: 0; bottom: 0; pointer-events: none; }
.mark60 i { position: absolute; left: -1px; top: 8px; width: 2px; height: 10px; background: var(--k-ink-2); }
.mark60 span { position: absolute; left: 0; bottom: -2px; transform: translateX(-50%); font-size: 12px; color: var(--k-sub); white-space: nowrap; line-height: 1; }
body.narrow .mark60 span, body.short .mark60 span { display: none; }
.step { width: var(--tap); min-width: var(--tap); flex: none; padding: 0; font-size: 20px; font-weight: 800; }
#ctlLine { display: flex; flex-wrap: wrap; gap: 0 14px; } /* 좁으면 n 줄을 아래로(기울기 단추를 n 값이 덮지 않게) */
#ctlLine .rowM { flex: none; }
#ctlLine .rowN { flex: 1 1 250px; }
body.tall #ctlLine { flex-direction: column; gap: 0; align-items: stretch; }
body.tall #ctlLine .rowN { flex: 0 0 auto; } /* 세로 배치에서 flex-basis 250px가 높이가 되어 n 줄이 아래로 밀려 잘리던 것을 바로잡는다 */
#ctlNote { font-size: 14px; line-height: 1.4; color: var(--k-sub); padding: 4px 2px; }
#ctlNote b { color: var(--k-ink); }
.choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.choices.answered .ch:not(.right) { display: none; }
.choices.answered { grid-template-columns: 1fr !important; }
.ch {
  min-height: 48px; border-radius: var(--k-r); border: 1.5px solid var(--k-ctl); background: var(--k-paper); color: var(--k-ink); font-size: 15px;
  display: flex; align-items: center; justify-content: center; padding: 2px 4px; white-space: nowrap; font-variant-numeric: tabular-nums;
}
@media (hover: hover) { .ch:hover:not(:disabled) { background: var(--k-wash); } }
.ch.right { border-color: var(--ok-p); color: var(--ok-p); font-weight: 800; }
.ch.wrong { border-color: var(--bad-p); color: var(--bad-p); }
.ch b, .rrow .eqn b { font-weight: 400; padding: 0 3px; }
/* 결과 보기·다음 단추 줄: 조작판 아래 한 줄(막대를 좁히지 않게). 세로 화면은 조작판 오른쪽 칸 */
#acts { flex: 1 1 100%; display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
#acts .k-btn { height: var(--tap); flex: 0 0 auto; }
/* 예전 이름의 단추(창 안): 공용 단추로 그린다 */
.primary, .ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); padding: 0 14px; border-radius: var(--k-r);
  border: 1.5px solid var(--k-ctl); background: var(--k-paper); color: var(--k-ink); font-size: 15px; font-weight: 650; white-space: nowrap;
}
.primary { background: var(--k-ink); border-color: var(--k-ink); color: var(--k-paper) !important; }
.primary:disabled, .ghost:disabled { opacity: 0.45; }
@media (hover: hover) { .ghost:not(:disabled):hover { background: var(--k-wash); } .primary:not(:disabled):hover { background: #000; } }

/* ── 시작 화면(_kit/start.js의 startSheet): 판 자리에 놓인다. 장면은 그대로 보인다 ── */
body.starting #v2d { padding: 0; }
body.starting #v2d > :not(.k-start) { display: none !important; }
#v2d > .k-start { flex: 1; min-height: 0; overflow: hidden; padding: 14px 14px 12px 8px; }
.k-start.x-tiny { gap: 4px; padding-top: 6px; padding-bottom: 4px; }
.k-start.x-tiny .k-q { font-size: 13px; line-height: 1.25; }
/* 그래도 넘치는 아주 작은 틀(320×200): 진행 지우기는 메뉴에만 두고 모드 제목과 단추를 한 줄에 */
.k-start.x-tiny .k-link, .k-start.x-tiny .k-tot { display: none; }

/* ── 창: 흰 종이, 반경 0, 그림자 없음. 몸통(.cb)이 넘치면 몸통만 스크롤하고 단추 줄은 늘 보인다 ── */
#modal { position: fixed; inset: 0; background: var(--k-dim); display: grid; place-items: center; padding: 12px; z-index: 20; }
.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: 18px 20px 16px; -webkit-user-select: text; user-select: text;
}
.card > .cb { min-height: 0; overflow: auto; }
.card > .row { flex: none; }
.card [tabindex="-1"]:focus { outline: none; }
.card h2 { margin: 0 0 8px; font-size: 21px; font-weight: 750; line-height: 1.35; }
.card h2 .snum { font-weight: 800; color: var(--k-sub); margin-right: 8px; font-variant-numeric: tabular-nums; }
.card .lead { margin: 6px 0; line-height: 1.55; font-size: 15px; }
.card .note { margin: 6px 0; color: var(--k-sub); line-height: 1.5; font-size: 13.5px; }
/* 질문(예측·확인): 가장 큰 글자. 라벨 없이 */
.pred { margin: 8px 0; }
.pq { font-size: 18px; font-weight: 750; line-height: 1.4; }
.opts { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.opt {
  display: flex; align-items: baseline; gap: 10px; min-height: 44px; border-radius: var(--k-r); border: 1.5px solid var(--k-ctl); background: var(--k-paper);
  color: var(--k-ink); padding: 8px 12px; text-align: left; font-size: 15px; font-weight: 650; line-height: 1.35;
}
.opt .num { flex: none; font-weight: 800; color: var(--k-sub); font-variant-numeric: tabular-nums; }
@media (hover: hover) { .opt:not(:disabled):hover { background: var(--k-wash); border-color: var(--k-ink); } }
.opt[aria-pressed="true"] { border-color: var(--k-ink); font-weight: 800; box-shadow: inset 0 -3px 0 var(--k-ink); }
.opt.right { border-color: var(--ok-p); color: var(--ok-p); }
.opt.wrong { border-color: var(--bad-p); color: var(--bad-p); }
.card .row { display: flex; gap: 8px 10px; margin-top: 12px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }
.card .row .k-link { margin-right: auto; }
.fb { margin: 6px 0 0; font-size: 14px; line-height: 1.5; color: var(--k-ink-2); }
.mk { font-weight: 800; }
.mk.ok { color: var(--ok-p); }
.mk.bad { color: var(--bad-p); }
/* 별(★ 얻음, ☆ 아직) */
.stars-big { font-size: 22px; margin: 2px 0 6px; color: var(--k-ink); }
.rule { display: flex; flex-direction: column; margin: 8px 0; }
.rrow { display: grid; grid-template-columns: 10px auto minmax(0, 1fr); align-items: center; column-gap: 8px; border-top: 1px solid var(--k-rule); padding: 6px 2px; font-size: 14.5px; line-height: 1.4; }
.rrow:last-child { border-bottom: 1px solid var(--k-rule); }
.rrow > .full { grid-column: 2 / 4; }
.rrow > b { min-width: 52px; }
.rrow.stack { grid-template-columns: 14px auto minmax(0, 1fr); }
.rrow.stack .eqn { white-space: nowrap; }
.rrow.stack .desc { font-size: 14px; color: var(--k-ink-2); }
@media (max-width: 520px) { .rrow.stack { grid-template-columns: 14px minmax(0, 1fr); } .rrow.stack .desc { grid-column: 2; } }
.rrow .sw { margin-right: 0; }
/* 단계 목록(메뉴): 줄로 나눈 목록, 지금 단계 = 공용 .k-on */
.mlist { display: grid; margin: 6px 0; }
.mrow {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 6px; min-height: 44px; border: 0; border-top: 1px solid var(--k-rule);
  background: none; color: var(--k-ink); padding: 4px 4px; font-size: 16px; text-align: left;
}
.mrow:last-child { border-bottom: 1px solid var(--k-rule); }
@media (hover: hover) { .mrow:not(.k-on):hover { background: var(--k-wash); } }
.mnum { color: var(--k-sub); font-weight: 700; font-variant-numeric: tabular-nums; }
.mt { font-weight: 650; }
.mstars { font-size: 14px; color: var(--k-ink); white-space: nowrap; }
.info h3 { font-size: 16px; margin: 14px 0 4px; }
.info h3:first-child { margin-top: 0; }
.info ul { margin: 0; padding-left: 18px; }
.info li, .info p { font-size: 14.5px; line-height: 1.6; margin: 4px 0; }

/* 옆 창(예측·결과): 막 없이 좌표평면 판 맨 위에 끼운다. 판이 낮으면 판을 다 쓴다 */
#v2d > .card.side { width: auto; max-height: none; flex: 0 1 auto; min-height: 0; padding: 10px 2px 12px 4px; margin-bottom: 6px; border-bottom: 1px solid var(--k-rule); }
#v2d.cardOnly > :not(.card) { display: none !important; }
#v2d.cardOnly > .card.side { flex: 1 1 auto; border-bottom: 0; margin: 0; }
#v2d.cardWide > .card.side {
  position: fixed; right: 0; top: var(--hdr); bottom: 0; width: min(58vw, 560px); z-index: 20;
  padding: 12px 16px; border-left: 1px solid var(--k-rule);
}

/* ── 세로 화면: 그림 위, 좌표평면 아래 ── */
body.tall #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--hdr) minmax(0, 1.35fr) minmax(0, 1fr); grid-template-areas: "top" "view" "panel"; }
body.tall.f2d #app { grid-template-rows: var(--hdr) minmax(0, 0.7fr) minmax(0, 1fr); }
body.tall.g2mini #app { grid-template-rows: var(--hdr) minmax(0, 1fr) auto; }
body.g2mini #gwrap { display: none; }
body.tall #view { padding: 0 10px; }
body.tall #v2d { padding: 0 10px 6px; }
body.tall #dock { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; padding: 4px 0; }
body.tall #ctlPlane { flex-direction: column; gap: 0; }
body.tall #ctlPlane .row, body.tall #ctlPlane #rowTh { flex: 0 0 auto; }
body.tall .lbl { min-width: 54px; }
body.tall output { min-width: 50px; }
body.tall #acts { grid-column: 2; grid-row: 1; align-self: center; flex-direction: column; align-items: stretch; flex: none; gap: 4px; }
body.tall #acts .k-btn { max-width: 112px; white-space: normal; line-height: 1.2; height: auto; min-height: var(--tap); padding: 4px 8px; font-size: 13.5px; }
/* 세로 화면: 단추 칸이 생기면 막대 이름('기울기 ', '높이 ')을 접어 막대와 − + 단추가 단추 칸에 눌리지 않게 */
body.tall.hasActs .lbl .lw { display: none; }
body.tall.hasActs .lbl { min-width: 0; }
body.tall.hasActs .rng { min-width: 50px; }
body.tall.hasActs output { min-width: 44px; }
body.tall .choices { grid-template-columns: 1fr 1fr; }
body.tall #h2d { min-height: 44px; padding: 2px 0; }
body.tall #read2d { padding: 2px 2px; min-height: 22px; font-size: 13px; }
/* 세로 화면 옆 창: 아래 판을 덮는다(막 없음, 장면은 그대로 보인다) */
body.tall #v2d > .card.side {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; max-height: calc(100% - var(--hdr));
  padding: 12px 14px; margin: 0; border-bottom: 0; border-top: 1px solid var(--k-rule);
}
body.tall #v2d > .card.side h2 { font-size: 17px; margin-bottom: 4px; }
body.tall #v2d > .card.side .pq { font-size: 16px; }
body.tall #v2d > .card.side .opts { gap: 6px; margin: 8px 0; }
body.tall #v2d > .card.side .opt { min-height: 40px; padding: 6px 10px; font-size: 14.5px; }
/* 시작 화면이 떠 있는 동안만 장면을 줄인다 */
body.tall.starting #app { grid-template-rows: var(--hdr) minmax(0, 1fr) minmax(0, 2.4fr); }
body.tall.starting #dock { display: none; }
body.tall #v2d > .k-start { padding: 12px 12px 8px; }
@media (max-height: 520px) { body.tall.starting #app { grid-template-rows: var(--hdr) minmax(0, 1fr) minmax(0, 2.9fr); } }
body.tall.narrow .choices:not(.answered) { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
body.tall.narrow .ch { font-size: 12.5px; min-height: 44px; padding: 0 1px; }
body.tall.narrow .ch .eqn b { padding: 0 2px; }

/* 좁은 화면 */
@media (max-width: 560px) {
  :root { --hdr: 58px; }
  #top { gap: 4px; padding: 4px 6px; }
  #goalBox .in { -webkit-line-clamp: 3; font-size: 13.5px; line-height: 1.26; }
  #goalBox.small .in { font-size: 12.5px; }
  #stepTag .tN { display: none; }
}
body.narrow .badge, body.narrow .chip { font-size: 12.5px; padding: 3px 6px; }
body.narrow .badge b { font-size: 13px; }
body.narrow #read3d { font-size: 12.5px; line-height: 1.45; padding: 3px 8px; }
body.narrow #eq { font-size: 14px; gap: 6px; }
body.narrow .tog { padding: 0 9px; font-size: 13px; }
body.narrow #tog3d { gap: 4px; top: auto; bottom: 46px; }
/* 세로 화면에서 좌표평면을 크게 볼 때(원뿔 칸이 낮다): 장면 단추는 오른쪽 아래 한 줄, 시점 단추·3D 읽기판은 접는다(같은 값은 좌표평면 아래 줄에 있다) */
body.tall.f2d #tog3d { flex-direction: row; top: auto; bottom: 0; gap: 4px; padding: 4px; }
body.tall.f2d #cam3d, body.tall.f2d #read3d { display: none; }
body.narrow #read3d { max-width: calc(100% - 134px); }
body.narrow #read3d .qn { display: none; }
body.narrow #chips3d { max-width: 100%; }
body.narrow .card { padding: 13px 14px; }
body.narrow .card h2 { font-size: 18px; }
body.narrow .pq { font-size: 16px; }
body.narrow .opt { min-height: 42px; padding: 5px 10px; font-size: 14px; }
body.narrow #toast { font-size: 13px; padding: 6px 10px; }
/* 세로 휴대폰: 원뿔 칸이 작으니 안내 상자를 작고 짧게(그림을 오래 덮지 않게) */
body.tall #toast { font-size: 13px; line-height: 1.35; padding: 5px 10px; }
body.narrow .mstars { display: none; }
/* 좁은 세로 화면의 결과 창: 별 줄과 설명 줄 간격을 줄여 한 화면에 넣는다 */
body.tall.narrow .card.side .stars-big { font-size: 18px; margin: 0 0 2px; }
body.tall.narrow .card.side .note { line-height: 1.4; margin: 4px 0; }
body.tall.narrow .card.side .fb { margin-top: 3px; }

/* 낮은 화면 (가로 휴대폰, 작은 데스크톱 틀) */
body.short { --hdr: 46px; }
body.short #top { padding: 2px 6px 2px 4px; gap: 4px; }
body.short #goalBox .in { font-size: 13px; line-height: 1.24; }
body.short #stars { font-size: 15px; }
body.short #h2d { min-height: 40px; padding: 0; }
body.short #read3d .qn { display: none; }
body.short #read2d { padding: 2px 2px; min-height: 22px; font-size: 12.5px; }
body.short #dock { min-height: calc(var(--tap) + 8px); padding: 4px 0; }
body.short .card { padding: 10px 14px; }
body.short .card h2 { font-size: 16px; margin-bottom: 4px; }
body.short .card .lead { font-size: 13px; margin: 3px 0; line-height: 1.45; }
body.short .pq { font-size: 15px; }
body.short .opts { gap: 4px; margin: 5px 0; }
body.short .opt { min-height: 36px; padding: 3px 10px; font-size: 13px; }
body.short .card .row { margin-top: 6px; }
body.short .stars-big { font-size: 18px; }
body.short .rrow { padding: 3px 2px; font-size: 13px; }
body.short #view { padding: 0 8px; }
body.short #toast { font-size: 12.5px; padding: 4px 10px; }
body.tiny #goalBox .in { font-size: 12.5px; line-height: 1.25; }
body.wide.short #v2d.cardOnly > .card.side {
  position: fixed; right: 0; top: var(--hdr); bottom: 0; width: min(72vw, 600px); z-index: 20;
  padding: 8px 12px; border-left: 1px solid var(--k-rule);
}
body.wide.short.starting { --pw: 58%; }

/* 썸네일 찍기용 (검증 창구에서만 켠다) */
body.thumbmode #top, body.thumbmode #dock, body.thumbmode #v2d, body.thumbmode #modal { display: none !important; }
body.thumbmode #chips3d, body.thumbmode #found, body.thumbmode #read3d, body.thumbmode #tog3d, body.thumbmode #cam3d, body.thumbmode #toast { visibility: hidden; }
body.thumbmode #app { grid-template-columns: 1fr; grid-template-rows: 1fr; grid-template-areas: "view"; }
body.thumbmode #view { padding: 0; }

/* 세로로 짧은 화면의 창 */
@media (max-height: 520px) {
  .card.final h2 { font-size: 16px; margin-bottom: 2px; }
  .card.final .pq { font-size: 15px; }
}
@media (max-height: 540px) {
  .card { padding: 12px 14px; }
  .card h2 { font-size: 17px; margin-bottom: 4px; }
  .card .lead { font-size: 13.5px; line-height: 1.45; margin: 4px 0; }
  .pq { font-size: 15.5px; }
  .opts { gap: 5px; margin: 6px 0; }
  .opt { min-height: 40px; padding: 4px 10px; }
  .card .row { margin-top: 8px; }
  .rrow { padding: 4px 2px; font-size: 13px; }
  .mrow { min-height: 40px; }
}
@media (max-height: 340px) {
  .opts { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
  .opt { min-height: 36px; padding: 3px 8px; font-size: 13px; }
  .mlist { grid-template-columns: 1fr 1fr; column-gap: 12px; }
  .mrow { min-height: 36px; font-size: 14px; }
  .mlist .mrow:nth-last-child(-n+2) { border-bottom: 1px solid var(--k-rule); }
  .card .pq { font-size: 14px; }
  .fb { font-size: 12.5px; line-height: 1.4; margin-top: 4px; }
  .card .note { font-size: 12.5px; margin: 4px 0; }
  .rule { margin: 5px 0; }
}
/* 아주 낮은 가로 화면(750×280 등)의 창: 몸통이 넘치지 않게 촘촘하게 */
@media (max-height: 300px) {
  .card.side .stars-big { display: none; } /* 별은 위 막대에도 있다 */
  .card.side h2 { font-size: 15px; margin-bottom: 2px; }
  .rrow { padding: 1px 2px; font-size: 12.5px; }
  .rrow .eqn { font-size: 13px; }
  .rrow .frac { line-height: 1; }
  .card .note, .card .fb { font-size: 12.5px; line-height: 1.35; margin: 3px 0; }
  .card.final .pq { font-size: 14px; margin: 2px 0; }
  .card .lead { font-size: 12.5px; line-height: 1.4; margin: 3px 0; }
  body.wide.short #v2d.cardOnly > .card.side { width: min(88vw, 660px); } /* 줄 수를 줄여 몸통이 넘치지 않게 */
}
@media (max-width: 360px) and (max-height: 300px) {
  body:not(.tall) #app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "view"; grid-template-rows: var(--hdr) minmax(0, 1fr); }
  body:not(.tall) #v2d { display: none; }
  body.starting #v2d { display: flex; grid-area: view; }
  body.starting #view { display: none; }
  /* 좌표평면 판이 없는 아주 작은 틀: 옆 창(예측·결과)은 위 막대 아래를 덮는다(막 없음, 창 안 스크롤 허용) */
  body.sidecard:not(.tall) #v2d { display: flex; position: fixed; left: 0; right: 0; top: var(--hdr); bottom: 0; z-index: 20; padding: 0; }
  body.sidecard:not(.tall) #v2d > :not(.card) { display: none !important; }
  body.sidecard:not(.tall) #v2d > .card.side { position: static; width: auto; flex: 1 1 auto; margin: 0; padding: 8px 12px; border: 0; border-top: 1px solid var(--k-rule); }
  /* 좌표평면이 주인 장면(실과 핀·방정식·접선): 원뿔 대신 좌표평면을 보이고 조작판은 그 아래 */
  body.f2d:not(.tall):not(.starting) #app { grid-template-areas: "top" "panel" "view"; grid-template-rows: var(--hdr) minmax(0, 1fr) auto; }
  body.f2d:not(.tall):not(.starting) #v2d { display: flex; padding: 0 10px; }
  body.f2d:not(.tall):not(.starting) #v3d { display: none; }
  body.f2d:not(.tall):not(.starting) #h2d { min-height: 0; padding: 0; }
  body.f2d:not(.tall):not(.starting) #h2d .tools, body.f2d:not(.tall):not(.starting) #read2d { display: none; }
  body.f2d:not(.tall):not(.starting) #eq { font-size: 13px; }
  #stars { display: none; } /* 별은 결과 창·메뉴에 있다 */
}
/* 아주 작은 틀(320×200 등): 조작판의 두 막대를 이름 없이 한 줄에, 장면 단추는 위쪽 가로 줄, 식 고르기는 작은 글자 */
@media (max-height: 300px) and (max-width: 480px) {
  :root body { --hdr: 54px; }
  #goalBox .in, body.tiny #goalBox .in { font-size: 12px; line-height: 1.2; -webkit-line-clamp: 3; }
  .lbl .lw { display: none; }
  output { min-width: 34px; font-size: 15px; }
  #ctlPlane { gap: 10px; }
  .rng, .rng .k-range { min-width: 50px; }
  .row { gap: 5px; }
  #cmpChip { display: none; }
  body #tog3d { flex-direction: row; top: 0; bottom: auto; gap: 4px; padding: 4px; }
  .tog { padding: 0 8px; font-size: 13px; }
  .ch { font-size: 12px; padding: 0; min-height: 40px; }
  .ch b { padding: 0 1px; }
  .ch .frac > span { padding-left: 1px; padding-right: 1px; }
  .choices { gap: 3px; }
}
@media (prefers-reduced-motion: reduce) {
  #toast, #prog i { transition: none; }
}
/* 한 단계에 한 가지: 1단계(θ와 60° 비교)는 방정식·a b c·용어·좌표축 돌리기를 숨기고 단면 그림만 둔다 */
body.lean1 #h2d, body.lean1 #read2d { display: none; }
/* 1단계 예측 중: 답을 말하는 비교 칩과 60° 눈금을 감춘다 */
body.hide60 #cmpChip, body.hide60 .mark60 { visibility: hidden; }
