/* 기체의 압력과 부피: 화면 배치와 GlowScript 위젯(단추·슬라이더·그래프) 모양.
   디자인은 studio/DESIGN.md '종이 위 그림'(2026-10-17)을 따른다. 공용 토큰(--k-*)과 부품은 paper.css에서 온다
   (build.sh가 _kit/paper.css를 dist/paper.css로 고치지 않고 복사하고, index.html이 이 파일보다 먼저 부른다).
   - 틀은 흰 종이와 잉크. 단추는 잉크 칠(주 동작 '측정점 찍기') 또는 회색 테두리. 색은 장면 속 대상과 물리량에만 쓴다.
   - 고른 상태(탭·예측·판 고르기)는 공용 .k-on·.k-seg: 굵은 글자 + 칸 아래 3px 막대. sim.py의 paint()는 aria-pressed·aria-selected만 바꾼다.
   - GlowScript 단추는 글자색·바탕을 style 속성으로 박아 넣으므로 여기서 !important로 덮는다.
   - 반경은 단추·세그먼트 3px(--k-r)만. 판·그래프·표·창·꼬리표는 0, 슬라이더 손잡이만 원.
   배치 모드(body.wide / body.narrow)와 캔버스·그래프 크기는 sim.py의 layout()이 정한다. */
:root {
  /* 장면 속 대상의 색: sim.py의 SLOW_COL·FAST_COL·PRES_COL·VOL_COL과 같은 값 */
  --c-slow: #2563eb;  /* 느린 입자 */
  --c-fast: #dc2626;  /* 빠른 입자, 온도 */
  --c-pres: #c7299a;  /* 압력 (압력계 바늘) */
  --c-vol: #0f766e;   /* 부피 */
  --btn-h: 40px;      /* 누르는 것의 높이: 40px, 낮은 화면(560px 이하) 36px (DESIGN.md '크기') */
}
@media (max-height: 560px) { :root { --btn-h: 36px; } }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
/* 줄바꿈은 낱말 경계에서만: 한국어는 어절, 영어는 단어(하이픈 분철 없음), 일본어는 구절(크롬)과 금칙.
   사파리(auto-phrase 없음)는 wrap.js가 넣은 U+200B(구절 경계)와 빈칸에서만 줄을 바꾼다 */
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; }
@supports not (word-break: auto-phrase) { html:lang(ja) { word-break: keep-all; } }
/* 그래프(Flot) 눈금 숫자는 칸이 좁아도 줄을 바꾸지 않는다("20 / 0"이 되지 않게) */
.tickLabel { overflow-wrap: normal; color: var(--k-sub) !important; }
body {
  background: var(--k-paper);
  color: var(--k-ink);
  font-family: var(--k-font);
  font-size: 15px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

#app { display: flex; padding: 8px 10px; overflow: hidden; overflow: clip; }
/* ↑ GlowScript 그래프(Flot)는 눈금 글자 크기를 잴 때 너비 10000px짜리 임시 상자를 잠깐 붙였다 뗀다.
   휴대폰에서 직접 열면 그 순간 페이지가 넓어져 스크롤이 튄다. #app 밖으로 넘친 것을 잘라 페이지 크기가 변하지 않게 한다 */
/* GlowScript가 만드는 빈 제목·설명 칸과 크기 조절 손잡이는 쓰지 않는다 */
#glowscript > :not(.glowscript-canvas-wrapper):not(.glowscript-graph):not(.stage) { display: none; }
.ui-resizable-handle { display: none !important; }
/* 3D·그래프: 카드 없이 종이 위에 (반경 0, 테두리 없음) */
.glowscript-canvas-wrapper { overflow: hidden; background: var(--k-paper); }
.glowscript-graph { background: var(--k-paper); margin-top: 4px; }

/* ── 배치: 창 하나에 다 들어간다 (페이지 스크롤 없음). 3D·그래프 크기는 sim.py의 layout()이 정한다 ──
   #glowscript·#side는 상자 없이(contents) 그 안의 칸들이 #app 격자에 바로 놓인다 */
#glowscript { display: contents; }
.glowscript-canvas-wrapper { grid-area: view; align-self: start; justify-self: start; position: relative; touch-action: none; }
.glowscript-canvas-wrapper > canvas { vertical-align: top; }
.stage.gcap { grid-area: cap; margin: 0; }
.glowscript-graph { grid-area: graph; margin: 0; align-self: start; }
/* 측정 표 + 결과 문장: 상자 없이 종이 위 (넓은 화면은 위에 구역 선 하나) */
.stage.res { grid-area: res; margin: 0; display: flex; flex-direction: column; gap: 2px; padding: 4px 0 2px; }
body.wide .stage.res { border-top: 1px solid var(--k-rule); }
.res .out { margin: 0; flex: none; }
.res .msg { margin: 0; font-size: 14px; line-height: 1.4; }
.res .older { color: var(--k-sub); }
.res .hint { color: var(--k-sub); }
.res.tight table.tbl th, .res.tight table.tbl td { font-size: 12px; line-height: 1.3; }
.res.tight .msg { font-size: 12.5px; }
.switch { display: none; }
.inforow { display: flex; margin-left: auto; }
.inforow button { margin: 0 !important; }

/* 'ⓘ 설명' 창: 흰 종이, 반경 0, 그림자 없음. 뒤는 어둡게만 (닫기 · Esc · 바깥 누르기로 닫는다) */
.infoov { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 14px;
  background: var(--k-dim); }
.infocard { background: var(--k-paper); border-radius: 0; width: 100%; max-width: 580px; max-height: 100%; overflow-y: auto;
  padding: 0 18px 16px; overscroll-behavior: contain; }
.infocard:focus { outline: none; }
.infohead { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--k-paper); padding: 10px 0 8px; border-bottom: 1px solid var(--k-rule); margin-bottom: 6px; font-size: 16px; }
.infohead b { font-weight: 800; }
.infohead button { margin: 0 !important; }
.infocard .more .note, .infocard .more .foot { font-size: 14px; line-height: 1.55; color: var(--k-ink); margin: 0 0 8px; padding: 0; }
.infocard .more .expl:empty { display: none; }

