/* ==========================================================================
   REWRITE SENTENCES PRO HSG9 - DESIGN SYSTEM & STYLESHEET
   Biên soạn & Giảng dạy: Thầy Võ Ngọc Tùng - Tổ Tiếng Anh THCS Nhuận Phú Tân
   Hệ Thống Trực Quan Hóa Sư Phạm & Luyện Thi Chuyên Sâu
   ========================================================================== */

/* --- CSS Variables & Design Tokens --- */
:root {
  /* Palette - Light Theme (Default fallback) */
  --bg-canvas: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-card-glass: rgba(255, 255, 255, 0.85);
  --bg-accent-subtle: #f1f5f9;
  --bg-input: #ffffff;
  
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-focus: #6366f1;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --text-inverse: #ffffff;
  
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-glow: rgba(79, 70, 229, 0.2);
  --primary-surface: #eef2ff;
  
  --accent-cyan: #0284c7;
  --accent-cyan-surface: #e0f2fe;
  
  --success: #10b981;
  --success-surface: #ecfdf5;
  --success-border: #a7f3d0;
  --success-glow: rgba(16, 185, 129, 0.25);
  
  --danger: #ef4444;
  --danger-surface: #fef2f2;
  --danger-border: #fecaca;
  
  --warning: #f59e0b;
  --warning-surface: #fffbeb;
  --warning-border: #fde68a;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.25);

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Dark Theme Tokens (Deep Academic Obsidian) */
[data-theme="dark"] {
  --bg-canvas: #070b14;
  --bg-surface: #0f172a;
  --bg-surface-elevated: #1e293b;
  --bg-card-glass: rgba(15, 23, 42, 0.82);
  --bg-accent-subtle: #192338;
  --bg-input: #0b1120;
  
  --border-subtle: #24324d;
  --border-strong: #334668;
  --border-focus: #818cf8;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-inverse: #070b14;
  
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-glow: rgba(99, 102, 241, 0.35);
  --primary-surface: rgba(99, 102, 241, 0.12);
  
  --accent-cyan: #38bdf8;
  --accent-cyan-surface: rgba(56, 189, 248, 0.12);
  
  --success: #34d399;
  --success-surface: rgba(52, 211, 153, 0.12);
  --success-border: rgba(52, 211, 153, 0.3);
  --success-glow: rgba(52, 211, 153, 0.3);
  
  --danger: #f87171;
  --danger-surface: rgba(248, 113, 113, 0.12);
  --danger-border: rgba(248, 113, 113, 0.3);
  
  --warning: #fbbf24;
  --warning-surface: rgba(251, 191, 36, 0.12);
  --warning-border: rgba(251, 191, 36, 0.3);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 24px -4px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 24px rgba(99, 102, 241, 0.3);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-canvas);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* --- Header / Navigation Bar --- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card-glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}

.header-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-shrink: 0;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
  transition: transform var(--transition-bounce);
}
.brand-logo:hover {
  transform: rotate(-6deg) scale(1.05);
}

.brand-title {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.brand-title span {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Nav Modes */
.mode-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-accent-subtle);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.nav-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-btn.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

.nav-badge {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--primary-surface);
  color: var(--primary);
  font-weight: 700;
}

.nav-badge.count {
  background: var(--warning-surface);
  color: var(--warning);
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.stats-pill {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  box-shadow: var(--shadow-sm);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 600;
}

.stat-divider {
  width: 1px;
  height: 14px;
  background: var(--border-subtle);
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.dark-icon { display: none; }
.light-icon { display: block; }
[data-theme="dark"] .dark-icon { display: block; }
[data-theme="dark"] .light-icon { display: none; }

/* --- Main Layout --- */
.main-content {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
  flex: 1;
}

.view-section {
  display: none;
}
.view-section.active {
  display: block;
  animation: fadeIn 250ms ease-out;
}

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

/* Section Header Bar */
.view-header-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.view-heading {
  font-family: var(--font-sans);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-main);
}

.view-subheading {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  max-width: 780px;
}

/* Search Box */
.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0.5rem 1rem;
  width: 280px;
  color: var(--text-muted);
  transition: border-color var(--transition-fast);
}

