/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --bg3: #334155;
  --surface: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --text3: #64748b;
  --accent: #6FBA2C;
  --accent2: #8FC31F;
  --green: #14b8a6;
  --red: #ef4444;
  --yellow: #f59e0b;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  /* Type Scale */
  --fs-xs: 12px;    /* 라벨, 배지, 힌트 */
  --fs-sm: 13px;    /* 보조 텍스트, 파일정보 */
  --fs-base: 15px;  /* 탭, 버튼, 기본 UI */
  --fs-md: 17px;    /* 성경참조, 모달제목 */
  --fs-lg: 22px;    /* 입력 필드 */
  --fs-xl: 26px;    /* 성경 본문 */
  --fs-2xl: 28px;   /* 통계 숫자 */
}

/* Light theme */
[data-theme="light"] {
  --bg: #f8fafc;
  --bg2: #f1f5f9;
  --bg3: #e2e8f0;
  --surface: #ffffff;
  --border: #cbd5e1;
  --text: #1e293b;
  --text2: #475569;
  --text3: #94a3b8;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

[data-theme="light"] header { background: rgba(248,250,252,0.9); }
[data-theme="light"] .today-card { background: linear-gradient(135deg, #F1FAEA 0%, #ffffff 100%); border-color: rgba(111,186,44,0.2); }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  font-size: var(--fs-md);
  -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */
header {
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.logo svg { color: var(--accent); }
.logo-home { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.back-link {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 44px; padding: 6px 14px;
  color: var(--accent); text-decoration: none;
  font-size: var(--fs-sm); font-weight: 700;
  border: 1px solid var(--accent); border-radius: 8px;
  white-space: nowrap; flex-shrink: 0;
}
.back-link:hover { background: rgba(111,186,44,0.12); }

.bible-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bible-ref {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text);
}

.bible-actions { display: flex; gap: 8px; }

.file-info {
  font-size: var(--fs-xs);
  color: var(--text3);
  padding: 4px 0 16px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.file-info .sep { color: var(--bg3); }

/* ===== Buttons ===== */
.btn-outline {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-accent {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 10px;
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-accent:hover { background: #5aa024; transform: translateY(-1px); }

.file-upload-label { display: inline-block; cursor: pointer; }

.theme-toggle {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 4px;
  margin-left: 4px;
  border-radius: 6px;
  transition: color 0.2s;
}
.theme-toggle:hover { color: var(--accent); }
.theme-toggle .hidden { display: none; }

.btn-sm-outline {
  background: transparent;
  color: var(--text3);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 6px;
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-sm-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm-outline.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.btn-sm {
  padding: 4px 12px;
  font-size: var(--fs-xs);
}

.option-toggle {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  user-select: none;
}
.option-toggle input { accent-color: var(--accent); width: 20px; height: 20px; cursor: pointer; margin: 0; }

/* Range Panel */
.range-panel {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  flex-wrap: wrap;
}
.range-panel.hidden { display: none; }
.range-label { font-size: var(--fs-xs); font-weight: 600; color: var(--text3); }
.range-sep { font-size: var(--fs-base); color: var(--text3); margin: 0 4px; }
.range-select {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: var(--fs-sm);
  outline: none;
}

/* Listen options */
.listen-options {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 3px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.repeat-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text3);
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: 8px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.repeat-btn.active { background: var(--bg3); color: var(--text); }

/* ===== Container ===== */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 24px;
}

/* ===== Mode Tabs ===== */
.mode-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg2);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 12px;
}

.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text3);
  font-size: var(--fs-base);
  font-weight: 600;
  padding: 12px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover { color: var(--text2); }
.tab.active { background: var(--accent); color: #fff; }
.tab svg { flex-shrink: 0; }

/* ===== Home Screen ===== */
.home-screen { display: flex; flex-direction: column; gap: 20px; }
.home-screen.hidden { display: none; }

.guide-card {
  background: linear-gradient(135deg, #213d1a 0%, #1e293b 100%);
  border: 1px solid rgba(111, 186, 44, 0.3);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: 0 4px 32px rgba(111, 186, 44, 0.1);
}

[data-theme="light"] .guide-card { background: linear-gradient(135deg, #F1FAEA 0%, #ffffff 100%); }

.guide-card-title {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
}

.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.guide-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: var(--fs-sm);
  color: var(--text2);
  line-height: 1.6;
}

.guide-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 700;
  flex-shrink: 0;
}

.guide-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-left: 40px;
  font-size: var(--fs-sm);
  color: var(--text3);
  line-height: 1.8;
}

/* Progress */
.progress-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

/* 연속 학습일(streak) — 진행률 카드 최상단 */
.streak-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.streak-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
}
.streak-flame { font-size: var(--fs-md); line-height: 1; }
.streak-label { font-size: var(--fs-md); font-weight: 700; color: var(--text); }
.streak-label b { font-size: var(--fs-lg); font-weight: 800; color: var(--yellow); }
.streak-best { font-size: var(--fs-sm); font-weight: 600; color: var(--text2); }
.streak-best b { font-weight: 800; color: var(--text); }
.streak-best.hidden { display: none; }
.streak-nudge { font-size: var(--fs-sm); color: var(--text2); }
.streak-nudge.done { color: var(--green); font-weight: 700; }

/* PWA 설치 넛지 (미설치 사용자에게만, 닫기 가능) */
.pwa-nudge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  color: var(--text2);
}
.pwa-nudge.hidden { display: none; }
.pwa-nudge-icon { flex-shrink: 0; }
.pwa-nudge-text { flex: 1; line-height: 1.4; }
.pwa-nudge-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text3);
  font-size: 20px;
  line-height: 1;
  padding: 0 4px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.progress-title {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--text);
}

.progress-count {
  font-size: var(--fs-base);
  font-weight: 800;
  color: var(--accent);
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 20px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 4px;
  transition: width 0.5s ease;
  width: 0%;
}

.progress-modes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.prog-mode {
  text-align: center;
  padding: 12px 8px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.prog-mode-label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.prog-mode-val {
  font-size: var(--fs-xl);
  font-weight: 800;
  color: var(--text);
}

/* ===== Practice Area ===== */
.practice-area.hidden { display: none; }
.practice-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
}

/* ===== Stats Bar ===== */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat {
  text-align: center;
  padding: 14px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.stat-label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.stat-value {
  font-size: var(--fs-2xl);
  font-weight: 800;
}

.accent-blue { color: var(--accent); }
.accent-green { color: var(--green); }

/* ===== Display Text ===== */
.display-text {
  font-size: var(--fs-xl);
  line-height: 2;
  padding: 28px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  min-height: 80px;
  margin-bottom: 16px;
  word-break: keep-all;
  color: var(--text3);
  font-family: 'Noto Serif KR', Georgia, 'Times New Roman', serif;
}

.display-text .correct { color: var(--green); }
.display-text .incorrect { color: var(--red); background: rgba(239, 68, 68, 0.15); border-radius: 2px; }
.display-text .current { border-bottom: 2px solid var(--accent); background: rgba(111, 186, 44, 0.15); border-radius: 2px; }
.display-text .word-match { color: var(--green); }
.display-text .word-miss { color: var(--red); text-decoration: underline; }

.display-text.hidden-text {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  color: var(--text3);
  font-size: var(--fs-md);
}

/* ===== Mode Inputs ===== */
.mode-input.hidden { display: none; }

/* ── Typing ── */
.typing-input {
  width: 100%;
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--text);
  font-size: var(--fs-lg);
  padding: 18px 22px;
  border-radius: var(--radius);
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
}

.typing-input:focus { border-color: var(--accent); }
.typing-input.completed { border-color: var(--green); background: rgba(16, 185, 129, 0.05); }

/* ── Voice ── */
.voice-difficulty {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
}

.voice-diff-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text3);
  margin-right: 4px;
}

