﻿/* ============================================================
   styles.css — English Learning App Design System
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Accent colours */
  --clr-beginner:    #22c55e;
  --clr-intermediate:#3b82f6;
  --clr-advanced:    #7C3AED;

  /* Dark theme (default) */
  --bg:         #0f172a;
  --bg2:        #1e293b;
  --bg3:        #334155;
  --surface:    #1e293b;
  --surface2:   #273549;
  --border:     #334155;
  --text:       #f1f5f9;
  --text2:      #94a3b8;
  --text3:      #64748b;
  --shadow:     rgba(0,0,0,0.4);

  /* Brand — MibooEnglish palette */
  --accent:     #2563EB;   /* Brand blue */
  --accent-h:   #7C3AED;   /* Brand purple */
  --brand-blue: #2563EB;
  --brand-purp: #7C3AED;
  --brand-grad: linear-gradient(135deg, #2563EB 0%, #7C3AED 100%);
  --success:    #22C55E;
  --danger:     #ef4444;
  --warning:    #f59e0b;

  /* Layout */
  --sidebar-w:  240px;
  --radius:     12px;
  --radius-sm:  8px;
  --radius-lg:  20px;
  --transition: 0.22s ease;
}

[data-theme="light"] {
  --bg:       #f1f5f9;
  --bg2:      #e2e8f0;
  --bg3:      #cbd5e1;
  --surface:  #ffffff;
  --surface2: #f8fafc;
  --border:   #e2e8f0;
  --text:     #0f172a;
  --text2:    #475569;
  --text3:    #94a3b8;
  --shadow:   rgba(0,0,0,0.1);
}

html { font-size: 16px; }

body {
  font-family: 'Sarabun', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--clr-advanced));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.sidebar-logo .logo-text {
  font-size: 1.1rem; font-weight: 700;
  background: linear-gradient(90deg, var(--accent-h), var(--clr-advanced));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}

.nav-items {
  list-style: none;
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-item button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text2);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  white-space: nowrap;
}
.nav-item button .nav-icon { font-size: 1.2rem; flex-shrink: 0; }
.nav-item button:hover { background: var(--bg3); color: var(--text); }
.nav-item button.active {
  background: linear-gradient(135deg, rgba(37,99,235,0.2), rgba(124,58,237,0.1));
  color: var(--accent-h);
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-icon {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px;
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text2);
  font-size: 0.9rem; cursor: pointer;
  transition: all var(--transition);
  text-align: left; white-space: nowrap;
}
.btn-icon:hover { background: var(--bg3); color: var(--text); }

/* ── Main Content ────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  padding: 32px;
  max-width: 100%;
}

/* ── Sections ────────────────────────────────────────────── */
.section { display: none; }
.section.active { display: block; animation: fadeIn 0.25s ease; }

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

.section-header {
  margin-bottom: 28px;
}
.section-header h1 {
  font-size: 1.8rem; font-weight: 700;
  background: linear-gradient(90deg, var(--text), var(--text2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.section-thai {
  font-size: 1rem; font-weight: 600;
  font-family: 'Sarabun', sans-serif;
  background: linear-gradient(135deg, var(--clr-beginner), var(--clr-intermediate));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.section-header p {
  color: var(--text2); margin-top: 4px; font-size: 0.95rem;
  font-family: 'Sarabun', sans-serif;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: 0 4px 20px var(--shadow); }

.card-grid {
  display: grid;
  gap: 16px;
}
.card-grid-2 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.card-grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px;
  border: none; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--clr-advanced));
  color: #fff;
  box-shadow: 0 2px 12px rgba(37,99,235,0.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(37,99,235,0.5); }
.btn-secondary {
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg3); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-accent  { background: linear-gradient(135deg, #f59e0b, #ef4444); color: #fff; box-shadow: 0 2px 12px rgba(245,158,11,0.35); }
.btn-accent:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(245,158,11,0.5); }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* ── Level Badges ────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.03em;
}
.badge-beginner     { background: rgba(34,197,94,0.15);  color: var(--clr-beginner); }
.badge-intermediate { background: rgba(59,130,246,0.15); color: var(--clr-intermediate); }
.badge-advanced     { background: rgba(124,58,237,0.15); color: var(--clr-advanced); }

/* ── Progress Bar ────────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--bg3);
  border-radius: 99px; overflow: hidden;
  height: 8px;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--clr-advanced));
  border-radius: 99px;
  transition: width 0.5s ease;
}

/* ════════════════════════════════════════════════════════════
   DASHBOARD
   ════════════════════════════════════════════════════════════ */
.dashboard-welcome {
  background: linear-gradient(135deg, rgba(37,99,235,0.15), rgba(124,58,237,0.1));
  border: 1px solid rgba(37,99,235,0.3);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 24px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 16px;
}
.dashboard-welcome-text h2 { font-size: 1.5rem; font-weight: 700; }
.dashboard-welcome-text p  { color: var(--text2); margin-top: 4px; }
.dashboard-welcome-badges  { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.streak-chip {
  display: flex; align-items: center; gap: 6px;
  background: rgba(245,158,11,0.15); color: var(--warning);
  border-radius: 20px; padding: 6px 14px;
  font-weight: 600; font-size: 0.9rem;
}
.level-chip {
  background: linear-gradient(135deg,var(--accent),var(--clr-advanced));
  color: #fff; border-radius: 20px; padding: 6px 14px;
  font-weight: 700; font-size: 0.9rem;
}

.xp-bar-section { margin-bottom: 24px; }
.xp-bar-label { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 0.85rem; color: var(--text2); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px,1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  transition: all var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px var(--shadow); }
.stat-icon { font-size: 2rem; margin-bottom: 8px; }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--accent-h); }
.stat-label { font-size: 0.8rem; color: var(--text2); margin-top: 2px; }

.chart-card { margin-bottom: 24px; }
.chart-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 14px; }

