/* にほんご — 듀오링고풍 모바일 우선 스타일 */
:root {
  --green: #58cc02;
  --green-dark: #46a302;
  --green-light: #d7ffb8;
  --red: #ff4b4b;
  --red-dark: #ea2b2b;
  --red-light: #ffdfe0;
  --blue: #1cb0f6;
  --blue-dark: #1899d6;
  --yellow: #ffc800;
  --orange: #ff9600;
  --gray-bg: #f7f7f7;
  --gray-line: #e5e5e5;
  --gray-text: #777;
  --text: #3c3c3c;
  --radius: 16px;
  --shadow-btn: 0 4px 0;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--gray-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Hiragino Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { -webkit-user-select: none; user-select: none; }

#app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100%;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.loading { text-align: center; padding: 40vh 0; color: var(--gray-text); }

/* ---------- 공통 버튼 ---------- */
.btn {
  display: block;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: transform .06s, filter .1s;
  font-family: inherit;
}
.btn:active { transform: translateY(3px); }
.btn-green { background: var(--green); color: #fff; box-shadow: var(--shadow-btn) var(--green-dark); }
.btn-green:active { box-shadow: 0 1px 0 var(--green-dark); }
.btn-blue { background: var(--blue); color: #fff; box-shadow: var(--shadow-btn) var(--blue-dark); }
.btn-blue:active { box-shadow: 0 1px 0 var(--blue-dark); }
.btn-white {
  background: #fff; color: var(--text);
  border: 2px solid var(--gray-line);
  box-shadow: var(--shadow-btn) var(--gray-line);
}
.btn-white:active { box-shadow: 0 1px 0 var(--gray-line); }
.btn:disabled { opacity: .45; pointer-events: none; }

/* ---------- 헤더 / 통계 ---------- */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 6px;
}
.top-bar .app-title { font-size: 24px; font-weight: 800; color: var(--green); }
.stat-chips { display: flex; gap: 10px; }
.chip {
  display: flex; align-items: center; gap: 4px;
  font-weight: 800; font-size: 16px;
  padding: 6px 10px; border-radius: 12px; background: #fff;
  border: 2px solid var(--gray-line);
}
.chip.streak { color: var(--orange); }
.chip.xp { color: var(--yellow); }
.chip.streak.off { filter: grayscale(1); opacity: .6; }

.streak-banner {
  margin: 8px 16px 0; padding: 10px 14px;
  background: #fff; border: 2px solid var(--gray-line); border-radius: var(--radius);
  font-size: 14px; color: var(--gray-text);
}

/* ---------- 홈: 에피소드 카드 ---------- */
.episode-list { padding: 12px 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.ep-card {
  background: #fff; border: 2px solid var(--gray-line); border-radius: 20px;
  padding: 16px; display: flex; gap: 14px; align-items: center;
  cursor: pointer; transition: transform .06s;
}
.ep-card:active { transform: scale(.98); }
.ep-emoji {
  width: 56px; height: 56px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; border-radius: 50%;
  background: var(--green-light);
}
.ep-card.done .ep-emoji { background: var(--yellow); }
.ep-info { flex: 1; min-width: 0; }
.ep-title { font-size: 17px; font-weight: 800; }
.ep-sub { font-size: 14px; color: var(--gray-text); margin-top: 2px; }
.ep-meta { font-size: 12px; color: var(--gray-text); margin-top: 6px; }
.ep-progress-dots { display: flex; gap: 5px; margin-top: 8px; }
.pdot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--gray-line);
}
.pdot.on { background: var(--green); }
.pdot.gold { background: var(--yellow); }
.ep-progress-dots { align-items: center; }
.ep-done-label { font-size: 11px; font-weight: 800; color: var(--green-dark); }
.ep-prog-label { font-size: 11px; font-weight: 700; color: var(--blue-dark); }
.ep-new-label { font-size: 11px; font-weight: 700; color: #bbb; }

/* ---------- 에피소드 상세 ---------- */
.page-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
}
.back-btn {
  border: none; background: none; font-size: 24px; color: var(--gray-text);
  cursor: pointer; padding: 4px 8px;
}
.page-head h2 { font-size: 19px; font-weight: 800; flex: 1; }

.section-label {
  font-size: 13px; font-weight: 800; color: var(--gray-text);
  letter-spacing: .05em; margin: 18px 16px 8px;
}

.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 16px; }
.mode-btn {
  background: #fff; border: 2px solid var(--gray-line); border-radius: var(--radius);
  padding: 14px 10px; text-align: center; cursor: pointer;
  box-shadow: 0 3px 0 var(--gray-line);
  transition: transform .06s;
  position: relative;
}
.mode-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--gray-line); }
.mode-btn .m-emoji { font-size: 26px; }
.mode-btn .m-name { font-size: 14px; font-weight: 700; margin-top: 6px; }
.mode-btn .m-score { font-size: 12px; color: var(--green-dark); font-weight: 800; margin-top: 3px; min-height: 15px; }
.mode-btn.locked { opacity: .5; }