.search-box:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-box input {
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.85rem;
  width: 100%;
  outline: none;
}

/* --- Set Selector Pills Track (Horizontal Scrollable Strip) --- */
.sets-selector-scroll {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  scrollbar-width: thin;
}

.sets-pills-track {
  display: flex;
  gap: 0.5rem;
  min-width: max-content;
}

.set-pill-btn {
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-accent-subtle);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  min-width: 78px;
  transition: all var(--transition-fast);
}

.set-pill-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-main);
  transform: translateY(-1px);
}

.set-pill-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 10px var(--primary-glow);
}

.set-pill-status {
  font-size: 0.68rem;
  opacity: 0.85;
  font-family: var(--font-mono);
}

/* --- Solver Studio & Question Card --- */
.solver-studio {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  position: relative;
}

.set-active-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 1rem;
}

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

.active-set-badge {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text-main);
}

.active-category-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--accent-cyan-surface);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.2);
}

.meta-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.question-pagers {
  display: flex;
  gap: 0.35rem;
}

.pager-dot {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-accent-subtle);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pager-dot:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
}

.pager-dot.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

.pager-dot.solved {
  background: var(--success-surface);
  border-color: var(--success-border);
  color: var(--success);
}

.btn-star {
  background: transparent;
  border: 1px solid var(--border-subtle);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-star:hover {
  color: var(--warning);
  border-color: var(--warning);
}

.btn-star.bookmarked {
  color: var(--warning);
  border-color: var(--warning);
  fill: var(--warning);
  background: var(--warning-surface);
}

/* Original Sentence Box */
.question-original-box {
  background: var(--bg-accent-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  position: relative;
}

.q-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.q-number-chip {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-surface);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.q-type-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  font-weight: 600;
}

.q-sentence-text {
  font-family: var(--font-sans);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.5;
}

/* Transformation Input Arena */
.transformation-arena {
  margin-top: 1rem;
}

.arena-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.arena-label {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}

.arena-tip {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Smart Input Container */
.smart-input-container {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1.25rem;
  gap: 0.65rem;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.smart-input-container:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.prompt-anchor {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  user-select: none;
}

.input-trans {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 500;
  outline: none;
  width: 100%;
}

.input-trans::placeholder {
  color: var(--text-dim);
  font-weight: 400;
}

/* Card Controls Row */
.card-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.controls-left, .controls-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-action.primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.btn-action.primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-action.secondary {
  background: var(--bg-surface-elevated);
  border-color: var(--border-subtle);
  color: var(--text-main);
}
.btn-action.secondary:hover {
  border-color: var(--warning);
  color: var(--warning);
}

.btn-action.ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-action.ghost:hover {
  color: var(--text-main);
  background: var(--bg-accent-subtle);
}

.btn-nav-step {
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-nav-step:hover:not(:disabled) {
  border-color: var(--border-strong);
  color: var(--text-main);
}
.btn-nav-step:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Feedback Banner */
.feedback-banner {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  animation: slideDown 200ms ease-out;
}

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

.feedback-banner.success {
  background: var(--success-surface);
  border: 1px solid var(--success-border);
  color: var(--success);
}

.feedback-banner.error {
  background: var(--danger-surface);
  border: 1px solid var(--danger-border);
  color: var(--danger);
}

.feedback-banner.hint {
  background: var(--warning-surface);
  border: 1px solid var(--warning-border);
  color: var(--warning);
}

/* Smart Diff Box */
.diff-analysis-box {
  margin-top: 1rem;
  background: var(--bg-accent-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
}

.diff-header {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.diff-body {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.8;
  word-break: break-word;
}

.token-correct {
  color: var(--success);
  font-weight: 700;
  background: var(--success-surface);
  padding: 2px 4px;
  border-radius: 4px;
}

.token-wrong {
  color: var(--danger);
  text-decoration: line-through;
  background: var(--danger-surface);
  padding: 2px 4px;
  border-radius: 4px;
  margin-right: 4px;
}

.token-missing {
  color: var(--warning);
  font-weight: 700;
  border-bottom: 2px dashed var(--warning);
  padding: 0 3px;
}

/* Pedagogical Deep-Dive Drawer */
.pedagogy-drawer {
  margin-top: 1.5rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  animation: fadeIn 300ms ease-out;
}

.pedagogy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.ped-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--primary);
  background: var(--primary-surface);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.05em;
}

.ped-rule-name {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-main);
  margin-left: 0.65rem;
}

.pedagogy-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.ped-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
}

.ped-card.formula-card {
  grid-column: span 2;
  background: var(--primary-surface);
  border-color: rgba(99, 102, 241, 0.25);
}

.card-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.45rem;
}

.formula-card .card-tag {
  color: var(--primary);
}

.formula-code {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary);
  word-break: break-word;
}