.quick-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ════════════════════════════════════════════════════════════
   FLASHCARDS
   ════════════════════════════════════════════════════════════ */
.flashcard-controls {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  margin-bottom: 24px;
}
.level-tabs {
  display: flex; gap: 6px;
}
.level-tab {
  padding: 7px 16px; border: 1px solid var(--border);
  border-radius: 20px; background: transparent;
  color: var(--text2); font-size: 0.85rem; font-weight: 500;
  cursor: pointer; transition: all var(--transition);
}
.level-tab:hover { border-color: var(--accent); color: var(--accent-h); }
.level-tab.active { border-color: var(--accent); background: rgba(37,99,235,0.1); color: var(--accent-h); }

.flashcard-stage {
  display: flex; flex-direction: column; align-items: center;
  padding: 20px 0;
}

.card-counter {
  font-size: 0.85rem; color: var(--text2);
  margin-bottom: 20px;
}

.flashcard-scene {
  width: 480px; max-width: 100%;
  height: 300px;
  perspective: 1200px;
  cursor: pointer;
}
.flashcard-inner {
  width: 100%; height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4,0,0.2,1);
}
.flashcard-inner.flipped { transform: rotateY(180deg); }

.flashcard-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 32px;
  text-align: center;
}
.flashcard-front {
  background: linear-gradient(145deg, var(--surface), var(--surface2));
}
.flashcard-back {
  background: linear-gradient(145deg, var(--bg2), var(--surface));
  transform: rotateY(180deg);
}
.card-learned .flashcard-front,
.card-learned .flashcard-back {
  border-color: var(--success);
}

.flashcard-word {
  font-size: 2.4rem; font-weight: 800;
  background: linear-gradient(135deg, var(--accent-h), var(--clr-advanced));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 12px;
}
.flashcard-tap-hint { color: var(--text3); font-size: 0.85rem; }
.flashcard-pos { color: var(--text3); font-style: italic; font-size: 0.85rem; margin-bottom: 10px; }
.flashcard-definition { font-size: 1.05rem; font-weight: 500; margin-bottom: 14px; }
.flashcard-example { color: var(--text2); font-size: 0.9rem; border-left: 3px solid var(--accent); padding-left: 12px; text-align: left; }

.flashcard-actions {
  display: flex; gap: 12px; margin-top: 28px;
  flex-wrap: wrap; justify-content: center;
}

.learned-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(34,197,94,0.15); color: var(--success);
  border-radius: 20px; padding: 4px 12px;
  font-size: 0.8rem; font-weight: 600;
  margin-top: 12px;
}
.keyboard-hint {
  color: var(--text3); font-size: 0.78rem; margin-top: 16px; text-align: center;
}
.keyboard-hint kbd {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px; font-size: 0.75rem;
  font-family: monospace;
}

/* ════════════════════════════════════════════════════════════
   GRAMMAR QUIZ
   ════════════════════════════════════════════════════════════ */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.category-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}
.category-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--shadow);
}
.category-icon { font-size: 2.2rem; margin-bottom: 10px; }
.category-name { font-weight: 700; font-size: 1rem; }
.category-count { color: var(--text2); font-size: 0.82rem; margin-top: 4px; }
.category-score {
  margin-top: 10px;
  font-size: 0.8rem; color: var(--accent-h); font-weight: 600;
}

.quiz-area { max-width: 680px; }
.quiz-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 10px;
}
.quiz-category-title { font-size: 1.2rem; font-weight: 700; }
.quiz-progress-text { font-size: 0.85rem; color: var(--text2); }

.quiz-q-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  animation: fadeIn 0.2s ease;
}
.quiz-q-level { margin-bottom: 12px; }
.quiz-question { font-size: 1.15rem; font-weight: 600; line-height: 1.5; margin-bottom: 20px; }
.quiz-blank { display: inline-block; min-width: 100px; border-bottom: 2px solid var(--accent); }

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.option-btn {
  padding: 13px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
}
.option-btn:hover:not(:disabled) { border-color: var(--accent); background: rgba(37,99,235,0.08); }
.option-btn.correct { border-color: var(--success); background: rgba(34,197,94,0.1); color: var(--success); }
.option-btn.wrong   { border-color: var(--danger);  background: rgba(239,68,68,0.1);  color: var(--danger); }
.option-btn:disabled { cursor: not-allowed; }

.fill-input {
  width: 100%; padding: 13px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text); font-size: 1rem;
  outline: none; transition: all var(--transition);
}
.fill-input:focus { border-color: var(--accent); }
.fill-input.correct { border-color: var(--success); background: rgba(34,197,94,0.08); }
.fill-input.wrong   { border-color: var(--danger);  background: rgba(239,68,68,0.08); }

.feedback-box {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 18px;
  margin-top: 14px; font-size: 0.9rem;
}
.feedback-box.correct { border-color: rgba(34,197,94,0.4); }
.feedback-box.wrong   { border-color: rgba(239,68,68,0.4); }
.feedback-box .answer-label { font-weight: 700; margin-bottom: 4px; }
.feedback-box .explanation  { color: var(--text2); margin-top: 6px; }

.score-summary {
  text-align: center; max-width: 480px; margin: 0 auto;
  animation: fadeIn 0.3s ease;
}
.score-big { font-size: 4rem; font-weight: 900; margin: 16px 0; }
.score-big.excellent { color: var(--success); }
.score-big.good      { color: var(--clr-intermediate); }
.score-big.okay      { color: var(--warning); }
.score-big.poor      { color: var(--danger); }
.score-message { font-size: 1.1rem; color: var(--text2); margin-bottom: 24px; }
.xp-earned { color: var(--warning); font-weight: 700; font-size: 1rem; margin-bottom: 20px; }

/* Shake animation for wrong */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}
.shake { animation: shake 0.4s ease; }

/* ════════════════════════════════════════════════════════════
   READING
   ════════════════════════════════════════════════════════════ */