/* 3D 시점: 끌어서 돌리기·확대 안내(장면 위 글, 불투명 종이 바탕, 반경 0)와 '처음 시점' 단추 */
.camhint { position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none; font-size: 12px; line-height: 1.3;
  color: var(--k-sub); background: var(--k-paper); padding: 1px 4px; max-width: 60%; }
.camhint.used { display: none; }
#app .camreset { position: absolute; right: 0; bottom: 0; z-index: 3; padding: 2px 10px; font-size: 13px !important; }
body.small-view .camhint { display: none; }

/* 넓은 화면: [3D | 그래프] 위, 측정 표 아래, 오른쪽에 조작판 */
body.wide #app { display: grid; height: 100vh; height: 100dvh; column-gap: 16px; row-gap: 4px;
  grid-template-columns: auto minmax(0, 1fr) var(--sw, 300px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "view cap side" "view graph side" "res res side"; }
body.wide .glowscript-canvas-wrapper { grid-row: 1 / span 2; }
body.wide #side { grid-area: side; display: flex; flex-direction: column; gap: 10px; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain; }
body.wide #side > * { flex-shrink: 0; }
/* ↑ 마지막 안전망: 목표 크기(830×466 이상)에서는 조작판이 창 안에 다 들어가 스크롤이 생기지 않는다 */
body.wide .hdr .title { display: none; }
body.wide .res .msg { min-height: 2.8em; }
body.wide .read { border-top: 1px solid var(--k-rule); padding-top: 8px; }
/* 낮은 가로 화면에서 조작판이 창보다 길 때 (sim.py layout()이 tight를 붙인다): 글자만 줄인다 */
body.wide.tight #side { gap: 6px; }
body.wide.tight #side button { font-size: 14px !important; line-height: 1.15; }
body.wide.tight .hdr .q { font-size: 15px; line-height: 1.3; }
body.wide.tight .read > span { gap: 2px 8px; }
body.wide.tight .read b { font-size: 14px; line-height: 1.15; }

