:root {
  color-scheme: light;
  --bg: #edf1fa;
  --sheet: #ffffff;
  --ink: #1a1d2e;
  --soft: #6b7189;
  --line: #dce2f0;
  --me: #2f5bff;
  --me-deep: #1f43cc;
  --sun: #ffd84d;
  --sun-soft: #fff4c2;
  --ok: #12a682;
  --bad: #f0475f;
  --mint: #19c39c;
  --orange: #ff8a3d;
  --font: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  word-break: keep-all;
}
button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--me); outline-offset: 2px; }
p { margin: 0; }
h1, h2 { margin: 0; letter-spacing: -0.02em; }
[lang="en"] { word-break: normal; }

.page { max-width: 520px; margin: 0 auto; padding: 20px 16px 40px; min-height: 100vh; }
.loading, .notice { color: var(--soft); padding: 64px 0; }
.notice strong { display: block; color: var(--ink); font-size: 1.3rem; margin-bottom: 8px; }

/* 공통 버튼 */
.cta {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 54px; padding: 12px 18px;
  border: 0; border-radius: 16px;
  background: var(--me); color: #fff;
  font-weight: 700; font-size: 1.05rem;
  box-shadow: 0 4px 0 var(--me-deep);
  transition: transform 0.08s, box-shadow 0.08s;
}
.cta:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--me-deep); }
.cta span { font-weight: 500; font-size: 0.85rem; opacity: 0.85; }
.cta:disabled { background: var(--line); color: var(--soft); box-shadow: none; cursor: default; }
.cta.plain { background: var(--sheet); color: var(--ink); box-shadow: 0 4px 0 var(--line); border: 1.5px solid var(--line); }
.ghost { background: none; border: 0; padding: 10px 6px; color: var(--soft); font-weight: 600; }
.ghost.wide { display: block; width: 100%; margin-top: 6px; }

.listen {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 8px; padding: 3px 10px 3px 8px;
  border: 0; border-radius: 999px;
  background: rgba(26, 29, 46, 0.08); color: inherit;
  font-size: 0.78rem; font-weight: 600; vertical-align: middle; white-space: nowrap;
}
.bubble.me .listen { background: rgba(255, 255, 255, 0.22); }
.wave { display: inline-flex; align-items: center; gap: 2px; height: 12px; }
.wave i { width: 2px; background: currentColor; border-radius: 2px; }
.wave i:nth-child(1) { height: 5px; } .wave i:nth-child(2) { height: 12px; } .wave i:nth-child(3) { height: 8px; }

mark { background: var(--sun); color: var(--ink); padding: 1px 5px; border-radius: 6px; font-weight: 600; }

/* 말풍선 */
.avatar {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1.05rem;
}
.avatar.mint { background: var(--mint); }
.avatar.orange { background: var(--orange); }
.bubble {
  display: inline-block; max-width: 100%;
  padding: 11px 15px; border-radius: 20px;
  font-size: 1.1rem; line-height: 1.45; font-weight: 500;
}
.bubble.them { background: var(--sheet); border-bottom-left-radius: 6px; box-shadow: 0 1px 0 var(--line); }
.bubble.me { background: var(--me); color: #fff; border-bottom-right-radius: 6px; }

/* ---------- 첫 화면 ---------- */
.top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 18px; }
.top h1 { font-size: 1rem; font-weight: 600; color: var(--soft); }
.streak { font-size: 0.85rem; font-weight: 700; color: var(--ok); }

.inbox { margin-bottom: 36px; }
.inbox .lead { font-size: 1.6rem; font-weight: 800; line-height: 1.3; letter-spacing: -0.02em; margin-bottom: 18px; }
.preview { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 20px; }
.preview .who { font-weight: 700; font-size: 0.9rem; margin-bottom: 4px; }
.preview .who span { font-weight: 500; color: var(--soft); margin-left: 6px; }
.preview .bubble { font-size: 1.25rem; animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1) 0.15s backwards; }