.passage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.passage-card {
  background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 22px;
  cursor: pointer; transition: all var(--transition);
}
.passage-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 20px var(--shadow); }
.passage-card.completed { border-color: var(--success); }
.passage-title { font-size: 1.05rem; font-weight: 700; margin: 10px 0 6px; }
.passage-meta  { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 0.8rem; color: var(--text2); }
.reading-time-badge { display: flex; align-items: center; gap: 4px; }
.passage-score { color: var(--success); font-weight: 700; font-size: 0.85rem; margin-top: 8px; }

.reading-area { max-width: 760px; }
.reading-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
}
.reading-timer-badge {
  background: rgba(245,158,11,0.15); color: var(--warning);
  border-radius: 20px; padding: 4px 12px; font-size: 0.85rem; font-weight: 600;
}

.passage-body {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  font-size: 1rem; line-height: 1.85;
  margin-bottom: 20px; white-space: pre-line;
}
.passage-body .vocab-word {
  text-decoration: underline dotted var(--accent);
  cursor: help; position: relative;
}
.vocab-tooltip {
  position: absolute; bottom: 100%; left: 50%;
  transform: translateX(-50%);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 12px;
  font-size: 0.8rem; white-space: nowrap;
  pointer-events: none; z-index: 20;
  box-shadow: 0 4px 16px var(--shadow);
  display: none;
}
.vocab-word:hover .vocab-tooltip { display: block; }

.comprehension-section { animation: fadeIn 0.3s ease; }
.q-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; margin-bottom: 16px;
}
.q-text { font-weight: 600; font-size: 1rem; margin-bottom: 14px; }
.q-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.q-option {
  padding: 11px 14px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface2);
  color: var(--text); cursor: pointer; font-size: 0.88rem;
  transition: all var(--transition); text-align: left;
}
.q-option:hover:not(:disabled) { border-color: var(--accent); background: rgba(37,99,235,0.08); }
.q-option.correct { border-color: var(--success); background: rgba(34,197,94,0.1); }
.q-option.wrong   { border-color: var(--danger);  background: rgba(239,68,68,0.1); }

/* ════════════════════════════════════════════════════════════
   LISTENING & SPEAKING
   ════════════════════════════════════════════════════════════ */
.listening-mode-tabs {
  display: flex; gap: 6px; margin-bottom: 24px;
}
.mode-tab {
  padding: 9px 20px; border: 2px solid var(--border);
  border-radius: 20px; background: transparent;
  color: var(--text2); font-size: 0.88rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
}
.mode-tab.active { border-color: var(--accent); background: rgba(37,99,235,0.1); color: var(--accent-h); }

.listening-level-tabs { display: flex; gap: 6px; margin-bottom: 20px; }

.listen-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 36px;
  max-width: 560px;
  animation: fadeIn 0.25s ease;
}
.listen-category { color: var(--text2); font-size: 0.82rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.listen-item-counter { color: var(--text3); font-size: 0.82rem; margin-bottom: 24px; }

.listen-text {
  font-size: 1.6rem; font-weight: 700;
  text-align: center; line-height: 1.4;
  margin-bottom: 8px;
  min-height: 60px;
}
.listen-hint { text-align: center; color: var(--text3); font-size: 0.85rem; margin-bottom: 28px; }

.listen-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.listen-btn {
  padding: 13px 24px; border: none; border-radius: 99px;
  font-size: 0.9rem; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  transition: all var(--transition);
}
.listen-btn-play {
  background: linear-gradient(135deg, var(--clr-intermediate), var(--accent));
  color: #fff; box-shadow: 0 2px 12px rgba(59,130,246,0.35);
}
.listen-btn-play:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(59,130,246,0.5); }

.listen-btn-mic {
  background: linear-gradient(135deg, var(--danger), #c2410c);
  color: #fff; box-shadow: 0 2px 12px rgba(239,68,68,0.35);
}
.listen-btn-mic.recording {
  animation: pulse-mic 1s infinite;
  box-shadow: 0 0 0 0 rgba(239,68,68,0.5);
}
@keyframes pulse-mic {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,0.6); }
  70%  { box-shadow: 0 0 0 12px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}

.speech-result {
  margin-top: 20px; padding: 16px 20px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); text-align: center;
  animation: fadeIn 0.2s ease;
}
.speech-heard { font-size: 0.9rem; color: var(--text2); margin-bottom: 8px; }
.speech-score { font-size: 1.8rem; font-weight: 800; }
.speech-score.perfect { color: var(--success); }
.speech-score.good    { color: var(--clr-intermediate); }
.speech-score.fair    { color: var(--warning); }
.speech-score.low     { color: var(--danger); }

.listening-nav { display: flex; gap: 10px; margin-top: 24px; justify-content: center; flex-wrap: wrap; }

.unsupported-box {
  background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3);
  border-radius: var(--radius-sm); padding: 14px 18px;
  font-size: 0.88rem; color: var(--warning); margin-top: 14px;
}

/* ════════════════════════════════════════════════════════════
   PROGRESS
   ════════════════════════════════════════════════════════════ */
