:root {
  --bg: #fafafa;
  --bg-elev: #ffffff;
  --bg-sidebar: #f6f6f7;
  --bg-soft: #f3f3f5;
  --bg-hover: #efeff2;
  --border: #ececef;
  --border-strong: #dcdce0;
  --text: #1a1a1a;
  --text-soft: #424247;
  --text-muted: #8a8a90;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --accent-soft: #f3eeff;
  --accent-soft-2: #ebe2ff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow-sm: 0 1px 2px rgba(15, 15, 30, 0.04);
  --shadow: 0 1px 3px rgba(15, 15, 30, 0.04), 0 4px 12px rgba(15, 15, 30, 0.05);
  --shadow-lg: 0 4px 16px rgba(15, 15, 30, 0.08), 0 12px 32px rgba(15, 15, 30, 0.06);
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

[data-theme="dark"] {
  --bg: #0f0f13;
  --bg-elev: #18181d;
  --bg-sidebar: #131318;
  --bg-soft: #1e1e24;
  --bg-hover: #25252c;
  --border: #2a2a32;
  --border-strong: #3a3a44;
  --text: #ececf0;
  --text-soft: #c2c2cc;
  --text-muted: #7d7d88;
  --accent: #a78bfa;
  --accent-hover: #8b67f1;
  --accent-soft: rgba(167, 139, 250, 0.12);
  --accent-soft-2: rgba(167, 139, 250, 0.20);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.5), 0 12px 32px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .modal-backdrop {
  background: rgba(0, 0, 0, 0.6);
}
[data-theme="dark"] .login-screen {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
}
[data-theme="dark"] .msg.user .msg-bubble {
  background: var(--accent);
  color: var(--bg);
}
[data-theme="dark"] .deck-card.ai::after {
  background: rgba(167, 139, 250, 0.20);
  color: var(--accent);
}

html { transition: background-color 0.2s; }
body, .app, .sidebar, .content-area, .modal-content, .deck-card,
.batch-card, .question-card, .home-card, .home-stat, .grammar-card,
.exam-sidebar, .article-block, .feedback-block, .explanation-block,
.audio-player, .progress-card, .subex-row, .card-row, .history-row,
.result-card, .review-fix, .review-col, .selection-bar, .floating-bar,
.q-option, .ap-btn, .icon-btn, .info-toggle, .info-panel,
.user-menu-popup, .users-add-row, .user-row, .toast {
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  max-width: 100vw;
}
*, *::before, *::after { box-sizing: border-box; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}
input, textarea, select { font-family: inherit; font-size: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }
.muted { color: var(--text-muted); }

/* ================ APP LAYOUT ================ */
.app {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

/* ================ SIDEBAR ================ */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 24px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  display: inline-block;
}
.brand-name { color: var(--text); }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-soft);
  font-weight: 500;
  font-size: 14px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-item.active .nav-icon { color: var(--accent); }
.nav-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.nav-icon svg {
  width: 18px;
  height: 18px;
}
.nav-item.active .nav-icon { color: var(--accent); }

.sidebar-footer {
  padding: 8px 4px 4px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

/* ================ MAIN ================ */
.main {
  padding: 32px 40px 60px;
  max-width: 1200px;
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
}
.view { min-width: 0; }

.view-header { margin-bottom: 24px; }
.view-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.view-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.content-area {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-sm);
  min-height: 400px;
}

.empty-block {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

/* ================ BUTTONS ================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 14px;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, color 0.15s;
  border: 1px solid transparent;
}
.btn:active { transform: scale(0.985); }

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

.btn-ghost {
  background: var(--bg-elev);
  color: var(--text-soft);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-ghost.danger { color: var(--danger); }
.btn-ghost.danger:hover { background: rgba(239, 68, 68, 0.06); border-color: var(--danger); }

.btn-soft {
  background: var(--accent-soft);
  color: var(--accent);
}
.btn-soft:hover { background: var(--accent-soft-2); }

.btn-lg { padding: 11px 20px; font-size: 15px; }
.btn.small { padding: 6px 11px; font-size: 13px; }

/* ================ INPUTS ================ */
.textinput, .textarea, .select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textinput:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: vertical; line-height: 1.5; }

/* ================ COMMON ================ */
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-end { display: flex; justify-content: flex-end; gap: 10px; }

.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }

.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row.inline { flex-direction: row; align-items: center; gap: 12px; }
.form-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.inline-label { font-size: 13px; color: var(--text-soft); margin-right: 4px; }

.checking-block {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 60px 20px;
}

.spinner {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state h3 { color: var(--text); font-size: 18px; margin-bottom: 6px; }

/* ================ DECK GRID (Flashcards list) ================ */
.deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.deck-card {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.05s;
  box-shadow: var(--shadow-sm);
}
.deck-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.deck-card:active { transform: scale(0.997); }

.deck-card.ai {
  border-color: rgba(124, 58, 237, 0.25);
}
.deck-card.ai::after {
  content: 'IA';
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 100px;
}

.deck-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.deck-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}
.deck-counts {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-muted);
}
.deck-counts b {
  color: var(--text);
  font-weight: 600;
  margin-right: 3px;
}
.deck-counts .due-highlight b { color: var(--accent); }

.deck-check {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  z-index: 2;
  display: none;
}
.deck-grid.edit-mode .deck-check { display: block; }
.deck-grid.edit-mode .deck-card .deck-name,
.deck-grid.edit-mode .deck-card .deck-counts {
  padding-left: 26px;
}

/* ================ STUDY (single card) ================ */
.study-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  gap: 16px;
}

.study-card {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 48px 44px;
  min-height: 380px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.study-card-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 6px;
}
.study-card-actions .icon-btn { width: 32px; height: 32px; font-size: 13px; }