.vdiff-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text2);
  font-size: var(--fs-base);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.vdiff-btn:hover { border-color: var(--accent); color: var(--accent); }
.vdiff-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.voice-diff-desc {
  font-size: var(--fs-xs);
  color: var(--text3);
  margin-left: 8px;
}

.display-text .word-hidden {
  color: var(--bg3);
  letter-spacing: 2px;
  user-select: none;
}

.display-text .word-chosung {
  color: var(--text3);
  font-size: 0.85em;
  letter-spacing: 1px;
}

.voice-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  margin: 0 auto 16px;
  transition: all 0.2s;
  font-size: var(--fs-xs);
  font-weight: 600;
}

.voice-btn:hover { background: #5aa024; transform: scale(1.05); }

.voice-btn.recording {
  background: var(--red);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 20px rgba(239, 68, 68, 0); }
}

.voice-result {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.voice-result.hidden { display: none; }

.voice-result-header {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.voice-result-text {
  font-size: var(--fs-md);
  color: var(--text);
  line-height: 1.8;
  margin-bottom: 8px;
  min-height: 24px;
}

.voice-similarity {
  font-size: var(--fs-md);
  font-weight: 800;
  text-align: center;
  padding: 8px;
}

.voice-similarity.good { color: var(--green); }
.voice-similarity.ok { color: var(--yellow); }
.voice-similarity.bad { color: var(--red); }

/* ── Blank ── */
.blank-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.blank-difficulty {
  display: flex;
  align-items: center;
  gap: 6px;
}

.blank-diff-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text3);
  margin-right: 4px;
}

