/* ==========================================================================
   GRAMMAR SPECTRUM MASTERY PLATFORM - CORE STYLES
   ========================================================================== */

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

/* Base Layout */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  padding: 2rem 1.5rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* Glassmorphism Navigation */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: rgba(var(--bg-surface), 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  background: var(--bg-surface);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: var(--text-main);
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #10b981 0%, #38bdf8 50%, #6366f1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 800;
  font-size: 1.3rem;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-badge {
  font-size: 0.68rem;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  border: 1px solid var(--border);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
}

.nav-link:hover, .nav-link.active {
  color: var(--text-main);
  background-color: var(--bg-card-hover);
  border-color: var(--border);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* User & Role Switcher Pills */
.role-badge {
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.role-badge.student {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.role-badge.teacher {
  background: #eef2ff;
  color: #4f46e5;
  border: 1px solid #c7d2fe;
}

.role-badge.admin {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.role-selector-pill {
  display: flex;
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.2rem;
  gap: 0.2rem;
}

.role-opt-btn {
  background: transparent;
  border: none;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.role-opt-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* Theme Selector Button */
.theme-trigger-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: var(--transition);
}

.theme-trigger-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

.theme-swatch-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px var(--border);
}

/* Modals & Popovers */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  transform: translateY(20px);
  transition: transform 0.25s ease;
}

.modal-overlay.open .modal-card {
  transform: translateY(0);
}

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

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: var(--transition);
}

.modal-close-btn:hover {
  color: var(--text-main);
}

/* 16 Themes Palette Grid */
.themes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.theme-card-option {
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  position: relative;
}

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

.theme-card-option.active {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.theme-preview-dots {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.theme-preview-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.theme-opt-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.theme-opt-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Hero Section */
.hero-banner {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-hover) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2rem;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.hero-banner::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #10b981, #06b6d4, #6366f1, #f59e0b, #ef4444);
}

.hero-title {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.75rem;
  color: var(--text-main);
}

.hero-gradient-text {
  background: linear-gradient(120deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 820px;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

/* Quick Action Badges & Level Filters */
.spectrum-level-tabs {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.level-tab-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.level-tab-btn:hover {
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

.level-tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 4px 14px var(--primary-glow);
}

/* Books Overview Cards */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.book-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

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

.book-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.book-tag {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-pill);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.book-tag.spectrum-1 { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.book-tag.spectrum-2 { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.book-tag.spectrum-3 { background: #eef2ff; color: #4f46e5; border: 1px solid #c7d2fe; }

.book-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.book-author {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

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

/* Voice Teacher Player Component */
.voice-teacher-bar {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-surface) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.25rem 1.75rem;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow-md);
  border-left: 5px solid var(--primary);
}

.voice-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.voice-avatar-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  position: relative;
}

.voice-avatar-icon.speaking {
  animation: pulse-ring 1.6s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 var(--primary-glow); }
  70% { box-shadow: 0 0 0 14px rgba(0,0,0,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); }
}

.voice-text-label h4 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.voice-text-label p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.voice-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.voice-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: var(--transition);
}

.voice-btn.play {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.voice-btn:hover {
  transform: scale(1.03);
}

.voice-speed-group {
  display: flex;
  align-items: center;
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.2rem;
}

.speed-chip {
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.speed-chip.active {
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

/* Lesson Content & Rule Cards */
.lesson-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2.25rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.lesson-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
}

.lesson-badge-category {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-pill);
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.lesson-title {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.grammar-rule-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin: 1.5rem 0;
}

.grammar-rule-box h4 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.structure-badge {
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  padding: 0.85rem 1.25rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-main);
  margin: 1rem 0;
  font-weight: 600;
}

.rule-list {
  padding-left: 1.25rem;
  margin-top: 0.75rem;
  color: var(--text-main);
}

.rule-list li {
  margin-bottom: 0.6rem;
}

/* Grammar Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  margin: 1rem 0;
}

.grammar-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.grammar-table th {
  background: var(--bg-card-hover);
  color: var(--text-main);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.grammar-table td {
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
}

.grammar-table tr:last-child td {
  border-bottom: none;
}

/* Visual Illustration & Timeline Diagrams */
.visual-diagram-card {
  background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-card-hover) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  margin: 2rem 0;
  box-shadow: var(--shadow-sm);
}

.diagram-header {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.timeline-canvas-container {
  padding: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

/* Interactive Practice Exercise Cards */
.practice-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  margin-top: 2rem;
}

.practice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.practice-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-main);
}

.exercise-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: var(--transition);
}

.exercise-item:hover {
  border-color: var(--border-focus);
}

.exercise-prompt {
  font-size: 0.98rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-main);
}

.input-gap-field {
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 0.92rem;
  font-family: inherit;
  transition: var(--transition);
  min-width: 180px;
}

.input-gap-field:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.input-gap-field.correct {
  border-color: var(--success);
  background: var(--success-light);
}

.input-gap-field.incorrect {
  border-color: var(--danger);
  background: var(--danger-light);
}

/* Multiple Choice Questions (Deep Thinking 100+ Bank) */
.deep-quiz-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.question-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.question-card.active-q {
  border-color: var(--primary);
  box-shadow: var(--shadow-card);
}

.question-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.question-q-text {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.mcq-options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.mcq-option-btn {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.95rem 1.25rem;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.94rem;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}

.mcq-option-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

.mcq-option-btn.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}

.mcq-option-btn.is-correct {
  border-color: var(--success);
  background: var(--success-light);
  color: #065f46;
}

.mcq-option-btn.is-wrong {
  border-color: var(--danger);
  background: var(--danger-light);
  color: #991b1b;
}

.option-letter-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  background: var(--bg-card);
  flex-shrink: 0;
}

.reason-callout {
  margin-top: 1.25rem;
  padding: 1.15rem 1.4rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.5;
  display: none;
}

.reason-callout.show {
  display: block;
}

.reason-callout-title {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Submission Action Toolbar */
.submission-toolbar {
  position: sticky;
  bottom: 1.5rem;
  z-index: 100;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1rem 1.75rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 2rem;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.75rem 1.6rem;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: #ffffff;
  border: none;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--primary-glow);
  transition: var(--transition);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  color: var(--text-main);
  border: 1.5px solid var(--border);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-pill);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
  transition: var(--transition);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-pill);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.25);
  transition: var(--transition);
}