.study-face {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}
.study-face-front .vocab-sentence {
  background: var(--bg-soft);
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
}
.study-face-front .vocab-sentence b { color: var(--accent); font-weight: 700; }
.study-face-front .study-hint {
  margin-top: 16px;
  text-align: center;
  font-style: italic;
  font-size: 13px;
  color: var(--text-muted);
}
.study-face-front .word-only {
  text-align: center;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  padding: 30px 0;
}

.study-face-back .study-word {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  color: var(--text);
}
.study-face-back .study-translation {
  text-align: center;
  font-size: 22px;
  color: var(--accent);
  font-weight: 500;
  margin-top: 4px;
}
.study-face-back .study-divider {
  height: 1px;
  background: var(--border);
  margin: 18px 0;
}
.study-face-back .study-sentences { display: flex; flex-direction: column; gap: 8px; }
.study-face-back .study-sentence {
  font-size: 13px;
  color: var(--text-soft);
  padding-left: 14px;
  position: relative;
  line-height: 1.5;
}
.study-face-back .study-sentence::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--accent);
  opacity: 0.6;
}
.study-face-back .study-sentence b { color: var(--text); font-weight: 600; }

.study-actions {
  display: flex; justify-content: center;
  margin: 24px auto 8px;
}
.study-actions .btn-lg { padding: 14px 32px; font-size: 16px; gap: 12px; }
.kbd {
  display: inline-block;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.18);
}
[data-theme="dark"] .kbd { background: rgba(0, 0, 0, 0.35); color: rgba(255,255,255,0.7); }

.study-rate-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-width: 720px;
  margin: 24px auto 8px;
}
.btn-rate {
  background: var(--bg-elev);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}
.btn-rate:hover { background: var(--bg-hover); }
.btn-rate:active { transform: scale(0.98); }
.btn-rate .rate-label { font-size: 15px; font-weight: 700; }
.btn-rate .rate-sub { font-size: 11px; color: var(--text-muted); }
.btn-rate .kbd {
  background: var(--bg-soft);
  color: var(--text-muted);
  border-color: var(--border);
  margin-top: 2px;
}

.btn-rate.rate-again { border-color: rgba(239, 68, 68, 0.35); }
.btn-rate.rate-again .rate-label { color: var(--danger); }
.btn-rate.rate-again:hover { background: rgba(239, 68, 68, 0.06); }

.btn-rate.rate-hard { border-color: rgba(245, 158, 11, 0.35); }
.btn-rate.rate-hard .rate-label { color: var(--warning); }
.btn-rate.rate-hard:hover { background: rgba(245, 158, 11, 0.06); }

.btn-rate.rate-good { border-color: rgba(124, 58, 237, 0.35); }
.btn-rate.rate-good .rate-label { color: var(--accent); }
.btn-rate.rate-good:hover { background: var(--accent-soft); }

.btn-rate.rate-easy { border-color: rgba(16, 185, 129, 0.35); }
.btn-rate.rate-easy .rate-label { color: var(--success); }
.btn-rate.rate-easy:hover { background: rgba(16, 185, 129, 0.06); }

/* DONE step */
.done-block {
  text-align: center;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 32px;
  max-width: 520px;
  margin: 0 auto;
  box-shadow: var(--shadow);
}
.done-block h2 { font-size: 22px; font-weight: 700; margin: 12px 0 6px; }
.success-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 32px;
  font-weight: 700;
  margin: 0 auto;
}
.done-breakdown {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 18px;
  padding: 14px;
  background: var(--bg-soft);
  border-radius: var(--radius);
}
.done-breakdown > div { text-align: center; }
.done-breakdown b {
  display: block; font-size: 22px; font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.done-breakdown .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-top: 2px;
}
.done-breakdown .label.again { color: var(--danger); }
.done-breakdown .label.hard { color: var(--warning); }
.done-breakdown .label.good { color: var(--accent); }
.done-breakdown .label.easy { color: var(--success); }

@media (max-width: 760px) {
  .study-card { padding: 32px 22px; min-height: 280px; }
  .study-rate-row { grid-template-columns: repeat(2, 1fr); }
  .study-rate-row .btn-rate { padding: 12px 8px; }
  .study-face-front .word-only { font-size: 28px; }
  .study-face-back .study-word { font-size: 24px; }
  .study-face-back .study-translation { font-size: 18px; }
}