.progress-top {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 20px; margin-bottom: 24px;
}
.level-badge-card {
  background: linear-gradient(135deg, rgba(37,99,235,0.15), rgba(124,58,237,0.1));
  border: 1px solid rgba(37,99,235,0.3);
  border-radius: var(--radius); padding: 28px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.level-badge-icon { font-size: 3rem; margin-bottom: 10px; }
.level-badge-name { font-size: 1.3rem; font-weight: 800; color: var(--accent-h); }
.level-badge-xp   { color: var(--text2); font-size: 0.9rem; margin-top: 6px; }

.streak-card {
  background: linear-gradient(135deg, rgba(245,158,11,0.15), rgba(239,68,68,0.08));
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: var(--radius); padding: 28px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.streak-flame { font-size: 3rem; margin-bottom: 10px; }
.streak-count { font-size: 2.5rem; font-weight: 900; color: var(--warning); }
.streak-label { color: var(--text2); font-size: 0.9rem; margin-top: 4px; }

.progress-stats-table {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  margin-bottom: 24px;
}
.progress-stats-table table { width: 100%; border-collapse: collapse; }
.progress-stats-table th {
  background: var(--bg2); padding: 12px 18px;
  text-align: left; font-size: 0.82rem; color: var(--text2);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
}
.progress-stats-table td {
  padding: 14px 18px; font-size: 0.92rem;
  border-top: 1px solid var(--border);
}
.progress-stats-table tr:hover td { background: var(--surface2); }

.chart-section { margin-bottom: 24px; }
.chart-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: 14px; }

canvas { display: block; max-width: 100%; }

.reset-btn-wrap { text-align: right; }

/* ════════════════════════════════════════════════════════════
   MOBILE MENU TOGGLE
   ════════════════════════════════════════════════════════════ */
.mobile-toggle {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: 200;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px;
  cursor: pointer; font-size: 1.3rem;
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-240px);
    width: 240px;
  }
  .sidebar.open { transform: translateX(0); }

  .main-content { margin-left: 0; padding: 70px 16px 24px; }
  .mobile-toggle { display: flex; }

  .options-grid  { grid-template-columns: 1fr; }
  .q-options     { grid-template-columns: 1fr; }
  .flashcard-scene { height: 260px; }
  .flashcard-word  { font-size: 1.8rem; }
  .listen-text     { font-size: 1.2rem; }
  .progress-top    { grid-template-columns: 1fr; }
  .dashboard-welcome { flex-direction: column; }
  .category-grid   { grid-template-columns: repeat(2,1fr); }
}

/* ── Speak Button ────────────────────────────────────────── */
.speak-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  opacity: 0.55;
  padding: 2px 5px;
  border-radius: 6px;
  transition: opacity 0.15s, transform 0.15s, background 0.15s;
  vertical-align: middle;
  flex-shrink: 0;
}
.speak-btn:hover {
  opacity: 1;
  background: rgba(37,99,235,0.12);
}
.speak-btn.speak-lg {
  font-size: 1.1rem;
  opacity: 0.75;
  padding: 4px 8px;
}

/* ── Utility ─────────────────────────────────────────────── */
.text-center { text-align: center; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex  { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.hidden { display: none !important; }
.w-full { width: 100%; }

/* ════════════════════════════════════════════════════════════
   12-TENSE TUTORIAL
   ════════════════════════════════════════════════════════════ */

/* Grammar section tabs */
.grammar-tabs {
  display: flex; gap: 8px; margin-bottom: 28px; flex-wrap: wrap;
}
.grammar-tab {
  padding: 10px 22px;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text2);
  font-size: 0.9rem; font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'Sarabun', 'Segoe UI', system-ui, sans-serif;
}
.grammar-tab:hover { border-color: var(--accent); color: var(--accent-h); }
.grammar-tab.active {
  border-color: var(--accent);
  background: rgba(37,99,235,0.12);
  color: var(--accent-h);
}

/* Tense tutorial overview */
.tense-tutorial { animation: fadeIn 0.25s ease; }
.tense-intro {
  color: var(--text2);
  font-family: 'Sarabun', sans-serif;
  font-size: 0.95rem; margin-bottom: 28px; line-height: 1.7;
}
.tense-intro strong { color: var(--text); }

.tense-group-section { margin-bottom: 32px; }
.tense-group-header {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  border-left: 4px solid var(--border);
  background: var(--surface2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 16px;
}
.tense-group-label { font-size: 1.05rem; font-weight: 800; }
.tense-group-thai {
  font-family: 'Sarabun', sans-serif;
  font-size: 0.9rem; color: var(--text2); font-weight: 600;
}

.tense-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.tense-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex; flex-direction: column; gap: 6px;
}
.tense-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px var(--shadow); }
.tense-card.tense-present:hover { border-color: var(--clr-intermediate); }
.tense-card.tense-past:hover    { border-color: var(--warning); }
.tense-card.tense-future:hover  { border-color: var(--clr-advanced); }