/* Teacher Grading Review Suite */
.grading-panel {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.75rem;
}

@media (max-width: 1024px) {
  .grading-panel {
    grid-template-columns: 1fr;
  }
}

.grading-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  margin-bottom: 1.25rem;
}

.comparison-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1rem 0;
}

.answer-pill-box {
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-surface);
}

.answer-pill-box.student {
  border-left: 4px solid var(--primary);
}

.answer-pill-box.key {
  border-left: 4px solid var(--success);
  background: var(--success-light);
}

.score-display-card {
  background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-card-hover) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  text-align: center;
  position: sticky;
  top: 90px;
}

.score-large-number {
  font-size: 3.5rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
  margin: 1rem 0 0.5rem;
}

/* Admin Pairing & Approval Matrices */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.stat-icon-wrapper {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  flex-shrink: 0;
}

.stat-val {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.approval-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  transition: var(--transition);
}

.approval-user-row:hover {
  background: var(--bg-card-hover);
}

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

.avatar-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
}

/* Feedback & Gradebook Report Card */
.grade-report-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

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

.wrong-point-item {
  background: var(--danger-light);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.wrong-point-header {
  font-weight: 700;
  color: #b91c1c;
  margin-bottom: 0.4rem;
}

.teacher-annotation {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px dashed rgba(239, 68, 68, 0.3);
  font-size: 0.88rem;
  color: var(--text-main);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.4rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-main);
  font-size: 0.92rem;
  font-weight: 600;
  animation: slide-in 0.3s ease;
}

@keyframes slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   MOBILE & DESKTOP RESPONSIVE DESIGN SYSTEM
   ========================================================================== */

/* Mobile Hamburger Toggle */
.mobile-menu-btn {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: var(--radius-md);
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  cursor: pointer;
  transition: var(--transition);
}

.mobile-menu-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

