:root {
  --primary: #2b6cb0;
  --bg: #f7f9fc;
  --card: #ffffff;
  --text: #1a202c;
  --muted: #718096;
  --good: #2f855a;
  --bad: #c53030;
  --border: #e2e8f0;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Noto Sans KR", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 70px; /* 하단 번역기 버튼 공간 */
}
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--primary);
  color: white;
}
.app-header h1 { font-size: 18px; margin: 0; }
.app-header select {
  padding: 6px 10px;
  border-radius: 6px;
  border: none;
}
.tabs {
  display: flex;
  background: white;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.tab-btn {
  flex: 1;
  padding: 14px 0;
  background: none;
  border: none;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
}
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 28px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  text-align: center;
}
.category-badge {
  display: inline-block;
  font-size: 12px;
  color: var(--primary);
  background: #ebf4ff;
  padding: 2px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.word-jp {
  font-size: 32px;
  font-weight: 700;
  margin: 8px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.word-jp ruby { ruby-align: center; }
.word-jp rt {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}
.word-reading {
  font-size: 16px;
  color: var(--muted);
  margin-bottom: 12px;
}
.word-meaning {
  font-size: 20px;
  margin: 14px 0;
  min-height: 28px;
}
.example {
  font-size: 14px;
  color: var(--muted);
  margin-top: 14px;
  line-height: 1.6;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}
.quiz-option {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  font-size: 15px;
  cursor: pointer;
  text-align: left;
}
.quiz-option:hover:not(:disabled) { border-color: var(--primary); background: #f7faff; }
.quiz-option:disabled { cursor: default; }
.quiz-option.correct { background: #f0fff4; border-color: var(--good); color: var(--good); font-weight: 600; }
.quiz-option.wrong { background: #fff5f5; border-color: var(--bad); color: var(--bad); font-weight: 600; }
.speak-btn {
  border: none;
  background: #ebf4ff;
  color: var(--primary);
  border-radius: 999px;
  width: 30px;
  height: 30px;
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}
.speak-btn.small { width: 24px; height: 24px; font-size: 12px; }
.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}
button.primary {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: white;
  font-size: 15px;
  cursor: pointer;
}
button.outline {
  flex: 1;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}
button.correct { background: var(--good); color: white; border: none; }
button.wrong { background: var(--bad); color: white; border: none; }
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
}
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.stat-card {
  background: var(--card);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
}
.stat-card .num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 13px; color: var(--muted); margin-top: 4px; }
textarea.answer-box {
  width: 100%;
  min-height: 70px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 16px;
  margin-top: 12px;
  resize: vertical;
}
.prompt-ko { font-size: 18px; font-weight: 600; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.answer-reveal {
  margin-top: 14px;
  padding: 12px;
  background: #ebf8ff;
  border-radius: 10px;
  font-size: 16px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- 하단 번역 패널 ---------- */
.translator-toggle {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 30;
  border: none;
  background: var(--primary);
  color: white;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  cursor: pointer;
}
.kana-toggle-btn {
  right: auto;
  left: 16px;
  background: #6b46c1;
}
.kana-panel {
  max-height: 78vh;
  display: flex;
  flex-direction: column;
}
.kana-panel-body {
  overflow-y: auto;
}
/* 발음 패널은 화면 왼쪽 아래에 좁은 폭으로 붙여서, 가운데의 학습 카드를 가리지 않도록 함
   (id 선택자로 위의 .translator-panel 공용 규칙보다 우선 적용) */
#kana-panel {
  left: 16px;
  right: auto;
  margin: 0;
  width: min(360px, 90vw);
  max-width: none;
  border-radius: 16px;
}
#kana-panel.hidden { transform: translateX(-120%); }
.translator-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: white;
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.15);
  max-width: 480px;
  margin: 0 auto;
  transition: transform 0.2s ease;
}
.translator-panel.hidden { transform: translateY(110%); }
.translator-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.translator-header button {
  border: none;
  background: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--muted);
}
.translator-body { padding: 14px 16px 20px; }
.translator-direction {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.dir-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
}
.dir-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
#translator-input {
  width: 100%;
  min-height: 60px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 15px;
  resize: vertical;
}
.translator-result {
  margin-top: 10px;
  min-height: 20px;
  font-size: 15px;
  padding: 10px;
  background: #f7f9fc;
  border-radius: 8px;
  display: none;
}
.translator-result.show { display: flex; align-items: center; gap: 8px; }
.translator-external-links {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.translator-external-links.hidden { display: none; }
.translator-external-links a {
  color: var(--primary);
  margin-left: 6px;
  text-decoration: none;
  font-weight: 600;
}

/* ---------- 발음 가이드 ---------- */
.pronunciation-page { display: flex; flex-direction: column; gap: 18px; }
.kana-section {
  background: var(--card);
  border-radius: 14px;
  padding: 18px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.kana-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.kana-section h3 { margin: 0 0 4px; font-size: 16px; }
.kana-note { font-size: 13px; color: var(--muted); margin: 4px 0 12px; }
.small-toggle { flex: none; padding: 6px 12px; font-size: 12px; }
.kana-grid {
  display: grid;
  gap: 6px;
}
.kana-cell {
  border: 1px solid var(--border);
  background: #fafcff;
  border-radius: 8px;
  padding: 8px 2px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.kana-cell.empty { border: none; background: none; cursor: default; }
.kana-cell.wide { flex-direction: row; gap: 8px; padding: 10px 14px; width: auto; }
.kana-main { font-size: 18px; font-weight: 700; }
.kana-romaji { font-size: 11px; color: var(--muted); }
.kana-example-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