.tense-card-name { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.tense-card-thai {
  font-family: 'Sarabun', sans-serif;
  font-size: 0.82rem; color: var(--text2); font-weight: 600;
}
.tense-card-formula {
  display: block;
  font-family: 'Courier New', monospace;
  font-size: 0.78rem; color: var(--accent-h);
  background: rgba(37,99,235,0.08);
  border-radius: 4px; padding: 4px 8px; margin-top: 4px;
  white-space: normal; word-break: break-word;
}
.tense-card-cta { font-size: 0.78rem; color: var(--text3); margin-top: 6px; text-align: right; }

/* Tense detail view */
.tense-detail { max-width: 740px; animation: fadeIn 0.25s ease; }

.tense-detail-header {
  display: flex; align-items: flex-start; gap: 16px; margin-bottom: 24px;
}
.tense-detail-title { font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
.tense-detail-thai {
  font-family: 'Sarabun', sans-serif;
  font-size: 1rem; color: var(--text2); font-weight: 600; margin-top: 4px;
}

.tense-formula-box {
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px; margin-bottom: 24px;
}
.tense-formula-label {
  font-size: 0.8rem; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px;
  font-family: 'Sarabun', sans-serif;
}
.tense-formula-text {
  font-family: 'Courier New', monospace;
  font-size: 1.05rem; color: var(--accent-h); font-weight: 700;
  word-break: break-word;
}

.tense-section-title {
  font-size: 0.88rem; font-weight: 700; color: var(--text2);
  margin-bottom: 12px; margin-top: 24px;
  font-family: 'Sarabun', sans-serif;
  text-transform: uppercase; letter-spacing: 0.03em;
}

/* Structure table */
.tense-structure-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 4px;
}
.tense-structure-head {
  display: grid; grid-template-columns: 80px 1fr 1fr;
  background: var(--bg2); padding: 8px 16px;
  font-size: 0.75rem; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.04em; gap: 12px;
}
.tense-structure-row {
  display: grid; grid-template-columns: 80px 1fr 1fr;
  padding: 12px 16px; border-top: 1px solid var(--border);
  align-items: center; gap: 12px; font-size: 0.88rem;
  transition: background var(--transition);
}
.tense-structure-row:hover { background: var(--surface2); }
.tense-structure-form { font-size: 0.82rem; font-weight: 700; white-space: nowrap; }
.tense-structure-pattern code {
  background: rgba(37,99,235,0.08); color: var(--accent-h);
  font-family: 'Courier New', monospace; font-size: 0.82rem;
  padding: 2px 6px; border-radius: 4px; display: inline-block; line-height: 1.5;
}
.tense-structure-example {
  color: var(--text2); display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
}

/* Uses list */
.tense-uses { display: flex; flex-direction: column; gap: 12px; }
.tense-use-item {
  display: flex; align-items: flex-start; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  transition: background var(--transition);
}
.tense-use-item:hover { background: var(--surface2); }
.tense-use-number {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 800; flex-shrink: 0;
}
.tense-use-body { flex: 1; }
.tense-use-title {
  font-size: 0.9rem; margin-bottom: 6px;
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
}
.tense-use-thai {
  font-family: 'Sarabun', sans-serif;
  font-size: 0.82rem; color: var(--text2); font-weight: 600;
}
.tense-use-example {
  font-size: 0.87rem; color: var(--text2);
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
}

/* Signal word chips */
.tense-signals { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.signal-chip {
  display: inline-flex; padding: 5px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px; font-size: 0.82rem; font-weight: 600;
  background: var(--surface2); transition: all var(--transition);
  font-family: 'Courier New', monospace;
}
.signal-chip:hover { background: var(--bg3); transform: scale(1.04); }

/* Detail prev/next navigation */
.tense-detail-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 32px; padding-top: 20px;
  border-top: 1px solid var(--border); flex-wrap: wrap;
}

@media (max-width: 768px) {
  .tense-structure-head,
  .tense-structure-row { grid-template-columns: 60px 1fr; }
  .tense-structure-example { display: none; }
  .tense-overview-grid { grid-template-columns: repeat(2, 1fr); }
  .tense-detail-title { font-size: 1.2rem; }
  .tense-detail-nav { justify-content: center; }
}

/* ── Mind Map ─────────────────────────────────────────────── */
.tense-mindmap-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px 12px;
  margin-bottom: 20px;
  overflow-x: auto;
}
.tense-mindmap-title {
  font-size: 0.88rem; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 14px;
  font-family: 'Sarabun', sans-serif;
}
.tense-mindmap-svg {
  display: block;
  width: 100%; max-width: 700px;
  height: auto;
  margin: 0 auto;
}
.tense-mindmap-hint {
  font-size: 0.78rem; color: var(--text3);
  text-align: center; margin-top: 10px;
  font-family: 'Sarabun', sans-serif;
}

/* ── Collapsible panels ───────────────────────────────────── */
.tense-collapsible { margin-bottom: 16px; }
.tense-collapse-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text); font-size: 0.9rem; font-weight: 700;
  cursor: pointer; text-align: left;
  transition: all var(--transition);
  font-family: 'Sarabun', 'Segoe UI', system-ui, sans-serif;
}
.tense-collapse-btn:hover { background: var(--bg3); border-color: var(--accent); }
.collapse-arrow { font-size: 0.75rem; color: var(--text3); }
.tense-collapse-body {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 18px;
  animation: fadeIn 0.2s ease;
}

/* ── Quick Reference Table ────────────────────────────────── */
.tense-quickref-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.82rem; min-width: 560px;
}
.tense-quickref-table thead th {
  background: var(--bg2); padding: 9px 12px;
  text-align: left; font-size: 0.75rem; color: var(--text2);
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border);
}
.tense-quickref-table tbody tr { border-bottom: 1px solid var(--border); }
.tense-quickref-table tbody td { padding: 9px 12px; vertical-align: middle; }
.qr-row { cursor: pointer; transition: background var(--transition); }
.qr-row:hover { background: var(--surface2); }
.qr-formula {
  font-family: 'Courier New', monospace;
  font-size: 0.76rem; color: var(--accent-h);
  background: rgba(37,99,235,0.08);
  padding: 2px 6px; border-radius: 3px;
  display: inline-block; line-height: 1.5;
  white-space: normal;
}
.qr-example { color: var(--text2); font-style: italic; max-width: 220px; }
.qr-signals { color: var(--text3); font-size: 0.75rem; font-family: 'Courier New', monospace; }

/* ── Decision Chooser ────────────────────────────────────── */
.chooser-grid { display: flex; flex-direction: column; gap: 20px; }
.chooser-group-title {
  font-size: 0.92rem; font-weight: 800;
  margin-bottom: 10px;
  font-family: 'Sarabun', sans-serif;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.chooser-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  margin-bottom: 6px;
  transition: all var(--transition);
}
.chooser-item:hover {
  background: var(--bg3);
  transform: translateX(4px);
}
.chooser-arrow { font-size: 1.1rem; font-weight: 800; flex-shrink: 0; }
.chooser-body { flex: 1; }
.chooser-q { font-size: 0.86rem; font-weight: 600; display: block; }
.chooser-th {
  font-size: 0.78rem; color: var(--text2);
  font-family: 'Sarabun', sans-serif; font-weight: 600;
  display: block; margin-top: 2px;
}
.chooser-answer {
  font-size: 0.78rem; font-weight: 700;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 9px;
  white-space: nowrap;
  background: var(--surface);
  flex-shrink: 0;
}

/* ── Cards section header ────────────────────────────────── */
.tense-cards-header {
  font-size: 0.88rem; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin: 28px 0 16px;
  font-family: 'Sarabun', sans-serif;
}