/* ================ BATCH (study) ================ */
.batch-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}
.batch-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.batch-card.is-ai-generated {
  border-color: rgba(124, 58, 237, 0.25);
  box-shadow: inset 3px 0 0 0 var(--accent), var(--shadow-sm);
}
.batch-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.batch-card-meta-left { display: flex; gap: 6px; flex-wrap: wrap; }
.batch-card-meta-right { display: flex; gap: 6px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  background: var(--bg-soft);
  color: var(--text-soft);
  border-radius: 100px;
}
.pill-muted { background: transparent; border: 1px solid var(--border-strong); color: var(--text-muted); }
.pill-ai { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.icon-btn {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: background 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.icon-btn.danger:hover { background: rgba(239, 68, 68, 0.06); border-color: var(--danger); }

.batch-card-front { margin-bottom: 12px; }
.front-audio-row {
  display: flex; justify-content: flex-end;
  margin-bottom: 4px; min-height: 30px;
}
.btn-audio {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-audio:hover { background: var(--bg-hover); }

.vocab-sentence {
  background: var(--bg-soft);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin: 6px 0;
  font-size: 14px;
  color: var(--text);
}
.vocab-sentence b { color: var(--accent); font-weight: 600; }
.vocab-word-hint {
  font-size: 12px; color: var(--text-muted); font-style: italic;
  margin-top: 10px;
}

.batch-card-answer {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit; font-size: 14px;
  resize: none; outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.batch-card-answer:focus {
  border-color: var(--accent);
  background: var(--bg-elev);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.batch-footer {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; padding: 16px 0 4px;
  border-top: 1px solid var(--border);
}

/* ================ GAMIFICATION ================ */

/* Mute button (icon-only) */
.btn.icon-only {
  width: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Top game bar with progress + stats */
.game-bar {
  margin: 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gb-progress {
  height: 8px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
}
.gb-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  border-radius: 100px;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.gb-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  gap: 12px;
}
.gb-stat {
  color: var(--text-muted);
}

/* Gauge / velocimetro */
.gb-gauge {
  position: relative;
  width: 140px;
  height: 86px;
  flex-shrink: 0;
}
.gauge-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
.gauge-bg {
  stroke: var(--border);
}
.gauge-fill {
  stroke: #ef4444;
  transition: stroke-dasharray 0.5s cubic-bezier(0.16, 1, 0.3, 1), stroke 0.4s ease;
}
.gauge-fill.tier-mid { stroke: #f59e0b; }
.gauge-fill.tier-high { stroke: #22c55e; }
.gauge-needle {
  transform-origin: 70px 70px;
  transform: rotate(-90deg);
  transition: transform 0.6s cubic-bezier(0.34, 1.4, 0.64, 1);
}
.gauge-tip {
  fill: var(--text);
  stroke: var(--bg);
  stroke-width: 1.5;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}
.gauge-label {
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
}
.gauge-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
}
.gauge-pct {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 1px;
}
.gauge-sub {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 1px;
}
.gb-gauge.tier-bump {
  animation: gaugeBump 0.5s ease-out;
}
@keyframes gaugeBump {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}
.gb-streak {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 100px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(239, 68, 68, 0.15));
  color: var(--warning);
  font-size: 12px;
  font-weight: 700;
  animation: streakPulse 1.4s ease-in-out infinite;
}
.gb-fire {
  display: inline-block;
  animation: streakWobble 0.9s ease-in-out infinite;
}
@keyframes streakPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.35); }
  50%      { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
}
@keyframes streakWobble {
  0%, 100% { transform: rotate(-6deg); }
  50%      { transform: rotate(8deg); }
}

/* Question card animations */
.question-card.q-enter {
  animation: qEnter 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes qEnter {
  0%   { opacity: 0; transform: translateY(12px); }
  100% { opacity: 1; transform: translateY(0); }
}
.question-card.shake {
  animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}
.question-card.flash-correct {
  animation: flashCorrect 0.6s ease-out;
}
@keyframes flashCorrect {
  0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45); }
  60%  { box-shadow: 0 0 0 12px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.q-feedback .fb-correct { color: var(--success); }
.q-feedback .fb-wrong { color: var(--danger); }

/* Question verify ("report") — discrete button */
.q-verify-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed currentColor;
  border-color: rgba(255, 255, 255, 0.1);
  opacity: 0.45;
  transition: opacity 0.2s;
}
.q-feedback:hover .q-verify-row { opacity: 0.85; }
.q-verify-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
.q-verify-btn:hover:not(:disabled) {
  background: currentColor;
  color: var(--bg-elev);
}
.q-verify-btn:disabled { cursor: default; opacity: 0.6; }
.q-verify-hint {
  font-size: 11px;
  font-style: italic;
  color: inherit;
}
.q-verify-result {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.5;
}
.q-verify-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}
.q-verify-ok {
  padding: 10px 12px;
  background: rgba(16, 185, 129, 0.10);
  border-left: 3px solid var(--success);
  border-radius: 4px;
  color: var(--text);
}
.q-verify-fixed {
  padding: 10px 12px;
  background: rgba(245, 158, 11, 0.10);
  border-left: 3px solid var(--warning);
  border-radius: 4px;
  color: var(--text);
}
.q-verify-fail {
  padding: 8px 12px;
  background: rgba(239, 68, 68, 0.10);
  border-left: 3px solid var(--danger);
  border-radius: 4px;
  color: var(--danger);
}
.q-verify-rationale {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 6px;
  font-style: italic;
}
.q-verify-diff {
  margin-top: 10px;
}
.q-verify-block {
  background: var(--bg-soft);
  padding: 10px 12px;
  border-radius: 4px;
}
.q-verify-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 4px;
}
.q-verify-sentence {
  font-size: 13px;
  font-weight: 500;
}
.q-verify-correct {
  margin-top: 4px;
  font-size: 12px;
  color: var(--success);
}
.q-verify-newexp {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-soft);
}

/* Streak burst toast */
.streak-burst {
  position: fixed;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev);
  border: 2px solid var(--accent);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  max-width: 90vw;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.32), 0 2px 8px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  animation: burstIn 0.5s cubic-bezier(0.16, 1, 0.3, 1), burstOut 0.4s ease-in 1.4s forwards;
  pointer-events: none;
}
.streak-burst.good {
  border-color: var(--warning);
  /* solid bg-elev base + colored gradient tint on top */
  background:
    linear-gradient(135deg, rgba(245, 158, 11, 0.20), rgba(124, 58, 237, 0.20)),
    var(--bg-elev);
  color: var(--text);
}
.streak-burst.bad {
  border-color: var(--danger);
  background:
    linear-gradient(135deg, rgba(239, 68, 68, 0.18), rgba(239, 68, 68, 0.10)),
    var(--bg-elev);
  color: var(--danger);
}
@keyframes burstIn {
  0%   { opacity: 0; transform: translateX(-50%) translateY(-20px) scale(0.7); }
  60%  { transform: translateX(-50%) translateY(0) scale(1.08); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
@keyframes burstOut {
  to { opacity: 0; transform: translateX(-50%) translateY(-12px) scale(0.95); }
}

/* Confetti canvas overlay */
.confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 250;
  display: none;
}
.confetti-canvas.active {
  display: block;
}

/* Result hero (final results animated card) */
.result-hero {
  text-align: center;
  background: linear-gradient(180deg, var(--bg-elev), var(--bg));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 20px 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  animation: heroEnter 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes heroEnter {
  0%   { opacity: 0; transform: scale(0.92) translateY(8px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
.result-hero.tier-high {
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.10), var(--bg-elev));
  border-color: rgba(16, 185, 129, 0.30);
}
.result-hero.tier-mid {
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.08), var(--bg-elev));
  border-color: rgba(124, 58, 237, 0.25);
}
.result-hero.tier-low {
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.06), var(--bg-elev));
}