.ped-text {
  font-size: 0.88rem;
  color: var(--text-main);
  line-height: 1.55;
}

.trap-card {
  border-color: var(--warning-border);
  background: var(--warning-surface);
}

.trap-card .card-tag {
  color: var(--warning);
}

.alt-answers-list {
  list-style: none;
}

.alt-answers-list li {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--success);
  padding: 3px 0;
  position: relative;
  padding-left: 1.1rem;
}

.alt-answers-list li::before {
  content: '✔';
  position: absolute;
  left: 0;
  color: var(--success);
}

/* --- THEMATIC GRID VIEW --- */
.thematic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.thematic-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.thematic-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.t-icon-badge {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.t-title {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.t-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1.25rem;
  flex: 1;
}

.t-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.78rem;
}

.t-count {
  font-weight: 700;
  color: var(--primary);
}

.t-arrow {
  color: var(--text-dim);
  font-weight: 700;
}

/* Filtered Thematic Questions */
.thematic-filtered-container {
  animation: fadeIn 250ms ease-out;
}

.filtered-header {
  margin-bottom: 1.5rem;
}

.f-back-btn {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  display: inline-block;
  margin-bottom: 0.5rem;
}
.f-back-btn:hover {
  text-decoration: underline;
}

.f-title {
  font-family: var(--font-sans);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
  display: inline-block;
}

.f-count {
  font-size: 1rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.thematic-cards-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.thematic-q-row {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: all var(--transition-fast);
}

.thematic-q-row:hover {
  border-color: var(--border-strong);
}

.t-row-left {
  flex: 1;
}

.t-row-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.t-row-sentence {
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.98rem;
}

.t-row-prompt {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.btn-open-practice {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--primary);
  background: var(--primary-surface);
  color: var(--primary);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.btn-open-practice:hover {
  background: var(--primary);
  color: #ffffff;
}

/* --- ARENA MOCK EXAM --- */
.arena-hero {
  text-align: center;
  max-width: 680px;
  margin: 1rem auto 2.5rem;
}

.arena-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: var(--warning-surface);
  color: var(--warning);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.arena-hero-title {
  font-family: var(--font-sans);
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.65rem;
}

.arena-hero-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.arena-modes-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.75rem;
  max-width: 820px;
  margin: 0 auto;
}

.arena-mode-card {
  background: var(--bg-surface);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.arena-mode-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}

.arena-mode-card.featured {
  border-color: var(--primary);
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--primary-surface) 100%);
}

