/* 프리사이언스 분야 공용 화면(물리·세포·화석·수학) — 생명(inchae)과 같은 규칙:
   무채색 판 + 강조 금색은 고른 것에만, 단추 높이 32·모서리 8(알약 금지), 선 1.6px 아이콘, 흐림(backdrop-filter) 금지 */
:root {
  --bg: #0c0d0f;
  --panel: #131417;
  --panel-2: #1a1b1f;
  --panel-3: #202126;
  --line: #26282d;
  --line-2: #34373d;
  --text: #ececee;
  --sub: #a3a5ac;
  --faint: #6d6f76;
  --gold: #e8c46a;
  --gold-d: #b8933c;
  --hover: #7cc7ff;
  --ok: #5fcf8f;
  --bad: #ef6f6f;
  --r: 8px;
  --top: 52px;
  --left: 272px;
  --right: 400px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overscroll-behavior: none; }
button, a, input, select, label, [role="button"] { touch-action: manipulation; }
body {
  margin: 0; background: var(--bg); color: var(--text); overflow: hidden;
  font: 14px/1.6 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  letter-spacing: -0.01em; -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #2b2d33; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--sub);
  cursor: pointer; font-size: 13px; white-space: nowrap; transition: color .15s, border-color .15s, background .15s;
}
.btn:hover { color: var(--text); border-color: var(--line-2); background: var(--panel-2); }
.btn.on, .btn[aria-pressed="true"] { color: var(--bg); background: var(--text); border-color: var(--text); }
.btn.icon { width: 32px; padding: 0; }
.btn.gold { color: #17130a; background: var(--gold); border-color: var(--gold); font-weight: 650; }

/* ── 위 막대 ── */
.top {
  position: fixed; inset: 0 0 auto 0; height: var(--top); z-index: 30; display: flex; align-items: center; gap: 14px;
  padding: 0 14px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.home { display: flex; align-items: center; gap: 10px; color: var(--text); }
.home .mark { width: 22px; height: 22px; }
.home .fname { font-size: 18px; font-weight: 800; letter-spacing: -0.04em; }
.home .fbrand { font: 800 10.5px/1 Montserrat, 'Pretendard Variable', sans-serif; letter-spacing: .1em; color: var(--faint); }
.crumb { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--sub); font-size: 13.5px; }
.crumb b { color: var(--text); font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb .sep { color: var(--faint); }
.find { position: relative; margin-left: auto; width: 300px; }
.find input {
  width: 100%; height: 32px; padding: 0 30px 0 32px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--panel); color: var(--text); font: inherit; font-size: 13.5px; outline: none;
}
.find input:focus { border-color: var(--line-2); background: var(--panel-2); }
.find > .ic { position: absolute; left: 9px; top: 7px; color: var(--faint); width: 17px; height: 17px; }
.find kbd { position: absolute; right: 8px; top: 7px; font: 11px/16px inherit; color: var(--faint); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 5px; }
.hits {
  position: absolute; top: 38px; left: 0; right: 0; max-height: 60vh; overflow: auto; z-index: 40;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r); padding: 4px; box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.hit { display: block; width: 100%; text-align: left; padding: 7px 9px; border: 0; border-radius: 6px; background: none; cursor: pointer; }
.hit:hover, .hit.on { background: var(--panel-3); }
.hit b { display: block; font-weight: 600; font-size: 13.5px; }
.hit span { display: block; color: var(--faint); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hit mark { background: none; color: var(--gold); }
.top-r { display: flex; gap: 6px; }

/* ── 왼쪽 판: 분류·항목 ── */
.left {
  position: fixed; top: var(--top); bottom: 0; left: 0; width: var(--left); z-index: 20; display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line);
}
.left-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; color: var(--faint); font-size: 12px; }
.tree { flex: 1; overflow: auto; padding: 0 8px 20px; }
.cat { margin-top: 2px; }
.cat > button {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 8px; border: 0; background: none; cursor: pointer;
  color: var(--text); font-weight: 650; font-size: 13.5px; border-radius: 6px; text-align: left;
}
.cat > button:hover { background: var(--panel-2); }
.cat > button .chev { width: 14px; height: 14px; color: var(--faint); transition: transform .2s; }
.cat.open > button .chev { transform: rotate(90deg); }
.cat > button .n { margin-left: auto; color: var(--faint); font-weight: 400; font-size: 12px; font-variant-numeric: tabular-nums; }
.cat ul { list-style: none; margin: 0 0 6px; padding: 0 0 0 14px; display: none; }
.cat.open ul { display: block; }
.cat li a {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; color: var(--sub); font-size: 13.5px; line-height: 1.35;
  border-left: 1px solid var(--line); border-radius: 0 6px 6px 0;
}
.cat li a:hover { color: var(--text); background: var(--panel-2); }
.cat li a.on { color: var(--text); background: var(--panel-3); border-left-color: var(--gold); }
.lv { flex: none; margin-left: auto; font-size: 11px; color: var(--faint); }
.lv[data-l="3"] { color: var(--gold-d); }
.seen::after { content: ''; flex: none; width: 5px; height: 5px; border-radius: 50%; background: #4b4e55; }

/* ── 가운데 무대 ── */
.stage { position: fixed; top: var(--top); bottom: 0; left: var(--left); right: var(--right); overflow: hidden; background: var(--bg); }
.stage canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lab {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: auto; cursor: pointer;
  font-size: 12px; line-height: 1; padding: 4px 7px; border-radius: 5px; color: #dfe0e3; background: rgba(12, 13, 15, .78); border: 1px solid #2d3036;
  transition: opacity .2s, color .15s, border-color .15s;
}
.lab.plain { background: none; border-color: transparent; text-shadow: 0 1px 3px #000, 0 0 2px #000; padding: 0; pointer-events: none; }
.lab.hov { color: var(--hover); border-color: #3c6f93; }
.lab.sel { color: #17130a; background: var(--gold); border-color: var(--gold); font-weight: 650; }
.lab.dim { opacity: .35; }
.lab.ov { opacity: 0; pointer-events: none; }
.labels.off .lab:not(.sel):not(.keep) { opacity: 0; pointer-events: none; }
.tip {
  position: absolute; pointer-events: none; z-index: 5; padding: 5px 8px; border-radius: 6px; font-size: 12.5px;
  background: #0b0c0e; border: 1px solid var(--line-2); color: var(--text); white-space: nowrap; transform: translate(12px, 12px);
}
.tip small { color: var(--faint); margin-left: 6px; }

.s-title { position: absolute; left: 16px; top: 14px; max-width: calc(100% - 40px - var(--tools-w, 180px)); pointer-events: none; }
.s-title h1 { margin: 0; font-size: 20px; font-weight: 750; letter-spacing: -0.03em; line-height: 1.25; text-shadow: 0 1px 8px #000; word-break: keep-all; overflow-wrap: anywhere; }
.s-title p { margin: 3px 0 0; color: var(--sub); font-size: 13px; text-shadow: 0 1px 6px #000; }
.s-tools { position: absolute; right: 12px; top: 12px; display: flex; gap: 6px; }
.s-tools .btn { background: rgba(19, 20, 23, .92); }
.stage.dock-off .dock, .stage.dock-off .rd-box { display: none !important; }
.s-tools .btn[aria-pressed="true"] { background: #2a2c31; color: var(--text); border-color: #4a4d55; }
.s-guide {
  position: absolute; left: 16px; top: 66px; width: 290px; max-width: calc(100% - 32px); padding: 12px 14px 12px; border-radius: var(--r);
  background: rgba(19, 20, 23, .95); border: 1px solid var(--line); font-size: 12.5px; line-height: 1.55; color: var(--sub);
}
.s-guide { padding: 0; width: 300px; }
.s-guide .g-head { display: flex; align-items: center; gap: 6px; width: 100%; height: 34px; padding: 0 12px; border: 0; background: none; color: var(--text); font-weight: 650; font-size: 13px; cursor: pointer; text-align: left; }
.s-guide .g-head span { margin-left: auto; color: var(--faint); font-weight: 400; font-size: 12px; }
.s-guide .g-head .chev { width: 14px; height: 14px; color: var(--faint); transform: rotate(90deg); transition: transform .2s; }
.s-guide.fold .g-head .chev { transform: none; }
.s-guide.fold { width: auto; }
.s-guide ol { padding: 0 14px 12px 32px !important; }
.s-guide.fold ol { display: none; }
.s-guide ol { margin: 0; padding-left: 18px; }
.s-guide li { margin: 2px 0; }
.s-guide .x { position: absolute; right: 6px; top: 6px; width: 26px; height: 26px; }

/* 조작판(슬라이더·스위치·읽은 값) */
.dock {
  position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; pointer-events: none;
}
.ctl, .readouts {
  pointer-events: auto; background: rgba(19, 20, 23, .95); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px;
}
.ctl { display: flex; flex-direction: column; gap: 3px; min-width: 250px; padding: 6px 10px; }
.ctl > label > b { font-size: 12px; }
/* 막대 한 줄 = 이름 | 막대 | 값 — 이름 칸은 그 상자에서 가장 긴 이름에 맞춤(62~132px, 상자 안 줄끼리 맞춰짐) */
.ctl:has(> .sl) { display: grid; grid-template-columns: minmax(62px, max-content) minmax(110px, 1fr) minmax(70px, max-content); column-gap: 8px; row-gap: 3px; }
.ctl:has(> .sl) > * { grid-column: 1 / -1; }
.ctl .sl { display: grid; grid-template-columns: 62px 1fr 70px; align-items: center; gap: 8px; height: 24px; }
.ctl:has(> .sl) > .sl { grid-template-columns: subgrid; }
.ctl .sl span { color: var(--sub); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 132px; }
.ctl .sl output { color: var(--text); font-variant-numeric: tabular-nums; font-size: 12.5px; text-align: right; white-space: nowrap; }
.ctl label { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--sub); font-size: 12.5px; min-height: 24px; }
.ctl input[type=range] { width: 100%; accent-color: var(--gold); height: 16px; margin: 0; }
.ctl.row { flex-direction: row; align-items: center; min-width: 0; padding: 4px; gap: 4px; }
.ctl.row .btn { height: 30px; border-color: transparent; background: none; }
.ctl.row .btn:hover { background: var(--panel-3); }
.ctl.row .btn.on { background: var(--text); color: var(--bg); }
.ctl .sw { display: flex; align-items: center; justify-content: flex-start; gap: 7px; cursor: pointer; color: var(--sub); font-size: 12.5px; min-height: 22px; }
.ctl .sw input { margin: 0; accent-color: var(--gold); }
.ctl select { height: 28px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--panel-2); color: var(--text); font: inherit; font-size: 12.5px; padding: 0 6px; }
.readouts { margin: 0 0 0 auto; padding: 6px 10px; display: grid; grid-template-columns: auto auto; gap: 1px 14px; font-size: 12.5px; }
/* PC 읽은 값 = 접을 수 있는 상자(무대 오른쪽 위) — 펼친 채 두면 장면을 계속 가린다. 접은 상태는 기억 */
.rd-box {
  position: absolute; right: 12px; top: 54px; max-width: 46%; pointer-events: auto;
  background: rgba(19, 20, 23, .95); border: 1px solid var(--line); border-radius: var(--r);
}
.rd-box .rd-h {
  display: flex; align-items: center; gap: 6px; width: 100%; height: 28px; padding: 0 10px;
  border: 0; background: none; color: var(--sub); font-size: 12px; font-weight: 650; cursor: pointer;
}
.rd-box .rd-h:hover { color: var(--text); }
.rd-box .rd-h .chev { width: 13px; height: 13px; color: var(--faint); transform: rotate(90deg); transition: transform .2s; }
.rd-box.fold .rd-h .chev { transform: none; }
.rd-box .readouts { background: none; border: 0; margin: 0; padding: 0 10px 8px; max-height: 46vh; overflow: auto; scrollbar-width: thin; }
.rd-box.fold .readouts { display: none; }
.readouts dt { color: var(--faint); }
.readouts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.legend { pointer-events: auto; display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 7px 10px; font-size: 12px; color: var(--sub); background: rgba(19, 20, 23, .95); border: 1px solid var(--line); border-radius: var(--r); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); font-size: 13px; pointer-events: none; }
.err { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: 420px; padding: 16px; text-align: center; color: var(--sub); border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }

/* ── 오른쪽 판: 해설·부분·영상·문제·출처 ── */
.right {
  position: fixed; top: var(--top); bottom: 0; right: 0; width: var(--right); z-index: 20; display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--line);
}
.rtabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); }
.rtab {
  position: relative; height: 36px; padding: 0 10px; border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 13.5px; font-weight: 550;
}
.rtab:hover { color: var(--sub); }
.rtab[aria-selected="true"] { color: var(--text); }
.rtab[aria-selected="true"]::after { content: ''; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; background: var(--gold); }
.rtab .n { margin-left: 4px; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.rbody { flex: 1; overflow: auto; padding: 16px 18px 40px; }
.rfoot { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); }
.rfoot .btn { flex: 1; }

/* 글(해설) */
.doc { font-size: 14px; line-height: 1.75; color: #d6d7da; word-break: keep-all; overflow-wrap: anywhere; }
.doc h2 { margin: 26px 0 8px; font-size: 16px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.doc h3 { margin: 18px 0 6px; font-size: 14.5px; font-weight: 700; color: var(--text); }
.doc p { margin: 8px 0; }
.doc ul, .doc ol { margin: 8px 0; padding-left: 20px; }
.doc li { margin: 3px 0; }
.doc strong { color: var(--text); font-weight: 650; }
.doc code { font: 12.5px/1.4 ui-monospace, Consolas, monospace; background: var(--panel-3); padding: 1px 5px; border-radius: 4px; }
.doc .katex { font-size: 1.04em; }
.doc .katex-display { margin: 12px 0; padding: 10px 8px; overflow-x: auto; overflow-y: hidden; background: #0f1013; border: 1px solid var(--line); border-radius: 6px; }
.doc table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13px; display: block; overflow-x: auto; }
.doc th, .doc td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; }
.doc th { background: var(--panel-2); color: var(--text); font-weight: 650; white-space: nowrap; }
.doc a.ref { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; cursor: pointer; }
.doc a.ref:hover { text-decoration-color: var(--gold); }
.doc a.pt { color: var(--hover); cursor: pointer; border-bottom: 1px dotted #3c6f93; }
.doc blockquote { margin: 10px 0; padding: 8px 12px; border-left: 2px solid var(--line-2); color: var(--sub); background: #101114; }
.lead { margin: 0 0 14px; font-size: 14.5px; color: var(--text); line-height: 1.7; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 0 0 12px; color: var(--faint); font-size: 12px; }
.key { margin: 0 0 16px; padding: 12px 14px; border: 1px solid #3a3222; background: #17140d; border-radius: var(--r); }
.key b { display: block; margin-bottom: 4px; color: var(--gold); font-size: 12.5px; font-weight: 700; }
.key ul { margin: 0; padding-left: 18px; color: #e3dccb; font-size: 13.5px; }
.key li { margin: 3px 0; }
.toc { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 6px; }
.toc a { font-size: 12px; color: var(--sub); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; cursor: pointer; }
.toc a:hover { color: var(--text); border-color: var(--line-2); }

/* 부분 목록 */
.parts { list-style: none; margin: 0; padding: 0; }
.parts li button {
  display: flex; align-items: baseline; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px; background: none; cursor: pointer; text-align: left;
}
.parts li button:hover { background: var(--panel-2); }
.parts li button.on { background: var(--panel-3); box-shadow: inset 2px 0 var(--gold); }
.parts li b { font-weight: 600; font-size: 13.5px; }
.parts li span { color: var(--faint); font-size: 12px; }
.pcard { margin: 0 0 16px; padding: 14px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--panel-2); }
.pcard h3 { margin: 0; font-size: 16px; }
.pcard .en { color: var(--faint); font-size: 12.5px; margin: 2px 0 8px; }
.hint { color: var(--faint); font-size: 12.5px; margin: 0 0 12px; }

/* 영상 */
.vids { display: grid; gap: 12px; }
.vid { display: grid; grid-template-columns: 148px 1fr; gap: 10px; align-items: start; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.vid .th { position: relative; aspect-ratio: 16/9; border-radius: 6px; overflow: hidden; background: #000; border: 1px solid var(--line); }
.vid .th img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s var(--ease); }
.vid:hover .th img { transform: scale(1.04); }
.vid .th em { position: absolute; right: 4px; bottom: 4px; font-style: normal; font-size: 11px; background: rgba(0,0,0,.8); padding: 0 4px; border-radius: 3px; }
.vid b { display: block; font-size: 13px; font-weight: 600; line-height: 1.4; color: var(--text); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.vid span { display: block; margin-top: 3px; font-size: 12px; color: var(--faint); }
.vid .why { color: var(--sub); }
.player { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(0,0,0,.86); padding: 24px; }
.player .box { position: relative; width: min(1100px, 100%, calc((100vh - 120px) * 16 / 9)); }
.player .scr { position: relative; aspect-ratio: 16/9; background: #000; border-radius: 8px; overflow: hidden; }
.player .cap { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; color: var(--sub); font-size: 13px; }
.player .cap b { color: var(--text); font-weight: 600; }
.player .x { position: absolute; right: -6px; top: -42px; }

/* 문제 */
.q { margin: 0 0 18px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-2); }
.q p.qq { margin: 0 0 10px; color: var(--text); font-weight: 550; }
.q .ch { display: grid; gap: 6px; }
.q .ch button { text-align: left; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--panel); cursor: pointer; font-size: 13.5px; line-height: 1.5; }
.q .ch button:hover { border-color: #4a4d55; }
.q .ch button.ok { border-color: var(--ok); color: #c8f2d8; }
.q .ch button.no { border-color: var(--bad); color: #f7cccc; }
.q .why { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--sub); font-size: 13px; }
.score { color: var(--sub); font-size: 13px; margin: 0 0 14px; }

/* 출처 */
.refs { margin: 0; padding-left: 18px; font-size: 13px; color: var(--sub); }
.refs li { margin: 6px 0; }
.refs a { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.rel { display: flex; flex-wrap: wrap; gap: 6px; }
.rel a { padding: 4px 9px; font-size: 12.5px; border: 1px solid var(--line); border-radius: 6px; color: var(--sub); cursor: pointer; }
.rel a:hover { color: var(--text); border-color: var(--line-2); }
.sub-h { margin: 22px 0 8px; font-size: 12px; font-weight: 700; color: var(--faint); letter-spacing: .02em; }

/* ── 크게 읽기 ── */
.reader { position: fixed; top: var(--top); left: var(--left); right: 0; bottom: 0; z-index: 25; overflow: auto; background: var(--bg); }
.reader .in { max-width: 820px; margin: 0 auto; padding: 36px 32px 100px; }
.reader h1 { margin: 0 0 6px; font-size: 30px; letter-spacing: -0.035em; line-height: 1.25; }
.reader .doc { font-size: 15.5px; line-height: 1.85; }
.reader .doc h2 { font-size: 20px; margin-top: 40px; padding-top: 14px; border-top: 1px solid var(--line); }
.reader .doc h3 { font-size: 16.5px; }
.reader .close { position: sticky; top: 12px; float: right; z-index: 2; }
.reader .key ul { font-size: 15px; }

/* ── 분야 첫 화면 ── */
.home-pg { position: absolute; inset: 0; overflow: auto; z-index: 3; background: var(--bg); }
.home-pg .in { max-width: 1080px; margin: 0 auto; padding: 34px 32px 80px; }
.home-pg h1 { margin: 0; font-size: clamp(26px, 3.4vw, 38px); letter-spacing: -0.04em; line-height: 1.2; }
.home-pg .intro { margin: 12px 0 0; max-width: 760px; color: var(--sub); font-size: 15px; line-height: 1.75; }
.home-pg .facts { display: flex; flex-wrap: wrap; gap: 26px; margin: 22px 0 0; padding: 16px 0 0; border-top: 1px solid var(--line); }
.home-pg .facts b { display: block; font-size: 22px; font-weight: 750; font-variant-numeric: tabular-nums; }
.home-pg .facts span { color: var(--faint); font-size: 12.5px; }
.home-pg .path { margin: 30px 0 0; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.home-pg .path h2 { margin: 0 0 8px; font-size: 14px; color: var(--sub); }
.home-pg .path ol { margin: 0; padding-left: 20px; columns: 2; column-gap: 30px; font-size: 13.5px; }
.home-pg .path li { margin: 3px 0; break-inside: avoid; }
.home-pg .path a { color: var(--text); cursor: pointer; }
.home-pg .path a:hover { color: var(--gold); }
.home-pg section.c { margin: 34px 0 0; }
.home-pg section.c h2 { margin: 0; font-size: 19px; letter-spacing: -0.02em; }
.home-pg section.c > p { margin: 4px 0 12px; color: var(--sub); font-size: 13.5px; }
.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.tcard {
  display: flex; flex-direction: column; gap: 4px; padding: 13px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); cursor: pointer;
  transition: border-color .2s, background .2s, transform .3s var(--ease);
}
.tcard:hover { border-color: var(--line-2); background: var(--panel-2); transform: translateY(-2px); }
.tcard b { font-size: 14.5px; font-weight: 650; letter-spacing: -0.02em; }
.tcard span { color: var(--sub); font-size: 12.5px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tcard small { margin-top: auto; padding-top: 6px; color: var(--faint); font-size: 11.5px; }
.other { display: flex; flex-wrap: wrap; gap: 8px; margin: 40px 0 0; padding: 18px 0 0; border-top: 1px solid var(--line); color: var(--faint); font-size: 13px; align-items: center; }

/* ── 폰·태블릿 ── */
.mbar { display: none; }
@media (max-width: 1640px) { :root { --left: 244px; --right: 372px; } }
@media (max-width: 1180px) { :root { --left: 228px; --right: 336px; } }
/* 폰 구간 = 좁은 창 + 가로로 눕힌 폰(폭 900 넘는 큰 폰도 3칸 PC 화면이 되지 않게). app.js isPhone 과 같게 */
.sheet-grip { display: none; }
@media (max-width: 900px), (max-height: 520px) and (pointer: coarse) {
  :root { --top: 50px; --mbar: calc(56px + env(safe-area-inset-bottom)); }
  .find { display: none; }
  .find.open { display: block; position: fixed; left: 8px; right: 8px; top: 9px; width: auto; z-index: 45; }
  .find kbd { display: none; }
  .find input { font-size: 16px; padding-right: 8px; }   /* 16px 미만이면 아이폰이 눌렀을 때 화면을 확대함 */
  .hits { max-height: 45vh; }
  .hit { padding: 10px; }
  .crumb { display: none; }
  .top-r { margin-left: auto; }
  .left, .right {
    top: auto; left: 0; right: 0; bottom: var(--mbar); width: auto; height: min(max(52vh, 240px), 560px, calc(100vh - var(--top) - var(--mbar))); border: 0; border-top: 1px solid var(--line-2);
    border-radius: 12px 12px 0 0; transform: translateY(110%); visibility: hidden; z-index: 35; box-shadow: 0 -10px 40px rgba(0,0,0,.5);
    transition: transform .28s var(--ease), height .28s var(--ease), visibility 0s .28s;
  }
  .left.open, .right.open { transform: none; visibility: visible; transition: transform .28s var(--ease), height .28s var(--ease); }
  .left.full, .right.full { height: calc(100vh - var(--top) - var(--mbar)); }
  .left.drag, .right.drag { transition: none; }
  .rbody, .tree { overscroll-behavior: contain; }
  /* 손잡이 = 넓은 띠 전체가 끄는 자리(가운데 막대는 모양) */
  .sheet-grip { display: block; position: relative; flex: none; height: 26px; margin-bottom: -6px; touch-action: none; cursor: grab; }
  .sheet-grip::after { content: ''; position: absolute; left: 50%; top: 10px; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--line-2); }
  .left-head { padding-top: 10px; touch-action: pan-x; }
  .rtabs { overflow-x: auto; scrollbar-width: none; touch-action: pan-x; flex: none; }
  .rtabs::-webkit-scrollbar { display: none; }
  .rtab { height: 42px; flex: none; }
  .stage { left: 0; right: 0; bottom: var(--mbar); }
  .reader { left: 0; bottom: var(--mbar); }
  .reader .in { padding: 22px 16px 80px; }
  .reader h1 { font-size: 24px; }
  .s-title { left: 12px; top: 10px; max-width: calc(100% - 28px - var(--tools-w, 210px)); }
  .s-title h1 { font-size: 16px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .s-title p { display: none; }
  .s-tools { right: 8px; top: 8px; }
  .s-tools .wide { display: none; }
  .s-guide { top: 52px; left: 12px; width: auto; right: 12px; }
  /* 폰: 조작판은 「조작」 단추로 펴고 접는다(기본 접힘 — 3D 가 먼저 보이게) */
  /* 폰: 조작판 묶음 사이 틈으로 뒤 장면이 비치지 않게 판 전체를 불투명 바탕으로 */
  .dock { left: 0; right: 0; bottom: 0; gap: 6px; max-height: 58%; overflow: auto; padding: 8px; background: var(--bg); border-top: 1px solid var(--line); pointer-events: auto; }
  .ctl, .readouts { background: var(--panel); }
  .dock:empty { display: none; }
  .ctl { min-width: 0; flex: 1 1 100%; }
  .ctl .sl { grid-template-columns: 58px 1fr 64px; }
  .ctl:has(> .sl) { grid-template-columns: minmax(58px, max-content) minmax(80px, 1fr) minmax(64px, max-content); }
  .ctl .sl span { max-width: 104px; }
  .readouts { margin-left: 0; flex: 1 1 100%; }
  .s-guide { display: none; }
  .stage.guide-open .s-guide:not([hidden]) { display: block; }
  .mbar {
    position: fixed; left: 0; right: 0; bottom: 0; height: var(--mbar); z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr);
    background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .mbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; background: none; color: var(--faint); font-size: 11px; cursor: pointer; }
  .mbar button.on { color: var(--text); }
  .mbar .ic { width: 20px; height: 20px; }
  .home-pg .in { padding: 22px 16px 60px; }
  .home-pg .path ol { columns: 1; }
  .tgrid { grid-template-columns: 1fr 1fr; }
  .vid { grid-template-columns: 120px 1fr; }
  .player { padding: 10px; }
  .player .x { right: 0; }
  /* 이름표는 터치를 무대로 흘림 — 위에서 시작해도 모형이 돌고, 탭은 stage.js labelAt 이 찾음 */
  .lab { pointer-events: none; }
  /* 손가락 크기: 보이는 크기는 두고 누르는 자리만 넓힘 */
  .s-tools .btn { position: relative; }
  .s-tools .btn::after { content: ''; position: absolute; inset: -6px -3px; }
  .cat > button { padding: 11px 8px; }
  .cat li a { padding: 10px 8px; }
  .parts li button { padding: 11px 10px; }
  .toc { gap: 6px; }
  .toc a { padding: 6px 10px; }
  .rel a { padding: 8px 11px; }
  .q .ch button { padding: 11px 12px; }
  .ctl .sl { height: 34px; }
  .ctl input[type=range] { height: 30px; }
  .ctl .sw { min-height: 34px; }
  .ctl .sw input { width: 18px; height: 18px; }
  .ctl.row { flex-wrap: wrap; }   /* 단추가 많으면 오른쪽으로 잘려 못 누르던 것 */
  .ctl.row .btn { height: 36px; }
  .ctl select { height: 36px; font-size: 16px; }
  .report textarea { font-size: 16px; }
  .report fieldset label { min-height: 38px; }
  .report .rp-act .btn, .rfoot .btn, .player .x { height: 38px; }
}
/* 손가락은 hover 가 눌린 뒤에도 남음 — 터치 기기에선 hover 색을 끄고 눌림 표시만 */
@media (hover: none) {
  .btn:not(.on):not(.gold):not([aria-pressed="true"]):hover { color: var(--sub); border-color: var(--line); background: var(--panel); }
  .s-tools .btn:not([aria-pressed="true"]):hover { background: rgba(19, 20, 23, .92); }
  .ctl.row .btn:not(.on):hover { background: none; border-color: transparent; }
  .tcard:hover { transform: none; border-color: var(--line); background: var(--panel); }
  .parts li button:not(.on):hover, .cat > button:hover, .cat li a:not(.on):hover { background: none; }
  .vid:hover .th img { transform: none; }
  .btn:active, .tcard:active, .vid:active, .parts li button:active, .cat li a:active, .mbar button:active { opacity: .65; }
}
@media (max-width: 480px) { .tgrid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ── 틀린 곳 알리기 · 작성 방식 밝힘 ── */
.rfoot { flex-wrap: wrap; }
.report { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(0,0,0,.72); padding: 16px; }
.report[hidden] { display: none; }
.report .box { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; padding: 20px 20px 16px; }
.report h2 { margin: 0 0 4px; font-size: 18px; }
.report .rp-where { margin: 0 0 14px; color: var(--sub); font-size: 13px; }
.report fieldset { border: 0; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.report legend { font-size: 13px; color: var(--sub); margin-bottom: 6px; padding: 0; }
.report fieldset label { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r); font-size: 14px; cursor: pointer; }
.report fieldset label:has(input:checked) { border-color: var(--gold); color: var(--gold); }
.report fieldset input { accent-color: var(--gold); margin: 0; }
.report .rp-l { display: block; font-size: 13px; color: var(--sub); margin-bottom: 10px; }
.report textarea { display: block; width: 100%; margin-top: 4px; resize: vertical; font: inherit; font-size: 14px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; }
.report textarea:focus { outline: none; border-color: var(--gold-d); }
.report .rp-note { margin: 4px 0 0; color: var(--faint); font-size: 12px; }
.report .rp-msg { min-height: 20px; margin: 6px 0; font-size: 13px; color: var(--gold); }
.report .rp-act { display: flex; justify-content: flex-end; gap: 6px; }
.report .rp-act .btn { min-width: 84px; }
.ainote { margin: 22px 0 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-2); color: var(--sub); font-size: 12.5px; line-height: 1.6; }
.ainote b { display: block; color: var(--text); font-size: 13px; margin-bottom: 2px; }
.ainote span { display: block; color: var(--faint); margin-top: 4px; }
@media (max-width: 900px), (max-height: 520px) and (pointer: coarse) {
  .report { align-items: end; padding: 0; }
  .report .box { width: 100%; max-height: 92dvh; border-radius: 14px 14px 0 0; padding: 18px 16px calc(14px + env(safe-area-inset-bottom)); }
  .report fieldset label { font-size: 13px; padding: 6px 9px; }
}

/* 폰: 머리의 로고·분야 글자는 보이는 크기가 작다 — 누르는 자리만 넓힘 */
@media (pointer: coarse) {
  .fsb-logo, .fsb-field { position: relative; }
  .fsb-logo::after { content: ''; position: absolute; inset: -8px -8px -3px; }
  .fsb-field::after { content: ''; position: absolute; inset: -3px -8px -8px; }
}
