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

:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --border: #e2e4e9;
  --text: #1a1a2e;
  --text2: #555;
  --muted: #888;
  --accent: #2563eb;
  --primary: #2563eb;
  --accent-light: #dbeafe;
  --green: #16a34a;
  --green-light: #dcfce7;
  --red: #dc2626;
  --red-light: #fee2e2;
  --orange: #ea580c;
  --orange-light: #fff7ed;
  --yellow: #ca8a04;
  --purple: #9333ea;
  --positive: #16a34a;
  --negative: #dc2626;
  --neutral: #ea580c;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] {
  --bg: #0f1117;
  --card: #1a1d27;
  --border: #2a2d3a;
  --text: #e4e4e7;
  --text2: #a0aec0;
  --muted: #888;
  --primary: #6c8cff;
  --accent: #6c8cff;
  --accent-light: rgba(108, 140, 255, 0.15);
  --positive: #2ecc71;
  --negative: #e74c3c;
  --neutral: #f39c12;
  --danger: #e74c3c;
  --success: #2ecc71;
  --green: #2ecc71;
  --red: #e74c3c;
  --orange: #f39c12;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.5);
}

[data-theme="eye"] {
  --bg: #e8edd4;
  --card: #f4f7e8;
  --border: #c8ceaa;
  --text: #2b2e1f;
  --text2: #555842;
  --muted: #7a7d6a;
  --primary: #4a7c59;
  --accent: #4a7c59;
  --accent-light: rgba(74, 124, 89, 0.12);
  --positive: #2d8a4e;
  --negative: #c0392b;
  --neutral: #d4880f;
  --danger: #c0392b;
  --success: #2d8a4e;
  --green: #2d8a4e;
  --red: #c0392b;
  --orange: #d4880f;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Theme Switcher */
/* ===== Theme + Wallpaper Container ===== */
.theme-wp-container {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 6px;
}
.theme-switcher {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
}
.theme-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0;
}
.theme-btn:hover {
  transform: scale(1.15);
}
.theme-btn.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--accent-light);
}
.theme-btn[data-t="light"] {
  background: #ffffff;
  border-color: #ddd;
}
.theme-btn[data-t="dark"] {
  background: #1a1d27;
  border-color: #444;
}
.theme-btn[data-t="eye"] {
  background: #c8ceaa;
  border-color: #a8ae8a;
}

/* Wallpaper picker */
.wp-toggle-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  box-shadow: var(--shadow-lg);
  transition: transform 0.2s;
}
.wp-toggle-btn:hover {
  transform: scale(1.1);
}
.wp-panel {
  position: absolute;
  bottom: 42px;
  left: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  min-width: 200px;
}
.wp-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}
.wp-btn:hover {
  transform: scale(1.15);
}
.wp-btn.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--accent-light);
}

/* Shared utility for dark-only sub-pages */
.nav-back {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--primary);
  text-decoration: none;
  font-size: 0.9rem;
}
.nav-back:hover {
  text-decoration: underline;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition:
    background 0.3s,
    color 0.3s;
}

/* === Layout === */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