.rh-stars {
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: 38px;
  margin-bottom: 14px;
}
.rh-star {
  color: var(--border);
  transition: transform 0.3s, color 0.3s;
}
.rh-star.filled {
  color: #f59e0b;
  animation: starPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-shadow: 0 0 18px rgba(245, 158, 11, 0.5);
}
@keyframes starPop {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.rh-score-line {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 8px;
}
.rh-score { color: var(--text); }
.rh-score-max { color: var(--text-muted); font-size: 24px; }

.rh-pct {
  font-size: 22px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 16px;
}
.rh-pct-sign { font-size: 18px; }
.rh-pct-label { color: var(--text-muted); font-size: 13px; font-weight: 500; margin-left: 6px; }

.result-hero.tier-high .rh-pct { color: var(--success); }
.result-hero.tier-low  .rh-pct { color: var(--warning); }

.rh-message {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 12px;
  font-weight: 500;
}
.rh-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.rh-meta .dot { opacity: 0.4; }

/* ================ RESULTS ================ */
.overall-score-card {
  text-align: center;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.overall-score {
  display: inline-block;
  font-size: 60px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1;
}
.overall-max {
  display: inline-block;
  font-size: 22px;
  color: var(--text-muted);
  margin-left: 4px;
}
.overall-label { font-size: 14px; margin-top: 8px; }

.result-tabs {
  display: flex;
  gap: 6px;
  margin: 12px 0 14px;
  border-bottom: 1px solid var(--border);
}
.result-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  border-radius: 6px 6px 0 0;
}
.result-tab:hover { color: var(--text); background: var(--bg-soft); }
.result-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.rt-dot {
  width: 8px;
  height: 8px;
  border-radius: 100px;
  display: inline-block;
}
.rt-dot-wrong { background: var(--danger); }
.rt-dot-correct { background: var(--success); }
.rt-count {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 100px;
  background: var(--bg-soft);
  color: var(--text-muted);
  min-width: 22px;
  text-align: center;
}
.result-tab.active .rt-count {
  background: var(--accent);
  color: white;
}
.results-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.results-list {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 20px;
}
.result-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.result-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; margin-bottom: 10px;
}
.result-q { font-size: 14px; font-weight: 600; flex: 1; }
.result-head-right { display: flex; gap: 6px; align-items: center; }
.result-head-right .icon-btn { width: 26px; height: 26px; font-size: 11px; }

.rating-chip {
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.rating-chip.again { background: rgba(239, 68, 68, 0.10); color: var(--danger); }
.rating-chip.hard  { background: rgba(245, 158, 11, 0.12); color: var(--warning); }
.rating-chip.good  { background: rgba(124, 58, 237, 0.10); color: var(--accent); }
.rating-chip.easy  { background: rgba(16, 185, 129, 0.10); color: var(--success); }

.result-your, .result-correct {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.5;
}
.result-your b, .result-correct b { color: var(--text-muted); font-weight: 500; margin-right: 4px; }
.result-feedback {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-soft);
  line-height: 1.5;
}

/* ================ MODAL ================ */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 16px;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(20, 20, 30, 0.32);
  backdrop-filter: blur(2px);
}
.modal-content {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  padding: 24px 28px;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.modal-head h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.modal-close {
  font-size: 24px; line-height: 1;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }

/* deck modal */
.md-description {
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 4px;
  white-space: pre-wrap;
}
.md-description.empty { color: var(--text-muted); font-style: italic; }
.md-description:hover { color: var(--text); }

.md-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  padding: 12px 0 14px;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.md-stats > div { display: flex; flex-direction: column; gap: 2px; }
.md-stats b { color: var(--text); font-weight: 700; font-size: 16px; }

.md-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 14px 0;
}

.md-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--border);
  margin: 6px 0 14px;
}
.md-tab {
  padding: 10px 16px;
  color: var(--text-muted);
  font-weight: 500; font-size: 14px;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  transition: color 0.15s, border-color 0.15s;
}
.md-tab:hover { color: var(--text); }
.md-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.md-card-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0 10px;
  border-bottom: 1px solid var(--border);
}
.md-edit-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.check-label {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-soft);
  cursor: pointer; user-select: none;
}
.check-label input[type=checkbox] {
  width: 15px; height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

.selection-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--accent-soft);
  border: 1px solid rgba(124, 58, 237, 0.2);
  border-radius: var(--radius);
  margin: 10px 0;
  flex-wrap: wrap;
}
.selection-bar > span { flex: 1; font-size: 13px; font-weight: 500; color: var(--accent); }

