/* ============================================
   Thai Lessons V2 — DVC Dark Theme
   ============================================ */

:root {
  --bg-primary: #1a1a1a;
  --bg-card: #2a2a2a;
  --bg-card-hover: #333333;
  --bg-input: #222222;
  --accent: #c9a96e;
  --accent-dim: #a08450;
  --accent-glow: rgba(201, 169, 110, 0.15);
  --text-primary: #e0e0e0;
  --text-secondary: #999999;
  --text-muted: #666666;
  --text-thai: #ffffff;
  --green: #5cb85c;
  --green-dim: rgba(92, 184, 92, 0.15);
  --red: #d9534f;
  --red-dim: rgba(217, 83, 79, 0.15);
  --border: #3a3a3a;
  --nav-height: 64px;
  --header-height: 52px;
  --radius: 12px;
  --radius-sm: 8px;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.screen { height: 100vh; width: 100vw; }

/* ============ AUTH SCREEN ============ */

#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
}

.auth-container {
  text-align: center;
  padding: 40px 24px;
  max-width: 340px;
  width: 100%;
}

.auth-logo { font-size: 64px; margin-bottom: 16px; }

.auth-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-family: 'Noto Sans Thai', sans-serif;
}

.auth-input-wrap { display: flex; gap: 8px; }

.auth-input-wrap input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.auth-input-wrap input:focus { border-color: var(--accent); }

.auth-error {
  color: var(--red);
  font-size: 14px;
  margin-top: 12px;
  min-height: 20px;
}

/* ============ BUTTONS ============ */

.btn-gold {
  padding: 12px 24px;
  background: var(--accent);
  color: #1a1a1a;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

.btn-gold:active { transform: scale(0.97); background: var(--accent-dim); }
.btn-gold:disabled { opacity: 0.4; cursor: default; transform: none; }

.btn-large {
  display: block;
  width: 100%;
  padding: 16px;
  font-size: 18px;
  border-radius: var(--radius);
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 16px;
  transition: color 0.2s;
}

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

/* ============ HEADER ============ */

#app-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

#header-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
}

/* ============ APP LAYOUT ============ */

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#main-content {
  flex: 1;
  overflow: hidden;
}

.view {
  display: none;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.view.active { display: flex; flex-direction: column; }

/* ============ BOTTOM NAV ============ */

#bottom-nav {
  display: flex;
  height: var(--nav-height);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn.active { color: var(--accent); }
.nav-icon { font-size: 22px; line-height: 1; }
.nav-label { font-size: 11px; font-weight: 500; }

/* ============ LESSONS VIEW ============ */

#view-lessons { flex-direction: column; }

.sidebar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
  flex-shrink: 0;
}

.section-dropdown {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.section-nav { display: none; }

.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + 16px);
  -webkit-overflow-scrolling: touch;
}

.welcome-card {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-secondary);
}

.welcome-card h2 { font-size: 20px; margin-bottom: 8px; }

/* ============ SECTION INTRO CARD ============ */

.section-intro {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.intro-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.intro-thai {
  font-size: 32px;
  color: var(--text-thai);
  font-weight: 500;
  line-height: 1.3;
}

.intro-english {
  font-size: 20px;
  color: var(--accent);
  margin-bottom: 8px;
  font-weight: 600;
}

.intro-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}

.intro-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.intro-stat {
  font-size: 13px;
  color: var(--text-muted);
}

.intro-stat-sep {
  color: var(--text-muted);
  font-size: 13px;
}

.intro-progress-bar {
  flex: 1;
  min-width: 80px;
  height: 4px;
  background: var(--bg-primary);
  border-radius: 2px;
  overflow: hidden;
}

.intro-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.intro-pct {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
}

/* ============ GRAMMAR BLOCKS ============ */

.grammar-section {
  margin-bottom: 20px;
}

.grammar-block {
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.grammar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.grammar-header:active { background: var(--bg-card-hover); }

.grammar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
}

.grammar-chevron {
  font-size: 20px;
  color: var(--text-muted);
  transition: transform 0.25s ease;
  font-weight: 300;
}