.dialogue-list { padding: 0 16px 10px; display: flex; flex-direction: column; gap: 10px; }
.bubble-row { display: flex; gap: 8px; align-items: flex-end; }
.bubble-row.right { flex-direction: row-reverse; }
.speaker-tag { font-size: 11px; color: var(--gray-text); margin: 0 4px 2px; }
.bubble {
  background: #fff; border: 2px solid var(--gray-line);
  border-radius: 16px; padding: 10px 12px; max-width: 82%;
}
.bubble-row.right .bubble { background: var(--green-light); border-color: #b8e894; }
.bubble .jp { font-size: 17px; font-weight: 600; line-height: 2.2; }

/* 품사 색상 + 단어 위 로마자 루비 */
.tk-n { color: var(--blue-dark); }
.tk-v { color: var(--green-dark); }
.tk-adj { color: var(--orange); }
.tk-o { color: var(--text); }
ruby { ruby-position: over; }
ruby rt {
  font-size: 9px; font-weight: 700; color: #9aa0a6;
  letter-spacing: 0; text-align: center;
}
.pos-legend {
  display: flex; gap: 12px; padding: 2px 18px 0;
  font-size: 12px; font-weight: 700;
}
.pos-legend .lg-n { color: var(--blue-dark); }
.pos-legend .lg-v { color: var(--green-dark); }
.pos-legend .lg-adj { color: var(--orange); }
.pos-legend .lg-o { color: var(--gray-text); }
.tk-tap { cursor: pointer; border-bottom: 1px dotted #cfd4da; }
.tk-tap:active { background: #eef7ff; border-radius: 4px; }

/* ---------- 단어 상세 카드 (바텀 시트) ---------- */
#wsOverlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  display: none; z-index: 100;
}
#wsOverlay.show { display: block; }
.word-sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: 640px; margin: 0 auto;
  background: #fff; border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 72vh; overflow-y: auto;
  animation: sheetUp .22s ease;
}
@keyframes sheetUp { from { transform: translateY(40%); opacity: .5; } to { transform: none; opacity: 1; } }
.ws-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.ws-surface { font-size: 30px; font-weight: 800; }
.ws-reading { font-size: 15px; color: var(--blue-dark); font-weight: 700; margin-top: 4px; }
.ws-pos {
  font-size: 11px; color: var(--gray-text); background: var(--gray-bg);
  border-radius: 8px; padding: 2px 8px; margin-left: 6px; vertical-align: 2px;
}
.ws-ko { font-size: 17px; font-weight: 800; color: var(--green-dark); margin-top: 6px; }
.ws-close { border: none; background: var(--gray-bg); border-radius: 50%; width: 34px; height: 34px; font-size: 16px; color: var(--gray-text); cursor: pointer; flex: none; }
.ws-forms { margin-top: 14px; border-top: 2px solid var(--gray-line); padding-top: 6px; }
.ws-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--gray-bg);
}
.ws-row .ws-form { flex: none; width: 92px; font-size: 12px; font-weight: 800; color: var(--gray-text); }
.ws-row .ws-word { font-size: 19px; font-weight: 700; flex: 1; }
.ws-row .ws-kana { font-size: 12px; color: var(--blue-dark); font-weight: 600; text-align: right; line-height: 1.5; }
.ws-row .ws-kana i { color: var(--orange); font-style: normal; font-weight: 700; }
.ws-row .ws-ko-form { display: block; font-size: 12px; color: var(--green-dark); font-weight: 700; }
.ff-row .ff-right { display: flex; flex-direction: column; align-items: flex-end; }
.ff-row .ff-ko { font-size: 11px; color: var(--green-dark); font-weight: 700; }
.bubble .reading { font-size: 13px; color: var(--blue-dark); margin-top: 2px; display: none; }
.show-reading .bubble .reading { display: block; }
.bubble .ko { font-size: 13px; color: var(--gray-text); margin-top: 4px; }