.diff-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text2);
  font-size: var(--fs-base);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.diff-btn:hover { border-color: var(--accent); color: var(--accent); }
.diff-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.blank-word {
  display: inline-flex;
  position: relative;
  margin: 0 0.32em;
  cursor: text;
}

.blank-cells {
  display: inline-flex;
  gap: 2px;
}

.blank-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4em;
  height: 1.6em;
  border: 2px dashed var(--accent);
  border-radius: 5px;
  color: var(--text3);
  pointer-events: none;
  transition: all 0.15s;
}

.blank-cell.filled {
  color: var(--text);
  border-style: solid;
  border-color: var(--accent);
}

.blank-cell.cursor {
  border-style: solid;
  border-color: var(--accent2);
  animation: cellBlink 1s step-end infinite;
}

@keyframes cellBlink {
  50% { border-color: transparent; }
}

.blank-word:focus-within .blank-cell:not(.filled):not(.cursor) {
  border-color: rgba(143, 195, 31, 0.4);
}

.blank-word-input {
  position: absolute;
  inset: 0;
  color: transparent;
  caret-color: transparent;
  font-size: inherit;
  cursor: text;
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
}

.blank-word.correct .blank-cell { border-color: var(--green); color: var(--green); border-style: solid; }
.blank-word.wrong .blank-cell { border-color: var(--red); color: var(--red); border-style: solid; }

.blank-answer {
  font-size: 0.6em;
  color: var(--green);
  position: absolute;
  bottom: -1.4em;
  left: 0;
  white-space: nowrap;
}