@media (max-width: 768px) {
  .chooser-answer { display: none; }
  .chooser-item { padding: 8px 10px; }
  .tense-mindmap-wrap { padding: 14px 10px 8px; }
}

/* ══════════════════════════════════════════════════════════
   PER-TENSE QUIZ
══════════════════════════════════════════════════════════ */
.tense-quiz-wrap { max-width: 680px; margin: 0 auto; }

.tense-quiz-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.tq-progress {
  font-size: 0.82rem; font-weight: 700;
  color: var(--text2);
}
.tq-label {
  font-size: 0.85rem; font-weight: 700;
  font-family: "Sarabun", sans-serif;
  margin-bottom: 8px;
}
.tq-progress-bar-wrap {
  height: 5px; background: var(--border);
  border-radius: 9px; overflow: hidden;
  margin-bottom: 22px;
}
.tq-progress-bar-fill {
  height: 100%; border-radius: 9px;
  transition: width 0.4s ease;
}

/* Question card */
.tq-question-card { padding: 24px; }
.tq-qnum {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text3);
  margin-bottom: 10px;
}
.tq-qtext {
  font-size: 1.1rem; font-weight: 600; color: var(--text);
  margin-bottom: 20px; line-height: 1.55;
}

/* Options */
.tq-options { display: flex; flex-direction: column; gap: 10px; }
.tq-option {
  padding: 13px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  text-align: left; font-size: 0.97rem;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform 0.1s;
}
.tq-option:not(:disabled):hover {
  background: var(--bg3);
  border-color: var(--accent);
  transform: translateX(4px);
}
.tq-option.tq-correct {
  background: rgba(34,197,94,0.15);
  border-color: var(--success);
  color: var(--success);
  font-weight: 700;
}
.tq-option.tq-wrong {
  background: rgba(239,68,68,0.12);
  border-color: var(--danger);
  color: var(--danger);
}

/* Feedback */
.tq-feedback {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--bg2);
  border: 1px solid var(--border);
}
.tq-fb-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.tq-fb-icon { font-size: 1.3rem; }
.tq-fb-msg  { font-size: 0.97rem; font-weight: 600; color: var(--text); }
.tq-fb-exp  { font-size: 0.88rem; color: var(--text2); line-height: 1.5; }

/* Summary */
.tq-summary {
  text-align: center;
  padding: 36px 28px;
  max-width: 480px;
  margin: 0 auto;
}
.tq-summary-label {
  font-size: 0.85rem; font-weight: 700;
  font-family: "Sarabun", sans-serif;
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 12px;
}
.tq-summary-stars { font-size: 2rem; margin-bottom: 8px; }
.tq-summary-score {
  font-size: 3rem; font-weight: 900;
  color: var(--text); margin-bottom: 2px;
}
.tq-summary-pct {
  font-size: 1.15rem; font-weight: 700;
  color: var(--text2); margin-bottom: 10px;
}
.tq-summary-msg {
  font-size: 1.05rem; font-weight: 600;
  color: var(--text);
  font-family: "Sarabun", sans-serif;
  margin-bottom: 10px;
}
.tq-summary-xp {
  display: inline-block;
  background: rgba(37,99,235,0.15);
  border: 1.5px solid var(--accent);
  color: var(--accent-h);
  border-radius: 99px;
  padding: 4px 16px;
  font-size: 0.9rem; font-weight: 700;
  margin-bottom: 22px;
}
.tq-summary-actions {
  display: flex; gap: 12px;
  justify-content: center; flex-wrap: wrap;
  margin-top: 6px;
}

@media (max-width: 600px) {
  .tq-question-card { padding: 16px; }
  .tq-qtext { font-size: 1rem; }
  .tq-option { padding: 11px 14px; font-size: 0.92rem; }
  .tq-summary-score { font-size: 2.3rem; }
}

.tq-qthai { font-family: 'Sarabun', sans-serif; font-size: 0.9rem; color: var(--text2); margin: -12px 0 18px; line-height: 1.5; }

/* ============================================================
   TOEIC PRACTICE TEST — Styles
   ============================================================ */

/* ── HOME SCREEN ─────────────────────────────────────────── */
.toeic-home { max-width: 860px; margin: 0 auto; padding: 0 0 40px; }
.toeic-home-badge {
  display: inline-block; background: var(--accent); color: #fff;
  font-weight: 900; font-size: 1rem; letter-spacing: 3px;
  padding: 4px 18px; border-radius: 6px; margin-bottom: 12px;
}
.toeic-home-title { font-size: 2.2rem; font-weight: 900; margin: 0 0 6px; }
.toeic-home-sub   { color: var(--text2); font-family: 'Sarabun', sans-serif; margin: 0 0 28px; }

.toeic-home-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
@media (max-width: 600px) { .toeic-home-cards { grid-template-columns: 1fr; } }

.toeic-test-card {
  background: var(--surface2); border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 28px 24px; text-align: center; display: flex; flex-direction: column; gap: 8px;
  transition: border-color .2s, box-shadow .2s;
}
.toeic-test-card:hover { border-color: var(--accent); box-shadow: 0 4px 20px rgba(37,99,235,.15); }
.ttc-icon  { font-size: 2.4rem; }
.ttc-title { font-size: 1.3rem; font-weight: 800; color: var(--text); }
.ttc-sub   { font-size: .9rem; color: var(--accent); font-family: 'Sarabun', sans-serif; }
.ttc-detail{ font-size: .8rem; color: var(--text2); }
.ttc-btn   { margin-top: 14px; font-size: .95rem; }