.speak-btn {
  flex: none; border: none; background: var(--blue); color: #fff;
  width: 62px; height: 62px; border-radius: 50%; font-size: 30px;
  cursor: pointer; box-shadow: 0 3px 0 var(--blue-dark);
}
.speak-btn:active { transform: translateY(2px); box-shadow: none; }
.speak-btn.small { width: 54px; height: 54px; font-size: 26px; }
.speak-btn.big { width: 86px; height: 86px; font-size: 40px; box-shadow: 0 5px 0 var(--blue-dark); }

.toggle-row { padding: 0 16px; display: flex; justify-content: flex-end; }
.toggle-reading {
  border: 2px solid var(--gray-line); background: #fff; border-radius: 12px;
  font-size: 13px; font-weight: 700; color: var(--gray-text);
  padding: 6px 12px; cursor: pointer;
}
.toggle-reading.on { color: var(--blue-dark); border-color: var(--blue); }

.word-list { padding: 0 16px 30px; display: flex; flex-direction: column; gap: 8px; }
.word-row {
  background: #fff; border: 2px solid var(--gray-line); border-radius: var(--radius);
  padding: 10px 14px; display: flex; align-items: center; gap: 10px;
}
.word-row .w-main { flex: 1; min-width: 0; }
.word-row .w-romaji { font-size: 12px; color: var(--orange); font-weight: 700; letter-spacing: .03em; }
.word-row .w-jp { font-size: 19px; font-weight: 700; }
.word-row .w-kana { font-size: 13px; color: var(--blue-dark); font-weight: 600; margin-top: 1px; }
.word-row .w-ko { font-size: 13px; color: var(--gray-text); margin-top: 2px; }
.word-row .w-pos {
  flex: none; font-size: 11px; font-weight: 700; color: var(--gray-text);
  background: var(--gray-bg); border-radius: 8px; padding: 3px 8px;
}