/* 세로 화면: 탭·질문 → [3D | 읽은 값] → 조작 → 판 고르기 → 판 하나가 남은 높이를 다 쓴다 */
body.narrow #app { display: grid; height: 100vh; height: 100dvh; gap: 6px 16px; padding: 4px 10px 8px;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto auto auto auto minmax(0, 1fr);
  grid-template-areas: "hdr hdr" "view read" "panel panel" "switch switch" "cap cap" "pane pane"; }
body.narrow #side { display: contents; }
body.narrow .hdr { grid-area: hdr; }
body.narrow .read { grid-area: read; align-self: start; }
body.narrow .read > span { margin-top: 0; }
body.narrow .panel { grid-area: panel; margin: 0; }
body.narrow .switch { grid-area: switch; display: flex; }
body.narrow .switch button { flex: 1 1 0; margin: 0 !important; }
body.narrow .switch button.infobtn { flex: 0 0 52px; font-size: 18px !important; }
body.narrow .inforow { display: none; }
body.narrow .glowscript-graph { grid-area: pane; }
body.narrow .stage.res { grid-row: 5 / span 2; grid-column: 1 / span 2; overflow: hidden; padding: 4px 0; }
body.narrow:not(.pane0) .stage.gcap, body.narrow:not(.pane0) .glowscript-graph { display: none !important; }
body.narrow:not(.pane1) .stage.res { display: none !important; }
body.narrow:not(.roomy) .hdr .title { display: none; }
body.narrow #app button { font-size: 14px !important; line-height: 1.15; padding: 4px 6px; }
body.narrow .hdr .q { font-size: 16px; }