.collection { background: var(--sheet); border-radius: 22px; padding: 20px 18px; margin-bottom: 14px; }
.collection .row { display: flex; justify-content: space-between; align-items: baseline; }
.collection h2 { font-size: 1.1rem; }
.collection .count { color: var(--soft); font-variant-numeric: tabular-nums; }
.collection .count b { font-size: 1.5rem; color: var(--ink); }
.meter { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; margin: 10px 0 12px; }
.meter i { display: block; height: 100%; background: var(--sun); border-radius: 999px; transition: width 0.4s; }
.hint { color: var(--soft); font-size: 0.86rem; margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 13px; border-radius: 999px;
  border: 1.5px dashed var(--line); background: none; color: var(--soft);
  font-size: 0.95rem; font-weight: 500;
}
.chip.half { border-style: solid; border-color: var(--sun); color: var(--ink); }
.chip.got { border: 1.5px solid var(--sun); background: var(--sun); color: var(--ink); font-weight: 700; }
.chip.sel { border: 1.5px solid var(--ink); background: var(--ink); color: #fff; }
.chip.pop { animation: pop 0.4s cubic-bezier(0.2, 1.6, 0.4, 1) backwards; }
.chip.pop:nth-child(2) { animation-delay: 0.12s; } .chip.pop:nth-child(3) { animation-delay: 0.24s; }
.chip.pop:nth-child(4) { animation-delay: 0.36s; } .chip.pop:nth-child(n+5) { animation-delay: 0.48s; }

.linkcard {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  width: 100%; padding: 16px 18px; text-align: left;
  background: var(--sheet); border: 0; border-radius: 22px;
}
.linkcard b { display: block; }
.linkcard small { color: var(--soft); font-size: 0.86rem; }
.linkcard .go { color: var(--me); font-weight: 700; flex: 0 0 auto; }
.picker { width: 100%; margin-top: 14px; padding: 12px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--sheet); }

/* 표현 카드 */
.sheet {
  width: min(520px, 100%); max-width: 100%; max-height: 85vh;
  margin: auto auto 0; padding: 24px 18px calc(20px + env(safe-area-inset-bottom));
  border: 0; border-radius: 24px 24px 0 0; background: var(--sheet); color: var(--ink);
}
.sheet::backdrop { background: rgba(26, 29, 46, 0.45); }
.sheet[open] { animation: rise 0.22s ease-out; }
.sheet .term { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.01em; }
.sheet .meaning { color: var(--soft); margin-bottom: 14px; }
.ex { padding: 12px 0; border-top: 1px solid var(--line); }
.ex p { display: inline; font-size: 1.08rem; font-weight: 500; }
.ex small { display: block; color: var(--soft); font-size: 0.86rem; margin-top: 2px; }
.ex.main { border-top: 0; background: var(--bg); border-radius: 16px; padding: 14px; margin: 12px 0; }
.sheet .cta { margin-top: 16px; }

.memo { background: var(--sun-soft); border-radius: 14px; padding: 10px 14px; font-size: 0.9rem; margin: 4px 0 4px 50px; }
.sheet .memo { margin: 0 0 12px; }
.memo b { display: block; font-size: 0.78rem; margin-bottom: 2px; }

/* ---------- 대화 ---------- */
.page.chat { display: flex; flex-direction: column; padding-bottom: 0; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -8px 0 8px; }
.dots { display: flex; gap: 6px; }
.dots i { width: 22px; height: 6px; border-radius: 999px; background: var(--line); transition: background 0.2s; }
.dots i.now { background: var(--ink); }
.dots i.ok { background: var(--ok); }
.dots i.retry { background: var(--sun); }