.toeic-home-info { padding: 20px; margin-top: 8px; }
.toeic-home-info h3 { margin: 0 0 12px; font-size: 1rem; }
.toeic-info-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.toeic-info-table th, .toeic-info-table td { padding: 8px 12px; border: 1px solid var(--border); text-align: left; }
.toeic-info-table thead tr { background: var(--surface2); color: var(--text2); font-weight: 600; }
.toeic-info-total td { font-weight: 700; background: rgba(37,99,235,.08); }
.toeic-home-note { font-family: 'Sarabun', sans-serif; font-size: .83rem; color: var(--text2); margin: 8px 0 0; line-height: 1.6; }

/* ── TOP BAR ─────────────────────────────────────────────── */
.toeic-topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface2); border-bottom: 2px solid var(--accent);
  padding: 10px 16px; border-radius: var(--radius) var(--radius) 0 0;
  gap: 12px; margin-bottom: 0;
}
.toeic-topbar-left  { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.toeic-topbar-center{ font-weight: 700; font-size: 1rem; color: var(--text); white-space: nowrap; }
.toeic-topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.toeic-part-label   { font-weight: 700; font-size: .9rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toeic-part-label-th{ font-family: 'Sarabun', sans-serif; font-size: .75rem; color: var(--text2); }

.toeic-timer { font-size: 1.1rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text); }
.toeic-timer-urgent { color: var(--danger) !important; animation: pulse 1s ease-in-out infinite; }

/* ── LISTENING NOTE ──────────────────────────────────────── */
.toeic-listening-note {
  background: rgba(37,99,235,.12); border-left: 4px solid var(--accent);
  padding: 8px 14px; font-size: .82rem; color: var(--text2);
  font-family: 'Sarabun', sans-serif; line-height: 1.6;
}

/* ── CONTENT AREA ────────────────────────────────────────── */
.toeic-content-area { display: flex; gap: 0; min-height: 380px; }
.toeic-split { flex-direction: row; }
.toeic-single { flex-direction: column; }

.toeic-context-panel {
  width: 55%; border-right: 1px solid var(--border);
  padding: 20px; overflow-y: auto; max-height: 60vh;
  background: var(--surface);
  font-size: .88rem; line-height: 1.8; color: var(--text);
}
.toeic-question-panel {
  flex: 1; padding: 20px; overflow-y: auto; max-height: 60vh;
  background: var(--surface2);
}
.toeic-single .toeic-question-panel { max-height: none; border-radius: 0; }

@media (max-width: 700px) {
  .toeic-split { flex-direction: column; }
  .toeic-context-panel { width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 240px; }
  .toeic-question-panel { max-height: none; }
}

/* ── CONTEXT PANEL INTERNALS ─────────────────────────────── */
.toeic-ctx-label   { font-size: .78rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.toeic-ctx-label-th{ display: block; font-family: 'Sarabun', sans-serif; font-weight: 400; text-transform: none; color: var(--text2); font-size: .8rem; letter-spacing: 0; }
.toeic-ctx-header  { font-weight: 700; font-size: .9rem; margin-bottom: 10px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.toeic-ctx-title   { font-size: 1rem; font-weight: 700; margin-bottom: 10px; color: var(--text); }
.toeic-ctx-body    { font-size: .87rem; line-height: 1.9; color: var(--text); }
.toeic-ctx-letter  { white-space: pre-line; font-family: inherit; }
.blank-marker      { background: rgba(234,179,8,.25); border: 1.5px dashed #eab308; border-radius: 4px; padding: 0 6px; font-weight: 700; color: #eab308; }

/* ── QUESTION PANEL INTERNALS ────────────────────────────── */
.toeic-q-num      { font-size: .78rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }
.toeic-q-text     { font-size: 1rem; font-weight: 600; color: var(--text); line-height: 1.6; margin-bottom: 6px; }
.toeic-q-text-th  { font-family: 'Sarabun', sans-serif; font-size: .85rem; color: var(--text2); margin-bottom: 16px; line-height: 1.6; }
.toeic-q-instr    { font-size: .83rem; color: var(--text2); margin-bottom: 12px; }
.toeic-tc-blank-label { font-size: .9rem; font-weight: 700; color: #eab308; margin-bottom: 14px; padding: 8px 12px; background: rgba(234,179,8,.1); border-radius: var(--radius); }

/* ── Part 1: Photograph frame (TOEIC official-style) ── */
.toeic-photo-frame {
  position: relative;
  max-width: 720px;
  margin: 0 auto 20px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,.10);
}
.toeic-photo-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  background:
    linear-gradient(135deg, #1e293b, #0f172a);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.toeic-photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background:
    linear-gradient(135deg, #475569, #1e293b);
}
.toeic-photo-img-wrap::before {
  /* Subtle "loading" shimmer behind the image */
  content: '🖼 Loading photograph...';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.4);
  font-size: .9rem;
  z-index: 0;
}
.toeic-photo-img { position: relative; z-index: 1; }

.toeic-photo-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: linear-gradient(135deg, #475569, #1e293b);
  color: #fff;
  z-index: 2;
}
.toeic-photo-emoji-large {
  font-size: 5rem;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.4));
}
.toeic-photo-scene-caption {
  font-size: .9rem;
  text-align: center;
  line-height: 1.5;
  max-width: 480px;
  color: rgba(255,255,255,.88);
}

.toeic-photo-badge {
  position: absolute;
  top: 22px;
  right: 22px;
  background: rgba(0,0,0,.7);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: .5px;
  z-index: 3;
  backdrop-filter: blur(6px);
}

@media (max-width: 600px) {
  .toeic-photo-frame { padding: 10px; }
  .toeic-photo-emoji-large { font-size: 3.5rem; }
  .toeic-photo-scene-caption { font-size: .82rem; }
  .toeic-photo-badge { top: 16px; right: 16px; font-size: .68rem; }
}

/* Q-R prompt */
.toeic-qr-prompt    { font-size: 1.1rem; font-weight: 700; color: var(--text); line-height: 1.5; margin-bottom: 6px; padding: 16px; background: var(--surface); border-radius: var(--radius); border-left: 4px solid var(--accent); }
.toeic-qr-prompt-th { font-family: 'Sarabun', sans-serif; font-size: .85rem; color: var(--text2); margin: 6px 0 16px 4px; }

/* Options */
.toeic-options { display: flex; flex-direction: column; gap: 9px; margin-top: 4px; }
.toeic-option-btn {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius); background: var(--surface);
  cursor: pointer; text-align: left; transition: all .15s; line-height: 1.5;
  font-size: .9rem; color: var(--text); width: 100%;
}
.toeic-option-btn:hover  { border-color: var(--accent); background: rgba(37,99,235,.06); }
.toeic-option-btn.selected{ border-color: var(--accent); background: rgba(37,99,235,.14); font-weight: 600; }
.toeic-opt-letter { font-weight: 800; color: var(--accent); flex-shrink: 0; min-width: 26px; }
.toeic-opt-text   { flex: 1; }

/* ── NAVIGATION BAR ──────────────────────────────────────── */
.toeic-navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--surface2);
  border-top: 1px solid var(--border); gap: 10px;
}
.toeic-flag-btn {
  background: none; border: 1.5px solid var(--border); border-radius: 20px;
  padding: 6px 14px; cursor: pointer; font-size: .85rem; color: var(--text2);
  transition: all .15s;
}
.toeic-flag-btn.flagged { border-color: #f97316; color: #f97316; background: rgba(249,115,22,.1); }
.toeic-flag-btn:hover   { border-color: #f97316; color: #f97316; }

/* ── QUESTION PALETTE ────────────────────────────────────── */
.toeic-palette-wrap { background: var(--surface); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); }
.toeic-palette-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; cursor: pointer; font-size: .85rem; font-weight: 600;
  color: var(--text2); user-select: none;
}
.toeic-palette-header:hover { color: var(--accent); }
.toeic-palette-chevron { margin-left: auto; font-size: .75rem; }
#palette-answered { font-weight: 400; }