/* ── 조작판 ── */
.hdr .title { font-size: 17px; font-weight: 700; margin: 0 0 4px; }
/* 탐구 질문: '탐구 질문' 라벨과 노란 상자 없이 화면에서 가장 큰 글자 */
.hdr .q { font-size: 18px; font-weight: 750; line-height: 1.32; margin: 4px 0 0; }
/* 실험 탭: 글자 탭, 고른 탭은 공용 .k-on (굵은 글자 + 칸 아래 3px 막대) */
.tabs { display: flex; gap: 0 14px; margin: 0; }
#app .tabs button { flex: 0 1 auto; border: 0 !important; background: none !important; border-radius: 0; padding: 0 4px; color: var(--k-sub) !important; font-weight: 600; margin: 0 !important; min-width: 32px; }
#app .tabs button.k-on { color: var(--k-ink) !important; font-weight: 750; }
@media (hover: hover) { #app .tabs button:not(.k-on):hover { color: var(--k-ink) !important; } }
/* 판: 상자 없이 종이 위 (넓은 화면은 판 사이에만 구역 선) */
.panel { padding: 0; }
body.wide .panel { border-top: 1px solid var(--k-rule); padding-top: 8px; }
.stage { margin-top: 6px; }
.gcap { font-size: 13px; line-height: 1.35; color: var(--k-sub); }
.gcap b { color: var(--k-ink); }
.res { margin-top: 4px; }
.row { margin: 2px 0 0; font-size: 14px; display: flex; align-items: center; gap: 4px; }
.row > span:first-child { flex: none; white-space: nowrap; }
.row > .ui-slider { flex: 1 1 auto; min-width: 80px; }
/* 읽음값: tabular 숫자, 숫자는 그 물리량의 색(--q), 단위는 같은 줄 */
.rv { white-space: nowrap; font-variant-numeric: tabular-nums; }
.rv b { font-weight: 800; color: var(--q, var(--k-ink)); }
.btns { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0 2px; }
.btns button { margin: 0 !important; }
.btns > span { align-self: center; font-size: 13px; color: var(--k-sub); margin-left: 4px; }
/* 예측 세그먼트: 모양은 공용 .k-seg. 여기서는 배치만 */
.seg { display: flex; margin: 2px 0; }
#app .seg button { flex: 1 1 0; min-width: 0; margin: 0 !important; padding: 4px 4px !important; white-space: normal; line-height: 1.15; }
.pred { font-size: 14px; margin: 2px 0 4px; }
.pred b { font-weight: 800; margin-right: 4px; }
.out { font-size: 14px; margin-top: 6px; }
.msg { font-size: 14px; margin-top: 6px; min-height: 1.4em; }
.panel .msg { min-height: 0; margin-top: 2px; }
.mine { font-weight: 700; }
.mk { font-weight: 800; color: var(--k-ink); }
.note { font-size: 13px; line-height: 1.4; color: var(--k-sub); margin-top: 2px; }
.foot { font-size: 13px; line-height: 1.4; color: var(--k-sub); padding: 4px 0 0; }
/* 표: 줄 사이 옅은 선 */
table.tbl { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.tbl th, table.tbl td { border-bottom: 1px solid var(--k-rule); padding: 1px 4px; text-align: right; font-size: 13.5px; line-height: 1.45; white-space: nowrap; }
table.tbl th:first-child, table.tbl td:first-child { text-align: left; }
table.tbl th { color: var(--k-sub); font-weight: 600; font-size: 12.5px; white-space: normal; vertical-align: bottom; }
/* 글 속 낱말 = 장면의 범례: 공용 .k-w에 대상 색 */
.w-slow { --w: var(--c-slow); }
.w-fast { --w: var(--c-fast); }
.w-temp { --w: var(--c-fast); }
.w-pres { --w: var(--c-pres); }
.w-vol { --w: var(--c-vol); }

/* ── GlowScript 단추: 보조는 회색 테두리, 주 동작은 잉크 칠 (style 속성을 덮는다) ── */
#app button, .infocard button {
  min-height: var(--btn-h);
  padding: 4px 12px;
  border: 1.5px solid var(--k-ctl);
  border-radius: var(--k-r);
  background: var(--k-paper) !important;
  color: var(--k-ink) !important;
  font: inherit;
  font-size: 15px !important;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  text-wrap: balance;
}
#app button.primary { background: var(--k-ink) !important; border-color: var(--k-ink); color: var(--k-paper) !important; font-weight: 700; }
@media (hover: hover) {
  #app button:not(:disabled):not(.primary):not([aria-pressed="true"]):not([aria-selected="true"]):hover, .infocard button:hover { background: var(--k-wash) !important; }
  #app button.primary:not(:disabled):hover { background: #000 !important; }
}
#app button:disabled { cursor: default; opacity: 0.45; }
#app button:focus-visible, .infocard button:focus-visible, .ui-slider-handle:focus-visible { outline: 2px solid var(--k-ink); outline-offset: 2px; }
/* 세그먼트 칸: 공용 .k-seg의 칸 모양 (테두리는 바깥 하나, 칸 사이 선) */
#app .k-seg > button { border: 0; border-radius: 0; color: var(--k-ink-2) !important; }
#app .k-seg > button + button { border-left: 1px solid var(--k-rule); }
#app .k-seg > button[aria-pressed="true"], #app .k-seg > button[aria-selected="true"] { color: var(--k-ink) !important; font-weight: 750; }
#app .k-seg > button:focus-visible { outline-offset: -4px; }
#app button .ico { width: 1em; height: 1em; flex: none; fill: currentColor; vertical-align: -0.125em; margin-right: 5px; }
/* 작은 3D: 안내 글은 빼고 '처음 시점' 단추는 아이콘만 */
body.small-view #app button.camreset { min-width: var(--btn-h); padding: 0 8px; }
body.small-view #app button.camreset .lb { display: none; }

/* ── jQuery UI 슬라이더: 공용 .k-range와 같은 모양으로 그린다 ──
   회색 트랙 4px, 지나온 쪽(range) 진하게, 흰 원 손잡이. 손잡이 테두리 = 그 물리량의 색(--q, sim.py slider_row) */
.ui-slider { position: relative; touch-action: none; }
.ui-slider-horizontal {
  display: block !important;
  width: auto !important;
  height: 4px !important;
  margin: 18px 14px 18px 12px !important;
  background: var(--k-rule);
  border-radius: 0;
  cursor: pointer;
}
.ui-slider-horizontal::before { content: ""; position: absolute; left: -12px; right: -14px; top: -18px; bottom: -18px; }
.ui-slider .ui-slider-range { position: absolute; z-index: 1; display: block; border: 0; top: 0; left: 0; height: 100%; border-radius: 0; background: var(--k-ink-2) !important; }
.ui-slider .ui-slider-handle {
  position: absolute; z-index: 2; top: -9px; width: 22px; height: 22px; margin-left: -11px;
  border-radius: 50%; border: 3px solid var(--q, var(--k-ink)); background: var(--k-paper) !important; box-shadow: none;
  cursor: grab; touch-action: none;
}
.ui-slider-disabled { opacity: 0.45; cursor: default; }

/* 불러오기·오류 안내: 종이 위 글 */
.boot { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); background: var(--k-paper);
  padding: 14px 18px; font-size: 15px; color: var(--k-sub); max-width: 92vw; }
