: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;
}
.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;
}
.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; }
