:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --accent: #f59e0b;
  --success-bg: #ecfdf5;
  --success-border: #10b981;
  --success-text: #065f46;
  --error-bg: #fef2f2;
  --error-border: #ef4444;
  --error-text: #991b1b;
  --radius: 16px;
  --shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-badge {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: #fff;
  font-weight: 800;
  font-size: 1.25rem;
  display: grid;
  place-items: center;
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.tagline {
  font-size: 0.75rem;
  color: var(--muted);
  display: block;
}

.nav-links {
  display: flex;
  gap: 0.5rem;
}

.nav-link {
  background: transparent;
  border: none;
  padding: 0.5rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.15s;
}

.nav-link:hover {
  color: var(--primary);
  background: var(--bg);
}

.nav-link.active {
  color: var(--primary);
  background: #eff6ff;
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.lang-select {
  padding: 0.5rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}

.stats {
  display: flex;
  gap: 0.5rem;
}

.stat-pill {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.container {
  width: 100%;
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem;
  flex: 1;
}

.view-section.hidden {
  display: none;
}

.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
  text-align: center;
  margin-bottom: 2rem;
}

.hero-title {
  font-size: 2rem;
  font-weight: 800;
  margin: 0.75rem 0;
  letter-spacing: -0.02em;
}

.hero-desc {
  font-size: 1.05rem;
  color: var(--muted);
  line-height: 1.6;
  max-width: 600px;
  margin: 0 auto 1.5rem auto;
}

.hero-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.feature-icon {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
}

.feature-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.feature-card p {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.lang-card {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}

.lang-card:hover {
  border-color: var(--primary);
  background: #eff6ff;
  transform: translateY(-2px);
}

.lang-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.lang-card p {
  font-size: 0.85rem;
  color: var(--muted);
}

.progress-wrapper {
  margin-bottom: 1.25rem;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.progress-track {
  width: 100%;
  height: 10px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 25%;
  background: linear-gradient(90deg, var(--primary), #10b981);
  transition: width 0.3s ease;
}

.step-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  overflow-x: auto;
}

.step-tab {
  flex: 1;
  min-width: 90px;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
}

.step-tab.active {
  border-color: var(--primary);
  color: var(--primary);
  background: #eff6ff;
}

.step-tab.completed {
  border-color: var(--success-border);
  color: var(--success-text);
  background: var(--success-bg);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.exercise-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--primary);
  margin-bottom: 0.75rem;
}

.prompt-text {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.sub-prompt {
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.sentence-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  font-size: 1.35rem;
  line-height: 1.8;
  margin-bottom: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.blank-input {
  font-size: 1.25rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border: 2px solid var(--primary);
  border-radius: 8px;
  width: 170px;
  text-align: center;
  color: var(--text);
  background: #fff;
  outline: none;
}

.blank-input:focus {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.char-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
  align-items: center;
}

.char-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-right: 0.25rem;
}

.char-btn {
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.char-btn:hover {
  background: #e2e8f0;
}

.word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.word-chip {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.word-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.speech-target-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

.target-phrase {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 0.4rem;
}

.phonetic-hint {
  font-size: 0.95rem;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.translation-hint {
  font-size: 0.9rem;
  color: var(--muted);
}

.audio-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.btn {
  padding: 0.75rem 1.35rem;
  border-radius: 10px;
  border: none;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-mic {
  background: #dc2626;
  color: #fff;
}

.btn-mic.listening {
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
  70% { box-shadow: 0 0 0 12px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

.transcript-box {
  margin-top: 1rem;
  padding: 0.85rem;
  border-radius: 10px;
  background: #f1f5f9;
  font-size: 0.95rem;
  text-align: center;
}

.word-scores {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.word-score-pill {
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.85rem;
}

.word-ok {
  background: #d1fae5;
  color: #065f46;
}

.word-miss {
  background: #fee2e2;
  color: #991b1b;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.feedback-drawer {
  margin-top: 1.25rem;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius);
  border: 2px solid transparent;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.feedback-drawer.hidden {
  display: none;
}

.feedback-drawer.correct {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

.feedback-drawer.incorrect {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-text);
}

.feedback-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.feedback-detail {
  font-size: 0.9rem;
  max-width: 480px;
}

.summary-screen {
  text-align: center;
  padding: 1rem 0;
}

.summary-stats {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.summary-stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.5rem;
}

.summary-stat strong {
  display: block;
  font-size: 1.5rem;
  color: var(--primary);
}

.footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}
