/* 포식자와 피식자: 한 화면에 질문, 그래프(왼쪽·위), 단계 판(오른쪽·아래).
   디자인은 studio/DESIGN.md '종이 위 그림'(2026-10-17). 공용 토큰(--k-*)과 부품(.k-seg, .k-on, .k-w, .k-range)은
   paper.css에서 온다(build.sh가 _kit에서 dist로 복사). 이 파일에는 배치와 크기, 대상의 색만 적는다.
   - 틀은 흰 종이와 잉크. 단추는 잉크 칠(주 동작: 실행, '② 사건에서 확인하기') 또는 회색 테두리, 반경 3px. 판·그래프·창은 각지다.
   - 색은 그래프 속 대상에만: 토끼 파랑, 여우 주황(py/plotting.py의 PREY·PRED와 같은 값). 글 속 범례 낱말(.k-w)도 같은 색 */
:root {
  --prey: #2563eb;                      /* 토끼(피식자) N */
  --pred: #c2410c;                      /* 여우(포식자) P */
  --remove: rgba(194, 65, 12, 0.2);     /* 여우를 없앤 기간(그래프의 띠와 같은 색) */
  --drought: rgba(161, 98, 7, 0.24);    /* 가뭄 기간 */
  --btn-h: 40px;                        /* 누르는 것: 40px, 낮은 화면(560px 이하) 36px */
  --qfs: 19px;                          /* 탐구 질문: 화면에서 가장 큰 글자 */
}
@media (max-height: 560px) { :root { --btn-h: 36px; } }
* { box-sizing: border-box; }
/* 한 화면: 문서는 스크롤하지 않고, 그래프가 남는 높이를 채운다 */
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  display: flex; flex-direction: column; background: var(--k-paper); color: var(--k-ink); font-family: var(--k-font); font-size: 14px; line-height: 1.45;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
}
/* 줄바꿈: 한국어는 어절, 영어는 단어(하이픈 없이), 일본어는 구절 단위와 금칙. 화면보다 긴 낱말만 끊는다 */
html { overflow-wrap: break-word; hyphens: none; -webkit-hyphens: none; }
html:lang(ko) { word-break: keep-all; }
html:lang(ja) { word-break: auto-phrase; line-break: strict; }
/* 사파리(auto-phrase 없음): wrap.js가 넣은 U+200B(구절 경계)와 빈칸에서만 줄을 바꾼다 */
@supports not (word-break: auto-phrase) { html:lang(ja) { word-break: keep-all; } }
button, input, textarea { font: inherit; color: inherit; }
.nw { white-space: nowrap; }
.w-prey { --w: var(--prey); }
.w-pred { --w: var(--pred); }
.mine { font-weight: 700; }
.mk { font-weight: 800; color: var(--k-ink); }

/* ── 단추: 보조는 회색 테두리, 주 동작은 잉크 칠 ── */
.b {
  min-height: var(--btn-h); padding: 4px 12px; border: 1.5px solid var(--k-ctl); border-radius: var(--k-r);
  background: var(--k-paper); color: var(--k-ink); font-size: 14px; font-weight: 650; line-height: 1.25; cursor: pointer; touch-action: manipulation;
}
@media (hover: hover) { .b:not(:disabled):not(.k-on):not(.primary):hover { background: var(--k-wash); } }
.b:disabled { opacity: 0.45; cursor: default; }
.b.primary { background: var(--k-ink); border-color: var(--k-ink); color: var(--k-paper); font-weight: 700; }
@media (hover: hover) { .b.primary:not(:disabled):hover { background: #000; } }
.b:focus-visible, textarea:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--k-ink); outline-offset: 2px; }
.ico { width: 14px; height: 14px; flex: none; }

/* ── 머리: 탐구 질문 (라벨·상자 없이 가장 큰 글자) ── */
.top { flex: none; padding: 10px 14px 8px; }
.question { margin: 0; font-size: var(--qfs); font-weight: 750; line-height: 1.32; }