.boot.error { color: #9b1c1c; top: 10px; transform: translateX(-50%); border: 1.5px solid var(--k-ctl); }
.boot pre { white-space: pre-wrap; font-size: 13px; margin: 8px 0 0; color: var(--k-ink); }

/* 측정 표 (가로로 늘어나는 표) */
.scroll { overflow-x: auto; }
table.tbl.wide { width: auto; }
table.tbl.wide th { text-align: left; padding-right: 10px; }
table.tbl.wide td { min-width: 44px; padding-left: 8px; }
/* 읽은 값: 상자 없이 이름(작은 글자) + 값(굵은 tabular 숫자). 압력·부피·온도 숫자는 그 대상의 색 */
.read > span { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 10px; }
.read > span > span { min-width: 0; overflow: hidden; }
body.narrow .read > span { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.read i { display: block; font-style: normal; font-size: 12px; line-height: 1.15; color: var(--k-sub); }
.read b { font-size: 15px; font-weight: 800; line-height: 1.25; font-variant-numeric: tabular-nums; white-space: nowrap; }
.read b.vp { color: var(--c-pres); }
.read b.vv { color: var(--c-vol); }
.read b.vt { color: var(--c-fast); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ── 낮은 화면(compact): 3D(+읽은 값)도 판 하나가 된다 ──
   판 고르기 [장면 · 그래프 · 표 · ⓘ] 아래 판 하나가 남은 높이를 다 쓰고, 조작판(예측·슬라이더·측정)은 늘 보인다.
   판은 학생이 누를 때만 바뀐다. 처음에는 '장면' 판(sim.py layout)
   세로: 탭·질문 → 판 고르기 → [판] → 조작판.  가로(눕힌 휴대폰·320×200): 왼쪽 판 고르기·판, 오른쪽 한 칸(.minicol)에 탭·질문·조작판 */
.minicol, .ph { display: none; }
body:not(.compact) .switch .scenebtn { display: none !important; }
body.compact #app { display: grid; height: 100vh; height: 100dvh; gap: 6px 16px; padding: 4px 10px 8px; }
body.compact #side { display: contents; }
body.compact .switch { grid-area: switch; display: flex; }
body.compact .switch button { flex: 1 1 0; min-width: 0; margin: 0 !important; }
body.compact .switch button.infobtn { flex: 0 0 52px; font-size: 18px !important; }
body.compact .inforow { display: none; }
body.compact .read { border-top: 0; padding-top: 0; }
body.compact:not(.paneS) .glowscript-canvas-wrapper, body.compact:not(.paneS) .read { display: none !important; }
body.compact:not(.pane0) .stage.gcap, body.compact:not(.pane0) .glowscript-graph { display: none !important; }
body.compact:not(.pane1) .stage.res { display: none !important; }
body.compact.paneS .glowscript-canvas-wrapper { grid-column: 1; grid-row: main-start / main-end; align-self: start; }
body.compact.paneS .read { grid-column: 2; grid-row: main-start / main-end; align-self: start; }
body.compact.pane0 .stage.gcap { grid-area: cap; margin: 0; }
body.compact.pane0 .glowscript-graph { grid-area: main; margin: 0; }
body.compact.pane1 .stage.res { grid-column: 1 / span 2; grid-row: cap-start / main-end; overflow: hidden; align-self: stretch; border-top: 0; }
/* 조작판: '예측' 이름표 옆에 단추 셋 (예측 물음은 바로 위 탐구 질문과 같아 줄인다) */
body.compact .panel { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; align-items: center; }
body.compact .panel > * { grid-column: 1 / -1; }
body.compact .panel > .pred { grid-column: 1; margin: 0; }
body.compact .panel > .seg { grid-column: 2; margin: 0; }
body.compact .panel .pq { display: none; }
body.compact .btns { margin: 2px 0 0; }
/* 세로 낮은 화면 */
body.narrow.compact #app { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  grid-template-areas: "hdr hdr" "switch switch" "cap cap" "main main" "panel panel"; }
body.narrow.compact .hdr { grid-area: hdr; }
body.narrow.compact .panel { grid-area: panel; }
body.narrow.compact .hdr .q { font-size: 15px; }
/* 가로 낮은 화면·아주 작은 창: 오른쪽 한 칸 */
body.wide.compact #app { grid-template-columns: auto minmax(0, 1fr) var(--sw, 300px); grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-areas: "switch switch col" "cap cap col" "main main col"; padding: 4px 10px; gap: 4px 16px; }
body.wide.compact .minicol { grid-area: col; display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
body.wide.compact .minicol > * { flex: none; }
body.wide.compact .hdr .q { font-size: 14px; line-height: 1.3; }
body.wide.compact .panel { border-top: 0; padding-top: 0; }
body.mini .minicol { font-size: 13px; }
body.mini #app .seg button, body.mini #app .switch button { font-size: 13px !important; }
body.mini #app .tabs button { white-space: normal; font-size: 13px !important; }
body.mini .read > span { grid-template-columns: minmax(0, 1fr); }
/* 낮은 화면의 읽은 값: 3D 옆 좁은 칸이라 한 줄에 하나씩, 이름과 값을 한 줄에 */
body.compact .read > span { grid-template-columns: minmax(0, 1fr); gap: 2px; }
body.compact .read > span > span { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
body.compact .read i { display: inline; font-size: 12px; }
body.compact .read b { font-size: 14px; }
/* 아주 작은 창(320×200): [왼쪽 판 하나 | 오른쪽 한 칸(탭·질문·판 고르기·조작판, 이 칸만 안에서 스크롤)]. 읽은 값은 숨긴다(압력은 3D의 압력계, 부피·온도는 슬라이더) */
body.mini.compact #app { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "cap col" "main col"; }
body.mini .read { display: none !important; }
body.mini.pane1 .stage.res { grid-column: 1; overflow: auto; overscroll-behavior: contain; }
body.mini .k-seg { flex-wrap: wrap; }
body.mini #app .seg button, body.mini #app .switch button { flex: 1 1 auto; min-width: 44px; white-space: nowrap; }
body.mini .row { flex-wrap: wrap; }
body.mini .row > .ui-slider { flex: 1 1 100%; min-width: 0; }
body.mini .panel > .seg { grid-column: 1 / -1; }