header {
  text-align: center;
  padding: 28px 0 20px;
  position: relative;
}
header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
}
header h1 .version {
  font-size: 0.7rem;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 8px;
  vertical-align: middle;
}
header .subtitle {
  font-size: 0.85rem;
  color: var(--text2);
  margin-top: 4px;
}
.header-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-top: 12px;
}
.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--card);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}
.icon-btn:hover {
  transform: scale(1.1);
}
.progress-badge {
  background: var(--accent);
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* === Search Bar === */
.search-section {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.search-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.search-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
  background: var(--card);
  color: var(--text);
}
.search-input:focus {
  border-color: var(--accent);
}
.search-input::placeholder {
  color: #aaa;
}

.search-btn {
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.search-btn:hover {
  opacity: 0.9;
}

/* === Filters === */
.filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.filter-select {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}
.filter-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* === Mode Tabs === */
.mode-tabs {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.mode-tab {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg);
  color: var(--text2);
  transition: all 0.2s;
}
.mode-tab:hover {
  background: var(--accent-light);
  color: var(--accent);
}
.mode-tab.active {
  background: var(--accent);
  color: white;
}

/* === Practice Panel === */
.practice-panel {
  display: none;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.practice-panel.visible {
  display: block;
}

.practice-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border);
}
.ctrl-btn {
  padding: 10px 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
}
.ctrl-btn:hover {
  opacity: 0.9;
}
.ctrl-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.practice-info {
  text-align: center;
}
#practiceProgress {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}
.timer {
  font-size: 0.9rem;
  color: var(--text2);
  margin-top: 4px;
  font-family: "Courier New", monospace;
}

#practiceQuestion .q-card {
  margin-bottom: 0;
}

.practice-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 2px solid var(--border);
  flex-wrap: wrap;
}
.action-btn {
  flex: 1;
  min-width: 120px;
  padding: 10px;
  border: 1.5px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}
.action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.action-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* === Stats Panel === */
.stats-panel {
  display: none;
}
.stats-panel.visible {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-card .num {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}
.stat-card .label {
  font-size: 0.8rem;
  color: var(--text2);
  margin-top: 4px;
}

.charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.chart-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.chart-card h3 {
  font-size: 1rem;
  margin-bottom: 16px;
  color: var(--text);
}
#progressChart,
#accuracyChart {
  min-height: 200px;
  padding: 10px;
}
.progress-bar {
  background: var(--border);
  height: 24px;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 12px;
}
.progress-fill {
  background: linear-gradient(90deg, var(--accent), var(--purple));
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  transition: width 0.5s;
}
.category-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.category-bar .name {
  min-width: 100px;
  font-size: 0.85rem;
}
.category-bar .bar {
  flex: 1;
  height: 20px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.category-bar .fill {
  height: 100%;
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
}

.top-words {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.top-words h3 {
  margin-bottom: 12px;
}
.word-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.word-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.word-chip:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-2px);
}
.word-chip .count {
  font-size: 0.7rem;
  opacity: 0.8;
}

/* === Review Panel === */
.review-panel {
  display: none;
}
.review-panel.visible {
  display: block;
}

.review-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.review-tab {
  flex: 1;
  min-width: 150px;
  padding: 12px;
  background: var(--card);
  border-radius: var(--radius);
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all 0.2s;
}
.review-tab:hover {
  background: var(--accent-light);
  color: var(--accent);
}
.review-tab.active {
  background: var(--accent);
  color: white;
}

#reviewContent {
  min-height: 200px;
}

/* === Dedup Panel === */
.dedup-panel {
  display: none;
}
.dedup-panel.visible {
  display: block;
}

.dedup-group {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.dedup-group h4 {
  color: var(--accent);
  margin-bottom: 8px;
  font-size: 0.9rem;
}
.dedup-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.dedup-item:last-child {
  border-bottom: none;
}

/* === Question Cards === */
.question-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.q-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: all 0.2s;
}
.q-card:hover {
  box-shadow: var(--shadow-lg);
}

.q-header {
  padding: 14px 16px;
  background: var(--bg);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}
.q-header:hover {
  background: var(--accent-light);
}