/* ---------- AI 회화 ---------- */
.chat-input-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: 640px; margin: 0 auto;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: #fff; border-top: 2px solid var(--gray-line);
  display: flex; gap: 8px; align-items: center; z-index: 60;
}
.chat-input-bar input {
  flex: 1; padding: 12px 14px; font-size: 16px;
  border: 2px solid var(--gray-line); border-radius: 14px;
  font-family: inherit; outline: none;
}
.chat-input-bar input:focus { border-color: var(--blue); }
.chat-mic {
  flex: none; width: 50px; height: 50px; border-radius: 50%;
  border: none; background: var(--red); color: #fff; font-size: 22px;
  cursor: pointer; box-shadow: 0 3px 0 var(--red-dark);
}
.chat-mic:active { transform: translateY(2px); box-shadow: none; }
.chat-mic.listening { animation: pulse 1s infinite; background: var(--red-dark); }
.chat-ask {
  flex: none; width: 50px; height: 50px; border-radius: 50%;
  border: 2px solid var(--gray-line); background: #fff; font-size: 20px;
  cursor: pointer; box-shadow: 0 3px 0 var(--gray-line);
}
.chat-ask.on { background: var(--yellow); border-color: #d9a900; box-shadow: 0 3px 0 #d9a900; }
.chat-ask:active { transform: translateY(2px); box-shadow: none; }
.bubble.ask-q { background: #fff8e0; border-color: var(--yellow); }
.bubble.ask-a { background: #fffdf2; border-color: var(--yellow); max-width: 100%; }
.ask-answer { font-size: 15px; line-height: 1.7; }
.ask-ex {
  margin-top: 8px; padding: 8px 10px; border-radius: 10px;
  background: #fff; border: 1px solid var(--gray-line);
  font-size: 16px; font-weight: 600; line-height: 2.1;
}
.ask-ex .ko { font-size: 13px; color: var(--gray-text); font-weight: 600; }
.chat-typing { color: var(--gray-text); font-size: 14px; font-weight: 700; padding: 6px 4px; }
.chat-reading { font-size: 13px; color: var(--blue-dark); margin-top: 4px; }
.corr-card {
  margin-top: 6px; padding: 10px 12px; border-radius: 12px;
  background: var(--red-light); border: 2px solid var(--red);
  font-size: 14px; line-height: 1.7; text-align: left;
}
.corr-bad { color: var(--red-dark); font-weight: 700; text-decoration: line-through; }
.corr-card.corr-kr { background: #e8f4ff; border-color: var(--blue); }
.corr-asked { color: var(--blue-dark); font-weight: 700; }
.corr-good { color: var(--green-dark); font-weight: 700; font-size: 16px; line-height: 2; }
.corr-reading { font-size: 12px; color: var(--blue-dark); font-weight: 600; }
.corr-explain { font-size: 13px; color: var(--text); margin-top: 4px; }
.corr-explain small { color: var(--gray-text); }
.corr-ok { margin-top: 4px; font-size: 13px; font-weight: 800; color: var(--green-dark); text-align: right; }
.my-said { margin-top: 6px; border-top: 1px dashed #b8e894; padding-top: 6px; }
.my-meaning { font-size: 13px; font-weight: 700; color: var(--text); margin-top: 3px; }
.vocab-word .corr-bad, .vocab-word .corr-good { display: block; }

/* ---------- 오늘의 단어장 ---------- */
.vocab-list { padding: 0 16px; display: flex; flex-direction: column; gap: 10px; }
.vocab-word {
  background: #fff; border: 2px solid var(--gray-line); border-radius: var(--radius);
  padding: 12px 14px;
}
.vocab-word.vmastered { opacity: .75; border-color: #b8e894; background: #f4ffe9; }
.vw-top { display: flex; align-items: center; gap: 10px; }
.vw-main { flex: 1; min-width: 0; }
.vw-main .w-jp { font-size: 30px; font-weight: 800; line-height: 1.3; }
.vw-main .w-kana { font-size: 16px; }
.vw-main .w-romaji { font-size: 14px; }
.vw-meaning { margin-top: 10px; border-top: 1px dashed var(--gray-line); padding-top: 10px; cursor: pointer; }
.vw-meaning .vw-reveal-hint { display: none; }
.vw-meaning.hidden-meaning .vw-reveal-hint {
  display: block; text-align: center; color: var(--gray-text);
  font-size: 13px; font-weight: 700; padding: 6px 0;
}
.vw-meaning.hidden-meaning .vw-answer { display: none; }
.vw-answer b { font-size: 17px; color: var(--green-dark); }
.vw-example { font-size: 14px; margin-top: 6px; line-height: 1.6; }
.vw-example small { color: var(--gray-text); display: block; }
.vw-ex-reading { display: block; font-size: 13px; color: var(--blue-dark); font-weight: 600; line-height: 1.5; }
.vw-ex-reading i { color: var(--orange); font-style: normal; font-weight: 700; }
.vw-answer .flash-forms { border-top-color: var(--gray-line); }
.vw-actions { margin-top: 10px; display: flex; gap: 8px; }
.btn-mini {
  border: none; border-radius: 12px; font-size: 14px; font-weight: 800;
  padding: 9px 14px; cursor: pointer; font-family: inherit;
  transition: transform .06s;
}
.btn-mini:active { transform: translateY(2px); }
.btn-mini-green { background: var(--green); color: #fff; box-shadow: 0 3px 0 var(--green-dark); }
.btn-mini-red { background: var(--red); color: #fff; box-shadow: 0 3px 0 var(--red-dark); }
.btn-mini-white { background: #fff; color: var(--gray-text); border: 2px solid var(--gray-line); box-shadow: 0 2px 0 var(--gray-line); }
.vremember-ok { font-size: 14px; font-weight: 800; color: var(--green-dark); padding: 9px 0; }

/* ---------- 읽기 속도 조절 ---------- */
.rate-box {
  margin: 0 16px; padding: 12px 14px;
  background: #fff; border: 2px solid var(--gray-line); border-radius: var(--radius);
  display: flex; align-items: center; gap: 8px;
}
.rate-box input[type=range] { flex: 1; accent-color: var(--green); height: 30px; }
.rate-icon { font-size: 18px; }
.rate-value { font-size: 13px; font-weight: 800; color: var(--gray-text); min-width: 44px; text-align: right; }
.rate-test {
  border: 2px solid var(--blue); background: #fff; color: var(--blue-dark);
  border-radius: 10px; font-size: 12px; font-weight: 800; padding: 6px 8px;
  cursor: pointer; font-family: inherit; flex: none;
}
.rate-test:active { background: var(--blue); color: #fff; }

/* ---------- 학습 도구 (오십음도·문법) ---------- */
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 16px; }

.kanji-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 16px; }
@media (min-width: 500px) { .kanji-grid { grid-template-columns: repeat(3, 1fr); } }
.kanji-cell {
  background: #fff; border: 2px solid var(--gray-line); border-radius: 12px;
  padding: 10px 8px; font-family: inherit; text-align: center;
  box-shadow: 0 2px 0 var(--gray-line);
  display: flex; flex-direction: column; gap: 3px; align-items: center;
}
.kanji-cell .kj-char { font-size: 40px; font-weight: 800; color: var(--text); line-height: 1.2; }
.kanji-cell .kj-char:active { color: var(--blue); transform: scale(1.1); }
.kanji-cell .kj-read.tappable { background: var(--gray-bg); border-radius: 8px; padding: 3px 8px; }
.kanji-cell .kj-read.tappable:active { background: var(--green-light); }
.kanji-cell .kj-read.dim { opacity: .4; }
.kanji-cell .kj-ex:active { background: var(--green-light); border-radius: 8px; }
.kanji-cell .kj-ko { font-size: 13px; font-weight: 800; color: var(--green-dark); }
.kanji-cell .kj-read { font-size: 11px; color: var(--blue-dark); font-weight: 600; line-height: 1.5; }
.kanji-cell .kj-ex { font-size: 11px; color: var(--gray-text); font-weight: 600; line-height: 1.5; margin-top: 2px; }
.kanji-cell .kj-ex b { color: var(--blue-dark); }
.tool-card {
  background: #fff; border: 2px solid var(--gray-line); border-radius: var(--radius);
  padding: 14px; text-align: center; cursor: pointer;
  box-shadow: 0 3px 0 var(--gray-line); transition: transform .06s;
  display: flex; flex-direction: column; gap: 3px;
}
.tool-card:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--gray-line); }
.tool-card .t-emoji { font-size: 28px; }
.tool-card .t-name { font-size: 16px; font-weight: 800; }
.tool-card .t-sub { font-size: 12px; color: var(--gray-text); font-weight: 600; }

.kana-toggle { display: flex; gap: 6px; }
.kt-btn {
  border: 2px solid var(--gray-line); background: #fff; border-radius: 12px;
  font-size: 13px; font-weight: 800; color: var(--gray-text);
  padding: 7px 10px; cursor: pointer;
}
.kt-btn.on { color: #fff; background: var(--green); border-color: var(--green-dark); }
.kana-grid { padding: 0 16px; display: flex; flex-direction: column; gap: 6px; }
.kana-row { display: grid; gap: 6px; }
.kana-cell {
  background: #fff; border: 2px solid var(--gray-line); border-radius: 12px;
  padding: 8px 2px; text-align: center; cursor: pointer;
  box-shadow: 0 2px 0 var(--gray-line); font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.kana-cell:active { transform: translateY(2px); box-shadow: none; background: var(--green-light); }
.kana-cell.empty { visibility: hidden; }
.kana-cell .k-char { font-size: 24px; font-weight: 700; color: var(--text); }
.kana-cell .k-romaji { font-size: 11px; font-weight: 700; color: var(--orange); }

.tappable { cursor: pointer; }
.tappable:active { opacity: .6; }
.gr-row small, .ff-row .ff-romaji { user-select: none; }

.num-note { font-size: 13px; color: var(--gray-text); font-weight: 600; margin: -4px 16px 8px; }
.num-conv { margin: 0 16px 14px; }
.num-conv input {
  width: 100%; padding: 14px; font-size: 20px; font-weight: 700;
  border: 2px solid var(--gray-line); border-radius: var(--radius);
  font-family: inherit; text-align: center; outline: none;
}
.num-conv input:focus { border-color: var(--blue); }
.num-conv-out {
  margin-top: 8px; padding: 14px; background: #fff; border: 2px solid var(--gray-line);
  border-radius: var(--radius); text-align: center; font-size: 14px; color: var(--gray-text);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.num-conv-out .nc-kana { font-size: 24px; font-weight: 800; color: var(--blue-dark); }
.num-conv-out .nc-romaji { font-size: 15px; font-weight: 700; color: var(--orange); }
.num-details { margin: 0 16px 10px; background: #fff; border: 2px solid var(--gray-line); border-radius: var(--radius); }
.num-details summary {
  padding: 13px 14px; font-size: 15px; font-weight: 800; cursor: pointer;
  list-style: none; color: var(--blue-dark);
}
.num-details summary::-webkit-details-marker { display: none; }
.num-details[open] summary { border-bottom: 1px solid var(--gray-bg); }
.num-details .num-grid { padding: 10px; }
.num-details .num-note { margin: 8px 14px 0; }
.num-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 16px; }
.num-cell {
  background: #fff; border: 2px solid var(--gray-line); border-radius: 12px;
  padding: 10px 8px; cursor: pointer; font-family: inherit; text-align: center;
  box-shadow: 0 2px 0 var(--gray-line);
  display: flex; flex-direction: column; gap: 1px;
}
.num-cell:active { transform: translateY(2px); box-shadow: none; background: var(--green-light); }
.num-cell .n-disp { font-size: 21px; font-weight: 800; color: var(--text); }
.num-cell .n-reading { font-size: 14px; font-weight: 700; color: var(--blue-dark); }
.num-cell .n-romaji { font-size: 12px; font-weight: 700; color: var(--orange); }
.num-cell .n-ko { font-size: 12px; color: var(--gray-text); font-weight: 600; }
@media (min-width: 500px) { .num-grid { grid-template-columns: repeat(3, 1fr); } }

.gr-card {
  background: #fff; border: 2px solid var(--gray-line); border-radius: var(--radius);
  margin: 0 16px; padding: 6px 14px;
}
.gr-rule { padding: 10px 0; border-bottom: 1px solid var(--gray-bg); }
.gr-rule:last-child { border-bottom: none; }
.gr-rule-name { font-size: 14px; font-weight: 800; color: var(--blue-dark); margin-bottom: 6px; }
.gr-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; flex-wrap: wrap; }
.gr-row .gr-dict, .gr-row .gr-form { font-size: 17px; font-weight: 700; }
.gr-row small { display: block; font-size: 11px; color: var(--gray-text); font-weight: 600; }
.gr-row .gr-form small { color: var(--orange); }
.gr-row .gr-arrow { color: var(--gray-text); font-weight: 800; }
.gr-row .gr-ko { font-size: 13px; color: var(--gray-text); flex: 1; }
.gr-lesson-title { font-size: 14px; font-weight: 800; margin: 12px 16px 6px; color: var(--text); }
.stage-body { padding-bottom: 10px; }
.stage-body .gr-card { margin: 0 12px; }
.stage-desc { display: block; font-size: 12px; color: var(--gray-text); font-weight: 600; margin-top: 2px; }
.gs-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--gray-bg); }
.gs-row:last-child { border-bottom: none; }
.gs-main { flex: 1; min-width: 0; }
.gs-main .gs-jp { font-size: 16px; font-weight: 700; line-height: 1.5; display: block; }
.gs-main .gs-reading { display: block; font-size: 12px; color: var(--blue-dark); font-weight: 600; }
.gs-main .gs-reading, .gs-main .gs-ko { line-height: 1.5; }
.gs-main .gs-ko { display: block; font-size: 12px; color: var(--gray-text); font-weight: 600; }

/* 조사 훈련: 예문을 칸으로 분리하고 문장을 크게 */
.particle-view .gs-row {
  background: var(--gray-bg); border-radius: 12px;
  padding: 10px 12px; margin: 7px 0; border-bottom: none;
}
.particle-view .gs-main .gs-jp { font-size: 19px; line-height: 2.4; }
.particle-view .gs-main .gs-reading { font-size: 13px; margin-top: 3px; }
.particle-view .gs-main .gs-ko { font-size: 13px; color: var(--green-dark); }
.particle-view .gr-rule-name { font-size: 15px; }

/* 단어장 연관 단어 */
.vw-related { margin-top: 10px; border-top: 1px dashed var(--gray-line); padding-top: 8px; }
.vw-related .vr-title { font-size: 12px; font-weight: 800; color: var(--gray-text); margin-bottom: 4px; }
.vr-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.vr-row .vr-jp { font-size: 17px; font-weight: 700; }
.vr-row .vr-kana { font-size: 12px; color: var(--blue-dark); font-weight: 600; }
.vr-row .vr-kana, .vr-row .vr-ko { flex: none; }
.vr-row .vr-ko { font-size: 13px; color: var(--green-dark); font-weight: 700; margin-left: auto; }

/* ---------- 퀴즈 공통 ---------- */
.quiz-top {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px 6px;
}
.quiz-close { border: none; background: none; font-size: 22px; color: var(--gray-text); cursor: pointer; }
.progress-track {
  flex: 1; height: 14px; border-radius: 8px; background: var(--gray-line); overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 8px; background: var(--green);
  transition: width .3s ease; min-width: 0;
}
.quiz-body { padding: 18px 16px 140px; }
.quiz-question { font-size: 19px; font-weight: 800; margin-bottom: 6px; }
.quiz-sub { font-size: 14px; color: var(--orange); font-weight: 700; margin: -2px 0 6px; letter-spacing: .03em; }
.quiz-instruction { font-size: 14px; color: var(--gray-text); margin-bottom: 16px; }
.quiz-sentence {
  background: #fff; border: 2px solid var(--gray-line); border-radius: var(--radius);
  padding: 16px; font-size: 20px; line-height: 2.2; font-weight: 600;
  margin-bottom: 8px;
  display: flex; gap: 10px; align-items: flex-start;
}
.quiz-sentence .txt { flex: 1; }
.quiz-sentence .blank {
  display: inline-block; min-width: 74px; border-bottom: 3px solid var(--blue);
  text-align: center; color: var(--blue-dark); font-weight: 800;
}
.quiz-hint { font-size: 14px; color: var(--gray-text); margin: 0 2px 16px; }

.choices { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.choice {
  background: #fff; border: 2px solid var(--gray-line); border-radius: var(--radius);
  padding: 14px 16px; font-size: 18px; font-weight: 600; cursor: pointer;
  box-shadow: 0 3px 0 var(--gray-line);
  transition: transform .06s;
  text-align: left; width: 100%; font-family: inherit; color: var(--text);
}
.choice:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--gray-line); }
.choice .c-sub { display: block; font-size: 12px; font-weight: 700; color: var(--orange); margin-top: 2px; letter-spacing: .03em; }
.romaji-inline { color: var(--orange); font-weight: 700; font-size: 12px; letter-spacing: .03em; }
.choice.correct {
  background: var(--green-light); border-color: var(--green); color: var(--green-dark);
  box-shadow: 0 3px 0 var(--green);
}
.choice.wrong {
  background: var(--red-light); border-color: var(--red); color: var(--red-dark);
  box-shadow: 0 3px 0 var(--red);
}
.choice.dim { opacity: .5; }
.choices.answered .choice { pointer-events: none; }

.feedback-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: 640px; margin: 0 auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  background: #fff; border-top: 2px solid var(--gray-line);
  transform: translateY(110%); transition: transform .22s ease;
}
.feedback-bar.show { transform: translateY(0); }
.feedback-bar.good { background: var(--green-light); border-color: var(--green); }
.feedback-bar.bad { background: var(--red-light); border-color: var(--red); }
.feedback-title { font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.feedback-bar.good .feedback-title { color: var(--green-dark); }
.feedback-bar.bad .feedback-title { color: var(--red-dark); }
.feedback-detail { font-size: 15px; margin-bottom: 12px; color: var(--text); }
.fb-example {
  margin-top: 8px; padding: 10px 12px; border-radius: 12px;
  background: rgba(255,255,255,.75); font-size: 15px; line-height: 1.6;
}
.fb-example .fb-ex-reading { font-size: 13px; color: var(--blue-dark); font-weight: 600; }
.fb-example .fb-ex-ko { font-size: 13px; color: var(--gray-text); }

/* ---------- 단어 카드 ---------- */
.flash-wrap { padding: 20px 16px 30px; }
.flash-counter { text-align: center; color: var(--gray-text); font-weight: 700; margin-bottom: 14px; }
.flash-card {
  perspective: 1000px; height: 430px; cursor: pointer;
}
.flash-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform .4s;
}
.flash-card.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: #fff; border: 2px solid var(--gray-line); border-radius: 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 20px; text-align: center;
  box-shadow: 0 4px 0 var(--gray-line);
}
.flash-face.back { transform: rotateY(180deg); background: var(--green-light); border-color: #b8e894; }
.flash-face .big { font-size: 44px; font-weight: 800; }
.flash-face .romaji-top { font-size: 16px; color: var(--orange); font-weight: 800; letter-spacing: .04em; }
.flash-face .kana-line { font-size: 17px; color: var(--blue-dark); font-weight: 700; }
.flash-face .mid { font-size: 20px; color: var(--blue-dark); font-weight: 700; }
.flash-face .meaning { font-size: 30px; font-weight: 800; color: var(--green-dark); }
.flash-face .pos { font-size: 13px; color: var(--gray-text); font-weight: 700; }
.flash-face.back { justify-content: flex-start; overflow-y: auto; padding: 18px 16px; }
.flash-face .example { font-size: 15px; color: var(--text); line-height: 1.6; margin-top: 6px; }
.example .ex-jp, .vw-example .ex-jp { font-size: 17px; font-weight: 600; line-height: 2.3; }
.flash-face .example small { color: var(--gray-text); display: block; }
.flash-face .example .ex-reading {
  display: block; font-size: 13px; color: var(--blue-dark); font-weight: 600; line-height: 1.5;
}
.flash-face .example .ex-reading i { color: var(--orange); font-style: normal; font-weight: 700; }
.flash-forms {
  width: 100%; margin-top: 10px; border-top: 2px dashed #c9e8ae; padding-top: 8px;
  text-align: left;
}
.flash-forms .ff-title { font-size: 12px; font-weight: 800; color: var(--gray-text); margin-bottom: 4px; }
.ff-row { display: flex; align-items: baseline; gap: 8px; padding: 3px 0; }
.ff-row .ff-label { flex: none; width: 56px; font-size: 12px; font-weight: 800; color: var(--gray-text); }
.ff-row .ff-word { font-size: 17px; font-weight: 700; }
.ff-row .ff-word .ff-kana { display: block; font-size: 12px; color: var(--blue-dark); font-weight: 600; }
.ff-row .ff-romaji { font-size: 12px; color: var(--orange); font-weight: 700; }
.flash-tip { text-align: center; color: var(--gray-text); font-size: 13px; margin-top: 12px; }
.flash-nav { display: flex; gap: 10px; margin-top: 18px; }
.flash-nav .btn { flex: 1; }

/* ---------- 발음 따라하기 ---------- */
.speak-card {
  background: #fff; border: 2px solid var(--gray-line); border-radius: 20px;
  padding: 20px; text-align: center;
}
.speak-card .jp { font-size: 22px; font-weight: 700; line-height: 2.1; }
.speak-card .reading { font-size: 15px; color: var(--blue-dark); margin-top: 6px; }
.speak-card .ko { font-size: 14px; color: var(--gray-text); margin-top: 6px; }
.speak-controls { display: flex; gap: 12px; justify-content: center; margin-top: 20px; }
.round-btn {
  width: 64px; height: 64px; border-radius: 50%; border: none; cursor: pointer;
  font-size: 26px; color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.round-btn.listen { background: var(--blue); box-shadow: 0 4px 0 var(--blue-dark); }
.round-btn.rec { background: var(--red); box-shadow: 0 4px 0 var(--red-dark); }
.round-btn.rec.recording { animation: pulse 1s infinite; }
.round-btn:active { transform: translateY(3px); box-shadow: none; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.speak-result { margin-top: 18px; min-height: 80px; }
.score-big { font-size: 42px; font-weight: 800; }
.score-big.good { color: var(--green); }
.score-big.mid { color: var(--orange); }
.score-big.bad { color: var(--red); }
.recog-text { font-size: 15px; color: var(--gray-text); margin-top: 6px; }
.speech-note {
  margin: 14px 0; padding: 12px; border-radius: var(--radius);
  background: #fff8e0; border: 2px solid var(--yellow);
  font-size: 14px; color: #8a6d00;
}

/* ---------- 결과 화면 ---------- */
.result-wrap { text-align: center; padding: 60px 24px 40px; }
.result-emoji { font-size: 72px; }
.result-title { font-size: 26px; font-weight: 800; margin-top: 14px; }
.result-stats { display: flex; justify-content: center; gap: 12px; margin: 26px 0; }
.result-box {
  border-radius: var(--radius); padding: 4px; min-width: 100px;
  border: 2px solid; overflow: hidden;
}
.result-box .rb-label { font-size: 12px; font-weight: 800; color: #fff; padding: 4px; border-radius: 10px 10px 0 0; }
.result-box .rb-value { font-size: 24px; font-weight: 800; padding: 10px 6px; background: #fff; border-radius: 0 0 12px 12px; }
.result-box.xp { border-color: var(--yellow); } .result-box.xp .rb-label { background: var(--yellow); }
.result-box.acc { border-color: var(--green); } .result-box.acc .rb-label { background: var(--green); }
.result-box.acc .rb-value { color: var(--green-dark); }
.result-box.xp .rb-value { color: #b78b00; }

.confetti-piece { position: fixed; top: -12px; font-size: 20px; animation: fall linear forwards; z-index: 50; pointer-events: none; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .7; } }

@media (min-width: 700px) {
  .mode-grid { grid-template-columns: repeat(3, 1fr); }
}
