:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --primary: #2f80ed;
  --secondary: #e9eef6;
  --text: #1f2933;
  --muted: #6b7280;

  --success: #27ae60;
  --warning: #f2c94c;
  --error: #eb5757;

  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ================= HEADER ================= */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: #fff;
  border-bottom: 1px solid #eee;
}

.brand strong {
  font-size: 18px;
}

.brand span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.icon-btn {
  border: none;
  background: none;
  font-size: 18px;
}

/* ================= NAV ================= */

.mode-tabs {
  display: flex;
  background: #fff;
}

.tab {
  flex: 1;
  padding: 12px;
  border: none;
  background: none;
  font-size: 14px;
  cursor: pointer;
}

.tab.active {
  border-bottom: 3px solid var(--primary);
  font-weight: 600;
}

/* ================= LAYOUT ================= */

.page {
  display: none;
}

.page.active {
  display: block;
}

.container {
  padding: 16px;
  max-width: 720px;
  margin: auto;
}

.section-header {
  margin-bottom: 12px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

/* ================= TEXT ================= */

h1 {
  font-size: 22px;
  margin-bottom: 4px;
}

h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
  display: block;
}

.hint {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* ================= BUTTONS ================= */

.btn {
  padding: 12px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  cursor: pointer;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.secondary {
  background: var(--secondary);
}

.btn.full {
  width: 100%;
}

.btn.small {
  font-size: 13px;
  padding: 8px 10px;
}

.button-row {
  display: flex;
  gap: 10px;
}

/* ================= SHADOWING ================= */

.phrase-text {
  font-size: 20px;
  font-weight: 500;
  margin: 14px 0;
  line-height: 1.4;
}

.mic-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 28px;
  display: block;
  margin: 12px auto;
}

.mic-btn.recording {
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(47,128,237,.6); }
  70% { box-shadow: 0 0 0 18px rgba(47,128,237,0); }
  100% { box-shadow: 0 0 0 0 rgba(47,128,237,0); }
}

/* ================= FEEDBACK ================= */

.word-feedback {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.word {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 14px;
}

.word.correct {
  background: #e8f7ef;
  color: var(--success);
}

.word.close {
  background: #fff6db;
  color: #b7791f;
}

.word.missing {
  background: #fdecea;
  color: var(--error);
}

/* ================= PHONEMES ================= */

.phoneme-panel {
  margin-top: 12px;
}

.phoneme-header {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ipa {
  color: var(--muted);
  font-size: 14px;
}

.phoneme-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.phoneme {
  padding: 6px 8px;
  border-radius: 8px;
  background: #eef2f7;
  font-size: 14px;
}

/* ================= UTILS ================= */

.processing {
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  margin: 12px 0;
}

.hidden {
  display: none;
}

.shadow-actions {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

/* ================= FOOTER ================= */

.footer {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  padding: 20px 10px;
}

/* ================= COOKIE ================= */

.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #222;
  color: #fff;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  z-index: 9999;
}

.cookie-banner a {
  color: #4ea3ff;
}

.cookie-banner button {
  background: #4ea3ff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.shadowing-phoneme-actions{
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  margin-top: 10px;
}

.shadowing-processing {
  margin-top: 16px;
  margin-bottom: 16px;
}

.label {
  font-weight: 600;
  margin-bottom: 6px;
}

.bar {
  height: 6px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  width: 30%;
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #60a5fa);
  animation: loading 1.8s ease-in-out infinite;
}

@keyframes loading {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}

.score-panel {
  max-width: 420px;
  margin: 2rem auto;
  padding: 1.5rem;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(0,0,0,0.06);
  text-align: center;
}

.score-main {
  margin-bottom: 1rem;
}

.score-value {
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1;
}

.score-grade {
  margin-top: 0.25rem;
  font-size: 1.1rem;
  text-transform: capitalize;
  opacity: 0.85;
}

/* Grade colors */
.score-panel.excellent .score-value { color: #16a34a; }
.score-panel.good .score-value { color: #22c55e; }
.score-panel.fair .score-value { color: #facc15; }
.score-panel.weak .score-value { color: #fb923c; }
.score-panel.try_again .score-value { color: #ef4444; }

.score-progress {
  margin: 1rem 0;
}

.progress-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: currentColor;
  transition: width 0.4s ease;
}

.score-breakdown {
  margin-top: 1.2rem;
  text-align: left;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
  font-size: 0.95rem;
}

.score-tip {
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: 8px;
  background: #f9fafb;
  font-size: 0.9rem;
}

.progress-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;

  padding: 6px 12px;
  margin-top: 8px;

  border-radius: 999px;
  background: #f3f4f6;
  font-size: 0.85rem;
  font-weight: 600;
}

.level-label {
  color: #1f2937;
}

.streak-label {
  color: #ef4444;
}

/* Level accents */
.progress-badge.starter {
  background: #eef2ff;
}

.progress-badge.beginner {
  background: #ecfeff;
}

.progress-badge.intermediate {
  background: #ecfdf5;
}

.progress-badge.advanced {
  background: #fff7ed;
}

.shadowing-phoneme {
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: transform 0.1s ease, background 0.2s ease;
}

.shadowing-phoneme:hover {
  transform: scale(1.08);
}

.shadowing-good { background: #e6f7ee; color: #1b7f4a; }
.shadowing-low  { background: #fff6e0; color: #8a6d1d; }
.shadowing-bad  { background: #fdecea; color: #a12622; }

.shadowing-phoneme[data-difficulty="high"] {
  border-bottom: 3px solid #d32f2f;
}

.shadowing-phoneme[data-difficulty="medium"] {
  border-bottom: 3px solid #fbc02d;
}

.shadowing-phoneme[data-difficulty="easy"] {
  border-bottom: 3px solid #388e3c;
}