/* ── 원문 엿보기 (peek) ── */
.peek-bar { margin-bottom: 12px; }
.peek-btn {
  width: 100%;
  display: flex; align-items: center; gap: 6px;
  padding: 9px 14px;
  background: var(--bg2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text2);
  font-size: var(--fs-sm); font-family: inherit;
  cursor: pointer;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
  transition: background .12s, color .12s, border-color .12s;
}
.peek-btn:active,
.peek-bar.peeking .peek-btn { background: var(--accent); color: #fff; border-style: solid; border-color: var(--accent); }
.peek-hint { font-size: var(--fs-xs); opacity: .75; margin-left: auto; }
.peek-body {
  max-height: 0; overflow: hidden; opacity: 0;
  padding: 0 16px;
  background: var(--bg); border-radius: var(--radius);
  color: var(--text);
  line-height: 1.9;
  font-family: 'Noto Serif KR', Georgia, serif;
  transition: max-height .2s ease, padding .2s ease, opacity .2s ease, margin-top .2s ease;
}
.peek-bar.peeking .peek-body {
  max-height: 50vh; overflow: auto; opacity: 1;
  padding: 14px 16px; margin-top: 8px;
  border: 1px solid var(--border);
}

/* ── 시험: 단계 선택 ── */
.exam-stages { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.exam-stage-label { font-size: var(--fs-xs); color: var(--text3); margin-right: 2px; }
.estage-btn {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text2);
  font-size: var(--fs-sm); font-family: inherit; cursor: pointer; white-space: nowrap;
}
.estage-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.estage-btn.hidden { display: none; }

/* ── 시험 4단계: 백지(자유 입력) ── */
.exam-free {
  width: 100%; box-sizing: border-box; min-height: 150px;
  padding: 14px 16px; font-size: 1.15rem; line-height: 1.9;
  border: 2px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  resize: vertical; font-family: inherit;
}
.exam-free:focus { outline: none; border-color: var(--accent); }

/* ── 시험 5단계: 음성 암송 ── */
.exam-voice { text-align: center; padding: 10px 0; }
.exam-voice-prompt { color: var(--text2); margin-bottom: 16px; font-size: var(--fs-sm); }
.exam-voice-unsupported { color: var(--text2); text-align: center; padding: 24px 12px; line-height: 1.7; }

/* ── 시험 1단계: 단어 블록 ── */
.wordslot {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.2em; min-height: 1.6em;
  margin: 2px 0.18em; padding: 0 8px;
  border: 2px dashed var(--accent); border-radius: 6px;
  color: var(--text3); cursor: pointer;
}
.wordslot.filled { border-style: solid; color: var(--text); background: rgba(143, 195, 31, 0.08); }
/* 채운 칸 = 누르면 취소 (✕ 배지 + 호버 강조) */
.wordslot.filled::after {
  content: '✕';
  position: absolute; top: -7px; right: -7px;
  min-width: 16px; height: 16px; line-height: 15px; padding: 0 2px;
  box-sizing: border-box; font-size: 10px; text-align: center;
  background: var(--red); color: #fff; border-radius: 50%;
  opacity: 0.4; transition: opacity .12s, transform .12s; pointer-events: none;
}
.wordslot.filled:hover { border-color: var(--red); color: var(--red); }
.wordslot.filled:hover::after { opacity: 1; transform: scale(1.12); }

.exam-wb-actions { display: flex; gap: 8px; justify-content: flex-end; margin: 8px 0 -4px; }
.exam-wb-actions.hidden { display: none; }
.wb-act-btn {
  padding: 5px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text2);
  font-size: var(--fs-xs); font-family: inherit; cursor: pointer;
}
.wb-act-btn:hover { border-color: var(--red); color: var(--red); }
.exam-wordbank {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 6px 0 14px; padding: 14px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
}
.exam-wordbank.hidden { display: none; }
.wordchip {
  padding: 8px 14px; border: 1px solid var(--accent); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font-size: var(--fs-base); font-family: 'Noto Serif KR', Georgia, serif; cursor: pointer;
  transition: opacity .12s, transform .08s;
}
.wordchip:active { transform: scale(0.95); }
.wordchip.used { opacity: 0; pointer-events: none; }

/* ── Listen ── */
.listen-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.listen-voice {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 3px;
  border-radius: 8px;
}

.voice-sel {
  flex: 1;
  background: none;
  border: none;
  color: var(--text3);
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.voice-sel.active { background: var(--bg3); color: var(--text); }

.listen-player {
  display: flex;
  align-items: center;
  gap: 16px;
}

.play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 12px 28px;
  border-radius: 12px;
  font-size: var(--fs-base);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.play-btn:hover { background: #5aa024; }
.play-btn .hidden { display: none; }

.speed-control {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.speed-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text3);
  flex-shrink: 0;
}

#speed-range {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
}