.arena-card-badge {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

.arena-mode-card.featured .arena-card-badge {
  color: var(--primary);
}

.arena-card-num {
  font-family: var(--font-sans);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0.5rem 0 0.2rem;
}

.arena-card-time {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: 1rem;
}

.arena-card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.btn-start-arena {
  width: 100%;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-start-arena:hover {
  background: var(--text-main);
  color: var(--text-inverse);
}

.btn-start-arena.featured {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-start-arena.featured:hover {
  background: var(--primary-hover);
}

/* Active Arena Room */
.arena-top-cockpit {
  position: sticky;
  top: 72px;
  z-index: 50;
  background: var(--bg-card-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
}

.cockpit-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.arena-current-label {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-main);
}

.arena-timer-box {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--danger-surface);
  border: 1px solid var(--danger-border);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--danger);
}

.btn-submit-exam {
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--primary);
  border: none;
  color: #ffffff;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

.arena-q-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.arena-q-index {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.arena-orig-text {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-main);
  margin-bottom: 0.85rem;
}

.arena-input-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
}

.arena-input-row:focus-within {
  border-color: var(--border-focus);
}

.arena-prompt {
  font-weight: 700;
  color: var(--primary);
}

.arena-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  outline: none;
}

/* Arena Report Panel */
.arena-report-panel {
  max-width: 820px;
  margin: 0 auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.report-score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--primary-surface);
  border: 4px solid var(--primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 1rem auto 1.5rem;
}

.score-num {
  font-family: var(--font-sans);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.score-max {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* --- HANDBOOK VIEW --- */
.handbook-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.25rem;
}

.handbook-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: all var(--transition-fast);
}

.handbook-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.hb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hb-title {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.hb-formula-box {
  background: var(--primary-surface);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 600;
}

.hb-example-box {
  background: var(--bg-accent-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
}

.hb-ex-orig {
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.hb-ex-trans {
  color: var(--success);
  font-weight: 600;
}

.hb-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.hb-trap {
  font-size: 0.8rem;
  color: var(--warning);
  background: var(--warning-surface);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--warning);
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: toastIn 250ms ease-out;
  pointer-events: auto;
}

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

/* --- PRINT-FRIENDLY STYLESHEET (A4 chuẩn cho Giáo viên in đề) --- */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .app-header, .sets-selector-scroll, .card-controls-row, .header-actions, .toast-container, .view-filter-group {
    display: none !important;
  }
  .print-paper {
    display: block !important;
    padding: 1.5cm;
    font-family: 'Times New Roman', Times, serif;
    font-size: 13pt;
    line-height: 1.6;
  }
  .print-header {
    text-align: center;
    border-bottom: 2px solid #000;
    padding-bottom: 12pt;
    margin-bottom: 18pt;
  }
  .print-school {
    font-weight: bold;
    font-size: 13pt;
  }
  .print-exam-title {
    font-weight: bold;
    font-size: 15pt;
    margin: 8pt 0;
  }
  .print-meta-row {
    display: flex;
    justify-content: space-between;
    font-size: 11pt;
    font-style: italic;
  }
  .print-q-item {
    margin-bottom: 16pt;
    page-break-inside: avoid;
  }
  .print-q-orig {
    font-weight: bold;
  }
  .print-q-prompt {
    margin-top: 4pt;
    color: #333;
  }
  .print-dotted-line {
    border-bottom: 1px dotted #555;
    display: inline-block;
    width: 80%;
    margin-left: 6pt;
  }
}

/* --- Responsive Breakpoints --- */
@media (max-width: 1024px) {
  .pedagogy-grid {
    grid-template-columns: 1fr;
  }
  .ped-card.formula-card {
    grid-column: span 1;
  }
  .arena-modes-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .header-container {
    flex-wrap: wrap;
    padding: 0.65rem 1rem;
  }
  .mode-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
  }
  .solver-studio {
    padding: 1.25rem 1rem;
  }
  .q-sentence-text {
    font-size: 1.05rem;
  }
  .prompt-anchor, .input-trans {
    font-size: 0.95rem;
  }
  .card-controls-row {
    flex-direction: column;
    align-items: stretch;
  }
  .controls-left, .controls-right {
    width: 100%;
    justify-content: space-between;
  }
}