/* Mobile Drawer (Off-Canvas Menu) */
.mobile-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.mobile-drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 82%;
  max-width: 320px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  z-index: 2600;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.mobile-drawer-overlay.open .mobile-drawer {
  transform: translateX(0);
}

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

.drawer-links-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.drawer-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-main);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.drawer-link:hover, .drawer-link.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--border);
}

/* Mobile Bottom Navigation Bar */
.mobile-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  z-index: 1500;
  padding: 0 0.5rem;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  justify-content: space-around;
  align-items: center;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
}

.mobile-bar-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  flex: 1;
  height: 100%;
  color: var(--text-muted);
  background: transparent;
  border: none;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.mobile-bar-tab i {
  font-size: 1.15rem;
}

.mobile-bar-tab.active {
  color: var(--primary);
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
  .navbar {
    padding: 0.75rem 1.25rem;
  }
  .role-selector-pill {
    display: none; /* Accessible in mobile drawer */
  }
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
  }
  .nav-links {
    display: none;
  }
  .mobile-bottom-bar {
    display: flex;
  }
  .main-content {
    padding: 1.25rem 1rem 80px 1rem; /* Extra padding for bottom bar */
  }
  .hero-banner {
    padding: 1.75rem 1.25rem;
    border-radius: var(--radius-lg);
  }
  .hero-title {
    font-size: 1.55rem;
    line-height: 1.3;
  }
  .hero-subtitle {
    font-size: 0.92rem;
  }
  .spectrum-level-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
    gap: 0.5rem;
  }
  .level-tab-btn {
    white-space: nowrap;
    padding: 0.6rem 1rem;
    font-size: 0.84rem;
    flex-shrink: 0;
  }
  .books-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  .lesson-card {
    padding: 1.35rem 1.15rem;
    border-radius: var(--radius-lg);
  }
  .lesson-title {
    font-size: 1.4rem;
  }
  .voice-teacher-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 1.25rem;
    gap: 1rem;
  }
  .voice-controls {
    justify-content: space-between;
    width: 100%;
  }
  .voice-btn.play {
    flex: 1;
    justify-content: center;
  }
  .practice-section {
    padding: 1.25rem 1rem;
    border-radius: var(--radius-lg);
  }
  .practice-header {
    flex-direction: column;
    align-items: stretch;
  }
  .practice-header > div:last-child {
    display: flex;
    flex-direction: column;
    width: 100%;
  }
  .practice-header button {
    width: 100%;
    justify-content: center;
  }
  .input-gap-field {
    min-width: 140px;
    font-size: 16px !important; /* Prevents auto-zoom in mobile Safari */
  }
  .mcq-option-btn {
    padding: 0.85rem 1rem;
    font-size: 0.9rem;
  }
  .comparison-box {
    grid-template-columns: 1fr;
  }
  .score-display-card {
    position: static;
    margin-top: 1.5rem;
  }
  .submission-toolbar {
    bottom: 72px; /* Floats directly above bottom bar */
    padding: 0.85rem 1.15rem;
    flex-direction: column;
    align-items: stretch;
    border-radius: var(--radius-lg);
  }
  .submission-toolbar > div {
    display: flex;
    justify-content: space-between;
    width: 100%;
  }
  .submission-toolbar button {
    flex: 1;
    justify-content: center;
  }
  .modal-card {
    padding: 1.25rem;
    max-width: 95%;
    max-height: 85vh;
  }
  .themes-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  .theme-card-option {
    padding: 0.75rem;
  }
  .theme-opt-title {
    font-size: 0.85rem;
  }
  .theme-opt-desc {
    display: none; /* Keep clean and compact on phone */
  }
}

@media (max-width: 480px) {
  .brand-title span:first-child {
    font-size: 1.05rem;
  }
  .brand-badge {
    display: none;
  }
  .theme-trigger-btn span:nth-child(2) {
    display: none; /* Show swatch and icon only */
  }
  #currentUserBadge {
    display: none; /* Relocated into mobile drawer */
  }
  .navbar {
    padding: 0.65rem 0.85rem;
  }
  .hero-title {
    font-size: 1.35rem;
  }
  .themes-grid {
    grid-template-columns: 1fr;
  }
}