.grammar-block.expanded .grammar-chevron {
  transform: rotate(90deg);
}

.grammar-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.grammar-block.expanded .grammar-body {
  max-height: 2000px;
}

.grammar-body > *:first-child {
  padding-top: 0;
}

.grammar-content {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  padding: 0 16px 12px;
}

.grammar-points {
  list-style: none;
  padding: 0 16px 12px;
}

.grammar-points li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(58, 58, 58, 0.5);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.grammar-points li:last-child { border-bottom: none; }

.gp-text {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.4;
}

.gp-thai {
  font-size: 16px;
  color: var(--text-thai);
  opacity: 0.7;
}

.grammar-examples {
  padding: 0 16px 12px;
}

.grammar-example {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.ge-thai {
  font-size: 20px;
  color: var(--text-thai);
  font-weight: 500;
}

.ge-english {
  font-size: 13px;
  color: var(--text-secondary);
  flex: 1;
  min-width: 120px;
}

.grammar-tip {
  margin: 0 16px 16px;
  padding: 12px 14px;
  background: var(--accent-glow);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  color: var(--accent);
  line-height: 1.5;
}

/* ============ VOCAB CARDS — INTERACTIVE ============ */

.vocab-section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 16px 0 8px;
}

.category-divider {
  margin: 20px 0 12px;
  padding: 6px 12px;
  background: var(--accent-glow);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.vocab-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  transition: background 0.15s, border-color 0.2s;
  cursor: pointer;
  border: 1px solid transparent;
  position: relative;
}

.vocab-card:active { background: var(--bg-card-hover); }

.vocab-card.mastered {
  border-color: rgba(92, 184, 92, 0.3);
}

.vocab-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.vocab-thai {
  font-size: 28px;
  font-weight: 500;
  color: var(--text-thai);
  line-height: 1.3;
}

.vocab-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.vocab-romanization {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  margin-top: 2px;
  font-style: italic;
}

/* English hidden by default, revealed on tap */
.vocab-english-wrap {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}

.vocab-card.revealed .vocab-english-wrap {
  max-height: 200px;
  opacity: 1;
}

.vocab-english {
  font-size: 16px;
  color: var(--text-primary);
  line-height: 1.4;
  padding-top: 8px;
}

.vocab-example {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
}

.vocab-notes {
  font-size: 12px;
  color: var(--accent-dim);
  margin-top: 4px;
}

.vocab-tap-hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.vocab-card.revealed .vocab-tap-hint {
  display: none;
}

.vocab-mastered-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 11px;
  color: var(--green);
  background: var(--green-dim);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  pointer-events: none;
}

/* Speaker button */
.btn-speak {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
  line-height: 1;
}

.btn-speak:active {
  background: var(--accent-glow);
  border-color: var(--accent);
}

.btn-speak-large {
  width: 44px;
  height: 44px;
  min-width: 44px;
  font-size: 20px;
}

.btn-speak-sm {
  width: 34px;
  height: 34px;
  min-width: 34px;
  font-size: 15px;
}

/* Favorite/bookmark button */
.btn-fav {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}

.btn-fav.active {
  color: var(--accent);
}

/* Section footer */
.section-footer {
  margin-top: 24px;
  padding: 20px 0;
  text-align: center;
}

.footer-progress {
  margin-bottom: 16px;
}

.footer-label {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ============ SIDEBAR PROGRESS ============ */

.nav-item-label {
  display: block;
}

.nav-progress-bar {
  height: 3px;
  background: var(--bg-primary);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.nav-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.section-nav-item.completed .nav-item-label::after {
  content: ' ✓';
  color: var(--accent);
  font-size: 12px;
}

/* ============ QUIZ VIEW ============ */

#view-quiz { flex-direction: column; }

.quiz-config {
  padding: 24px 16px;
  padding-bottom: calc(var(--nav-height) + 16px);
  overflow-y: auto;
  flex: 1;
}

.quiz-config h2 {
  font-size: 22px;
  color: var(--accent);
  margin-bottom: 20px;
}

.config-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 16px 0 8px;
}

.config-label:first-of-type { margin-top: 0; }

.chip-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.picker-chip {
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.picker-chip.selected {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

.picker-chip:active { transform: scale(0.96); }

#quiz-start { margin-top: 24px; }

/* Quiz Player */
.quiz-player {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + 16px);
}

.quiz-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-shrink: 0;
}

#quiz-counter {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.quiz-timer-bar {
  flex: 1;
  height: 4px;
  background: var(--bg-card);
  border-radius: 2px;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s linear;
  width: 100%;
}