.thread { flex: 1 1 auto; display: flex; flex-direction: column; gap: 8px; padding-bottom: 20px; }
.from { font-size: 0.8rem; color: var(--soft); font-weight: 600; margin: 14px 0 0 50px; }
.msg { display: flex; gap: 10px; align-items: flex-end; animation: pop 0.25s cubic-bezier(0.2, 1.3, 0.4, 1) backwards; }
.msg.me { justify-content: flex-end; padding-left: 40px; }
.msg.them { padding-right: 24px; }
.typing { display: inline-flex; gap: 4px; padding: 6px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--soft); animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; } .typing i:nth-child(3) { animation-delay: 0.3s; }

.composer {
  position: sticky; bottom: 0; margin: 0 -16px;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--sheet); border-radius: 24px 24px 0 0;
  box-shadow: 0 -6px 24px rgba(26, 29, 46, 0.08);
}
.composer:empty { display: none; }
.intent { font-size: 1.15rem; font-weight: 700; line-height: 1.4; margin-bottom: 14px; }
.intent > span:first-child { display: block; font-size: 0.82rem; font-weight: 600; color: var(--me); margin-bottom: 2px; }
.intent .answer { font-weight: 600; }

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  width: 100%; padding: 14px 16px; text-align: left;
  background: var(--sheet); border: 1.5px solid var(--line); border-radius: 16px;
  box-shadow: 0 3px 0 var(--line);
  font-size: 1.08rem; font-weight: 500; line-height: 1.4;
}
.option:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.option.wrong { border-color: var(--bad); color: var(--bad); box-shadow: none; text-decoration: line-through; animation: shake 0.3s; }
.cloze { font-size: 1.15rem; font-weight: 500; margin-bottom: 14px; }
.gap { display: inline-block; width: 90px; border-bottom: 3px solid var(--me); margin: 0 4px; }