#speed-val {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text2);
  min-width: 36px;
  text-align: right;
}

/* ===== Completion Effect ===== */
@keyframes celebrate {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.practice-area.celebrate {
  animation: celebrate 0.8s ease 2;
  border-color: var(--green);
}

.celebrate-msg {
  text-align: center;
  padding: 8px;
  margin-top: 12px;
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--green);
  opacity: 0;
  transition: opacity 0.3s;
}

.celebrate-msg.show { opacity: 1; }

/* ===== Shortcut Hints ===== */
.shortcut-hints {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
  font-size: var(--fs-xs);
  color: var(--text3);
}

.shortcut-hints kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: var(--fs-xs);
  color: var(--text2);
}

/* ===== Chapter Grid ===== */
.chapter-grid-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.chapter-grid-title {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 6px;
}

.ch-block {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: var(--fs-xs);
  font-weight: 700;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text3);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.ch-block:hover { border-color: var(--accent); color: var(--accent); }
.ch-block.partial { background: rgba(111, 186, 44, 0.15); border-color: rgba(111, 186, 44, 0.3); color: var(--accent); }
.ch-block.done { background: rgba(16, 185, 129, 0.15); border-color: rgba(16, 185, 129, 0.3); color: var(--green); }

/* ===== Selector Done Mark ===== */
.selector-btn.practiced { position: relative; }
.selector-btn.practiced::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.selector-btn.all-done {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
}

/* ===== Mode Transition ===== */
.practice-area { transition: opacity 0.2s ease; }
.practice-area.fading { opacity: 0; }
.home-screen { transition: opacity 0.2s ease; }
.home-screen.fading { opacity: 0; }

