:root {
  --bg: #f4f5fb; --card: #fff; --ink: #1c1d2e; --sub: #6b6f85; --line: #e4e6f0;
  --brand: #4f46e5; --brand-soft: #eef0ff; --ok: #0f9d6b; --ok-soft: #e7f8f0;
  --no: #e0364f; --no-soft: #fdecef; --warn: #f59e0b; --warn-soft: #fff6e0;
  --radius: 18px; --shadow: 0 6px 24px rgba(40, 44, 90, .07);
  font-family: Pretendard, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  color: var(--ink); background: var(--bg); -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 3px solid #a5b4fc; outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }

.app { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(28px + env(safe-area-inset-bottom)); }
.loading { text-align: center; color: var(--sub); padding: 80px 0; }

.top { display: flex; align-items: center; gap: 10px; margin: 4px 0 16px; }
.top h1 { font-size: 20px; font-weight: 800; flex: 1; letter-spacing: -.02em; }
.logo { width: 34px; height: 34px; border-radius: 11px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 900; }
.icon-btn { border: 0; background: transparent; width: 44px; height: 44px; border-radius: 12px; font-size: 20px; display: grid; place-items: center; }
.icon-btn:hover { background: #e9ebf5; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; }
.card h2 { font-size: 14px; color: var(--sub); font-weight: 700; margin-bottom: 10px; }

.mic-card h2 { color: var(--ink); font-size: 16px; }
.mic-card.warn { background: var(--warn-soft); box-shadow: none; }
.mic-card summary { cursor: pointer; padding: 6px 0; font-weight: 600; }
.today { display: flex; align-items: center; gap: 14px; }
.flame { font-size: 15px; font-weight: 800; background: var(--warn-soft); color: #a66300; padding: 8px 12px; border-radius: 999px; white-space: nowrap; }
.goal { flex: 1; min-width: 0; }
.goal span { font-size: 13px; color: var(--sub); }
.track { height: 9px; background: #e7e9f3; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.track i { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 9px 14px; font-size: 14px; font-weight: 600; color: var(--sub); min-height: 40px; }
.chip.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.chip.ghost { border-style: dashed; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; text-align: center; }
.stats div { background: var(--bg); border-radius: 12px; padding: 10px 4px; }
.stats b { display: block; font-size: 20px; }
.stats span { font-size: 12px; color: var(--sub); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bg); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 10px 4px; font-size: 14px; font-weight: 600; color: var(--sub); min-height: 42px; }
.seg button.on { background: #fff; color: var(--brand); box-shadow: 0 1px 4px rgba(0, 0, 0, .1); }
.row { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 10px; margin-top: 10px; }
.row:first-of-type { margin-top: 0; }
.row label, .row > span { font-size: 13px; color: var(--sub); font-weight: 600; }

.btn { border: 0; border-radius: 14px; padding: 14px 18px; font-weight: 700; font-size: 16px; min-height: 52px; background: #e9ebf5; color: var(--ink); width: 100%; }
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(79, 70, 229, .3); }
.btn.primary:active { transform: translateY(1px); }
.btn.big { font-size: 19px; padding: 18px; min-height: 64px; }
.btn small { display: block; font-weight: 500; font-size: 12px; opacity: .85; margin-top: 3px; }
.btn.ok { background: var(--ok-soft); color: var(--ok); }
.btn.danger { background: var(--no-soft); color: var(--no); }
.btn.slim { min-height: 42px; padding: 9px 14px; font-size: 14px; width: auto; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.link { border: 0; background: none; color: var(--sub); font-size: 14px; text-decoration: underline; padding: 10px; min-height: 44px; }

/* 문제 화면 */
.qbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.qbar .track { flex: 1; margin: 0; }
.qbar .count { font-size: 13px; color: var(--sub); font-variant-numeric: tabular-nums; }
.combo { font-weight: 800; color: #c2410c; font-size: 14px; min-width: 42px; text-align: right; }
.combo.pop { animation: pop .35s; }
@keyframes pop { 40% { transform: scale(1.45); } }
.qcard { text-align: center; padding: 28px 18px; }
.qlabel { font-size: 14px; color: var(--sub); font-weight: 600; }
.qword { font-size: clamp(34px, 11vw, 52px); font-weight: 800; letter-spacing: -.03em; margin: 12px 0 6px; word-break: keep-all; overflow-wrap: anywhere; }
.qword.ko { font-size: clamp(26px, 8vw, 38px); }
.cloze { font-size: 22px; font-weight: 700; line-height: 1.5; margin: 14px 0 8px; }
.cloze .blank { display: inline-block; min-width: 84px; border-bottom: 3px solid var(--brand); color: transparent; }
.cloze-ko { color: var(--sub); font-size: 15px; }
.say { border: 0; background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 700; min-height: 40px; }
.badge-new { display: inline-block; background: var(--warn-soft); color: #a66300; font-size: 12px; font-weight: 700; border-radius: 99px; padding: 3px 9px; margin-bottom: 6px; }

.answer { text-align: center; }
.status { min-height: 24px; font-size: 15px; color: var(--sub); }
.status.err { color: var(--no); }
.heard { min-height: 34px; font-size: 24px; font-weight: 800; margin: 6px 0; overflow-wrap: anywhere; }
.mic { width: 108px; height: 108px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; font-size: 44px; margin: 8px auto 6px; display: grid; place-items: center; box-shadow: 0 10px 26px rgba(79, 70, 229, .35); position: relative; transition: transform .1s; }
.mic:active { transform: scale(.96); }
.mic.live { background: var(--no); box-shadow: 0 0 0 calc(6px + var(--level, 0) * 22px) rgba(224, 54, 79, .18), 0 10px 26px rgba(224, 54, 79, .35); animation: breathe 1.2s infinite; }
.mic.busy { background: #9aa0b8; animation: none; box-shadow: none; }
@keyframes breathe { 50% { transform: scale(1.05); } }
.mic-hint { font-size: 13px; color: var(--sub); margin-bottom: 12px; }
.typed { display: flex; gap: 8px; margin-top: 6px; }
.typed input { flex: 1; min-width: 0; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 16px; background: #fff; }
.typed input:focus { border-color: var(--brand); outline: none; }
.typed button { width: auto; }
.step { text-align: left; font-size: 14px; font-weight: 800; color: var(--brand); margin: 14px 0 6px; }
.step:first-child { margin-top: 0; }
.mic.small { width: 84px; height: 84px; font-size: 34px; }
.mic.nudge { animation: nudge .5s; }
@keyframes nudge { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.typed input.spell { font-size: 22px; font-weight: 700; letter-spacing: .06em; text-align: center; }
.kbd { margin-top: 10px; display: grid; gap: 6px; user-select: none; }
.kbd div { display: flex; justify-content: center; gap: 4px; }
.kbd button { flex: 1 1 0; max-width: 40px; height: 46px; border: 0; border-radius: 8px; background: #fff; box-shadow: 0 1px 0 #c9cde0; font-size: 18px; font-weight: 600; padding: 0; }
.kbd button:active { background: var(--brand-soft); }
.kbd button.wide { max-width: 56px; flex-grow: 1.5; background: #e2e5f1; }
.sayline { font-size: 14px; color: var(--sub); margin-bottom: 10px; overflow-wrap: anywhere; }
.sayline.good { color: var(--ok); }
.item .sayline { margin: 0; grid-column: 2; }
.options { display: grid; gap: 10px; }
.options button { text-align: left; background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 16px; font-size: 17px; font-weight: 600; min-height: 56px; }
.options button.right { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.options button.wrong { border-color: var(--no); background: var(--no-soft); color: var(--no); }
.retry-box { background: var(--warn-soft); border-radius: 14px; padding: 12px; margin: 10px 0; font-size: 14px; }
.retry-box audio { width: 100%; margin: 8px 0; }

.fb { border-radius: var(--radius); padding: 18px; margin-bottom: 14px; animation: rise .2s; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.fb.ok { background: var(--ok-soft); }
.fb.no { background: var(--no-soft); }
.fb h2 { font-size: 20px; margin-bottom: 6px; }
.fb.ok h2 { color: var(--ok); }
.fb.no h2 { color: var(--no); }
.fb .mine { font-size: 15px; color: var(--sub); margin-bottom: 10px; overflow-wrap: anywhere; }
.fb audio { width: 100%; margin-top: 6px; }

/* 단어 설명 */
.wv { background: #fff; border-radius: 14px; padding: 14px; text-align: left; }
.wv-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wv-head b { font-size: 22px; }
.wv-pos { font-size: 12px; color: var(--sub); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; }
.stars { color: var(--warn); letter-spacing: 1px; font-size: 13px; margin-left: auto; }
.stars i { color: #d7dae8; font-style: normal; }
.wv-ko { font-size: 18px; font-weight: 700; margin: 8px 0 4px; }
.wv-syn { font-size: 13px; color: var(--sub); line-height: 1.6; }
.wv-syn summary { cursor: pointer; padding: 4px 0; }
.ex { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: start; }
.ex-en { font-size: 16px; font-weight: 600; line-height: 1.45; }
.ex-en mark { background: #dfe3ff; color: var(--brand); border-radius: 4px; padding: 0 3px; }
.ex-en .kw { border-bottom: 2px dotted var(--warn); cursor: pointer; }
.ex-ko { font-size: 14px; color: var(--sub); grid-column: 1; }
.ex .say { grid-row: span 2; padding: 6px 10px; }
.tip { margin-top: 10px; font-size: 13px; background: var(--warn-soft); border-radius: 10px; padding: 9px 11px; color: #7a4b00; }

/* 단어 카드 */
.flip { min-height: 300px; display: flex; flex-direction: column; justify-content: center; text-align: center; cursor: pointer; user-select: none; }
.flip .qword { margin-top: 0; }
.flip .hint { color: var(--sub); font-size: 13px; margin-top: 14px; }
.nav3 { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.nav3 span { font-size: 14px; color: var(--sub); font-variant-numeric: tabular-nums; }

/* 결과 */
.score { text-align: center; padding: 26px 18px; }
.score .num { font-size: 54px; font-weight: 900; letter-spacing: -.03em; color: var(--brand); }
.score .num small { font-size: 24px; color: var(--sub); font-weight: 700; }
.score p { color: var(--sub); margin-top: 4px; }
.item { border-top: 1px solid var(--line); padding: 12px 0; display: grid; grid-template-columns: 26px 1fr; gap: 4px 8px; }
.item:first-of-type { border-top: 0; }
.item .mark { font-size: 18px; grid-row: span 3; }
.item .q { font-weight: 700; }
.item .a { font-size: 14px; color: var(--sub); overflow-wrap: anywhere; }
.item .a b { color: var(--ink); }
.item audio { width: 100%; height: 34px; margin-top: 4px; }
.item .btn { margin-top: 6px; }

/* 단어집 관리·설정 */
.pack { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pack:first-of-type { border-top: 0; }
.pack .name { flex: 1; min-width: 140px; font-weight: 700; }
.pack .name small { display: block; font-weight: 500; color: var(--sub); font-size: 12px; }
.pack input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--brand); }
.field { display: block; margin-top: 10px; }
.field span { display: block; font-size: 13px; color: var(--sub); font-weight: 600; margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; font-size: 16px; background: #fff; }
.field textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.help { font-size: 13px; color: var(--sub); line-height: 1.6; margin-top: 8px; }
.steps { counter-reset: s; display: grid; gap: 14px; }
.steps > div { counter-increment: s; }
.steps > div > h3::before { content: counter(s); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; margin-right: 6px; }
.steps h3 { font-size: 15px; }
.words { max-height: 260px; overflow: auto; font-size: 14px; margin-top: 8px; }
.words div { display: flex; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); align-items: center; }
.words div span { flex: 1; color: var(--sub); }
.switch { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); gap: 12px; }
.switch:first-of-type { border-top: 0; }
.switch input { width: 24px; height: 24px; accent-color: var(--brand); flex: none; }
.switch small { display: block; color: var(--sub); font-size: 12px; }
progress { width: 100%; height: 8px; margin-top: 8px; accent-color: var(--brand); }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #23253a; color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px; max-width: calc(100vw - 32px); z-index: 20; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); text-align: center; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { top: 105%; transform: rotate(720deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