.q-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.badge {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-source {
  background: var(--accent-light);
  color: var(--accent);
}
.badge-module {
  background: #e0e7ff;
  color: #4f46e5;
}
.badge-category {
  background: var(--purple);
  color: white;
  opacity: 0.9;
}
.badge-easy {
  background: var(--green-light);
  color: var(--green);
}
.badge-medium {
  background: var(--orange-light);
  color: var(--orange);
}
.badge-hard {
  background: var(--red-light);
  color: var(--red);
}
.badge-answer {
  background: var(--green);
  color: white;
}

/* Answer hidden by default — reveal on click */
.q-card.answer-hidden .badge-answer {
  display: none;
}
.q-card.answer-hidden .q-choices li.correct {
  background: var(--card);
  border-color: var(--border);
}
.q-card.answer-hidden .choice.correct {
  background: var(--card);
  border-color: var(--border);
  color: var(--text);
}
.reveal-answer-btn {
  margin-top: 10px;
  padding: 6px 16px;
  border: 1px solid var(--green);
  border-radius: 6px;
  background: transparent;
  color: var(--green);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}
.reveal-answer-btn:hover {
  background: var(--green-light);
}
.badge-status {
  background: var(--yellow);
  color: white;
}

/* Difficulty badges (star ratings from DIFFICULTY_SCORES) */
.diff-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 4px;
}
.diff-1 {
  background: #dcfce7;
  color: #16a34a;
}
.diff-2 {
  background: #dbeafe;
  color: #2563eb;
}
.diff-3 {
  background: #fef3c7;
  color: #b45309;
}
.diff-4 {
  background: #fed7aa;
  color: #ea580c;
}
.diff-5 {
  background: #fecaca;
  color: #dc2626;
}

.q-id {
  font-size: 0.8rem;
  color: var(--text2);
  font-family: "Courier New", monospace;
}

.q-body {
  padding: 16px;
  display: none;
}
.q-card.open .q-body {
  display: block;
}

.q-passage {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1.7;
}

.q-stem {
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 0.95rem;
}

.q-choices {
  list-style: none;
}
.q-choices li {
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  display: flex;
  gap: 10px;
  transition: all 0.2s;
  cursor: pointer;
}
.q-choices li:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}
.q-choices li.correct {
  background: var(--green-light);
  border-color: var(--green);
}
.q-choices li.hidden-answer {
  background: var(--card);
  border-color: var(--border);
}
.choice {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 14px;
  transition: all 0.15s;
}
.choice.correct {
  background: var(--green-light);
  border-color: var(--green);
  color: var(--green);
}
.choice-label {
  font-weight: 700;
  color: var(--accent);
  min-width: 20px;
}
.choice-text {
  flex: 1;
}

.q-note {
  margin-top: 12px;
  padding: 12px;
  background: var(--yellow);
  background: #fffbeb;
  border-left: 3px solid var(--yellow);
  border-radius: 4px;
  font-size: 0.85rem;
}
[data-theme="dark"] .q-note {
  background: rgba(202, 138, 4, 0.2);
}

mark {
  background: #fef08a;
  padding: 2px 4px;
  border-radius: 2px;
}
[data-theme="dark"] mark {
  background: rgba(250, 204, 21, 0.3);
  color: var(--text);
}

/* === Pagination === */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.page-btn {
  min-width: 36px;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  background: var(--card);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.page-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* === Results Info === */
.results-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: var(--text2);
}