.card-rows {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 10px;
}
.card-row {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex; gap: 10px; align-items: center;
}
.card-row.selected { border-color: var(--accent); background: var(--accent-soft); }
.card-check {
  width: 15px; height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  display: none;
}
.card-rows.edit-mode .card-check { display: inline-block; }
.card-row-body { flex: 1; min-width: 0; }
.card-row-front {
  font-size: 14px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-row-back {
  font-size: 12px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-row-meta {
  font-size: 11px; color: var(--text-muted);
  white-space: nowrap;
}
.btn-delete-card {
  color: var(--text-muted); padding: 4px 8px; font-size: 14px;
}
.btn-delete-card:hover { color: var(--danger); }

/* history */
.history-list {
  display: flex; flex-direction: column; gap: 6px; margin-top: 8px;
}
.history-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 16px; align-items: center;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.history-date { font-size: 13px; color: var(--text-soft); }
.history-count { font-size: 12px; color: var(--text-muted); }
.history-score { font-size: 17px; font-weight: 700; }
.history-score.low { color: var(--danger); }
.history-score.mid { color: var(--warning); }
.history-score.high { color: var(--success); }
.history-empty { text-align: center; color: var(--text-muted); padding: 30px 20px; }

/* review modal */
.review-list {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 55vh; overflow-y: auto;
  padding-right: 4px;
}
.review-fix {
  display: grid; grid-template-columns: auto 1fr;
  gap: 12px; align-items: flex-start;
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.review-check {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  margin-top: 3px;
}
.review-issue {
  color: var(--warning);
  font-size: 12px;
  margin-bottom: 6px;
  font-weight: 500;
}
.review-diff {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin-top: 4px;
}
.review-col {
  padding: 8px 10px;
  background: var(--bg-elev);
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.4;
}
.review-col.after { border-color: rgba(16, 185, 129, 0.25); }
.review-col .review-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.review-col.after .review-label { color: var(--success); }
.review-col .review-text { color: var(--text); }
.review-col .review-pt { color: var(--text-muted); margin-top: 2px; }

@media (max-width: 640px) {
  .review-diff { grid-template-columns: 1fr; }
}

/* floating bar (decks bulk) */
.floating-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center;
  padding: 12px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 80;
  flex-wrap: wrap;
  max-width: calc(100vw - 40px);
}
.floating-bar > span { font-weight: 500; color: var(--text); padding-right: 4px; }

/* ================ HOME ================ */
.home-grid {
  display: grid;
  gap: 16px;
}
.home-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}
.home-card * { max-width: 100%; }
.home-card.feedback {
  border-color: rgba(124, 58, 237, 0.18);
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--bg-elev) 70%);
}
.home-card-eyebrow {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 8px;
}
.home-card h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.home-card p {
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.home-topic-why,
.home-topic-name {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.home-topics {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 16px;
}
.home-topic {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.05s;
}
.home-topic:hover { border-color: var(--accent); }
.home-topic-name { font-weight: 600; font-size: 13px; }
.home-topic-why { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.home-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.home-stat {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}
.home-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.home-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.home-empty {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-elev);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}
.home-empty h2 { margin-bottom: 8px; }

.home-history-list {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 14px;
}
.home-history-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.home-history-row:hover { border-color: var(--accent); background: var(--accent-soft); }
.home-history-row .home-history-summary {
  font-size: 13px;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-history-row .home-history-date {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ================ GRAMMAR ================ */
.grammar-toolbar {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}
.grammar-toolbar .textinput { max-width: 380px; }

.grammar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.grammar-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.05s;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.grammar-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.grammar-card:active { transform: scale(0.997); }

.grammar-card-group {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.grammar-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.grammar-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}
.grammar-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 11px;
}
.grammar-card-meta .dot {
  opacity: 0.5;
}
.grammar-card.highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.breadcrumb-link {
  background: none;
  border: 0;
  padding: 4px 6px;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
}
.breadcrumb-link:hover { color: var(--accent); background: var(--accent-soft); }
.breadcrumb-sep { color: var(--text-muted); opacity: 0.5; }

/* explanation block (category & sub-exercise) */
.explanation-block {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.explanation-block.info-variant {
  background: var(--accent-soft);
  border-color: rgba(124, 58, 237, 0.18);
}

.explanation-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.explanation-head .section-title { margin-bottom: 0; }
.explanation-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.explanation-text {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-soft);
  white-space: pre-wrap;
}
.explanation-text strong, .explanation-text b { color: var(--text); font-weight: 600; }
.explanation-text .ex-section {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-top: 14px;
  margin-bottom: 6px;
}
.explanation-text .ex-section:first-child { margin-top: 0; }
.explanation-text ul {
  list-style: none;
  padding: 0;
  margin: 4px 0 0 0;
}
.explanation-text li {
  position: relative;
  padding-left: 16px;
  margin: 4px 0;
}
.explanation-text li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--accent);
}
.explanation-loading {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
  padding: 12px 0;
}
.explanation-empty {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 16px 0;
}

/* progress card */
.progress-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
}
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-soft);
  border-radius: 100px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 100px;
  transition: width 0.4s ease;
}
.progress-label {
  font-size: 12px;
  color: var(--text-muted);
}
.progress-final {
  text-align: right;
  font-size: 11px;
  color: var(--text-muted);
}
.progress-final-score {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  display: block;
}
.progress-final-score.low { color: var(--danger); }
.progress-final-score.mid { color: var(--warning); }
.progress-final-score.high { color: var(--success); }

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 10px;
  letter-spacing: -0.005em;
}

/* info toggle on practice */
.info-row { margin-bottom: 12px; }
.info-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.info-toggle:hover { border-color: var(--accent); color: var(--accent); }
.info-i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-style: italic;
  font-family: serif;
}
.info-panel {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--accent-soft);
  border: 1px solid rgba(124, 58, 237, 0.18);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.info-text {
  flex: 1;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}