.timer-fill.urgent {
  background: var(--red);
}

#quiz-score {
  font-size: 14px;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

/* Quiz question card */
.quiz-question {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.quiz-question .q-prompt {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.quiz-question .q-text {
  font-size: 36px;
  color: var(--text-thai);
  font-weight: 500;
  line-height: 1.3;
}

.quiz-question .q-text-en {
  font-size: 24px;
  color: var(--text-primary);
  font-weight: 500;
  line-height: 1.4;
}

.quiz-question .q-romanization {
  font-size: 14px;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 8px;
}

.quiz-question .q-speak {
  margin-top: 12px;
}

/* Quiz answer buttons */
.quiz-answers {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
}

.quiz-answer-btn {
  width: 100%;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  min-height: 52px;
}

.quiz-answer-btn:active { background: var(--bg-card-hover); }

.quiz-answer-btn.correct {
  border-color: var(--green);
  background: var(--green-dim);
  color: var(--green);
}

.quiz-answer-btn.wrong {
  border-color: var(--red);
  background: var(--red-dim);
  color: var(--red);
}

.quiz-answer-btn.disabled {
  pointer-events: none;
  opacity: 0.5;
}

.quiz-answer-btn .answer-thai {
  font-size: 22px;
  color: var(--text-thai);
  display: block;
  margin-bottom: 2px;
}

.quiz-answer-btn .answer-sub {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Quiz feedback */
.quiz-feedback {
  text-align: center;
  padding: 16px;
  border-radius: var(--radius);
  margin-top: 12px;
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
}

.quiz-feedback.correct-fb {
  background: var(--green-dim);
  color: var(--green);
}

.quiz-feedback.wrong-fb {
  background: var(--red-dim);
  color: var(--red);
}

.quiz-feedback .fb-correct-answer {
  font-size: 20px;
  color: var(--text-thai);
  display: block;
  margin-top: 4px;
}

/* Typing quiz */
.quiz-typing {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-shrink: 0;
}

.quiz-typing input {
  flex: 1;
  padding: 14px 16px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.quiz-typing input:focus { border-color: var(--accent); }

/* Flashcard mode in quiz */
.quiz-flashcard-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-shrink: 0;
}

.btn-action {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  min-height: 48px;
}

.btn-action:active { transform: scale(0.96); }

.btn-miss {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(217, 83, 79, 0.3);
}

.btn-know {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(92, 184, 92, 0.3);
}

/* Quiz results */
.quiz-results {
  padding: 48px 24px;
  padding-bottom: calc(var(--nav-height) + 24px);
  text-align: center;
  overflow-y: auto;
}

.quiz-results h2 {
  font-size: 24px;
  color: var(--accent);
  margin-bottom: 24px;
}

.result-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 32px;
}

.result-pct {
  font-size: 64px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.result-frac {
  font-size: 18px;
  color: var(--text-secondary);
}

.result-missed {
  text-align: left;
  margin-bottom: 24px;
}

.result-missed h3 {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.missed-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}

.missed-item .mi-thai {
  font-size: 18px;
  color: var(--text-thai);
}

.missed-item .mi-english {
  font-size: 14px;
  color: var(--text-secondary);
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ============ SEARCH VIEW ============ */

#view-search { flex-direction: column; }

.search-bar {
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input:focus { border-color: var(--accent); }

.search-bar .section-dropdown {
  width: auto;
  min-width: 100px;
  flex-shrink: 0;
}

#search-results { padding: 16px; }

.search-placeholder {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-secondary);
}

.search-count {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Search results cards should be revealed by default */
#search-results .vocab-card { cursor: default; }
#search-results .vocab-english-wrap {
  max-height: 200px;
  opacity: 1;
}
#search-results .vocab-tap-hint { display: none; }

/* ============ STATS VIEW ============ */

#view-stats { flex-direction: column; }

.stats-container {
  padding: 24px 16px;
  padding-bottom: calc(var(--nav-height) + 16px);
  overflow-y: auto;
  flex: 1;
}

.stats-title {
  font-size: 22px;
  color: var(--accent);
  margin-bottom: 20px;
}

.stats-summary {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 90px;
}

.stat-big {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
}

.stat-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.stats-overall-bar {
  height: 8px;
  background: var(--bg-card);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.stats-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0;
}

.stats-bar-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.stats-sections { }

.stats-section-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(58, 58, 58, 0.5);
}

.stats-section-row:last-child { border-bottom: none; }

.stats-sec-name {
  font-size: 13px;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-sec-bar {
  width: 80px;
  height: 4px;
  background: var(--bg-card);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

.stats-sec-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

.stats-sec-pct {
  font-size: 13px;
  color: var(--text-muted);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

/* ============ DESKTOP ============ */

@media (min-width: 768px) {
  #view-lessons { flex-direction: row; }

  .sidebar {
    width: 280px;
    border-bottom: none;
    border-right: 1px solid var(--border);
    padding: 12px;
    overflow-y: auto;
    flex-shrink: 0;
  }

  .section-dropdown { display: none; }

  .section-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .section-nav-item {
    display: block;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    background: none;
    text-align: left;
    width: 100%;
    line-height: 1.3;
  }

  .section-nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
  .section-nav-item.active { background: var(--accent-glow); color: var(--accent); }

  .section-nav-part {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 16px 12px 6px;
  }

  .section-nav-part:first-child { padding-top: 8px; }

  .quiz-config, .quiz-results {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
  }

  .quiz-player {
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
  }

  .search-bar {
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
    padding: 16px;
  }

  .stats-container {
    max-width: 600px;
    margin: 0 auto;
  }

  .quiz-question .q-text { font-size: 48px; }
  .vocab-thai { font-size: 32px; }
}

/* ============ ANIMATIONS ============ */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.vocab-card {
  animation: fadeIn 0.2s ease-out;
}

@keyframes correctFlash {
  0% { background-color: var(--green-dim); }
  100% { background-color: transparent; }
}

@keyframes wrongFlash {
  0% { background-color: var(--red-dim); }
  100% { background-color: transparent; }
}

.quiz-flash-correct {
  animation: correctFlash 0.4s ease-out;
}

.quiz-flash-wrong {
  animation: wrongFlash 0.4s ease-out;
}

/* ============ QUIZ FLASHCARD ============ */

.quiz-flashcard {
  cursor: pointer;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quiz-fc-inner {
  width: 100%;
  position: relative;
}

.quiz-fc-front,
.quiz-fc-back {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.quiz-fc-back {
  display: none;
}

.quiz-flashcard.flipped .quiz-fc-front {
  display: none;
}

.quiz-flashcard.flipped .quiz-fc-back {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

/* ============ QUIZ LISTENING ============ */

.quiz-listening-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.quiz-listening-hint {
  font-size: 14px;
  color: var(--text-secondary);
  font-style: italic;
}

/* ============ QUIZ TYPING RESULTS ============ */

.quiz-typing-result {
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.quiz-typing-result.correct {
  background: var(--green-dim);
  color: var(--green);
}

.quiz-typing-result.wrong {
  background: var(--red-dim);
  color: var(--red);
}

.quiz-typing-correct {
  font-size: 15px;
  color: var(--text-secondary);
  padding: 8px 16px;
}

.quiz-typing-correct strong {
  color: var(--text-thai);
  font-size: 20px;
}

/* ============ QUIZ ANSWER NUMBER ============ */

.quiz-answer-num {
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  border-radius: 50%;
  background: var(--bg-primary);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  margin-right: 8px;
  flex-shrink: 0;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