.line {
  display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start;
  min-height: 58px; padding: 8px; margin-bottom: 12px;
  background: var(--bg); border-radius: 16px;
}
.line.shake { animation: shake 0.3s; }
.placeholder { color: var(--soft); font-size: 0.9rem; padding: 9px 6px; font-family: var(--font); }
.tray { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.tile {
  min-height: 42px; padding: 7px 13px;
  background: var(--sheet); border: 1.5px solid var(--line); border-radius: 12px;
  box-shadow: 0 3px 0 var(--line);
  font-size: 1.05rem; font-weight: 600;
}
.tile:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.tile:disabled { color: transparent; background: var(--bg); border-color: var(--bg); box-shadow: none; cursor: default; }
.tile.on { background: var(--me); border-color: var(--me); color: #fff; box-shadow: 0 3px 0 var(--me-deep); }
.tile.wrong { border-color: var(--bad); color: var(--bad); box-shadow: none; animation: shake 0.3s; }
.line.spot { padding: 12px; gap: 8px; }
.gapin {
  width: auto; max-width: 100%; margin: 0 4px; padding: 4px 8px;
  border: 0; border-bottom: 3px solid var(--me); border-radius: 8px 8px 0 0; background: var(--bg);
  font: inherit; font-size: 1.15rem; font-weight: 700; color: var(--me-deep);
}
.gapin:focus { outline: 2px solid var(--me); outline-offset: 2px; }
.gapin.shake { animation: shake 0.3s; border-bottom-color: var(--bad); }
.intent .listen { margin-top: 10px; }
.feedback { min-height: 1.4em; font-size: 0.88rem; color: var(--soft); margin: 4px 0 8px; }
.sendrow { display: flex; align-items: center; gap: 10px; }
.sendrow .cta { flex: 1 1 0; }
.sendrow.two .cta { font-size: 0.98rem; padding: 12px 8px; }
.sendrow .count, .sendrow .time { color: var(--soft); font-weight: 700; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.composer > .cta + .cta { margin-top: 12px; }

.result { padding: 28px 0 8px; }
.result .lead { font-size: 1.7rem; font-weight: 800; line-height: 1.3; letter-spacing: -0.02em; margin-bottom: 18px; }
.result .again { margin-top: 26px; }
.result .again p { color: var(--soft); font-size: 0.9rem; margin-bottom: 8px; }
.result .tally { margin-top: 28px; color: var(--soft); font-weight: 600; }

/* ---------- 숙제 ---------- */
.page.hw .top h1 { font-size: 1.6rem; font-weight: 800; color: var(--ink); }
.block { background: var(--sheet); border-radius: 22px; padding: 20px 18px; margin-bottom: 14px; }
.block h2 { font-size: 1.1rem; margin-bottom: 2px; }
.q { padding: 14px 0; border-top: 1px solid var(--line); }
.q p { font-weight: 600; margin-bottom: 6px; }
.q textarea {
  display: block; width: 100%; margin-top: 10px; padding: 10px 12px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg);
  font-size: 1.05rem; line-height: 1.45; resize: vertical;
}
.qa .sendrow { padding-top: 14px; border-top: 1px solid var(--line); }
.targets { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; font-size: 1.1rem; }
.rec audio { width: 100%; margin-top: 12px; }

@keyframes pop { from { opacity: 0; transform: scale(0.85) translateY(6px); } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* 표현 전체 진도: 내 것 / 한 번 맞힘 / 아직 */
.progress { margin: 14px 0 6px; text-align: left; }
.progress .stack { display: flex; gap: 3px; height: 14px; }
.progress .stack i { flex: 0 0 0; min-width: 6px; border-radius: 7px; }
.progress i.got { background: var(--sun); box-shadow: inset 0 0 0 1.5px #e0b400; }
.progress i.half { background: var(--sun-soft); box-shadow: inset 0 0 0 1.5px var(--sun); }
.progress i.rest { background: var(--line); }
.progress ul { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 8px; padding: 0; font-size: 0.9rem; color: var(--ink); }
.progress li { display: flex; align-items: center; gap: 6px; }
.progress li i { width: 12px; height: 12px; border-radius: 4px; }
.progress p { font-size: 0.88rem; color: var(--soft); line-height: 1.45; }
.result .progress { margin-top: 28px; padding: 16px; background: var(--sheet); border-radius: 18px; }

/* 회차 고르기 */
.round { margin-top: 14px; }
.round .cta { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; }
.round .cta b { font-size: 1.1rem; }
.round .cta span { font-size: 0.86rem; font-weight: 600; opacity: 0.85; }
.round > p { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 8px 4px 0; font-size: 0.88rem; color: var(--soft); }
.round .donemark { color: var(--ok); font-weight: 700; }
.round .ghost { padding: 2px 0; font-size: 0.88rem; text-decoration: underline; }
.tip { margin-top: 18px; padding: 12px 14px; background: var(--sun-soft); border-radius: 14px; font-size: 0.9rem; line-height: 1.5; color: var(--ink); text-align: left; }
.tip b { display: block; font-size: 0.82rem; margin-bottom: 2px; }
/* 대화 중 진행 표시 */
.runmeter { flex: 1 1 auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.runmeter .track { flex: 1 1 auto; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.runmeter .track i { display: block; height: 100%; width: 0; background: var(--ok); border-radius: 4px; transition: width 0.3s; }
.runmeter span { flex: 0 0 auto; font-size: 0.82rem; font-weight: 700; color: var(--soft); font-variant-numeric: tabular-nums; }
.result .score { margin-top: 8px; font-size: 1.05rem; color: var(--soft); }
.result .score b { font-size: 1.8rem; color: var(--ink); }

/* 카카오톡 안에서 열렸을 때의 안내 */
.inapp { margin: 12px 16px 0; padding: 12px 14px; background: var(--sun-soft); border: 1.5px solid var(--sun); border-radius: 14px; font-size: 0.9rem; line-height: 1.5; color: var(--ink); }
.inapp[hidden] { display: none; }
.inapp b { display: block; }
.inapp button { margin-top: 8px; padding: 8px 14px; border: 0; border-radius: 10px; background: var(--ink); color: #fff; font-weight: 700; font-size: 0.9rem; }
