/* 글자공장 — 초등 4학년이 크롬북과 휴대폰에서 쓰는 화면.
   글자와 버튼을 크게, 한 화면에 한 단계씩. */

:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #1d2330;
  --muted: #667085;
  --line: #e3e7ef;
  --brand: #3b5bdb;
  --brand-ink: #ffffff;
  --good: #2b8a3e;
  --warn: #b35309;
  --warn-bg: #fff7ed;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 6px 20px rgba(16, 24, 40, .05);
  --ts: 1;                         /* 글씨 크기 배율 — 오른쪽 아래 '가+' 버튼이 바꾼다 */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 20px 48px;            /* 좁은 화면에서 좌우 여백 확보 */
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  font-size: calc(18px * var(--ts));
  line-height: 1.65;
  overflow-x: hidden;
}

/* TV 와 크롬북에서 좌우가 너무 비어 보이지 않게 넓게 쓴다. */
main, .top, .foot { max-width: 1180px; margin: 0 auto; }

/* ---- 표지 (수업 첫 슬라이드) ---- */

/* 제목은 이 공장에 들어 있는 글씨체로 찍는다. 제목 자체가 오늘의 예시가 된다.
   swap 이라 글씨체가 늦게 와도 글자는 바로 보인다. */
@font-face {
  font-family: 'PosterKR';
  src: url('../fonts/black-han-sans.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

.top { padding: 20px 0 0; }
.hero {
  --ts: 1;                         /* 표지는 이미 슬라이드 크기라 배율을 따르지 않는다 */
  position: relative; overflow: hidden;
  border-radius: 22px;
  padding: clamp(34px, 6vw, 70px) clamp(20px, 4vw, 56px);
  min-height: clamp(360px, 58vh, 620px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; text-align: center;
  background:
    radial-gradient(120% 130% at 12% 0%, #4c6ef5 0%, #3b5bdb 45%, #24327a 100%);
  box-shadow: 0 12px 40px rgba(36, 50, 122, .3);
}

/* 공장 도면 같은 잔 격자 + 커다란 물음표 */
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .07) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(120% 90% at 50% 40%, #000 30%, transparent 78%);
}
.hero::after {
  content: '?';
  position: absolute; right: -2%; bottom: -30%;
  font-family: 'PosterKR', system-ui, sans-serif;
  font-size: calc((clamp(280px, 46vw, 620px)) * var(--ts)); line-height: 1;
  color: rgba(255, 255, 255, .08);
  pointer-events: none; user-select: none;
}
.hero > * { position: relative; z-index: 1; }

.hero-kicker {
  margin: 0 0 clamp(10px, 1.6vw, 18px);
  font-size: calc((clamp(13px, 1.7vw, 18px)) * var(--ts)); font-weight: 700;
  letter-spacing: .16em; color: #c3cfff;
}
.hero h1 {
  margin: 0; line-height: .95; letter-spacing: -.01em;
  font-family: 'PosterKR', system-ui, sans-serif;
  font-size: calc((clamp(64px, 16vw, 168px)) * var(--ts)); font-weight: 400;
  text-shadow: 0 6px 26px rgba(0, 0, 0, .28);
}
.hero h1 span { color: #ffd43b; }          /* 공장 쪽만 노랗게 */

.hero .big-q {
  margin: clamp(16px, 2.6vw, 30px) 0 0; color: #eef2ff;
  font-size: calc((clamp(21px, 3.6vw, 40px)) * var(--ts)); font-weight: 800; line-height: 1.3;
}
.hero .big-q b { color: #ffd43b; }
.hero .big-q .qm {
  font-family: 'PosterKR', system-ui, sans-serif;
  font-size: 1.5em; color: #ffd43b; line-height: 0; vertical-align: -.12em;
  margin-left: .06em;
}

/* 내 이름 ▸ PNG JPG SVG ▸ 틴커캐드 — 무엇을 만드는 공장인지 한눈에 */
.hero-line {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: 9px; margin-top: clamp(22px, 3.2vw, 38px);
}
.hero-line .chip {
  padding: 9px 18px; border-radius: 999px; font-weight: 800;
  font-size: calc((clamp(14px, 1.9vw, 20px)) * var(--ts));
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .28);
}
.hero-line .chip-svg { background: #ffd43b; color: #24327a; border-color: #ffd43b; }
.hero-line .chip-in, .hero-line .chip-out { background: rgba(255, 255, 255, .24); }
.hero-line .arrow { color: #c3cfff; font-size: calc((clamp(15px, 2vw, 22px)) * var(--ts)); }

.lead { margin: 8px 0 0; color: var(--muted); }

.field-label { display: block; font-weight: 700; margin-bottom: 8px; }
.card.act > p { margin: 0 0 12px; }
.card h3 { margin: 20px 0 10px; font-size: calc((19px) * var(--ts)); }

/* 발견한 것을 정리해 주는 칸 */
.discover {
  margin-top: 16px; padding: 14px 16px;
  background: #f3f6ff; border: 1px solid #dbe3fb; border-radius: 12px;
}
.discover h3 { margin: 0 0 10px; font-size: calc((19px) * var(--ts)); color: var(--brand); }
.discover p { margin: 0 0 10px; }
.discover p:last-child { margin-bottom: 0; }
/* ---- 글자 친구 옷 갈아입히기 ----
   "폰트 = 옷" 을 말로만 하면 안 남는다. 글자에 눈을 달아 캐릭터로 만들고,
   글씨체를 고르면 그 자리에서 갈아입게 한다. 고른 옷은 옷장에 모인다. */
.dressup {
  display: grid; grid-template-columns: minmax(230px, 300px) 1fr; gap: 18px;
  margin: 4px 0 16px;
}

.stage {
  position: relative; overflow: hidden;
  border-radius: 18px; padding: 18px 14px 14px;
  background: linear-gradient(180deg, #fff6d8 0%, #ffe6f2 55%, #e7ecff 100%);
  border: 2px solid #ffd9ec;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  min-height: 268px;
}
/* 무대 조명 */
.stage-lights {
  position: absolute; inset: -30% -20% auto; height: 150%;
  background:
    radial-gradient(45% 55% at 25% 0%, rgba(255, 255, 255, .85), transparent 70%),
    radial-gradient(45% 55% at 75% 0%, rgba(255, 255, 255, .7), transparent 70%);
  pointer-events: none;
}
.stage > * { position: relative; }

.char { display: flex; flex-direction: column; align-items: center; }
.char-body {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  animation: char-idle 3.2s ease-in-out infinite;
}
.char-glyph {
  font-size: calc((clamp(88px, 13vw, 126px)) * var(--ts)); line-height: 1.05; color: #2b2f3a;
  display: block;
}
/* 눈 — 글자 위쪽에 얹어 캐릭터처럼 보이게 */
.face {
  position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%);
  display: flex; gap: 14px; pointer-events: none;
}
.eye {
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; border: 2.5px solid #2b2f3a;
  display: grid; place-items: center;
  animation: blink 4.6s infinite;
}
.eye i { width: 9px; height: 9px; border-radius: 50%; background: #2b2f3a; display: block; }
.blush {
  position: absolute; top: 47%; width: 16px; height: 9px; border-radius: 50%;
  background: rgba(255, 130, 160, .75); pointer-events: none;
}
.blush-l { left: 16%; }
.blush-r { right: 16%; }
.char-shadow {
  width: 108px; height: 14px; border-radius: 50%; margin-top: 6px;
  background: rgba(60, 40, 90, .17); filter: blur(2px);
  animation: shadow-idle 3.2s ease-in-out infinite;
}

.speech {
  margin: 12px 0 0; padding: 8px 14px; border-radius: 999px;
  background: #fff; border: 2px solid #ffd9ec; color: #6b3a52;
  font-size: calc((15px) * var(--ts)); font-weight: 700; text-align: center;
}
.stage-tag {
  margin: 8px 0 0; font-size: calc((13px) * var(--ts)); font-weight: 800; color: #8a6d9b;
  background: rgba(255, 255, 255, .7); padding: 3px 12px; border-radius: 999px;
}

/* 갈아입을 때 — 폴짝 뛰고 반짝 */
.char.is-changing .char-body { animation: char-hop .55s cubic-bezier(.3, 1.4, .5, 1); }
.stage.is-changing::after {
  content: '✨'; position: absolute; top: 14%; left: 50%;
  font-size: calc((40px) * var(--ts)); animation: sparkle .7s ease-out forwards; pointer-events: none;
}
@keyframes char-idle { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes shadow-idle { 0%, 100% { transform: scale(1); opacity: .17; } 50% { transform: scale(.86); opacity: .12; } }
@keyframes char-hop {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-26px) scale(1.06, .94); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes sparkle {
  0% { opacity: 0; transform: translate(-50%, 6px) scale(.6) rotate(-16deg); }
  40% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -34px) scale(1.25) rotate(14deg); }
}
@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(.12); }
}

/* ---- 옷장 ---- */
.dress-lead { margin: 0 0 14px; }
.wardrobe-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin: 0 0 10px;
}
.wardrobe-title { font-weight: 800; font-size: calc((17px) * var(--ts)); }
.wardrobe-count { font-size: calc((14px) * var(--ts)); color: var(--muted); }
.wardrobe-count b { color: var(--brand); font-size: calc((18px) * var(--ts)); }

.font-zoo {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start;
  min-height: 96px;
}
.font-zoo:empty::before {
  content: '글씨체를 누르면 옷이 하나씩 모여요';
  color: var(--muted); font-size: calc((15px) * var(--ts));
}
.zoo-item {
  position: relative; width: 82px; padding: 10px 6px 7px; border-radius: 14px;
  text-align: center; background: #fff; border: 2px solid #e7ecff;
  font: inherit; color: inherit; cursor: pointer; display: block;
  animation: zoo-in .3s ease;
  transition: transform .12s ease, border-color .12s ease;
}
.zoo-item:hover { transform: translateY(-3px); border-color: #c9d4f5; }
.zoo-item:active { transform: translateY(0) scale(.96); }
.zoo-item:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.zoo-item::before {                 /* 옷걸이 고리 */
  content: ''; position: absolute; top: -7px; left: 50%; transform: translateX(-50%);
  width: 16px; height: 9px; border: 2.5px solid #c9d4f5; border-bottom: 0;
  border-radius: 9px 9px 0 0;
}
.zoo-item.is-now { border-color: var(--brand); background: #f3f6ff; }
.zoo-item.is-now::before { border-color: var(--brand); }
.zoo-glyph { display: block; font-size: calc((36px) * var(--ts)); line-height: 1.15; color: var(--ink); overflow: hidden; white-space: nowrap; }
.zoo-name { display: block; font-size: calc((11px) * var(--ts)); color: var(--muted); margin-top: 2px; }
@keyframes zoo-in { from { opacity: 0; transform: translateY(8px) scale(.85); } }

@media (max-width: 720px) {
  .dressup { grid-template-columns: 1fr; }
  .stage { min-height: 236px; }
}

.fact-line {
  font-weight: 700; font-size: calc((19px) * var(--ts)); padding: 14px 16px; border-radius: 10px;
  background: #fff; border: 1px solid #dbe3fb;
}

/* 이 수업에서 숫자는 두 갈래뿐이다: 네모 칸(주황)과 점(초록).
   어디서 보든 같은 색이어야 아이들이 두 방식을 색으로 구분한다. */
.hl-cell, .hl-dot { font-weight: 800; font-variant-numeric: tabular-nums; }
.hl-cell { color: var(--warn); }
.hl-dot { color: var(--good); }
.fact-line .hl-cell, .fact-line .hl-dot { font-size: 1.25em; }
.found { margin: 0; padding-left: 20px; }
.found li { margin: 9px 0; }

/* ---- 두 가지 방법으로 그려 보기 ---- */
.lab2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin: 14px 0; }
.lab-panel {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fff;
  display: flex; flex-direction: column;
}
.lab-panel h3 { margin: 0 0 12px; font-size: calc((19px) * var(--ts)); }
.lab-stage {
  aspect-ratio: 1; max-width: 400px; margin-inline: auto; width: 100%;
  border-radius: 10px; overflow: hidden; background: #fff;
  border: 1px solid var(--line); display: grid; place-items: center;
}
.lab-stage canvas { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
.lab-do {
  margin: 0 0 10px; font-size: calc((15px) * var(--ts)); font-weight: 700; color: var(--brand);
  background: #eef2ff; border-radius: 999px; padding: 6px 14px; align-self: flex-start;
}
.lab-note { margin: 10px 0 0; font-size: calc((16px) * var(--ts)); color: var(--muted); }

/* 얼마나 칠했는지 / 모았는지 */
.lab-bar {
  margin-top: 12px; height: 10px; border-radius: 999px;
  background: #eef1f7; overflow: hidden;
}
.lab-fill {
  display: block; height: 100%; width: 0%; border-radius: 999px;
  background: var(--warn); transition: width .18s ease;
}
.lab-fill.is-dot { background: var(--good); }

.lab-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.lab-tools .zoom-ctl { margin-top: 0; flex: 1 1 160px; }
.lab-tools .btn { margin-top: 0; padding: 9px 14px; font-size: calc((15px) * var(--ts)); }


/* ---- 살펴보기 미션 ---- */
.mission {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 14px 0; padding: 12px 16px;
  border: 2px dashed #c9d4f5; border-radius: 12px; background: #f7f9ff;
  font-size: calc((15px) * var(--ts));
}
.mission.done { border-style: solid; border-color: #b7e4c7; background: #f1fbf4; }
.mission-label {
  background: #eef2ff; color: var(--brand); font-weight: 800; font-size: calc((13px) * var(--ts));
  padding: 3px 10px; border-radius: 999px;
}
.mission.done .mission-label { background: #d8f3e0; color: var(--good); }
.mission-text { flex: 1; min-width: 180px; }
.mission-dots { font-size: calc((18px) * var(--ts)); letter-spacing: 3px; color: var(--brand); }
.mission.done .mission-dots { color: var(--good); }

/* ---- 퀴즈 ---- */
.quiz {
  margin: 4px 0 8px; padding: 18px;
  border: 2px solid #dbe3fb; border-radius: 14px;
  background: linear-gradient(180deg, #f7f9ff, #fff);
}
.quiz-head { display: flex; align-items: center; gap: 10px; font-size: calc((14px) * var(--ts)); color: var(--muted); }
.quiz-badge {
  background: var(--brand); color: #fff; font-weight: 800; font-size: calc((13px) * var(--ts));
  padding: 3px 10px; border-radius: 999px; letter-spacing: .04em;
}
.quiz .ask { margin: 10px 0 14px; font-size: calc((clamp(18px, 4.2vw, 23px)) * var(--ts)); font-weight: 800; }

.predict-btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.predict-btn {
  position: relative; cursor: pointer; font: inherit; color: inherit; text-align: left;
  background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 14px;
  display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center;
  transition: transform .12s ease, border-color .12s ease;
}
.predict-btn:hover:not(:disabled) { transform: translateY(-2px); border-color: #c3ccdd; }
.predict-btn:disabled { cursor: default; }
.opt-no {
  grid-row: span 2; width: 30px; height: 30px; border-radius: 50%;
  background: #eef2ff; color: var(--brand); font-weight: 800;
  display: grid; place-items: center;
}
.opt-name { font-size: calc((19px) * var(--ts)); font-weight: 800; }
.opt-sub { font-size: calc((12px) * var(--ts)); color: var(--muted); }
.opt-mark { position: absolute; top: 8px; right: 10px; font-size: calc((20px) * var(--ts)); }

.predict-btn.picked { border-color: var(--brand); background: #f3f6ff; }
.predict-btn.is-right { border-color: var(--good); background: #eefaf1; }
.predict-btn.is-wrong { border-color: #e5484d; background: #fdf1f1; }

.predict-result { margin: 16px 0 0; padding: 14px 16px; border-radius: 12px; font-weight: 700; font-size: calc((17px) * var(--ts)); }
.predict-result.right { background: #e9f8ee; border: 1px solid #b7e4c7; color: var(--good); }
.predict-result.wrong { background: var(--warn-bg); border: 1px solid #fed7aa; color: var(--warn); }

/* ---- 따라 그린 점 보여 주기 ---- */
.dots { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.dots figure { margin: 0; }
.dots .box { aspect-ratio: 1; max-width: 420px; margin-inline: auto; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.dots canvas { width: 100%; height: 100%; display: block; }
.dots figcaption { margin-top: 8px; text-align: center; }
.dots .n { font-size: calc((34px) * var(--ts)); font-weight: 800; font-variant-numeric: tabular-nums; display: block; }
.dots .n.bad { color: var(--warn); }
.dots .n.ok { color: var(--good); }
.dots .what { font-size: calc((13px) * var(--ts)); color: var(--muted); }

/* 정리 */
.wrapup { background: #f9fbff; }
.learned { margin: 0 0 12px; padding-left: 22px; }
.learned li { margin: 8px 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 26px;
  margin: 18px 0;
}
.card h2 { margin: 0 0 14px; font-size: calc((23px) * var(--ts)); display: flex; align-items: center; gap: 12px; }

.num {
  flex: none;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand); color: var(--brand-ink);
  font-size: calc((18px) * var(--ts)); font-weight: 800;
  display: grid; place-items: center;
}

.hint { margin: 10px 0 0; color: var(--muted); font-size: calc((15px) * var(--ts)); }
.muted { color: var(--muted); }

.warn {
  margin: 12px 0 0; padding: 10px 12px;
  background: var(--warn-bg); border: 1px solid #fed7aa; border-radius: 10px;
  color: var(--warn); font-size: calc((14px) * var(--ts));
}

/* ---- 1. 글자 입력 ---- */
.text-input {
  width: 100%; padding: 14px 16px;
  font-size: calc((28px) * var(--ts)); font-weight: 700;
  border: 2px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink);
}
.text-input:focus { outline: none; border-color: var(--brand); }

/* ---- 2. 폰트 고르기 ---- */
.font-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 12px; }
.font-btn {
  padding: 12px; text-align: left; cursor: pointer;
  background: #fff; border: 2px solid var(--line); border-radius: 12px;
  font: inherit; color: inherit;
}
.font-btn:hover { border-color: #c3ccdd; }
.font-btn[aria-pressed="true"] { border-color: var(--brand); background: #f3f6ff; }
.font-btn .sample { font-size: calc((26px) * var(--ts)); line-height: 1.3; font-weight: 700; }
.font-btn .desc { font-size: calc((12px) * var(--ts)); color: var(--muted); margin-top: 2px; }
.font-btn .tag { font-size: calc((12px) * var(--ts)); margin-top: 4px; }
.font-btn.is-local { border-style: dashed; }
.local-font { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
/* 선생님 페이지 */
.btn-lg { padding: 14px 22px; font-size: calc((17px) * var(--ts)); }
.unlock-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin: 14px 0 4px;
  padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fafbfe;
}
.unlock-state { font-size: calc((20px) * var(--ts)); font-weight: 800; }
.unlock-state.is-on { color: var(--good); }
.unlock-state.is-off { color: var(--muted); }
.tag.good { color: var(--good); }
.tag.ok { color: var(--muted); }
.tag.warn { color: var(--warn); }

/* ---- 미리보기 (화면 위에 붙어 있는 띠) ---- */
/* 글씨체를 고르는 동안 늘 보여야 하므로 카드가 아니라 sticky 띠로 둔다. */
/* 글씨체를 고르는 동안에만 따라오면 된다. 감싼 칸이 끝나면 sticky 도 끝난다. */
.pick-zone { position: relative; }
.preview-bar {
  position: sticky; top: 0; z-index: 5;
  margin: 16px 0;
  padding: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.preview-cap {
  margin: 8px 2px 0; font-size: calc((13px) * var(--ts)); color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#preview-font { font-weight: 700; color: var(--ink); }

.preview {
  height: 150px; padding: 10px; border-radius: 10px;
  display: grid; place-items: center; overflow: auto;
  border: 1px solid var(--line);
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e9edf5 25%, transparent 25%, transparent 75%, #e9edf5 75%),
    linear-gradient(45deg, #e9edf5 25%, transparent 25%, transparent 75%, #e9edf5 75%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}
.preview img, .preview canvas { max-width: 100%; max-height: 100%; width: auto; height: auto; }

/* 화면이 짧으면 띠를 줄여 글씨체 목록이 더 보이게 한다 */
@media (max-height: 700px) { .preview { height: 104px; } }

/* ---- 4. 파일 카드 ---- */
.files { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.file {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.file.is-pick { border-color: var(--brand); background: #f3f6ff; }
.file .ext { font-size: calc((20px) * var(--ts)); font-weight: 800; letter-spacing: .02em; }
.file .why { font-size: calc((13px) * var(--ts)); color: var(--muted); min-height: 3.2em; }
.file .meta { font-size: calc((12px) * var(--ts)); color: var(--muted); font-variant-numeric: tabular-nums; }
.file .pick { font-size: calc((12px) * var(--ts)); font-weight: 700; color: var(--brand); }

.btn {
  padding: 12px 16px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 700; cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }

/* ---- 돋보기 ---- */
.lens-wrap {
  position: relative; margin: 12px auto 0;
  height: 300px;                   /* 가로는 글자 비율(JS 가 aspect-ratio 를 넣는다)로 정해진다 */
  border: 1px solid var(--line); border-radius: 12px;
  background-repeat: no-repeat; background-position: center; background-size: 100% 100%;
  background-color: #fff;
  cursor: crosshair;
  touch-action: none;              /* 터치로 끌 때 화면이 같이 스크롤되지 않게 */
  overflow: hidden;                /* 돋보기 바깥을 덮는 장막이 페이지로 번지지 않게 */
}
.lens {
  position: absolute; left: 0; top: 0;
  border: 3px solid var(--brand); border-radius: 6px;
  background: rgba(59, 91, 219, .08);
  box-shadow: 0 0 0 9999px rgba(255, 255, 255, .6);   /* 돋보기 바깥을 흐리게 */
  pointer-events: none;            /* 끌기는 바깥 판이 받는다 */
}
.lens:focus-visible { outline: 3px solid var(--warn); outline-offset: 2px; }

.zoom-ctl { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: calc((14px) * var(--ts)); }
.zoom-ctl input[type="range"] { flex: 1; max-width: 320px; accent-color: var(--brand); }
.zoom-ctl output { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.5em; }

.zoom { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-top: 14px; }
.zoom figure { margin: 0; }
.zoom-frame {
  aspect-ratio: 1; max-width: 340px; margin-inline: auto; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e9edf5 25%, transparent 25%, transparent 75%, #e9edf5 75%),
    linear-gradient(45deg, #e9edf5 25%, transparent 25%, transparent 75%, #e9edf5 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}
.zoom-img { width: 100%; height: 100%; background-repeat: no-repeat; }
/* 픽셀 그림은 늘렸을 때 계단이 보이도록 부드럽게 펴지 않는다 */
.zoom-img.px { image-rendering: pixelated; }
.zoom figcaption { font-size: calc((13px) * var(--ts)); color: var(--muted); margin-top: 6px; }
.zoom figcaption b { color: var(--ink); }

/* ---- 따라 그리기 체험 ---- */
.trace-out { margin-top: 14px; }
.trace-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.trace-grid .box { height: 160px; border: 1px solid var(--line); border-radius: 10px; display: grid; place-items: center; background: #fff; }
.count { font-size: calc((26px) * var(--ts)); font-weight: 800; font-variant-numeric: tabular-nums; }
.count.bad { color: var(--warn); }
.count.ok { color: var(--good); }

.steps { margin: 0; padding-left: 22px; }
.steps li { margin: 6px 0; }
.howto { background: #f9fbff; }

.foot { color: var(--muted); font-size: calc((13px) * var(--ts)); text-align: center; padding-top: 8px; }

/* ---- 학습지 (화면에는 안 보이고 인쇄할 때만) ---- */
.worksheet { display: none; }

@media print {
  :root { --ts: 1; }          /* 학습지는 화면 배율과 상관없이 늘 같은 크기 */
  body { padding: 0; background: #fff; }
  .top, main, .foot, .ts-fab { display: none !important; }

  .worksheet { display: block; max-width: none; color: #000; font-size: calc((12pt) * var(--ts)); }
  .worksheet h1 { margin: 0 0 2mm; font-size: calc((20pt) * var(--ts)); }
  .worksheet h2 { margin: 6mm 0 2mm; font-size: calc((13pt) * var(--ts)); border-bottom: 1px solid #000; padding-bottom: 1mm; }
  .worksheet p { margin: 2mm 0; line-height: 1.9; }
  .ws-sub { font-size: calc((13pt) * var(--ts)); font-weight: bold; }
  .ws-name { margin-bottom: 4mm; }
  .ws-answer { font-weight: bold; }
  .ws-table { width: 100%; border-collapse: collapse; margin: 2mm 0 3mm; }
  .ws-table th, .ws-table td {
    border: 1px solid #000; padding: 2.5mm 3mm; text-align: left; font-size: calc((11pt) * var(--ts));
  }
  .ws-table th { background: #f0f0f0; width: 40%; font-weight: bold; }
  /* 세 칸짜리 표는 첫 칸만 좁게 두고 나머지를 넓게 쓴다 */
  .ws-table.three th { width: 20%; }
  .ws-table.three td { height: 11mm; }
  @page { margin: 14mm; }
}

@media (max-width: 480px) {
  body { padding: 0 12px 40px; }
  .card { padding: 16px 14px; }
  .card h2 { font-size: calc((20px) * var(--ts)); }
  .text-input { font-size: calc((24px) * var(--ts)); }
}

/* ---- 마무리 문제 슬라이드 (선생님 페이지 전용) ----
   TV 에 띄우고 다 같이 푼다. 한 화면에 한 문제, 피피티 슬라이드처럼 크게.
   글자 크기는 모두 화면 크기(vmin)를 따라가서 55인치 TV 에서도 크롬북에서도 꽉 찬다. */
body.slides-open { overflow: hidden; }

.slides {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column;
  padding: clamp(14px, 2.4vw, 34px);
  color: #fff; text-align: center;
  background: radial-gradient(120% 130% at 12% 0%, #4c6ef5 0%, #3b5bdb 45%, #24327a 100%);
  overflow-y: auto;
}
.slides[hidden] { display: none; }

.slide-bar {
  flex: none; display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap; justify-content: space-between;
}
.slide-step { font-size: calc((clamp(14px, 1.6vw, 20px)) * var(--ts)); font-weight: 800; opacity: .85; letter-spacing: .04em; }
.slide-dots { display: inline-flex; gap: 8px; }
.slide-dots span {
  width: 12px; height: 12px; border-radius: 50%;
  background: rgba(255, 255, 255, .28);
}
.slide-dots span.on { background: #ffd43b; }
.slide-dots span.now { background: #fff; box-shadow: 0 0 0 4px rgba(255, 255, 255, .22); }
.slide-bar-btns { display: inline-flex; gap: 8px; }
.slide-bar-btns .btn { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .3); color: #fff; }

.slide-body {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  gap: clamp(18px, 3vh, 36px);
  max-width: 1400px; width: 100%; margin: 0 auto;
  padding: clamp(10px, 3vh, 30px) 0;
}

.slide-ask {
  margin: 0 0 clamp(18px, 3.5vh, 44px);
  font-size: calc((clamp(30px, 5.6vmin, 76px)) * var(--ts)); line-height: 1.25; font-weight: 800;
  word-break: keep-all;            /* 좁은 화면에서 낱말 가운데가 끊기지 않게 */
  text-shadow: 0 4px 18px rgba(16, 24, 40, .25);
}
.slide-ask b { color: #ffd43b; }

.slide-choices {
  display: grid; gap: clamp(12px, 1.6vw, 22px);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
}
.slide-choice {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: clamp(16px, 2.6vmin, 34px) 14px;
  border: 3px solid rgba(255, 255, 255, .35); border-radius: 20px;
  background: rgba(255, 255, 255, .12); color: #fff;
  font: inherit; cursor: pointer;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.slide-choice:hover:not(:disabled) { transform: translateY(-3px); background: rgba(255, 255, 255, .2); }
.slide-choice:disabled { cursor: default; }
.slide-no {
  display: grid; place-items: center;
  width: clamp(28px, 3.4vmin, 44px); height: clamp(28px, 3.4vmin, 44px);
  border-radius: 50%; background: rgba(255, 255, 255, .25);
  font-size: calc((clamp(14px, 1.9vmin, 22px)) * var(--ts)); font-weight: 800;
}
.slide-name { font-size: calc((clamp(26px, 4.6vmin, 58px)) * var(--ts)); font-weight: 800; line-height: 1.2; }
.slide-sub { font-size: calc((clamp(13px, 1.8vmin, 22px)) * var(--ts)); opacity: .8; }
/* 정답은 멀리서도 한눈에 보이게 통째로 노란 카드가 된다. */
.slide-choice.is-right {
  border-color: #fff; background: #ffd43b; color: #24327a;
  transform: translateY(-4px); box-shadow: 0 10px 26px rgba(16, 24, 40, .3);
}
.slide-choice.is-right .slide-no { background: rgba(36, 50, 122, .18); }
.slide-choice.is-right .slide-sub { opacity: .7; }
.slide-choice.is-wrong { border-color: #fff; background: #ff8787; color: #4a0f0f; }
.slide-choice.is-wrong .slide-no { background: rgba(74, 15, 15, .18); }
.slide-choice.is-dim { opacity: .4; }
.slide-mark {
  position: absolute; top: clamp(-20px, -2.4vmin, -12px); right: -8px;
  font-size: calc((clamp(30px, 4.4vmin, 56px)) * var(--ts));
  filter: drop-shadow(0 3px 6px rgba(16, 24, 40, .35));
}

.slide-why {
  margin: clamp(16px, 3vh, 34px) auto 0; max-width: 1000px;
  padding: clamp(12px, 2vmin, 22px) clamp(14px, 2.4vw, 28px);
  border-radius: 16px; background: rgba(255, 255, 255, .14);
  font-size: calc((clamp(17px, 2.6vmin, 32px)) * var(--ts)); line-height: 1.5; word-break: keep-all;
}
.slide-why b { color: #ffd43b; }

.slide-score { margin: 0; font-size: calc((clamp(56px, 13vmin, 170px)) * var(--ts)); font-weight: 800; line-height: 1; }
.slide-score b { color: #ffd43b; }
.slide-word { margin: clamp(10px, 2vh, 22px) 0 0; font-size: calc((clamp(18px, 2.8vmin, 34px)) * var(--ts)); }
.slide-recap {
  list-style: none; margin: clamp(18px, 3vh, 34px) auto 0; padding: 0;
  max-width: 900px; text-align: left;
}
.slide-recap li {
  margin: 8px 0; padding: clamp(9px, 1.4vmin, 16px) 16px;
  border-radius: 12px; background: rgba(255, 255, 255, .12);
  font-size: calc((clamp(15px, 2.1vmin, 26px)) * var(--ts)); word-break: keep-all;
}
.slide-recap li.no { background: rgba(255, 135, 135, .2); }
.slide-recap b { color: #ffd43b; }

.slide-foot { flex: none; display: flex; justify-content: center; gap: 12px; min-height: 52px; }
.slide-foot .btn-ghost { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .3); color: #fff; }
.slide-foot .btn-primary { background: #ffd43b; color: #24327a; }
.slide-foot .btn { font-size: calc((clamp(16px, 2.2vmin, 26px)) * var(--ts)); padding: clamp(11px, 1.6vmin, 18px) clamp(20px, 3vw, 34px); }

/* ---- 글씨 크기 버튼 (오른쪽 아래 고정) ----
   이 버튼만은 배율을 따르지 않는다. 글씨를 키우면 버튼이 화면을 가려 버린다. */
.ts-fab {
  position: fixed; right: 14px; bottom: 14px; z-index: 70;
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--line);
  box-shadow: 0 6px 22px rgba(16, 24, 40, .18);
  font-family: system-ui, -apple-system, 'Segoe UI', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
}
.ts-now {
  min-width: 62px; text-align: center; white-space: nowrap;
  font-size: 13px; font-weight: 700; color: var(--muted);
}
.ts-btn {
  display: inline-flex; align-items: baseline; justify-content: center;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-family: inherit; font-size: 17px; font-weight: 800; line-height: 1;
  cursor: pointer;
}
.ts-btn small { font-size: 13px; margin-left: 1px; }
.ts-btn.ts-up { background: var(--brand); border-color: var(--brand); color: #fff; font-size: 21px; }
.ts-btn.ts-up small { font-size: 15px; }
.ts-btn:disabled { opacity: .4; cursor: default; }
.ts-btn:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

@media (max-width: 420px) {
  .ts-fab { right: 10px; bottom: 10px; padding: 6px 8px; gap: 4px; }
  .ts-now { display: none; }          /* 좁은 화면에서는 버튼만 */
  .ts-btn { width: 38px; height: 38px; }
}