/* progress chips on grammar list cards */
.grammar-card-progress {
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pgr-progress-line {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pgr-count {
  flex-shrink: 0;
  font-weight: 600;
}
.grammar-card-progress .pgr-bar {
  flex: 1;
  min-width: 40px;
  height: 4px;
  background: var(--bg-soft);
  border-radius: 100px;
  overflow: hidden;
}
.grammar-card-progress .pgr-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.4s;
}
.pgr-final-line {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* Mini gauge (used in category cards) */
.mini-gauge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 100px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}
.mini-gauge svg {
  width: 50px;
  height: 30px;
  flex-shrink: 0;
}
.mini-gauge .mg-bg {
  stroke: var(--border);
}
.mini-gauge .mg-fill {
  stroke: #ef4444;
  transition: stroke-dasharray 0.4s, stroke 0.3s;
}
.mini-gauge.tier-mid .mg-fill { stroke: #f59e0b; }
.mini-gauge.tier-high .mg-fill { stroke: #22c55e; }
.mini-gauge .mg-tip {
  fill: var(--text);
  stroke: var(--bg);
  stroke-width: 1;
}
.mini-gauge .mg-pct {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.mini-gauge.tier-low .mg-pct { color: var(--danger); }
.mini-gauge.tier-mid .mg-pct { color: var(--warning); }
.mini-gauge.tier-high .mg-pct { color: var(--success); }
.mini-gauge .mg-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.mini-gauge-empty {
  font-size: 11px;
  font-style: italic;
  opacity: 0.7;
}

/* final test sub-exercise visual */
.subex-row.is-final {
  background: linear-gradient(180deg, rgba(124,58,237,0.05), var(--bg-elev));
  border-color: rgba(124, 58, 237, 0.28);
}
.subex-row.is-final .subex-title::before {
  content: '★ ';
  color: var(--accent);
}

/* sub-exercises list inside category modal */
.subex-list {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 8px;
}
.subex-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.12s;
}
.subex-row:hover { border-color: var(--accent); }
.subex-row.is-done {
  opacity: 0.7;
}
.subex-row.is-done:hover { opacity: 1; }
.subex-row.is-done .subex-title { font-weight: 500; }
.subex-info { flex: 1; min-width: 0; }
.subex-title { font-size: 14px; font-weight: 600; }
.subex-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.subex-stats { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.subex-stats b { color: var(--text-soft); }
.subex-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

.diff-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.diff-pill.easy   { background: rgba(16, 185, 129, 0.10); color: var(--success); }
.diff-pill.medium { background: rgba(245, 158, 11, 0.12); color: var(--warning); }
.diff-pill.hard   { background: rgba(239, 68, 68, 0.10); color: var(--danger); }

/* practice screen */
.question-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 36px;
  box-shadow: var(--shadow);
  max-width: 720px;
  margin: 0 auto;
  position: relative;
}
.q-difficulty {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}
.q-sentence {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.5;
  margin-bottom: 28px;
}
.q-sentence .blank {
  display: inline-block;
  min-width: 90px;
  border-bottom: 2px dashed var(--accent);
  margin: 0 4px;
  color: transparent;
}
.q-options { display: flex; flex-direction: column; gap: 10px; }
.q-option {
  background: var(--bg-elev);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.q-option:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.q-option:disabled { cursor: default; }
.q-option.correct {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.08);
  color: var(--success);
}
.q-option.wrong {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.06);
  color: var(--danger);
}

.q-feedback {
  margin-top: 20px;
  padding: 14px 16px;
  background: var(--bg-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-soft);
  transition: background 0.25s, border-color 0.25s, color 0.25s;
}
.q-feedback.correct {
  background: rgba(16, 185, 129, 0.10);
  border: 1px solid rgba(16, 185, 129, 0.32);
  color: #065f46;
}
.q-feedback.correct .fb-correct,
.q-feedback.correct .fb-wrong { color: inherit; }
.q-feedback.wrong {
  background: rgba(239, 68, 68, 0.10);
  border: 1px solid rgba(239, 68, 68, 0.32);
  color: #991b1b;
}
.q-feedback.wrong .fb-correct,
.q-feedback.wrong .fb-wrong { color: inherit; }
[data-theme="dark"] .q-feedback.correct {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.45);
  color: #6ee7b7;
}
[data-theme="dark"] .q-feedback.wrong {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.q-actions { display: flex; justify-content: flex-end; margin-top: 18px; }

/* ================ EXAM ================ */
.exam-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  align-items: start;
}
.exam-chat {
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 500px;
}
.exam-messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px 28px 12px;
  flex: 1;
  overflow-y: auto;
  max-height: calc(100vh - 240px);
}
.msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.msg .msg-bubble {
  max-width: 85%;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.msg.assistant .msg-bubble {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
}
.msg.user {
  justify-content: flex-end;
}
.msg.user .msg-bubble {
  background: var(--accent);
  color: #fff;
}
.msg .msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.msg.user .msg-avatar { display: none; }

/* theme choices */
.theme-choices {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 12px;
}
.theme-choice {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.theme-choice:hover { border-color: var(--accent); background: var(--accent-soft); }

/* article message */
.article-block {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-top: 10px;
}
.article-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}
.article-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.article-meta a { color: var(--accent); }
.article-body {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-soft);
  white-space: pre-wrap;
}
.article-controls {
  display: flex; gap: 8px; margin-top: 12px;
}

/* ============== AUDIO PLAYER ============== */
.audio-player {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-wrap: wrap;
}
.ap-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.ap-btn:hover { background: var(--bg-hover); color: var(--text); }
.ap-btn.ap-play {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.ap-btn.ap-play:hover { background: var(--accent-hover); }

.ap-progress {
  flex: 1;
  min-width: 100px;
  height: 6px;
  background: var(--border);
  border-radius: 100px;
  position: relative;
  cursor: pointer;
}
.ap-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: var(--accent);
  border-radius: 100px;
  transition: width 0.05s linear;
}
.ap-progress-thumb {
  position: absolute;
  top: 50%; left: 0%;
  transform: translate(-50%, -50%);
  width: 12px; height: 12px;
  background: var(--accent);
  border-radius: 50%;
  pointer-events: none;
  transition: left 0.05s linear;
}
.ap-time {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ap-speed {
  padding: 4px 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-soft);
  cursor: pointer;
  outline: none;
}
.ap-speed:focus { border-color: var(--accent); }