/* ── 틀: 왼쪽 그래프 + 오른쪽 단계 판 ── */
.grid {
  flex: 1; min-height: 0; display: grid; gap: 10px 16px; padding: 0 14px 10px;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 37%); grid-template-rows: minmax(0, 1fr);
}
.plots { position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 0; container: plots / inline-size; }
.panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 8px; }

/* 그래프 보기 (시간 그래프, 상평면, 피라미드) + ⓘ 그래프 읽는 법 */
.gbar { flex: none; display: flex; gap: 8px; }
.ctabs { flex: 1; min-width: 0; display: flex; }
.ctabs > button, .steps > button { flex: 1 1 0; min-width: 0; min-height: var(--btn-h); padding: 2px 4px; font-size: 14px; line-height: 1.15; }
.ctabs > button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.ctabs .ico { width: 20px; height: 16px; display: none; }
.ibtn { flex: none; width: var(--btn-h); padding: 0; font-size: 18px; font-weight: 700; }
.legend { flex: none; display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 13px; color: var(--k-ink-2); }
.legend .lg { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend .S, .eq .S { display: none; }
.legend i { display: inline-block; width: 18px; height: 0; border-top: 3px solid; }
.legend i.dot { border-top: 2px dotted var(--k-sub); }
.legend i.dash { border-top: 2px dashed var(--k-ctl); }
.legend i.band { height: 11px; border: 0; width: 14px; }

.charts { flex: 1; min-height: 70px; display: flex; flex-direction: column; gap: 8px; }
.fig { flex: 1 1 0; min-height: 0; margin: 0; background: var(--k-paper); border: 1px solid var(--k-rule); padding: 4px 4px 3px; display: flex; flex-direction: column; }
.imgbox { position: relative; flex: 1; min-height: 0; width: 100%; }
.imgbox img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.imgbox img:not([src]) { visibility: hidden; }
/* 시간에 맞춰 선을 얹는 캔버스(app.js drawTime·drawPhase): 눌리지 않고 그림 위에만 */
.ov { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
figcaption { flex: none; font-size: 13px; color: var(--k-sub); padding: 1px 6px 0; line-height: 1.3; }
/* 한 번에 하나 (넓고 높은 화면이 아닐 때). 범례는 시간 그래프의 것이므로 상평면·피라미드에서는 감춘다 (상평면은 아래 설명 줄이 범례) */
@media not all and (min-width: 1000px) and (min-height: 700px) {
  .plots[data-view="time"] .fig-phase, .plots[data-view="time"] .pyramid,
  .plots[data-view="phase"] .fig-time, .plots[data-view="phase"] .pyramid,
  .plots[data-view="pyr"] .fig-time, .plots[data-view="pyr"] .fig-phase,
  .plots:not([data-view="time"]) .legend { display: none; }
}
/* 넓고 높은 화면: 시간 그래프 위, 상평면·피라미드 아래 (셋을 함께) */
@media (min-width: 1000px) and (min-height: 700px) {
  /* 그래프 보기 단추는 감추고 ⓘ(그래프 읽는 법)만 범례 줄 오른쪽 끝에 둔다 */
  .ctabs { display: none; }
  .gbar { position: absolute; top: 0; right: 0; z-index: 2; }
  .legend { min-height: var(--btn-h); align-content: center; padding-right: calc(var(--btn-h) + 8px); }
  .charts { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1.25fr) minmax(0, 1fr); }
  .fig-time { grid-column: 1 / -1; }
}

/* 피라미드: 각진 막대, 너비 = 개체 수 */
.pyramid { justify-content: center; padding: 8px 10px; font-size: 13px; }
.pyramid .h { font-size: 13px; color: var(--k-sub); margin-bottom: 8px; text-align: center; }
.pyr { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pyr div { height: 26px; color: #fff; font-size: 13px; font-weight: 650; display: flex; align-items: center; justify-content: center; white-space: nowrap; min-width: 56px; padding: 0 6px; font-variant-numeric: tabular-nums; }
.pyr .p2 { background: var(--pred); }
.pyr .p1 { background: var(--prey); }
.pyr .p0 { background: var(--k-paper); color: #15803d; border: 1.5px dashed #15803d; white-space: normal; height: auto; min-height: 26px; text-align: center; }

/* 시간 막대: 재생·멈춤(주 단추), 시각 막대, 읽음값, 빠르기(×1·×2·×4), 1초에 몇 년 */
.tbar { flex: none; display: flex; align-items: center; gap: 8px; }
.tbar .tplay { flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 2px 12px; }
.tplay .i-pause, .tplay[data-playing="1"] .i-play { display: none; }
.tplay[data-playing="1"] .i-pause { display: block; }
/* 두 낱말을 한 칸에 겹쳐 두고 하나만 보인다: 눌러도 단추 폭이 변하지 않는다 */
.tplay .tl { display: inline-grid; }
.tplay .tl > span { grid-area: 1 / 1; }
.tplay .tl-b, .tplay[data-playing="1"] .tl-a { visibility: hidden; }
.tplay[data-playing="1"] .tl-b { visibility: visible; }
.tbar .k-range { flex: 1 1 60px; min-width: 40px; width: auto; }
.tbar .tout { flex: none; min-width: 3.4em; text-align: right; font-size: 14px; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbar .tspeed { flex: none; min-width: 46px; padding: 2px 8px; font-variant-numeric: tabular-nums; }
.tbar .tratio { flex: none; font-size: 12.5px; color: var(--k-sub); white-space: nowrap; }

/* 늘 보이는 값: 평형점, 지금 시각의 개체 수 (상자 없이 한 줄) */
.eq { flex: none; display: flex; flex-wrap: wrap; gap: 1px 16px; align-items: baseline; font-size: 14px; line-height: 1.4; }
.eq b, .eq2 b { font-variant-numeric: tabular-nums; }
.eq .warn, .eq2 .warn { color: #b91c1c; font-weight: 700; }
.eq:empty { display: none; }

/* 좁은 그래프 칸: 짧은 범례·평형값 문장, 사건 띠 범례는 켠 사건만 */
@container plots (max-width: 460px) {
  .tbar { gap: 6px; }
  .tbar .tratio { display: none; }
  .tbar .tplay { padding: 2px 10px; }
  .legend .L, .eq .L { display: none; }
  .legend .S, .eq .S { display: inline; }
  .legend { gap: 2px 10px; }
  .legend .lg-band { display: none; }
  .on-remove .legend .lg-remove, .on-drought .legend .lg-drought { display: inline-flex; }
  body[data-step="events"] .legend .lg-band, body.c-band .legend .lg-band { display: none; } /* ② 단계에서는 사건 단추의 색 칸이 띠의 범례다 */
  .eq { gap: 1px 12px; }
}

/* 접기 (fit()): 평형값 줄, 시간 그래프 축 설명, ① 단계의 그래프 보기 단추 */
.c-eq .eq { display: none; }
.c-cap .fig-time figcaption { display: none; }
/* 그래프 보기 단추를 접어도 ⓘ(그래프 읽는 법)는 남긴다: 범례 줄 오른쪽 끝으로 */
.c-ctabs .ctabs { display: none; }
.c-ctabs .gbar { position: absolute; top: 0; right: 0; z-index: 2; }
.c-ctabs .legend { min-height: var(--btn-h); align-content: center; padding-right: calc(var(--btn-h) + 8px); }
.c-ctabs.c-legend .legend { display: flex; visibility: hidden; }
.c-legend .legend { display: none; }
/* 범례까지 접어 ⓘ만 남은 빈 줄에는 시간 막대를 올린다(휴대폰: 그래프가 그만큼 커진다) */
.c-ctabs.c-legend .tbar { position: absolute; top: 0; left: 0; right: calc(var(--btn-h) + 8px); z-index: 2; height: var(--btn-h); }
.c-pq.picked #predict-q { display: none; }
.card p.know { color: var(--k-ink-2); font-size: 13px; line-height: 1.45; }
.c-know .know { display: none; }
/* 닫힌 '그래프 코드'의 내용은 그리지 않는다 */
.plotsrc:not([open]) > :not(summary) { display: none; }

/* ── 불러오기: 그래프 자리를 덮는 흰 종이 ── */
.loading { position: absolute; inset: 0; z-index: 5; background: var(--k-paper); display: flex; align-items: flex-start; justify-content: center; padding: 12px 8px; overflow: hidden; }
.lcard { width: min(520px, 100%); padding: 4px 2px; }
.lstage { font-weight: 750; font-size: 15px; }
.bar { height: 6px; background: var(--k-rule); overflow: hidden; margin: 10px 0 6px; }
.bar > div { height: 100%; width: 2%; background: var(--k-ink); }
.lsize { font-size: 13px; color: var(--k-sub); font-variant-numeric: tabular-nums; }
.think { margin-top: 14px; font-size: 14px; line-height: 1.5; }
.think ol { margin: 4px 0 0; padding-left: 20px; }
.loading.failed .bar > div { background: #b91c1c; }

/* ── 단계 판 ── */
.steps { flex: none; display: flex; }
.steps > button { font-size: 13px; padding: 2px 3px; }
.card { min-height: 0; }
.card .h { font-weight: 750; font-size: 14.5px; margin-bottom: 4px; }
.card p { margin: 0 0 8px; font-size: 14px; line-height: 1.45; }
.card p.prompt { font-size: 15px; font-weight: 700; }
.choices { display: flex; flex-direction: column; gap: 6px; }
.choices .ch { text-align: left; font-weight: 600; padding: 4px 10px; }
.pnext { margin-top: 8px; }
.events { display: flex; flex-direction: column; gap: 8px; }
.ev { display: flex; align-items: center; gap: 8px; text-align: left; padding: 4px 10px; font-weight: 650; }
/* 사건 단추 앞 네모 = 그래프 띠의 색(범례). 켠 상태는 공용 .k-on(굵은 글자 + 칸 아래 막대) */
.ev .sw { width: 16px; height: 16px; flex: none; border: 1px solid var(--k-ctl); }
.sw-remove { background: var(--remove); }
.sw-drought { background: var(--drought); }
.feedback { margin: 10px 0 0 !important; font-size: 14px; line-height: 1.5; }
.hint { color: var(--k-sub); margin: 10px 0 0 !important; font-size: 13px !important; }
.sliders { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px 14px; }
/* ③ 판 아래: (평형값 줄을 접었을 때) 짧은 평형값 + 처음 값으로 */
.slfoot { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.slfoot .b { flex: none; }
.eq2 { display: none; flex: 1; min-width: 0; font-size: 13px; line-height: 1.4; }
.eq2 .eqv, .eq2 .warn { display: block; }
.c-eq .eq2 { display: block; }
.sl label { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.sl label b { font-variant-numeric: tabular-nums; font-weight: 750; }
.sl .k-range { margin: -6px 0 -4px; }
.b.small { font-size: 13.5px; }
.formula { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px !important; border-left: 0; padding: 0; }
.note { color: var(--k-ink-2); font-size: 13.5px !important; margin-bottom: 0 !important; }
/* 모형 설명을 ⓘ 창으로 (fit() → c-note) */
#model-more { display: none; align-items: center; gap: 6px; }
.c-note #model-note { display: none; }
.c-note #model-more { display: inline-flex; }

/* 파이썬 코드: 코드 칸만 안에서 스크롤 (실행·처음 코드로·오류 줄은 늘 보인다) */
.card.code { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.card.code[hidden] { display: none; }
.codehint { flex: none; font-size: 13px !important; color: var(--k-sub); margin: 0 0 6px; line-height: 1.4; }
.codehint .hs { display: none; }
.c-hint .codehint .hl { display: none; }
.c-hint .codehint .hs { display: inline; }
textarea#code {
  flex: 1 1 auto; min-height: 90px; width: 100%; resize: none; border: 1.5px solid var(--k-ctl); border-radius: 0; padding: 6px 8px;
  font: 13px/1.45 ui-monospace, "SF Mono", Menlo, Consolas, "D2Coding", monospace; color: var(--k-ink); background: var(--k-paper);
  tab-size: 4; white-space: pre; overflow: auto;
}
.codebar { flex: none; display: flex; align-items: center; gap: 6px 8px; margin: 8px 0; flex-wrap: wrap; }
/* 실행 단추 아래 줄: 계산 중… / 걸린 시간 (단추 폭을 고정해 줄이 바뀌어도 배치가 흔들리지 않는다) */
#run { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 84px; line-height: 1.15; padding: 2px 12px; }
#run .runl { display: inline-flex; align-items: center; gap: 6px; }
#run .runinfo { font-size: 12px; font-weight: 500; white-space: nowrap; }
#run .runinfo:empty { display: none; }
.c-code textarea#code { height: 86px; }
.output { flex: none; margin: 0; font: 13px/1.38 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--k-ink); border-top: 1px solid var(--k-rule); padding: 5px 2px; min-height: 2em; max-height: 6.4em; overflow: auto; white-space: pre-wrap; }
.output:empty { display: none; }
.output.err { color: #b91c1c; font-weight: 650; }
/* '그래프 코드': 실행 줄 안의 작은 단추. 펼치면 가운데 창(안에서 스크롤, 뒤는 어둡게만) */
.plotsrc { flex: none; font-size: 13px; }
.plotsrc summary {
  cursor: pointer; list-style: none; min-height: var(--btn-h); display: flex; align-items: center; gap: 6px;
  border: 1.5px solid var(--k-ctl); border-radius: var(--k-r); background: var(--k-paper); padding: 0 10px; font-size: 13.5px; font-weight: 650;
}
.plotsrc summary::-webkit-details-marker { display: none; }
.plotsrc .ps-l, .plotsrc[open] .ps-s { display: none; }
.plotsrc[open] .ps-l { display: inline; }
.plotsrc[open] { position: fixed; inset: 10px; z-index: 9; background: var(--k-paper); padding: 0 12px 12px; display: flex; flex-direction: column; box-shadow: 0 0 0 100vmax var(--k-dim); }
.plotsrc[open] summary { border: 0; padding: 0; font-weight: 800; font-size: 15px; justify-content: space-between; }
.plotsrc[open] summary::after { content: "✕"; margin-left: auto; width: var(--btn-h); height: var(--btn-h); display: inline-flex; align-items: center; justify-content: center; border: 1.5px solid var(--k-ctl); border-radius: var(--k-r); font-size: 16px; }
/* 펼친 내용은 ::details-content 안이라 flex 칸이 되지 않는다: 코드 칸 높이를 창 높이에서 직접 정한다. 읽기 전용 글 칸(코드는 글 마디가 아니라 줄바꿈 검사 대상이 아니다) */
.plotsrc textarea { display: block; width: 100%; margin: 0; height: calc(100vh - 150px); height: calc(100dvh - 150px); min-height: 60px; resize: none;
  font: 12.5px/1.45 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--k-ink); background: var(--k-paper); border: 1px solid var(--k-rule); padding: 6px; overflow: auto; white-space: pre; }
.plotsrc[open] { overflow: auto; overscroll-behavior: contain; }
.credits { flex: none; font-size: 12.5px !important; color: var(--k-sub); margin: 8px 0 0 !important; line-height: 1.4; }

/* ── ⓘ 창 (그래프 읽는 법, 모형 설명): 흰 종이, 반경 0, 그림자 없음. 뒤는 어둡게만 ── */
.sheet { position: fixed; inset: 0; z-index: 10; background: var(--k-dim); display: flex; align-items: center; justify-content: center; padding: 10px; }
.sheet-card { width: min(560px, 100%); max-height: 100%; display: flex; flex-direction: column; background: var(--k-paper); }
.sheet-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 12px 6px 16px; border-bottom: 1px solid var(--k-rule); font-size: 15px; }
.sheet-head b { font-weight: 800; }
.sheet-x { margin-left: auto; }
.sheet-body { overflow: auto; overscroll-behavior: contain; padding: 6px 16px 14px; font-size: 14px; line-height: 1.55; }
.sheet-body h3 { font-size: 14.5px; font-weight: 800; margin: 12px 0 2px; }
.sheet-body p { margin: 0 0 6px; }
.sheet-body .legend { gap: 4px 12px; margin: 4px 0 2px; }

/* ── 낮은 가로 화면 (사이트 데스크톱 틀 ≈ 830×466, 휴대폰 가로) ── */
@media (min-width: 560px) and (max-height: 560px) {
  .events { flex-direction: row; }
  .events .ev { flex: 1 1 0; min-width: 0; padding: 4px 8px; font-size: 13px; }
  .feedback { font-size: 13.5px !important; line-height: 1.42 !important; }
  .top { padding: 8px 12px 6px; }
  .question { font-size: 16px; }
  .choices { gap: 5px; }
  .note { line-height: 1.4; }
}
/* 아주 낮은 가로 화면 (휴대폰 가로 전체화면 ≈ 750×280): 그래프 왼쪽, 단계 판 오른쪽 그대로, 여백을 줄인다 */
@media (min-width: 560px) and (max-height: 420px) {
  .grid { grid-template-columns: minmax(0, 1fr) minmax(300px, 46%); gap: 6px 12px; padding: 0 12px 6px; }
  .top { padding: 5px 12px 4px; }
  .question { font-size: 14.5px; line-height: 1.3; }
  .gbar { gap: 6px; }
  .ctabs > button, .steps > button { font-size: 12.5px; }
  .panel { gap: 5px; }
  .card p { margin-bottom: 5px; font-size: 13px; }
  .card p.prompt { font-size: 13.5px; }
  .choices { gap: 4px; }
  .choices .ch { font-size: 13px; line-height: 1.2; padding: 2px 8px; }
  .pnext { margin-top: 5px; }
  .feedback { margin-top: 6px !important; line-height: 1.36 !important; font-size: 13px !important; }
  .sliders { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sl label { font-size: 13px; }
  .codehint { margin-bottom: 4px; }
  .codebar { margin: 4px 0; }
  textarea#code { min-height: 72px; }
  .output { font-size: 12px; }
  /* 코드 안내까지 접으면(c-hint) 이 높이에서는 안내 줄을 통째로 감춘다 (코드 위쪽 주석과 실행 단추가 대신한다) */
  .c-hint .codehint { display: none; }
  .legend { font-size: 12px; }
  .eq { font-size: 13px; }
}

/* ── 휴대폰 세로 (가로 559px 이하이거나 세로로 긴 760px 미만 화면): 그래프 위, 단계 판 아래.
   판은 내용 높이, 그래프가 남는 높이를 채운다. 그래도 모자라면 fit()이 접는다 ── */
@media (max-width: 759px) and (orientation: portrait), (max-width: 559px) {
  .grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 8px; padding: 0 10px 8px; }
  .top { padding: 8px 10px 6px; }
  .question { font-size: 16px; }
  .ctabs > button { font-size: 13px; }
  .legend { gap: 1px 10px; }
  .charts { min-height: 60px; }
  .events { flex-direction: row; }
  .events .ev { flex: 1 1 0; min-width: 0; padding: 4px 8px; font-size: 13px; }
  .feedback { font-size: 13.5px !important; line-height: 1.4 !important; margin-top: 8px !important; }
  .hint { margin-top: 8px !important; }
  .sliders { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card.code { flex: none; }
  textarea#code { height: 128px; flex: none; }
  .codehint { font-size: 12.5px !important; margin-bottom: 4px; }
  .codebar { margin: 4px 0; }
  .output { font-size: 12px; }
  /* 모형·코드 단계는 그래프 보기 단추·범례를 감춰 판과 그래프가 함께 들어오게 한다 */
  body[data-step="model"] .gbar, body[data-step="model"] .legend,
  body[data-step="code"] .gbar, body[data-step="code"] .legend { display: none; }
}
/* 휴대폰 세로, 높이 700px 미만 (사파리 임베드 틀 341×470 ~ 390×604): 여백을 줄여 그래프 몫을 늘린다 */
@media (max-width: 759px) and (orientation: portrait) and (max-height: 699px), (max-width: 559px) and (max-height: 699px) {
  .top { padding: 6px 10px 5px; }
  .question { font-size: 15.5px; line-height: 1.3; }
  .grid { gap: 6px; padding: 0 10px 6px; }
  .panel { gap: 6px; }
  .steps > button { font-size: 12.5px; padding: 2px 2px; }
  .card p { margin-bottom: 5px; font-size: 13.5px; }
  .card p.prompt { font-size: 14px; }
  .choices { gap: 4px; }
  .choices .ch { font-size: 13.5px; line-height: 1.25; }
  .pnext { margin-top: 5px; }
  .sliders { gap: 0 12px; }
  .slfoot { margin-top: 4px; }
  textarea#code { height: 104px; }
}

/* ── 아주 작은 창(320×200 등): 그래프 왼쪽, 단계 판 오른쪽. 탐구 질문·범례·평형값 줄은 접고(ⓘ 창에 있다), 단계 판만 안에서 스크롤한다(브리프 예외) ── */
@media (max-width: 420px) and (max-height: 240px) and (orientation: landscape) {
  .top, .legend, .eq { display: none !important; }
  .tbar .k-range, .tbar .tratio { display: none; }
  .eq2 { display: block; flex: 1 1 100%; }   /* 평형값·경고는 ③ 판 안의 짧은 문장으로, 한 줄을 다 쓴다 */
  .slfoot { flex-wrap: wrap; }
  .grid { grid-template-rows: minmax(0, 1fr) !important; gap: 6px; padding: 6px 8px; }
  .grid { grid-template-columns: minmax(0, 52fr) minmax(0, 48fr) !important; }
  .gbar { gap: 4px; }
  .ctabs > button { padding: 0; }
  .ctabs .ico { display: block; }
  .ctabs .lb { display: none; }
  .ibtn { width: 36px; }
  .pyramid { padding: 2px 4px; }
  .pyramid .h { display: none; }
  .pyr div { height: 22px; }
  .pyr .p0 { min-height: 22px; font-size: 12px; line-height: 1.2; }
  .panel { overflow: auto; overscroll-behavior: contain; gap: 6px; }
  .steps { flex-wrap: wrap; }
  .steps > button { flex: 1 1 30%; font-size: 12px; }
  .card p { font-size: 13px; }
  .card p.prompt { font-size: 13.5px; }
  .choices .ch { font-size: 13px; }
  .events { flex-direction: column; }
  .events .ev { flex: none; }   /* 판이 안에서 스크롤하므로 줄이지 않는다: 일본어 사건 단추가 세 줄로 접혀 다음 단추 밑으로 넘쳤다(2026-10-22) */
  .panel > .card { flex-shrink: 0; }
  .sliders { grid-template-columns: minmax(0, 1fr); }
  .card.code { flex: none; }
  textarea#code { height: 110px; flex: none; }
}