/* === Loading === */
.loading {
  text-align: center;
  padding: 60px 20px;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* === Modal === */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.visible {
  display: flex;
}
.modal-content {
  background: var(--card);
  border-radius: var(--radius);
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-size: 1.1rem;
}
.close-btn {
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--text2);
  line-height: 1;
}
.close-btn:hover {
  color: var(--text);
}
.modal textarea {
  width: 100%;
  padding: 16px 20px;
  border: none;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  background: var(--card);
  color: var(--text);
}
.modal textarea:focus {
  outline: none;
}
.modal-actions {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
}
.btn-secondary {
  padding: 10px 20px;
  border: 1.5px solid var(--border);
  background: var(--card);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.btn-primary {
  padding: 10px 20px;
  border: none;
  background: var(--accent);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.btn-primary:hover {
  opacity: 0.9;
}

/* === Shortcuts Hint === */
.shortcuts-hint {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 16px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  font-size: 0.8rem;
  color: var(--text2);
  opacity: 0.7;
  transition: opacity 0.2s;
}
.shortcuts-hint:hover {
  opacity: 1;
}
kbd {
  display: inline-block;
  padding: 2px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: "Courier New", monospace;
  font-size: 0.85em;
}

/* === Responsive === */
@media (max-width: 768px) {
  .container {
    padding: 16px 12px 40px;
  }
  header h1 {
    font-size: 1.3rem;
  }
  .search-row {
    flex-direction: column;
  }
  .search-btn {
    width: 100%;
  }
  .filter-row {
    flex-direction: column;
  }
  .filter-select {
    width: 100%;
  }
  .practice-controls {
    flex-direction: column;
    gap: 12px;
  }
  .practice-actions {
    flex-direction: column;
  }
  .action-btn {
    min-width: 100%;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .charts-row {
    grid-template-columns: 1fr;
  }
}

/* === Enhanced Dedup Styles === */
.dedup-group-enhanced {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.dedup-group-enhanced h4 {
  color: var(--accent);
  margin-bottom: 12px;
  font-size: 1rem;
}

.legend {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
  padding: 10px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text2);
}

.dedup-item-full {
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  background: var(--card);
  transition: all 0.2s;
}

.dedup-item-full:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
}

.dedup-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.dedup-passage {
  background: var(--bg);
  padding: 16px;
  border-radius: 6px;
  margin-bottom: 12px;
  line-height: 1.8;
  font-size: 0.95rem;
}

.dedup-passage strong {
  color: var(--text);
  font-weight: 700;
}

.dedup-passage em {
  color: var(--accent);
  font-style: italic;
  background: var(--accent-light);
  padding: 2px 4px;
  border-radius: 3px;
}

.dedup-question {
  margin-bottom: 12px;
  font-size: 0.9rem;
  padding: 10px;
  background: #f0f9ff;
  border-radius: 6px;
}

[data-theme="dark"] .dedup-question {
  background: rgba(37, 99, 235, 0.1);
}

.dedup-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dedup-choices > div {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  background: var(--bg);
}

.dedup-choices .correct-choice {
  background: var(--green-light);
  border-left: 3px solid var(--green);
  font-weight: 600;
}

[data-theme="dark"] .dedup-choices .correct-choice {
  background: rgba(22, 163, 74, 0.2);
}

/* === Vocab Panel === */
.vocab-panel {
  display: none;
}
.vocab-panel.visible {
  display: block;
}

.vocab-panel h2 {
  font-size: 1.4rem;
  margin-bottom: 8px;
}

.vocab-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  background: var(--card);
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

.filter-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.vocab-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.vocab-list {
  display: grid;
  gap: 10px;
}

.vocab-item {
  display: grid;
  grid-template-columns: 50px 1fr 150px 120px;
  gap: 16px;
  align-items: center;
  padding: 12px 16px;
  background: var(--card);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transition: all 0.2s;
}

.vocab-item:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.vocab-rank {
  font-size: 0.85rem;
  color: var(--text2);
  font-weight: 600;
}

.vocab-word {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

.vocab-freq {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.freq-bar {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 6px;
  background: var(--accent-light);
  border-radius: 3px;
  z-index: 0;
}

.vocab-freq span {
  position: relative;
  z-index: 1;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text2);
}

.vocab-root {
  font-size: 0.8rem;
  color: var(--text2);
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 12px;
  text-align: center;
}

/* === Hard Questions Panel === */
.hard-panel {
  display: none;
}
.hard-panel.visible {
  display: block;
}

.hard-panel h2 {
  font-size: 1.4rem;
  margin-bottom: 8px;
}

@media (max-width: 768px) {
  .vocab-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .vocab-freq {
    justify-content: space-between;
  }
}

/* === AA + App Store Sidebar Nav (v5) === */

/* Top bar */
.aa-topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.aa-topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 48px;
  gap: 16px;
}
.aa-brand {
  font-weight: 800;
  font-size: 20px;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
  white-space: nowrap;
}
.aa-brand:hover {
  color: var(--accent);
  text-decoration: none;
}
.aa-topbar-search {
  flex: 1;
  max-width: 560px;
}
.aa-search-input {
  width: 100%;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.aa-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 140, 255, 0.15);
}
.aa-search-input::placeholder {
  color: var(--text3, #888);
}
.aa-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  font-size: 13px;
  margin-left: auto;
}
.aa-user-name {
  color: var(--text2);
  font-weight: 500;
}
.aa-user-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
}
.aa-user-link:hover {
  text-decoration: underline;
}
.aa-logout-btn {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text2);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.aa-logout-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Sidebar */
.aa-sidebar {
  position: fixed;
  top: 48px;
  left: 0;
  bottom: 0;
  width: 200px;
  background: color-mix(in srgb, var(--card) 85%, var(--bg));
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 0;
  z-index: 80;
  scrollbar-width: thin;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.aa-sidebar::-webkit-scrollbar {
  width: 4px;
}
.aa-sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.aa-side-section {
  padding: 0 16px;
  margin-bottom: 20px;
}
.aa-side-heading {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.2px;
}
.aa-side-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  margin: 1px 0;
  border-radius: 6px;
  color: var(--text2);
  text-decoration: none;
  font-size: 13px;
  transition:
    background 0.12s,
    color 0.12s;
}
.aa-side-link:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}
.aa-side-link.active {
  background: var(--accent, #6c8cff);
  color: #fff;
  font-weight: 600;
}
.aa-side-link.active .aa-side-count {
  color: rgba(255, 255, 255, 0.7);
}
.aa-side-count {
  font-size: 11px;
  color: var(--text3, #888);
  font-family:
    ui-monospace, "Cascadia Mono", Menlo, Monaco, Consolas, monospace;
  flex-shrink: 0;
}
.aa-side-meta {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 8px;
}
.aa-side-meta-text {
  font-size: 12px;
  color: var(--text3, #888);
}

/* Layout: sidebar + main content */
.aa-layout {
  margin-left: 200px;
}
.aa-sidebar ~ .container,
.aa-layout > .container {
  max-width: 1100px;
  margin: 0 auto;
}

/* Mobile sidebar toggle */
.aa-side-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  border: none;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
}
.aa-side-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  transition: all 0.2s;
}
.aa-side-toggle.open span:nth-child(1) {
  transform: rotate(45deg) translate(4px, 4px);
}
.aa-side-toggle.open span:nth-child(2) {
  opacity: 0;
}
.aa-side-toggle.open span:nth-child(3) {
  transform: rotate(-45deg) translate(4px, -4px);
}

/* iframe SPA mode (teacher) */
.aa-iframe-mode .aa-layout {
  position: fixed;
  top: 48px;
  left: 200px;
  right: 0;
  bottom: 0;
}
.aa-main-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* === Tablet: sidebar overlay === */
@media (max-width: 900px) {
  .aa-sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }
  .aa-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
  }
  .aa-layout {
    margin-left: 0;
  }
  .aa-iframe-mode .aa-layout {
    left: 0;
  }
  .aa-side-toggle {
    display: flex;
  }
}

/* === Mobile: 480px === */
@media (max-width: 480px) {
  .aa-topbar-inner {
    padding: 0 12px;
    height: 44px;
    gap: 8px;
  }
  .aa-brand {
    font-size: 16px;
  }
  .aa-search-input {
    font-size: 16px;
    padding: 8px 10px;
  }

  .container {
    padding: 12px 8px 32px;
  }
  header h1 {
    font-size: 1.1rem;
  }
  .q-card {
    padding: 12px;
  }
  .badge {
    font-size: 10px;
    padding: 2px 6px;
  }
  .search-row,
  .filter-row {
    flex-direction: column;
    gap: 6px;
  }
  .search-input,
  .filter-select,
  .search-btn {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
  }
  .practice-controls {
    flex-direction: column;
  }
  .action-btn {
    min-width: 100%;
    min-height: 44px;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}