/* feedback message */
.feedback-block {
  background: var(--accent-soft);
  border: 1px solid rgba(124, 58, 237, 0.18);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-top: 8px;
}
.feedback-title { font-weight: 600; color: var(--accent); margin-bottom: 8px; }
.feedback-topics { display: flex; flex-direction: column; gap: 8px; }
.feedback-topic {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.feedback-topic:hover { border-color: var(--accent); }
.feedback-topic-name { font-weight: 600; font-size: 13px; }
.feedback-topic-why { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.exam-thinking {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 28px;
  font-size: 13px;
  border-top: 1px solid var(--border);
}
.spinner.small { width: 18px; height: 18px; border-width: 2px; }

.exam-input-row {
  display: flex;
  gap: 10px;
  padding: 14px 20px 16px;
  border-top: 1px solid var(--border);
}
.exam-input { flex: 1; }

/* sidebar (words) */
.exam-sidebar {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  position: sticky;
  top: 20px;
  box-shadow: var(--shadow-sm);
}
.exam-sidebar-head { margin-bottom: 12px; }
.exam-sidebar-head h3 { font-size: 14px; font-weight: 600; }
.exam-sidebar-head p { font-size: 11px; margin-top: 2px; }

.word-list {
  margin: 12px 0 0;
  display: flex; flex-direction: column; gap: 4px;
  max-height: 240px;
  overflow-y: auto;
}
.word-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.word-row .word-remove {
  font-size: 14px; color: var(--text-muted);
  width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.word-row .word-remove:hover { color: var(--danger); background: var(--bg-hover); }

.w-full { width: 100%; }

@media (max-width: 900px) {
  .exam-layout { grid-template-columns: 1fr; }
  .exam-sidebar { position: static; }
}

/* ================ LOGIN ================ */
.login-screen {
  position: fixed; inset: 0;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.login-box {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 18px;
  margin-bottom: 14px;
}
.login-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 12px;
  padding: 8px 10px;
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius);
}

/* ================ USER MENU ================ */
.user-menu {
  position: relative;
}
.user-menu-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}
.user-menu-toggle:hover { background: var(--bg-hover); }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-role { font-size: 11px; }
.user-menu-caret {
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.15s;
}
.user-menu.open .user-menu-caret { transform: rotate(180deg); }

.user-menu-popup {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  z-index: 60;
}
.user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.user-menu-item:hover { background: var(--bg-hover); color: var(--text); }
.user-menu-item.danger { color: var(--danger); }
.user-menu-item.danger:hover { background: rgba(239, 68, 68, 0.06); }

/* ================ USERS MANAGEMENT MODAL ================ */
.users-add-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 12px;
  background: var(--bg-soft);
  border-radius: var(--radius);
}
.users-list {
  display: flex; flex-direction: column; gap: 6px;
}
.user-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  gap: 10px;
}
.user-row .user-row-info { flex: 1; min-width: 0; }
.user-row .user-row-name { font-weight: 600; font-size: 14px; }
.user-row .user-row-role { font-size: 11px; color: var(--text-muted); }
.user-row .admin-badge {
  display: inline-block;
  padding: 1px 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 100px;
  margin-left: 6px;
}
.user-row .user-row-actions { display: flex; gap: 6px; }

@media (max-width: 760px) {
  .users-add-row { grid-template-columns: 1fr; }
  .login-box { padding: 24px; }

  /* Game bar mobile tweaks */
  .game-bar { margin-bottom: 14px; gap: 8px; }
  .gb-stats { font-size: 12px; }
  .gb-streak { padding: 3px 8px; font-size: 11px; }

  /* Gauge mobile */
  .gb-gauge { width: 110px; height: 70px; }
  .gauge-value { font-size: 18px; }
  .gauge-pct { font-size: 11px; }
  .gauge-sub { font-size: 9px; }

  /* Result hero mobile */
  .result-hero { padding: 28px 16px 22px; }
  .rh-stars { font-size: 32px; gap: 6px; margin-bottom: 12px; }
  .rh-score-line { font-size: 38px; }
  .rh-score-max { font-size: 20px; }
  .rh-pct { font-size: 18px; }
  .rh-message { font-size: 14px; }
  .rh-meta { font-size: 11px; gap: 4px; }

  /* Streak burst smaller on mobile, below the top nav */
  .streak-burst {
    font-size: 13px;
    padding: 10px 18px;
    top: 84px;
    max-width: calc(100vw - 24px);
    white-space: normal;
    text-align: center;
    line-height: 1.3;
  }

  /* Touch targets */
  .q-option { min-height: 48px; }
  .btn.icon-only { width: 40px; height: 40px; }
}

/* ================ EXAM MODE PICKER ================ */
.exam-mode-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 8px;
}
.exam-mode-card {
  text-align: left;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.exam-mode-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.10);
}
.emc-icon {
  font-size: 36px;
  margin-bottom: 12px;
}
.emc-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.emc-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ================ EXAM CONVERSATION FLOW ================ */
.conv-step {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.conv-step-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.conv-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-weight: 700;
  font-size: 14px;
}
.conv-step-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}
.conv-prompt-box {
  margin-top: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  position: relative;
}
.conv-prompt-pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  margin: 0 0 12px;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 280px;
  overflow-y: auto;
}
.conv-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 12px;
  vertical-align: middle;
}

.conv-result-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 16px;
  border-left: 3px solid var(--accent);
}
.conv-result-card h3 {
  margin: 0 0 12px;
  font-size: 18px;
}
.conv-result-card h4 {
  margin: 16px 0 8px;
  font-size: 14px;
  font-weight: 700;
}
.conv-summary {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
}
.conv-topics {
  list-style: none;
  padding: 0;
  margin: 0;
}
.conv-topics li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.5;
}
.conv-topics li:last-child { border-bottom: 0; }
.conv-topic-link {
  display: inline-block;
  margin-top: 6px;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  font-size: 12px;
}
.conv-topic-link:hover { text-decoration: underline; }
.conv-encourage {
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-soft);
  font-style: italic;
}

@media (max-width: 760px) {
  .exam-mode-picker { grid-template-columns: 1fr; gap: 12px; }
  .exam-mode-card { padding: 22px 18px; }
  .emc-icon { font-size: 30px; }
  .emc-title { font-size: 16px; }
  .conv-step { padding: 16px 18px; }
  .conv-prompt-pre { font-size: 11px; max-height: 220px; }
}