/* ===== Controls ===== */
.controls {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.btn-control {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 14px;
  border-radius: 10px;
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-control:hover { border-color: var(--text3); color: var(--text); }

.btn-next {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-next:hover { background: #5aa024; border-color: #5aa024; color: #fff; }

/* ===== History ===== */
.history { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 20px; }

.history-title {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 4px;
  font-size: var(--fs-sm);
}

.history-ref { font-weight: 600; color: var(--text); }
.history-stats { color: var(--text3); font-variant-numeric: tabular-nums; }
.history-stats .perfect { color: var(--green); font-weight: 700; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.modal-header h3 { flex: 1; font-size: var(--fs-md); font-weight: 700; }

.modal-back, .modal-close {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  font-size: var(--fs-lg);
  line-height: 1;
}

.modal-back:hover, .modal-close:hover { color: var(--text); }
.modal-back.hidden { display: none; }

.selector-grid {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

.selector-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 12px 8px;
  border-radius: 10px;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.selector-btn:hover { border-color: var(--accent); color: var(--accent); }
.selector-btn.current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== Wrong Answers ===== */
.wrong-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.wrong-section.hidden { display: none; }
.wrong-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.wrong-title { font-size: var(--fs-base); font-weight: 700; color: var(--text); }
.wrong-list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.wrong-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: border-color 0.2s;
  border: 1px solid transparent;
}
.wrong-item:hover { border-color: var(--accent); }
.wrong-ref { font-weight: 600; color: var(--text); }
.wrong-count { color: var(--red); font-weight: 700; font-size: var(--fs-xs); }
.wrong-preview { color: var(--text3); font-size: var(--fs-xs); margin-left: 8px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Text Input Modal ===== */
.text-modal { max-width: 640px; }

.text-modal-body { padding: 20px; }

.text-modal-guide {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

.guide-title {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.guide-example {
  font-size: var(--fs-sm);
  color: var(--accent);
  font-family: monospace;
  line-height: 1.8;
  margin-bottom: 8px;
}

.guide-note {
  font-size: var(--fs-xs);
  color: var(--text3);
}

.text-input-area {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 14px;
  border-radius: var(--radius);
  font-size: 16px;            /* iOS 포커스 자동 확대 방지(≥16px) */
  font-family: inherit;
  line-height: 1.8;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.text-input-area:focus { border-color: var(--accent); }

.text-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
}

.text-parse-info {
  font-size: var(--fs-sm);
  color: var(--text3);
}

.text-parse-info.success { color: var(--green); }
.text-parse-info.error { color: var(--red); }

/* ===== Footer ===== */
.site-footer {
  max-width: 900px;
  margin: 24px auto 40px;
  padding: 0 24px;
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--text3);
  line-height: 1.6;
}

.feedback-btn {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  padding: 9px 22px;
  border-radius: 999px;
  font-size: var(--fs-sm);
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 12px;
  transition: all 0.2s;
  box-shadow: 0 2px 10px rgba(111, 186, 44, 0.35);
}

.feedback-btn:hover { background: var(--accent2); border-color: var(--accent2); box-shadow: 0 4px 14px rgba(143, 195, 31, 0.45); transform: translateY(-1px); }

.feedback-note { font-size: var(--fs-sm); color: var(--text2); margin: 10px 0 0; line-height: 1.55; max-width: 100%; word-break: keep-all; overflow-wrap: break-word; }

/* ===== Responsive ===== */
/* ===== 시험 모드 ===== */
.exam-area.hidden,
#exam-run.hidden,
.exam-result.hidden,
.exam-best.hidden,
.exam-result-actions button.hidden { display: none; }
.exam-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.exam-progress { font-size: var(--fs-base); font-weight: 800; color: var(--accent); }
.exam-ref { font-size: var(--fs-md); font-weight: 700; color: var(--text2); margin-bottom: 10px; }
.exam-next { display: block; width: 100%; margin-top: 16px; min-height: 48px; }
.exam-hint { margin-top: 10px; font-size: var(--fs-xs); color: var(--text3); text-align: center; }

/* 절별 즉시 채점 */
.exam-locked { pointer-events: none; }
.exam-graded-actions { display: flex; gap: 8px; margin-top: 16px; }
.exam-graded-actions.hidden { display: none; }
.exam-graded-actions #exam-retry { flex: 0 0 38%; min-height: 48px; }
.exam-graded-actions #exam-advance { flex: 1; min-height: 48px; }
.wordslot.correct { border-style: solid; border-color: var(--green); color: var(--green); background: rgba(20, 184, 166, 0.10); }
.wordslot.wrong { border-style: solid; border-color: var(--red); color: var(--red); background: rgba(239, 68, 68, 0.10); }
.wordslot.correct::after, .wordslot.wrong::after { display: none; }
.exam-free-verdict { margin-top: 12px; padding: 12px 14px; border-radius: var(--radius); font-weight: 700; font-size: var(--fs-md); }
.exam-free-verdict.ok { color: var(--green); background: rgba(20, 184, 166, 0.10); border: 1px solid var(--green); }
.exam-free-verdict.bad { color: var(--red); background: rgba(239, 68, 68, 0.08); border: 1px solid var(--red); }
.exam-free-orig { margin-top: 8px; font-weight: 500; color: var(--text); font-size: var(--fs-base); line-height: 1.7; }
#exam-voice-text .word-match { color: var(--green); }
#exam-voice-text .word-miss { color: var(--red); text-decoration: underline; }
.exam-result { text-align: center; }
.exam-score { margin: 16px 0 8px; }
.exam-score-pct { display: block; font-size: 48px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.exam-score-detail { font-size: var(--fs-md); color: var(--text2); }
.exam-best { font-size: var(--fs-sm); color: var(--green); font-weight: 700; margin-bottom: 12px; }
.exam-wrong-section { text-align: left; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 12px 0; }
.exam-wrong-section.hidden { display: none; }
.exam-wrong-title { font-size: var(--fs-sm); font-weight: 700; color: var(--red); margin-bottom: 8px; }
.exam-wrong-list { display: flex; flex-wrap: wrap; gap: 6px; }
.exam-wrong-item { font-size: var(--fs-xs); background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; color: var(--text2); }
.exam-result-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.exam-result-actions button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }

/* 빈칸 난이도 설명 (Lv5 = 초성 노출) */
.blank-diff-desc { font-size: var(--fs-xs); color: var(--text2); margin-left: 6px; white-space: nowrap; }

/* 음성 모드 가용성 안내 */
.voice-support-note { font-size: var(--fs-sm); color: var(--text2); text-align: center; line-height: 1.5; margin-bottom: 12px; }
.voice-support-note.unsupported { color: var(--yellow); }

@media (max-width: 640px) {
  .header-inner { flex-direction: column; gap: 10px; }
  .bible-info { flex-direction: column; gap: 8px; align-items: center; }

  .mode-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: center;
  }
  .mode-tabs::-webkit-scrollbar { display: none; }
  .tab {
    flex: 0 0 auto;
    font-size: var(--fs-sm);
    padding: 8px 12px;
    gap: 4px;
    white-space: nowrap;
  }
  .tab svg { width: 14px; height: 14px; }

  .practice-area { padding: 20px 16px; }
  .display-text { font-size: var(--fs-lg); padding: 16px; line-height: 1.8; }
  .typing-input { font-size: var(--fs-md); padding: 14px; }
  .stat-value { font-size: var(--fs-lg); }
  .stat-label { font-size: var(--fs-xs); }
  .stats-bar { gap: 8px; }
  .tab { font-size: var(--fs-xs); padding: 8px 6px; }
  .btn-control { font-size: var(--fs-sm); padding: 12px; }

  .blank-toolbar { flex-direction: column; gap: 12px; }
  .blank-difficulty { justify-content: center; }

  .listen-player { flex-direction: column; }

  .chapter-grid { grid-template-columns: repeat(7, 1fr); }
  .shortcut-hints { display: none; }
  .guide-card { padding: 20px 14px; }
  .guide-modes { grid-template-columns: 1fr; margin-left: 40px; }
  .progress-modes { grid-template-columns: repeat(2, 1fr); }

  .voice-difficulty { flex-wrap: nowrap; overflow-x: auto; }
  .listen-player { flex-direction: column; gap: 12px; }
  .listen-voice { flex-shrink: 0; }
  .voice-sel { white-space: nowrap; font-size: var(--fs-xs); }
  .blank-toolbar { flex-wrap: nowrap; }
  .blank-diff-label { font-size: var(--fs-xs); }
  .diff-btn, .vdiff-btn { width: 32px; height: 32px; font-size: var(--fs-sm); }

  /* 반복 버튼 */
  .listen-options { flex-wrap: nowrap; }
  .repeat-btn { font-size: var(--fs-xs); padding: 6px 4px; }

  /* 범위 패널 */
  .range-panel { flex-wrap: wrap; gap: 6px; }
  .range-select { font-size: var(--fs-xs); padding: 3px 6px; }

  /* 옵션 토글 */
  .option-toggle { font-size: var(--fs-sm); }
  .option-toggle input { width: 18px; height: 18px; }
  .file-info { flex-wrap: wrap; gap: 6px; }

  /* 빈칸 셀 */
  .blank-cell { width: 1.1em; height: 1.4em; }
  .blank-word { margin: 0 1px; }

  /* 오답노트 */
  .wrong-item { padding: 8px 10px; font-size: var(--fs-xs); }

  .selector-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }

  /* 터치 타깃 ≥44px (모바일 손가락 친화) */
  .tab { min-height: 44px; }
  .btn-control { min-height: 44px; }
  .btn-outline, .btn-accent { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .theme-toggle { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
  .diff-btn, .vdiff-btn { width: 44px; height: 44px; flex-shrink: 0; }
  .repeat-btn { min-height: 44px; }
  .voice-sel { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .pwa-nudge-close { min-width: 36px; min-height: 36px; }
}