.toeic-palette { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px 16px; }
.toeic-palette.collapsed { display: none; }

.toeic-pal-btn {
  width: 36px; height: 36px; border-radius: 6px; border: 1.5px solid var(--border);
  background: var(--surface2); font-size: .78rem; font-weight: 600; cursor: pointer;
  color: var(--text2); transition: all .12s;
}
.toeic-pal-btn:hover { border-color: var(--accent); color: var(--accent); }
.toeic-pal-btn.answered { background: rgba(37,99,235,.15); border-color: var(--accent); color: var(--accent); }
.toeic-pal-btn.current  { background: var(--accent); border-color: var(--accent); color: #fff; }
.toeic-pal-btn.flagged-pal { border-color: #f97316 !important; }
.listen-pal { border-top: 3px solid #22c55e; }
.read-pal   { border-top: 3px solid var(--accent); }

/* ── RESULTS SCREEN ──────────────────────────────────────── */
.toeic-results { max-width: 700px; margin: 0 auto; padding-bottom: 40px; }

.toeic-score-header {
  text-align: center; padding: 36px 20px 20px;
  background: var(--surface2); border-radius: var(--radius);
  border: 1.5px solid var(--border); margin-bottom: 20px;
}
.toeic-score-main { display: flex; align-items: baseline; justify-content: center; gap: 4px; }
.toeic-score-num  { font-size: 5rem; font-weight: 900; line-height: 1; }
.toeic-score-max  { font-size: 1.8rem; color: var(--text2); font-weight: 700; }
.toeic-score-level{ font-size: 1.1rem; font-weight: 700; margin-top: 8px; font-family: 'Sarabun', sans-serif; }

.toeic-section-scores { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width: 500px) { .toeic-section-scores { grid-template-columns: 1fr; } }

.toeic-sec-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; text-align: center;
}
.toeic-sec-icon  { font-size: 1.8rem; margin-bottom: 6px; }
.toeic-sec-label { font-size: .85rem; color: var(--text2); font-weight: 600; margin-bottom: 4px; }
.toeic-sec-score { font-size: 2.2rem; font-weight: 900; color: var(--accent); }
.toeic-sec-score span { font-size: 1rem; color: var(--text2); font-weight: 400; }
.toeic-sec-detail{ font-size: .78rem; color: var(--text2); margin-top: 4px; }

.toeic-xp-chip {
  text-align: center; background: rgba(37,99,235,.1);
  border: 1.5px solid var(--accent); border-radius: 99px;
  padding: 8px 20px; font-weight: 700; color: var(--accent);
  font-size: .95rem; margin-bottom: 20px;
}

.toeic-breakdown-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.toeic-breakdown-table th { padding: 8px 12px; background: var(--surface2); border: 1px solid var(--border); text-align: left; font-size: .8rem; color: var(--text2); }
.toeic-breakdown-table td { padding: 10px 12px; border: 1px solid var(--border); vertical-align: middle; }
.toeic-mini-bar-wrap { background: var(--border); border-radius: 4px; height: 6px; margin-bottom: 3px; overflow: hidden; }
.toeic-mini-bar  { height: 100%; border-radius: 4px; transition: width .4s; }

.toeic-result-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 20px 0; }

/* ── REVIEW SECTION ──────────────────────────────────────── */
.toeic-review-wrap { margin-top: 8px; }
.toeic-review-item {
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px;
  border-left: 4px solid transparent;
}
.rev-correct { background: rgba(34,197,94,.07); border-color: var(--success); }
.rev-wrong   { background: rgba(239,68,68,.07);  border-color: var(--danger); }
.toeic-rev-header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.toeic-rev-num    { font-weight: 800; color: var(--accent); font-size: .85rem; }
.toeic-rev-part   { font-size: .78rem; color: var(--text2); }
.toeic-rev-status { margin-left: auto; font-size: .82rem; font-weight: 700; }
.toeic-rev-ans    { font-size: .85rem; margin-bottom: 5px; }
.toeic-rev-exp    { font-size: .83rem; color: var(--text2); line-height: 1.6; }