/* ================ ADMIN SETTINGS ================ */
.settings-section {
  margin-top: 8px;
}
.settings-section-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
}
.settings-current {
  margin-top: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.settings-current-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.settings-current-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 4px;
}
.settings-current-value {
  display: flex;
  gap: 8px;
  align-items: center;
}
.settings-badge {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 100px;
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
}
.settings-badge.ok { background: rgba(16, 185, 129, 0.12); color: var(--success); }
.settings-form .form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 6px;
}

/* ================ CLEAR PROGRESS ================ */
.clear-warning {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.30);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.5;
}
.clear-warning ul {
  margin: 8px 0 0 18px;
  padding: 0;
}
.clear-warning li { margin-bottom: 3px; }
.btn.btn-danger {
  background: var(--danger);
  color: white;
  border: 0;
}
.btn.btn-danger:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}
.btn.btn-danger:not(:disabled):hover {
  filter: brightness(0.9);
}

/* ================ TOAST ================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.toast-error { border-color: var(--danger); color: var(--danger); }
.toast.toast-success { border-color: var(--success); color: var(--success); }

/* ================ RESPONSIVE ================ */
@media (max-width: 900px) {
  .exam-layout { grid-template-columns: 1fr; }
  .exam-sidebar { position: static; }
}

/* ============= MOBILE TOPBAR + SIDEBAR ============= */
.mobile-topbar { display: none; }

@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }

  /* Mobile top bar with hamburger */
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 56px;
    padding: 0 16px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 90;
  }
  .mobile-menu-toggle {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 0;
    background: transparent;
    border: 0;
    flex-shrink: 0;
  }
  .mobile-menu-toggle:active { background: var(--bg-soft); }
  .mt-burger {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    transition: transform 0.25s, opacity 0.2s;
  }
  .mobile-menu-toggle.is-open .mt-burger:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .mobile-menu-toggle.is-open .mt-burger:nth-child(2) { opacity: 0; }
  .mobile-menu-toggle.is-open .mt-burger:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }
  .mobile-topbar-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
  }
  .mobile-topbar-spacer { flex: 1; }

  /* Backdrop when sidebar open */
  .sidebar-backdrop {
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 95;
    opacity: 0;
    transition: opacity 0.25s;
    pointer-events: none;
  }
  .sidebar-backdrop:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
  }

  /* Sidebar slide-in from left */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 84vw;
    height: 100vh;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 18px 14px;
    border-right: 1px solid var(--border);
    border-bottom: none;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
  }
  .sidebar.is-open { transform: translateX(0); }

  .sidebar-brand {
    padding: 4px 8px 14px;
    font-size: 16px;
  }
  .sidebar-nav {
    flex-direction: column;
    gap: 4px;
    flex: 1;
    overflow-x: visible;
  }
  .nav-item {
    padding: 12px 14px;
    flex-shrink: 0;
    justify-content: flex-start;
    width: 100%;
  }
  .nav-label { display: inline; }
  .sidebar-footer {
    display: block;
    padding: 12px 4px 4px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
  }
  .user-menu-popup {
    position: static;
    box-shadow: none;
    margin-top: 6px;
    padding: 4px 0;
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
  }

  .main { padding: 18px 14px 80px; max-width: 100%; }
  .view-title { font-size: 22px; }
  .view-sub { font-size: 13px; }
  .content-area { padding: 18px 16px; }

  .deck-grid { grid-template-columns: 1fr; }
  .grammar-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .grammar-card { padding: 12px 14px; }
  .grammar-card-name { font-size: 13px; }
  .grammar-card-desc { display: none; }

  .home-stats { grid-template-columns: 1fr 1fr; }

  .modal { padding: 12px; }
  .modal-content { padding: 18px 16px; max-height: calc(100vh - 24px); }
  .modal-head h2 { font-size: 18px; }

  .batch-card { padding: 14px 16px; }
  .vocab-sentence { font-size: 13px; padding: 8px 12px; }

  .question-card { padding: 22px 18px; }
  .q-sentence { font-size: 17px; line-height: 1.5; margin-bottom: 18px; }
  .q-option { padding: 12px 14px; font-size: 14px; }
  .q-feedback { font-size: 12px; padding: 12px; }

  .overall-score { font-size: 48px; }

  .exam-input-row { padding: 12px 14px; flex-direction: column; }
  .exam-input-row .btn { width: 100%; }
  .exam-messages { padding: 18px 16px 8px; max-height: 70vh; }
  .msg .msg-bubble { max-width: 95%; padding: 10px 12px; font-size: 13px; }
  .article-block { padding: 14px; }
  .article-title { font-size: 15px; }

  .audio-player { padding: 6px 8px; gap: 6px; }
  .ap-btn { width: 30px; height: 30px; font-size: 11px; }
  .ap-time { font-size: 10px; }
  .ap-speed { padding: 3px 6px; font-size: 11px; }

  .breadcrumb { font-size: 12px; }
  .breadcrumb-link { padding: 3px 5px; font-size: 12px; }

  .explanation-block { padding: 14px 16px; }
  .explanation-text { font-size: 13px; }
  .explanation-head { flex-direction: column; align-items: flex-start; gap: 8px; }

  .deck-counts { gap: 10px; font-size: 12px; }
  .row-between { gap: 10px; }
  .row-actions { gap: 6px; }

  .progress-card { grid-template-columns: 1fr; gap: 10px; }
  .progress-final { text-align: left; }

  .subex-row { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .subex-actions { width: 100%; justify-content: flex-start; gap: 6px; }

  .selection-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .selection-bar > span { flex: none; }
  .selection-bar .select { width: 100%; }
  .floating-bar {
    bottom: 12px;
    width: calc(100% - 24px);
    max-width: 380px;
    flex-direction: column;
    align-items: stretch;
    padding: 10px 12px;
  }
  .floating-bar .select { width: 100%; }
}

@media (max-width: 420px) {
  .grammar-grid { grid-template-columns: 1fr; }
  .home-stats { grid-template-columns: 1fr; }
}
