/* 영어 활동 화면: 주제 고르기, 그림 그리기, 대화, 마무리, 작품집 */
:root { --en-font: 'Nunito', 'Segoe UI', Roboto, sans-serif; }

/* 주제 고르기 */
.topic-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.topic-card {
  background: var(--surface); border: 3px solid transparent; border-radius: 24px; padding: 28px 22px;
  display: flex; flex-direction: column; gap: 6px; text-align: left; box-shadow: 0 2px 0 var(--line);
}
.topic-card:active { border-color: var(--kid); transform: scale(.98); }
.topic-card.unit-card { grid-column: 1 / -1; background: var(--kid-soft); border-color: var(--kid); }
.t-badge { align-self: flex-start; background: var(--kid); color: #fff; border-radius: 999px; padding: 2px 12px; font-size: 15px; }
.unit-card .t-ko { font-family: var(--en-font); font-weight: 800; color: var(--kid); }
.t-words { font-family: var(--en-font); font-weight: 600; font-size: 18px; color: var(--muted); }
.targets { background: var(--good-soft); color: var(--good); border-radius: 14px; padding: 10px 14px; width: 100%; }
.targets b { font-family: var(--en-font); }
.t-ko { font-family: var(--display); font-size: 30px; }
.t-en { font-family: var(--en-font); font-weight: 700; font-size: 19px; color: var(--kid); }

/* 그림 그리기 */
.en-draw { gap: 16px; }
.draw-body { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 20px; align-items: start; min-height: 0; }
.canvas-wrap { display: flex; justify-content: center; min-width: 0; }
#draw-canvas {
  display: block; width: auto; height: auto; max-width: 100%; max-height: calc(100vh - 150px);
  background: #fff; border-radius: 18px; box-shadow: 0 0 0 3px var(--line); touch-action: none; cursor: crosshair;
}
.toolbar { display: flex; flex-direction: column; gap: 16px; }
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.swatch {
  aspect-ratio: 1; border-radius: 50%; background: var(--c); border: 4px solid var(--surface);
  box-shadow: 0 0 0 2px var(--line); padding: 0;
}
.swatch.on { box-shadow: 0 0 0 5px var(--kid); }
.sizes { display: flex; gap: 10px; }
.size-btn {
  flex: 1; height: 64px; border-radius: 16px; background: var(--surface); border: 3px solid var(--line);
  display: grid; place-items: center;
}
.size-btn span { display: block; border-radius: 50%; background: var(--ink); }
.size-btn.on { border-color: var(--kid); }
.tool-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tool-row .btn { min-height: 52px; font-size: 19px; padding: 0 16px; flex: 1; }
.btn.ghost.on { background: var(--kid-soft); border-color: var(--kid); color: var(--kid); }
.clear-confirm { background: var(--bad-soft); border-radius: 16px; padding: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.clear-confirm .btn { min-height: 48px; font-size: 18px; padding: 0 16px; }

/* 대화 */
.en-talk { height: 100vh; min-height: 0; gap: 14px; }
.en-timer { font-family: var(--display); font-size: 22px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; white-space: nowrap; }
.en-timer.reached { color: var(--good); }
.en-goal { background: var(--good-soft); color: var(--good); border-radius: 14px; padding: 10px 16px; text-align: center; font-size: 18px; }
.en-body { flex: 1; min-height: 0; display: flex; gap: 20px; }
.en-side { width: 300px; flex: none; display: flex; flex-direction: column; gap: 12px; }
.en-side img { width: 100%; border-radius: 16px; border: 3px solid var(--line); background: #fff; }
.en-log { flex: 1; min-width: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 4px 4px 12px; overscroll-behavior: contain; }
.en-wait { color: var(--muted); text-align: center; margin: auto; font-size: 20px; }

.bubble { max-width: min(78%, 760px); padding: 16px 20px; border-radius: 22px; display: flex; flex-direction: column; gap: 8px; }
.bubble.ai { align-self: flex-start; background: var(--surface); border-bottom-left-radius: 6px; }
.bubble.kid { align-self: flex-end; background: var(--kid-soft); border-bottom-right-radius: 6px; }
.bubble.kid > p { font-family: var(--en-font); font-weight: 600; font-size: 22px; }
.who { font-size: 14px; color: var(--kid); font-family: var(--en-font); font-weight: 700; }
.en-text { font-family: var(--en-font); font-weight: 600; font-size: 25px; line-height: 1.4; }
.ko-text { color: var(--muted); font-size: 19px; }
.mini { align-self: flex-start; background: none; border: none; color: var(--muted); font-size: 15px; padding: 2px 0; text-decoration: underline; text-underline-offset: 3px; }
.repeat, .new-word { border-radius: 14px; padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.repeat { background: var(--kid-soft); }
.new-word { background: var(--warn-soft); }
.repeat b, .new-word b { font-family: var(--en-font); font-weight: 800; font-size: 24px; }
.r-label { font-size: 15px; color: var(--muted); }
.r-ko { font-size: 16px; color: var(--muted); }
.fix { background: var(--surface); border-radius: 12px; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.fix-label { font-size: 14px; color: var(--muted); }
.fix b { font-family: var(--en-font); font-weight: 700; font-size: 20px; color: var(--good); }
.fix-tip { font-size: 15px; color: var(--muted); }
.poem { background: var(--warn-soft); border-radius: 18px; padding: 16px 20px; display: flex; flex-direction: column; gap: 6px; }
.poem p, .art-poem p { font-family: var(--en-font); font-weight: 600; font-size: 22px; line-height: 1.3; }
.poem p span, .art-poem p span { display: block; font-family: var(--body); font-weight: 400; font-size: 16px; color: var(--muted); }
.poem .poem-title, .art-poem .poem-title { font-weight: 800; font-size: 25px; margin-bottom: 4px; }
.poem-saved { font-family: var(--body) !important; font-size: 15px !important; color: var(--good) !important; }

.en-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.ctl-side { display: flex; gap: 10px; flex-wrap: wrap; }
.ctl-side.right { justify-content: flex-end; }
.mic {
  width: 150px; height: 150px; border-radius: 50%; border: none; background: var(--kid); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--display); font-size: 21px; box-shadow: 0 6px 0 rgba(0, 0, 0, .12); padding: 12px;
}
.mic:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0, 0, 0, .12); }
.mic:disabled { background: #C9D1DC; box-shadow: none; }
.mic-dot { width: 26px; height: 26px; border-radius: 50%; background: #fff; }
.mic.recording { background: var(--bad); animation: mic-pulse 1.2s ease-in-out infinite; }
.mic.recording .mic-dot { border-radius: 6px; }
.mic-label { line-height: 1.2; text-align: center; }
@keyframes mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(214, 69, 69, .45); } 50% { box-shadow: 0 0 0 18px rgba(214, 69, 69, 0); } }
.en-msg { text-align: center; color: var(--warn); min-height: 26px; font-size: 18px; }

/* 마무리 */
.word-list { list-style: none; margin: 4px 0 0; padding: 0; width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.word-list li { background: var(--bg); border-radius: 12px; padding: 8px 12px; display: flex; flex-direction: column; text-align: left; }
.word-list b { font-family: var(--en-font); font-weight: 700; font-size: 19px; }
.word-list span { color: var(--muted); font-size: 15px; }

/* 작품집 */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.art-card { background: var(--surface); border-radius: 20px; overflow: hidden; display: flex; flex-direction: column; }
.art-card img { display: block; width: 100%; background: #fff; }
.art-poem { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 6px; }
.art-date { font-family: var(--body) !important; font-size: 14px !important; color: var(--muted); }
.gallery-empty { color: var(--muted); text-align: center; padding: 60px 0; font-size: 20px; }

/* 부모 모드: 영어 목표 시간 */
.goal-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.goal-val { font-family: var(--display); font-size: 30px; min-width: 80px; text-align: center; font-variant-numeric: tabular-nums; }

/* 부모 모드: 이번 주 교재 */
.unit-title { font-family: var(--en-font); font-weight: 800; font-size: 22px; }
.word-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.word-chips span { background: var(--bg); border-radius: 999px; padding: 4px 12px; font-family: var(--en-font); font-weight: 600; font-size: 16px; }
.unit-patterns { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 2px; font-family: var(--en-font); font-size: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 16px; color: var(--muted); }
.field input, .field textarea {
  font: inherit; color: var(--ink); font-family: var(--en-font); font-size: 18px; padding: 10px 14px;
  border-radius: 12px; border: 2px solid var(--line); background: var(--bg); user-select: text; resize: vertical;
}
.file-btn { position: relative; overflow: hidden; cursor: pointer; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }

/* 부모 모드: 교재 진도 */
.btn.small { min-height: 44px; font-size: 17px; padding: 0 14px; }
.pace-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pace-row > span { color: var(--muted); font-size: 16px; margin-right: 4px; }
.unit-all summary { cursor: pointer; color: var(--kid); font-size: 17px; padding: 6px 0; }
.unit-list { margin: 6px 0 0; padding-left: 26px; display: flex; flex-direction: column; gap: 6px; }
.unit-list li { padding: 8px 10px; border-radius: 12px; }
.unit-list li > * { vertical-align: middle; }
.unit-list li.cur { background: var(--kid-soft); }
.unit-list li { display: list-item; }
.ul-text { display: inline-flex; flex-direction: column; min-width: 0; margin-right: 10px; }
.ul-text b { font-family: var(--en-font); font-weight: 800; }
.ul-text span { color: var(--muted); font-size: 15px; font-family: var(--en-font); }

/* 받아쓰기 */
.dict { gap: 16px; }
.dc-body { flex: 1; display: flex; flex-direction: column; gap: 18px; }
.dc-card { background: var(--surface); border-radius: 24px; padding: 22px 26px; display: flex; flex-direction: column; gap: 14px; }
.dc-guide { color: var(--muted); font-size: 20px; }
.dc-tools { display: flex; gap: 10px; flex-wrap: wrap; }
.dc-answer {
  min-height: 92px; border: 4px solid var(--kid); border-radius: 18px; padding: 10px 20px; display: flex; align-items: center;
  font-family: var(--en-font); font-weight: 800; font-size: clamp(40px, 5vw, 60px); letter-spacing: .04em; background: var(--surface);
}
.dc-answer.good { border-color: var(--good); background: var(--good-soft); color: var(--good); }
.dc-answer.bad { border-color: var(--bad); }
.dc-placeholder { color: var(--line); font-family: var(--body); font-weight: 400; font-size: 26px; letter-spacing: 0; }
.dc-caret { display: inline-block; width: 4px; height: 1em; background: var(--kid); margin-left: 4px; animation: dc-blink 1s step-end infinite; }
.dc-answer.good .dc-caret { display: none; }
@keyframes dc-blink { 50% { opacity: 0; } }
.dc-reveal { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; align-items: baseline; background: var(--warn-soft); border-radius: 18px; padding: 14px 20px; }
.dc-label { color: var(--muted); font-size: 16px; }
.dc-mine { font-family: var(--en-font); font-weight: 700; font-size: 32px; text-decoration: line-through; color: var(--muted); }
.dc-correct { font-family: var(--en-font); font-weight: 800; font-size: 48px; letter-spacing: .05em; }
.dc-correct .ok { color: var(--good); }
.dc-correct .ng { color: var(--bad); text-decoration: underline; text-underline-offset: 6px; }
.dc-ko { font-size: 20px; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; }
.dc-ko b { font-size: 24px; }
.dc-ko span { font-family: var(--en-font); font-weight: 600; color: var(--muted); }
.dc-fb { min-height: 32px; font-family: var(--display); font-size: 26px; color: var(--muted); }
.dc-fb.good { color: var(--good); font-size: 34px; }
.dc-fb.bad { color: var(--bad); }
.dc-keys { display: flex; flex-direction: column; gap: 8px; align-items: center; margin-top: auto; }
.dc-row { display: flex; gap: 8px; justify-content: center; width: 100%; }
.dc-key {
  flex: 0 1 84px; height: 72px; border-radius: 14px; background: var(--surface); border: 2px solid var(--line);
  box-shadow: 0 3px 0 var(--line); font-family: var(--en-font); font-weight: 800; font-size: 30px;
}
.dc-key:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.dc-key:disabled { opacity: .4; }
.dc-key.wide { flex: 0 1 420px; font-family: var(--display); font-weight: 400; font-size: 22px; }
.dc-key.mid { flex: 0 1 160px; font-family: var(--display); font-weight: 400; font-size: 22px; color: var(--muted); }
.dc-key.ok { flex: 0 1 200px; background: var(--kid); border-color: var(--kid); color: #fff; box-shadow: none; font-family: var(--display); font-weight: 400; font-size: 26px; }
@media (max-width: 860px) {
  .dc-key { height: 56px; font-size: 22px; }
  .dc-row { gap: 4px; }
}

/* 부모 모드: 영어 AI 연결 */
.code-row { display: flex; gap: 10px; flex-wrap: wrap; }
.code-row input {
  flex: 1; min-width: 200px; min-height: 56px; padding: 0 16px; font-size: 20px;
  border-radius: 14px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); user-select: text;
}
.code-row input:focus { outline: 3px solid var(--kid); outline-offset: 1px; }
.code-msg { font-size: 16px; }

@media (max-width: 860px) {
  .draw-body { grid-template-columns: 1fr; }
  #draw-canvas { max-height: 55vh; }
  .en-body { flex-direction: column; }
  .en-side { width: 100%; flex-direction: row; align-items: center; }
  .en-side img { width: 140px; }
  .mic { width: 120px; height: 120px; font-size: 18px; }
  .en-controls { grid-template-columns: 1fr; justify-items: center; }
  .ctl-side, .ctl-side.right { justify-content: center; }
  .bubble { max-width: 92%; }
}
@media (prefers-reduced-motion: reduce) {
  .mic.recording { animation: none; }
}
