/* ==========================================================================
   CSS SYSTEM - AZTEST PLATFORM
   Built with premium CSS features: Custom variables, Backdrop filter, 
   Grid/Flex layouts, Keyframes, Custom UI controls, and Dark/Light Modes
   ========================================================================== */

:root {
  /* Dark Mode Palette (Default) */
  --bg-primary: #0b0f19;
  --bg-secondary: rgba(17, 24, 39, 0.7);
  --bg-tertiary: rgba(31, 41, 55, 0.5);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --primary: #7c3aed; /* Violet */
  --primary-light: #a78bfa;
  --primary-dark: #5b21b6;
  --primary-glow: rgba(124, 58, 237, 0.15);
  
  --accent: #06b6d4; /* Cyan */
  --accent-glow: rgba(6, 182, 212, 0.15);
  
  --success: #10b981; /* Green */
  --success-glow: rgba(16, 185, 129, 0.15);
  
  --warning: #f59e0b; /* Orange */
  --warning-glow: rgba(245, 158, 11, 0.15);
  
  --danger: #ef4444; /* Red */
  --danger-glow: rgba(239, 68, 68, 0.15);
  
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-reflection: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0) 100%);
  --shadow-lg: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-primary: 0 0 25px rgba(124, 58, 237, 0.35);
  
  --font-family: 'Be Vietnam Pro', Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --border-radius-sm: 8px;
  --border-radius-md: 16px;
  --border-radius-lg: 24px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Mode Variables Override */
.light-theme {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff; /* Solid white card for high contrast, no fog! */
  --bg-tertiary: #f1f5f9;
  
  --text-primary: #020617; /* Very dark slate for sharp text */
  --text-secondary: #1e293b; /* Extremely readable dark slate */
  --text-muted: #475569; /* Sharp muted slate */
  
  --primary: #4f46e5; /* Deeper Indigo for light mode */
  --primary-light: #6366f1;
  --primary-dark: #3730a3;
  --primary-glow: rgba(79, 70, 229, 0.08);
  
  --accent: #0284c7; /* Deeper Sky Blue */
  --accent-glow: rgba(2, 132, 199, 0.08);
  
  --success: #059669; /* Deeper Green */
  --success-glow: rgba(5, 150, 105, 0.08);
  
  --warning: #d97706;
  --warning-glow: rgba(217, 119, 6, 0.08);
  
  --danger: #dc2626;
  --danger-glow: rgba(220, 38, 38, 0.08);
  
  --glass-border: rgba(15, 23, 42, 0.12);
  --glass-reflection: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.02) 100%); /* Minimal reflection to keep text 100% sharp! */
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.05), 0 8px 16px -6px rgba(15, 23, 42, 0.03);
  --shadow-primary: 0 4px 20px rgba(79, 70, 229, 0.15);
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

/* Glowing Ambient Orbs for BG (Dark Mode only) */
.ambient-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -2;
  overflow: hidden;
  pointer-events: none;
  display: block;
}

.light-theme .ambient-bg {
  display: none; /* Hide dark ambient orbs in light theme */
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.15;
  animation: float 20s infinite alternate ease-in-out;
}

.orb-1 {
  top: -10%;
  left: 10%;
  width: 40vw;
  height: 40vw;
  background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
}

.orb-2 {
  bottom: -10%;
  right: 10%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  animation-delay: -5s;
}

.orb-3 {
  top: 40%;
  left: 50%;
  width: 30vw;
  height: 30vw;
  background: radial-gradient(circle, var(--danger) 0%, transparent 70%);
  animation-delay: -10s;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(50px, 30px) scale(1.1); }
  100% { transform: translate(-30px, -50px) scale(0.9); }
}

/* ==========================================================================
   SCROLLBAR & LAYOUT UTILITIES
   ========================================================================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.glass-card {
  background: var(--bg-secondary);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.glass-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--glass-reflection);
  pointer-events: none;
  z-index: 1;
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   NAVIGATION BAR
   ========================================================================== */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 15, 25, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  transition: var(--transition-smooth);
}

.light-theme header {
  background: rgba(248, 250, 252, 0.8);
}

.nav-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 1cm;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-decoration: none;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 20px;
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4);
}

.logo-text {
  font-size: 24px;
  font-weight: 800;
  background: linear-gradient(to right, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.5px;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--border-radius-sm);
  transition: var(--transition-smooth);
  cursor: pointer;
}

.nav-link:hover, .nav-link.active {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.nav-link.active {
  border-bottom: 2px solid var(--primary);
  border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.theme-toggle-btn:hover {
  background: var(--glass-border);
  transform: rotate(15deg);
}

.modal-close-btn {
  align-items: center;
  background: rgba(15, 23, 42, 0.88);
  border-color: rgba(148, 163, 184, 0.28);
  color: var(--text-primary);
  display: flex !important;
  height: 34px;
  justify-content: center;
  position: absolute;
  right: 14px;
  top: 14px;
  width: 34px;
  z-index: 20;
}

#auth-modal .auth-tabs {
  padding-right: 42px;
}

.coin-balance-pill {
  min-height: 36px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(6, 182, 212, 0.28);
  background: rgba(6, 182, 212, 0.08);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.account-profile-editor {
  display: grid;
  gap: 14px;
  max-width: 920px;
}

.account-profile-editor .profile-editor-grid {
  display: grid;
  grid-template-columns: minmax(260px, 300px) minmax(380px, 1fr);
  gap: 26px;
  align-items: start;
}

.account-profile-fields {
  display: grid;
  gap: 14px;
}

.account-avatar-panel {
  margin: 0;
}

.account-profile-static {
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  padding: 10px 12px;
  color: var(--text-primary);
  font-weight: 600;
}

.account-avatar-editor {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 16px;
  align-items: center;
}

.account-avatar-preview {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(6, 182, 212, 0.35);
  background: rgba(6, 182, 212, 0.08);
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.account-avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.account-avatar-preset-grid {
  grid-column: 2;
  display: grid;
  grid-template-columns: repeat(4, 42px);
  gap: 10px;
  justify-content: start;
}

.account-avatar-preset-btn {
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  width: 42px;
  height: 42px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
}

.account-avatar-preset-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.account-avatar-preset-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.18);
}

.account-avatar-dropzone {
  grid-column: 1 / -1;
  border: 1px dashed var(--glass-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 112px;
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
}

.account-avatar-dropzone.dragover {
  border-color: var(--accent);
  background: rgba(6, 182, 212, 0.1);
}

.account-avatar-dropzone ion-icon {
  font-size: 20px;
  color: var(--accent);
}

.account-avatar-dropzone span {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.account-avatar-dropzone small {
  font-size: 10px;
  color: var(--text-muted);
}

.account-avatar-upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(6, 182, 212, 0.25);
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

#account-avatar-file {
  display: none;
}

.coin-topup-card {
  border-color: rgba(6, 182, 212, 0.28);
  background:
    radial-gradient(circle at 80% 18%, rgba(6, 182, 212, 0.14), transparent 34%),
    rgba(6, 182, 212, 0.035);
}

.coin-topup-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: stretch;
}

@media (max-width: 640px) {
  .coin-balance-pill {
    min-height: 32px;
    padding: 0 9px;
    font-size: 11px;
  }

  .account-profile-editor .profile-editor-grid,
  .coin-topup-controls {
    grid-template-columns: 1fr;
  }

  .account-avatar-editor {
    grid-template-columns: 1fr;
  }

  .account-avatar-preview {
    margin: 0 auto;
  }

  .account-avatar-preset-grid {
    grid-column: 1;
    grid-template-columns: repeat(4, 42px);
    justify-content: center;
  }
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--border-radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: 1px solid transparent;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
}

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

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--glass-border);
}

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

.btn-accent {
  background: linear-gradient(135deg, var(--accent) 0%, #0891b2 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}

.btn-accent:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.5);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #b91c1c 100%);
  color: white;
}

.btn-danger:hover {
  transform: translateY(-2px);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* ==========================================================================
   PAGES / VIEWS (SPA ROUTER MECHANISM)
   ========================================================================== */
.app-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 1cm;
  min-height: calc(100vh - 73px);
}

.view-section {
  display: none; /* Controlled by JS Router */
  animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.view-section.active {
  display: block;
}

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

/* ==========================================================================
   VIEW 1: LANDING PAGE
   ========================================================================== */
.hero-section {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 48px;
  align-items: center;
  margin-bottom: 80px;
}

@media (max-width: 968px) {
  .hero-section {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 32px;
  }
  .hero-buttons {
    justify-content: center;
  }
}

.hero-title {
  font-size: 54px;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 24px;
}

.hero-title span {
  background: linear-gradient(to right, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 36px;
  max-width: 600px;
}

.hero-buttons {
  display: flex;
  gap: 16px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-glow);
  border: 1px solid rgba(124, 58, 237, 0.3);
  padding: 6px 16px;
  border-radius: 100px;
  color: var(--primary-light);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 20px;
}

/* Landing Graphic */
.landing-graphic {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.graphic-circle {
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
  position: absolute;
  z-index: -1;
  opacity: 0.3;
  animation: pulse 4s infinite alternate;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.2; }
  100% { transform: scale(1.1); opacity: 0.4; }
}

.landing-card {
  width: 100%;
  max-width: 360px;
  transform: rotate(-3deg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  animation: cardFloat 6s infinite alternate ease-in-out;
}

.landing-card-2 {
  position: absolute;
  right: -20px;
  bottom: -20px;
  width: 80%;
  transform: rotate(6deg);
  background: rgba(6, 182, 212, 0.1);
  border-color: rgba(6, 182, 212, 0.3);
  z-index: 2;
  animation: cardFloat 6s infinite alternate-reverse ease-in-out;
}

@keyframes cardFloat {
  0% { transform: translateY(0) rotate(-3deg); }
  100% { transform: translateY(-15px) rotate(-1deg); }
}

/* Feature Grid */
.landing-features-title {
  text-align: center;
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 48px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 80px;
}

.feature-card {
  padding: 32px;
  border-radius: var(--border-radius-md);
  text-align: left;
}

.feature-icon-wrapper {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  font-size: 24px;
}

.feat-1 {
  background: var(--primary-glow);
  color: var(--primary-light);
  border: 1px solid rgba(124, 58, 237, 0.2);
}

.feat-2 {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(6, 182, 212, 0.2);
}

.feat-3 {
  background: var(--success-glow);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.feature-card h3 {
  font-size: 20px;
  margin-bottom: 12px;
}

.feature-card p {
  color: var(--text-secondary);
  font-size: 15px;
}

/* Statistics Bar */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  text-align: center;
  margin-bottom: 80px;
}

@media (max-width: 768px) {
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat-num {
  font-size: 40px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ==========================================================================
   VIEW 2: TEACHER DASHBOARD
   ========================================================================== */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.dashboard-title h1 {
  font-size: 32px;
  font-weight: 800;
}

.dashboard-title p {
  color: var(--text-secondary);
}

/* Tabs */
.tab-container {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 12px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px 16px;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  border-radius: var(--border-radius-sm);
  transition: var(--transition-smooth);
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.tab-btn.active {
  color: var(--primary-light);
  background: var(--primary-glow);
  border: 1px solid rgba(124, 58, 237, 0.2);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Grid of Quizzes */
.quizzes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
  max-width: 1080px;
}

.quiz-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.quiz-subject-badge {
  position: absolute;
  top: 24px;
  right: 24px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-math { background: var(--primary-glow); color: var(--primary-light); border: 1px solid rgba(124, 58, 237, 0.3); }
.badge-english { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(6, 182, 212, 0.3); }
.badge-physics { background: var(--warning-glow); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-chemistry { background: var(--success-glow); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-general { background: var(--bg-tertiary); color: var(--text-secondary); }

.quiz-card h3 {
  font-size: 20px;
  margin-top: 10px;
  margin-bottom: 12px;
  padding-right: 80px; /* Leave space for badge */
  line-height: 1.4;
}

.quiz-card p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
  flex-grow: 1;
}

.quiz-meta-info {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  border-top: 1px solid var(--glass-border);
  padding-top: 16px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.quiz-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.quiz-actions {
  display: flex;
  gap: 10px;
}

/* ==========================================================================
   VIEW 3: CREATE / EDIT QUIZ & IMPORT
   ========================================================================== */
.create-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

@media (max-width: 968px) {
  .create-grid {
    grid-template-columns: 1fr;
  }
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.form-control {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 15px;
  transition: var(--transition-smooth);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(124, 58, 237, 0.2);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Advanced Switch Panel */
.switch-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--glass-border);
  margin-bottom: 16px;
}

.switch-label-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

.switch-btn {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.switch-btn input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-primary);
  transition: .3s;
  border-radius: 24px;
  border: 1px solid var(--glass-border);
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-muted);
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(24px);
  background-color: white;
}

/* Interactive Text Parser Module */
.parser-area {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.raw-textarea {
  min-height: 250px;
  font-family: monospace;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  background: #090c15;
}

.parser-instructions {
  background: var(--bg-tertiary);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.parser-preview-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  margin-bottom: 12px;
}

.parser-preview-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid var(--glass-border);
  padding: 16px;
  border-radius: var(--border-radius-sm);
  background: rgba(0, 0, 0, 0.2);
}

.preview-question-card {
  padding: 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
}

.preview-question-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
}

.preview-options {
  font-size: 13px;
  color: var(--text-secondary);
  padding-left: 12px;
}

.preview-meta {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  font-size: 11px;
}

.preview-meta-correct { color: var(--success); font-weight: 700; }
.preview-meta-level { color: var(--accent); }

/* ==========================================================================
   VIEW 4: EXAM TAKING ARENA (Vùng làm bài thi)
   ========================================================================== */
.arena-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 32px;
}

@media (max-width: 968px) {
  .arena-layout {
    grid-template-columns: 1fr;
  }
  .arena-sidebar {
    order: -1; /* Sidebar with countdown and questions on top on mobile */
  }
}

.arena-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--glass-border);
}

/* Exam Main Content */
.question-view-wrapper {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.arena-question-card {
  padding: 32px;
  position: relative;
}

.q-number-badge {
  position: absolute;
  top: 24px;
  left: 24px;
  background: var(--primary);
  color: white;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
}

.q-level-label {
  position: absolute;
  top: 24px;
  right: 24px;
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.q-text-content {
  font-size: 18px;
  font-weight: 500;
  margin-top: 24px;
  margin-bottom: 24px;
}

.rich-text-input {
  min-height: 64px;
  height: auto;
  overflow: auto;
  white-space: normal;
  line-height: 1.55;
  outline: none;
}

.rich-text-input.rich-text-input-tall {
  min-height: 116px;
  max-height: 220px;
}

.rich-text-input:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

.rich-text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.12);
}

.rich-text-input b,
.rich-text-input strong {
  font-weight: 800;
}

.rich-text-input u {
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.manual-editor-toolbar-card {
  position: sticky;
  top: 12px;
  z-index: 80;
}

.manual-format-toolbar {
  user-select: none;
}

.manual-format-toolbar:not(.is-floating) {
  display: none !important;
}

.manual-format-toolbar.is-floating {
  position: fixed !important;
  display: flex !important;
  z-index: 9999;
  max-width: min(560px, calc(100vw - 16px));
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(18px);
  opacity: 1 !important;
  pointer-events: auto !important;
}

.manual-format-drag-handle {
  cursor: grab;
}

.manual-format-drag-handle:active {
  cursor: grabbing;
}

.rich-color-select,
.rich-color-select:focus {
  background: rgba(15, 23, 42, 0.96) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--glass-border) !important;
  border-radius: 8px !important;
  box-shadow: none !important;
}

.rich-color-select option {
  background: #111827;
  color: #f8fafc;
}

.quiz-option-editor-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quiz-option-editor-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 7px;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.018);
}

.quiz-option-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: rgba(6, 182, 212, 0.13);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.quiz-option-editor-row .form-control {
  margin: 0;
  padding: 6px 8px;
  font-size: 11px;
  min-width: 0;
}

.option-image-picker {
  display: grid;
  grid-template-columns: minmax(44px, 1fr) 30px;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.option-image-btn,
.option-image-clear {
  height: 34px;
  border: 1px solid var(--glass-border);
  background: rgba(15, 23, 42, 0.48);
  color: var(--text-secondary);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 800 11px var(--font-family);
  cursor: pointer;
  transition: var(--transition-fast);
}

.option-image-btn ion-icon {
  font-size: 17px;
}

.option-image-btn:hover,
.option-image-picker.has-image .option-image-btn {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(6, 182, 212, 0.1);
}

.option-image-clear {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.28);
}

.option-image-preview {
  grid-column: 1 / -1;
  width: 100%;
  max-height: 82px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid rgba(6, 182, 212, 0.22);
  background: rgba(255, 255, 255, 0.04);
  padding: 4px;
}

.rich-editor-field {
  position: relative;
  min-width: 0;
  width: 100%;
}

.rich-editor-toggle {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  border: 1px solid rgba(6, 182, 212, 0.24);
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent);
  border-radius: 7px;
  padding: 3px 7px;
  font: 800 10px var(--font-family);
  cursor: pointer;
}

.rich-editor-field .rich-text-input {
  padding-right: 60px;
}

.quiz-option-rich-editor .rich-text-input {
  min-height: 36px;
  line-height: 1.35;
  padding-top: 7px;
  padding-bottom: 7px;
  font-size: 11px;
}

.rt-bold {
  font-weight: 800;
}

.rt-underline {
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.rt-italic {
  font-style: italic;
}

@media (max-width: 720px) {
  .manual-editor-toolbar-card {
    top: 8px;
  }

  .manual-format-toolbar {
    width: 100%;
  }

  .manual-format-toolbar > span {
    display: none !important;
  }

  .quiz-option-editor-row {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .quiz-option-editor-row .option-image-picker {
    grid-column: 2;
  }
}

/* Radio Choice styling */
.choices-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.choice-item {
  position: relative;
  display: flex;
  align-items: center;
  padding: 16px 20px 16px 54px;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-size: 15px;
  transition: var(--transition-smooth);
}

.choice-item:hover {
  background: var(--glass-border);
  border-color: rgba(255, 255, 255, 0.2);
}

.choice-item.selected {
  background: var(--primary-glow);
  border-color: var(--primary-light);
}

.choice-input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.choice-marker {
  position: absolute;
  top: 50%;
  left: 20px;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  background-color: var(--bg-primary);
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  color: var(--text-muted);
  transition: var(--transition-smooth);
}

.choice-item:hover .choice-marker {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

.choice-item.selected .choice-marker {
  border-color: var(--primary-light);
  background-color: var(--primary);
  color: white;
}

/* Flag question button */
.flag-btn {
  margin-top: 16px;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  background: none;
  border: none;
  transition: var(--transition-smooth);
}

.flag-btn.flagged {
  color: var(--warning);
}

/* Arena Sidebar with Countdown & Palette */
.arena-sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Countdown Panel */
.timer-panel {
  text-align: center;
  padding: 24px;
}

.timer-label {
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.timer-countdown {
  font-size: 36px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
  margin-bottom: 16px;
}

.timer-countdown.danger {
  background: var(--danger);
  -webkit-text-fill-color: var(--danger);
  animation: alarmPulse 1s infinite alternate;
}

@keyframes alarmPulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.05); }
}

.timer-bar-bg {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  overflow: hidden;
}

.timer-bar-fill {
  height: 100%;
  background: linear-gradient(to right, var(--accent), var(--primary));
  width: 100%;
  transition: width 1s linear;
}

/* Question Palette Grid */
.palette-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.palette-item {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.palette-item:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

.palette-item.current {
  border-color: var(--primary-light);
  box-shadow: 0 0 10px var(--primary-glow);
}

.palette-item.answered {
  background: var(--success-glow);
  border-color: var(--success);
  color: var(--success);
}

.palette-item.flagged {
  border-color: var(--warning);
  background: var(--warning-glow);
  color: var(--warning);
  position: relative;
}

.palette-item.flagged::after {
  content: '🚩';
  position: absolute;
  top: -6px;
  right: -4px;
  font-size: 8px;
}

/* Legend */
.palette-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  font-size: 11px;
  color: var(--text-secondary);
  border-top: 1px solid var(--glass-border);
  padding-top: 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
}

.dot-unanswered { background: var(--bg-tertiary); border: 1px solid var(--glass-border); }
.dot-answered { background: var(--success-glow); border: 1px solid var(--success); }
.dot-flagged { background: var(--warning-glow); border: 1px solid var(--warning); }
.dot-current { background: var(--bg-tertiary); border: 2px solid var(--primary-light); }

/* Navigation buttons (Prev/Next) */
.arena-nav-btns {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
}

/* ==========================================================================
   VIEW 5: SCORE & DETAILED EXAM REVIEW (Chấm điểm + Lời giải)
   ========================================================================== */
.results-layout {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.results-header-card {
  text-align: center;
  padding: 48px;
}

/* CSS radial circle for score */
.score-circle-wrapper {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto 24px;
}

.score-circle-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-circle-bg {
  fill: none;
  stroke: var(--bg-tertiary);
  stroke-width: 12;
}

.score-circle-fill {
  fill: none;
  stroke: url(#scoreGradient);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 502; /* 2 * PI * R (R=80) */
  stroke-dashoffset: 502;
  transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.score-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.score-number {
  font-size: 48px;
  font-weight: 800;
  line-height: 1;
}

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

.result-verdict {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
}

.result-advice {
  color: var(--text-secondary);
  font-size: 15px;
  max-width: 500px;
  margin: 0 auto 24px;
}

/* Results grid stats */
.result-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.result-stat-box {
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--glass-border);
}

.result-stat-val {
  font-size: 22px;
  font-weight: 700;
}

.result-stat-val.val-success { color: var(--success); }
.result-stat-val.val-danger { color: var(--danger); }
.result-stat-val.val-warning { color: var(--warning); }

.result-stat-lbl {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Reviewing choices */
.review-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.review-question-card {
  padding: 24px;
}

.review-question-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.review-q-text {
  font-size: 16px;
  font-weight: 600;
}

.review-status-badge {
  flex-shrink: 0;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
}

.badge-correct { background: var(--success-glow); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-incorrect { background: var(--danger-glow); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-unanswered { background: var(--bg-tertiary); color: var(--text-muted); border: 1px solid var(--glass-border); }

/* Review option boxes */
.review-choice {
  padding: 12px 16px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--bg-tertiary);
  margin-bottom: 8px;
  font-size: 14px;
  position: relative;
}

.review-choice.correct {
  background: var(--success-glow);
  border-color: var(--success);
  color: var(--text-primary);
}

.review-choice.incorrect {
  background: var(--danger-glow);
  border-color: var(--danger);
  color: var(--text-primary);
}

.review-choice::after {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 800;
}

.review-choice.correct::after { content: '✓'; color: var(--success); }
.review-choice.incorrect::after { content: '✗'; color: var(--danger); }

/* Explanation Box */
.explanation-box {
  margin-top: 16px;
  padding: 16px;
  background: rgba(6, 182, 212, 0.05);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
  font-size: 14px;
}

.explanation-title {
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.explanation-text {
  color: var(--text-secondary);
}

/* ==========================================================================
   VIEW 6: HISTORY & ANALYTICS CHARTS (Lịch sử & Biểu đồ)
   ========================================================================== */
.history-layout {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 32px;
}

@media (max-width: 968px) {
  .history-layout {
    grid-template-columns: 1fr;
  }
}

/* History table */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  background: var(--bg-secondary);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.data-table th {
  background: rgba(0, 0, 0, 0.2);
  padding: 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--glass-border);
  color: var(--text-primary);
}

.data-table td {
  padding: 16px;
  border-bottom: 1px solid var(--glass-border);
  color: var(--text-secondary);
}

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

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Custom pure CSS bar chart */
.chart-panel {
  padding: 24px;
}

.chart-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 24px;
}

.bar-chart-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chart-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chart-bar-lbl {
  width: 110px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-bar-bg {
  flex-grow: 1;
  height: 16px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  background: linear-gradient(to right, var(--primary), var(--accent));
  border-radius: 4px;
  width: 0; /* Animated dynamically with JS */
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.chart-bar-val {
  width: 40px;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Empty State Styling */
.empty-state {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

/* ==========================================================================
   VIEW 7: CLASSROOM MANAGEMENT (Quản lý Học sinh)
   ========================================================================== */
.class-mgmt-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.search-wrapper {
  position: relative;
  flex-grow: 1;
  max-width: 400px;
}

.search-input {
  width: 100%;
  padding-left: 40px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.table-student-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-glow);
  border: 1px solid var(--primary-light);
  color: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

/* ==========================================================================
   ALERT MESSAGE BOXES (Notification popup)
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 88px;
  right: 24px;
  bottom: auto;
  z-index: 5000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  padding: 16px 24px;
  border-radius: var(--border-radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
  pointer-events: auto;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-danger { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info { border-left: 4px solid var(--accent); }

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

/* Password Modal Popup */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: none; /* Controlled by JS */
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  width: 100%;
  max-width: 400px;
  animation: modalIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

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

/* ==========================================================================
   ADVANCED ENGLISH EXAM LAYOUTS & AUTHENTICATION STYLES
   ========================================================================== */

/* Auth modal & tabs */
.auth-tabs {
  display: flex;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--glass-border);
}

.auth-tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 10px;
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition-smooth);
}

.auth-tab-btn.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary);
}

/* Google Sign-in button */
.google-btn-wrapper {
  margin-top: 16px;
  border-top: 1px solid var(--glass-border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  background: white;
  color: #1f2937;
  border: 1px solid #d1d5db;
  border-radius: var(--border-radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.google-btn:hover {
  background: #f9fafb;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.google-btn img {
  width: 18px;
  height: 18px;
}

#header-user-badge-container {
  position: relative;
}

/* Auth Header User Badge */
.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: 100px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.user-profile-badge:hover {
  background: var(--glass-border);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  object-fit: cover;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* 1. English Split-Screen Reading Layout */
.split-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  height: 600px;
  margin-top: 16px;
}

@media (max-width: 968px) {
  .split-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
}

.reading-passage {
  background: rgba(0,0,0,0.15);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  padding: 24px;
  overflow-y: auto;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-primary);
  text-align: justify;
}

.questions-side-scroll {
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  padding-right: 4px;
}

/* 2. English Cloze Test Inline Selector */
.cloze-passage {
  font-size: 16px;
  line-height: 2.2;
  color: var(--text-primary);
  text-align: justify;
  background: rgba(255, 255, 255, 0.01);
  padding: 20px;
  border-radius: var(--border-radius-sm);
  border: 1px dashed var(--glass-border);
}

.cloze-select {
  display: inline-block;
  background: var(--bg-primary);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  color: var(--primary-light);
  padding: 2px 8px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  outline: none;
  transition: var(--transition-smooth);
  margin: 0 4px;
}

.cloze-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 5px var(--primary-glow);
}

.cloze-select.answered {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-glow);
}

/* 3. English Error Identification Underlines */
.error-sentence {
  font-size: 18px;
  line-height: 2;
  color: var(--text-primary);
  margin: 20px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.error-word {
  display: inline-block;
  border-bottom: 2px dashed var(--text-muted);
  padding: 0 4px;
  cursor: pointer;
  transition: var(--transition-smooth);
  font-weight: 600;
}

.error-word:hover {
  border-bottom-style: solid;
  border-bottom-color: var(--text-primary);
  background: var(--bg-tertiary);
}

.error-word.selected {
  border-bottom-style: solid;
  border-bottom-color: var(--primary-light);
  background: var(--primary-glow);
  color: var(--primary-light);
}

.error-word.correct {
  border-bottom-style: solid;
  border-bottom-color: var(--success);
  background: var(--success-glow);
  color: var(--success);
}

.error-word.incorrect {
  border-bottom-style: solid;
  border-bottom-color: var(--danger);
  background: var(--danger-glow);
  color: var(--danger);
}

.error-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
  vertical-align: super;
  margin-left: 2px;
}

/* ==========================================================================
   PREMIUM LEADERBOARD & PODIUM STYLES
   ========================================================================== */
.leaderboard-container {
  display: flex;
  flex-direction: column;
  gap: 32px;
  max-width: 800px;
  margin: 0 auto;
}

.podium-wrapper {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 16px;
  padding: 24px 0;
  margin-bottom: 16px;
}

.podium-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  transition: var(--transition-smooth);
}

.podium-step:hover {
  transform: translateY(-5px);
}

.podium-column {
  width: 120px;
  border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  font-weight: 800;
  font-size: 24px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,0.1);
  position: relative;
  overflow: hidden;
}

.podium-column::before {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: var(--glass-reflection);
}

/* 1st Place - Gold */
.podium-step.first .podium-column {
  height: 160px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border-color: rgba(245, 158, 11, 0.4);
  box-shadow: 0 0 25px rgba(245, 158, 11, 0.35);
}

/* 2nd Place - Silver */
.podium-step.second .podium-column {
  height: 120px;
  background: linear-gradient(135deg, #9ca3af 0%, #4b5563 100%);
  border-color: rgba(156, 163, 175, 0.4);
  box-shadow: 0 0 20px rgba(156, 163, 175, 0.25);
}

/* 3rd Place - Bronze */
.podium-step.third .podium-column {
  height: 90px;
  background: linear-gradient(135deg, #b45309 0%, #78350f 100%);
  border-color: rgba(180, 83, 9, 0.4);
  box-shadow: 0 0 15px rgba(180, 83, 9, 0.25);
}

.podium-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 22px;
  color: white;
  box-shadow: var(--shadow-lg);
  object-fit: cover;
}

.podium-step.first .podium-avatar {
  border-color: #f59e0b;
  background: #d97706;
  width: 72px;
  height: 72px;
  font-size: 26px;
}
.podium-step.second .podium-avatar {
  border-color: #9ca3af;
  background: #4b5563;
}
.podium-step.third .podium-avatar {
  border-color: #b45309;
  background: #78350f;
}

.podium-crown {
  font-size: 24px;
  margin-bottom: 4px;
  animation: crownBob 2s infinite ease-in-out alternate;
}

@keyframes crownBob {
  from { transform: translateY(0); }
  to { transform: translateY(-6px); }
}

.podium-name {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.podium-score {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 8px;
}

/* Leaderboard List */
.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  transition: var(--transition-smooth);
}

.leaderboard-row:hover {
  transform: translateX(5px);
  border-color: var(--primary-light);
  background: var(--bg-tertiary);
}

.leaderboard-rank {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-muted);
  width: 30px;
  text-align: center;
}

.leaderboard-row.first-row .leaderboard-rank { color: #f59e0b; font-size: 22px; }
.leaderboard-row.second-row .leaderboard-rank { color: #9ca3af; font-size: 20px; }
.leaderboard-row.third-row .leaderboard-rank { color: #b45309; font-size: 18px; }

.leaderboard-row-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-glow);
  border: 1px solid var(--primary-light);
  color: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}

.leaderboard-name-group {
  flex-grow: 1;
}

.leaderboard-row-name {
  font-weight: 600;
  font-size: 16px;
}

.leaderboard-row-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.leaderboard-row-score {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
}

/* ==========================================================================
   CLASSROOM ANALYTICS (PHỔ ĐIỂM) STYLES
   ========================================================================= */
.analytics-chart-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 24px;
}

.grade-distribution-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 250px;
  padding: 20px 10px 10px;
  background: rgba(0, 0, 0, 0.15);
  border-bottom: 2px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  margin-top: 10px;
  gap: 8px;
}

.chart-column-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
  justify-content: flex-end;
}

.chart-column-bar {
  width: 100%;
  max-width: 50px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--primary) 100%);
  border-radius: 6px 6px 0 0;
  transition: height 1s ease-in-out;
  position: relative;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.15);
}

.chart-column-bar:hover {
  filter: brightness(1.2);
}

.chart-column-bar-val {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.chart-column-lbl {
  margin-top: 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  white-space: nowrap;
}

.analytics-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 768px) {
  .analytics-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================================================
   BULK IMPORT PREVIEW UI STYLES
   ========================================================================== */
.bulk-preview-title {
  font-size: 18px;
  font-weight: 700;
  margin: 24px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bulk-preview-count {
  font-size: 12px;
  background: var(--primary-glow);
  color: var(--primary-light);
  border: 1px solid rgba(124, 58, 237, 0.3);
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 700;
}

.import-preview-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 500px;
  overflow-y: auto;
  padding-right: 6px;
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  padding: 16px;
  background: rgba(0, 0, 0, 0.1);
}

.preview-card {
  padding: 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preview-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 8px;
}

.preview-card-index {
  font-weight: 700;
  color: var(--accent);
}

.preview-card-type-badge {
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-single { background: var(--primary-glow); color: var(--primary-light); border: 1px solid rgba(124, 58, 237, 0.2); }
.badge-reading { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(6, 182, 212, 0.2); }
.badge-cloze { background: var(--warning-glow); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-error { background: var(--danger-glow); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); }

.preview-card-body {
  font-size: 14px;
}

.preview-passage-block {
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
  border-radius: 4px;
  border-left: 3px solid var(--accent);
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.preview-choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}

@media (max-width: 576px) {
  .preview-choices {
    grid-template-columns: 1fr;
  }
}

.preview-choice-item {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
}

.preview-choice-item.correct {
  background: var(--success-glow);
  color: var(--success);
  border-color: var(--success);
  font-weight: 600;
}

/* ==========================================================================
   PROFESSIONAL PRINT STYLES (@media print)
   ========================================================================== */
.print-only-header {
  display: none;
}

@media print {
  @page {
    size: A4;
    margin: 15mm 15mm 15mm 15mm;
  }
  
  body.print-mode-quiz {
    background: white !important;
    color: black !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    font-family: 'Times New Roman', Times, serif !important;
  }
  
  /* Hide all digital UI elements completely */
  body.print-mode-quiz header, 
  body.print-mode-quiz footer,
  body.print-mode-quiz .nav-container, 
  body.print-mode-quiz .theme-toggle-btn, 
  body.print-mode-quiz .btn, 
  body.print-mode-quiz .nav-actions, 
  body.print-mode-quiz .toast-container, 
  body.print-mode-quiz .modal-overlay, 
  body.print-mode-quiz .switch-panel, 
  body.print-mode-quiz .arena-sidebar,
  body.print-mode-quiz .arena-nav-btns,
  body.print-mode-quiz .dashboard-header,
  body.print-mode-quiz .tab-container,
  body.print-mode-quiz .form-group,
  body.print-mode-quiz .ambient-bg,
  body.print-mode-quiz .user-profile-badge {
    display: none !important;
  }
  
  /* Print layout styling */
  body.print-mode-quiz .app-container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: auto !important;
  }
  
  body.print-mode-quiz .print-only-header {
    display: block !important;
    margin-bottom: 25px;
    font-family: 'Times New Roman', Times, serif !important;
  }
  
  /* Print questions beautifully */
  body.print-mode-quiz .print-questions-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    font-family: 'Times New Roman', Times, serif !important;
  }
  
  body.print-mode-quiz .print-q-card {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  
  body.print-mode-quiz .print-q-text {
    font-weight: bold !important;
    margin-bottom: 8px !important;
    color: black !important;
    font-family: 'Times New Roman', Times, serif !important;
  }
  
  body.print-mode-quiz .print-passage {
    border: 1px solid #000 !important;
    background: #fcfcfc !important;
    padding: 12px !important;
    margin-bottom: 15px !important;
    font-style: italic;
    font-size: 13.5px !important;
    line-height: 1.6 !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    text-align: justify;
    font-family: 'Times New Roman', Times, serif !important;
  }
  
  body.print-mode-quiz .print-choices {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 10px !important;
    margin-top: 8px !important;
    padding-left: 15px;
  }
  
  body.print-mode-quiz .print-choice-item {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    color: black !important;
  }
  
  /* Matrix Answer sheet at the very end of print */
  body.print-mode-quiz .print-matrix-page {
    page-break-before: always !important;
    break-before: always !important;
    margin-top: 40px;
  }
  
  body.print-mode-quiz .print-matrix-title {
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 20px;
    text-transform: uppercase;
  }
  
  body.print-mode-quiz .print-matrix-table {
    width: 100%;
    border-collapse: collapse !important;
    margin: 0 auto;
    max-width: 500px;
  }
  
  body.print-mode-quiz .print-matrix-table th, 
  body.print-mode-quiz .print-matrix-table td {
    border: 1px solid #000 !important;
    padding: 8px !important;
    text-align: center !important;
    font-size: 13px !important;
    color: black !important;
  }
  
  body.print-mode-quiz .print-matrix-table th {
    background-color: #f2f2f2 !important;
    font-weight: bold !important;
  }
}

/* ==========================================================================
   5 NEW ADVANCED ENGLISH QUESTION TYPES - STORETESTS EXCLUSIVES
   ========================================================================== */

/* 1. Listening Type */
.listening-player-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 20px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  backdrop-filter: blur(10px);
}

.listening-player-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.listening-audio-element {
  width: 100%;
  outline: none;
  border-radius: 30px;
}

.listening-audio-element::-webkit-media-controls-enclosure {
  background-color: var(--bg-tertiary);
  border-radius: 30px;
  border: 1px solid var(--glass-border);
}

/* 2. Matching Type */
.matching-arena {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-top: 16px;
  position: relative;
}

@media (max-width: 768px) {
  .matching-arena {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

.matching-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.matching-column-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.matching-item {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  padding: 14px 20px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.matching-item:hover:not(.linked) {
  border-color: var(--primary-light);
  background: rgba(124, 58, 237, 0.1);
  transform: translateX(4px);
}

.matching-column-right .matching-item:hover:not(.linked) {
  transform: translateX(-4px);
}

.matching-item.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
  box-shadow: 0 0 15px var(--accent-glow);
}

.matching-item.linked {
  border-color: var(--success);
  background: var(--success-glow);
  cursor: default;
}

.matching-item.review-correct {
  border-color: var(--success);
  background: var(--success-glow);
}

.matching-item.review-incorrect {
  border-color: var(--danger);
  background: var(--danger-glow);
}

.matching-badge {
  font-size: 12px;
  font-weight: 700;
  background: var(--accent);
  color: white;
  padding: 2px 8px;
  border-radius: 100px;
}

.matching-item.linked .matching-badge {
  background: var(--success);
}

/* 3. Reordering Type */
.reordering-workspace {
  background: rgba(0, 0, 0, 0.15);
  border: 1px dashed var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 24px;
  margin-top: 16px;
}

.word-chips-result {
  min-height: 60px;
  background: var(--bg-secondary);
  border: 1px dashed var(--glass-border);
  border-radius: var(--border-radius-sm);
  padding: 12px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.word-chips-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.word-chip {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 8px 16px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  user-select: none;
}

.word-chip:hover:not(.selected) {
  border-color: var(--accent);
  background: var(--accent-glow);
  transform: translateY(-2px);
}

.word-chip.selected {
  opacity: 0.3;
  cursor: default;
  border-style: dashed;
}

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

/* 4. Writing Type */
.writing-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}

.writing-prompt-box {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  padding: 16px;
  font-size: 16px;
  font-weight: 500;
  border-left: 4px solid var(--accent);
}

.writing-suggestion {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}

.writing-input-box {
  width: 100%;
  min-height: 80px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-sm);
  padding: 14px 18px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 15px;
  line-height: 1.6;
  resize: vertical;
  transition: var(--transition-smooth);
}

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

.writing-feedback {
  margin-top: 8px;
  padding: 10px 14px;
  border-radius: var(--border-radius-sm);
  font-size: 14px;
}

/* 5. True / False Type */
.tf-btn-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 16px;
}

@media (max-width: 576px) {
  .tf-btn-group {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

.btn-tf {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 24px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  user-select: none;
}

.btn-tf-icon {
  font-size: 28px;
}

.btn-tf.true-btn:hover {
  border-color: var(--success);
  background: var(--success-glow);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.btn-tf.false-btn:hover {
  border-color: var(--danger);
  background: var(--danger-glow);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

.btn-tf.true-btn.active {
  background: var(--success);
  border-color: var(--success);
  color: white;
  box-shadow: 0 5px 15px rgba(16, 185, 129, 0.4);
}

.btn-tf.false-btn.active {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
  box-shadow: 0 5px 15px rgba(239, 68, 68, 0.4);
}

/* ==========================================================================
   ADVANCED RESPONSIVE SIDEBAR TREE & 2-3 COLUMN GRID OVERRIDES
   ========================================================================== */

/* 1. Split Layout Structure for Student Dashboard */
.dashboard-split-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 30px;
  align-items: start;
  margin-top: 20px;
}

/* 2. Premium Folder Tree Sidebar styling */
.dashboard-sidebar {
  position: sticky;
  top: 90px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 5;
}

.sidebar-tree-header {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 14px;
  margin-bottom: 18px;
  min-width: 0;
  letter-spacing: 0;
}

.sidebar-tree-header h3,
.sidebar-tree-header h4,
.sidebar-tree-header span,
.sidebar-collapsible summary,
.dashboard-sidebar h3,
.dashboard-sidebar h4 {
  font-family: var(--font-family);
  letter-spacing: 0 !important;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-rendering: geometricPrecision;
}

/* Scrollbar refinement for Sidebar */
.dashboard-sidebar::-webkit-scrollbar {
  width: 4px;
}
.dashboard-sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.dashboard-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
}
.dashboard-sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Category Tree Nodes */
.category-tree {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.tree-folder {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tree-folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1.35;
  letter-spacing: 0;
  cursor: pointer;
  transition: var(--transition-smooth);
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid transparent;
}

.tree-folder-header:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--accent);
}

.tree-folder-icon {
  font-size: 18px;
  color: var(--accent);
  transition: transform 0.2s ease;
}

.tree-sub-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 20px; /* Indent sub items */
  border-left: 1px dashed rgba(255, 255, 255, 0.05);
  margin-left: 20px;
  margin-top: 4px;
}

.tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 13px;
  line-height: 1.35;
  letter-spacing: 0;
  cursor: pointer;
  transition: var(--transition-smooth);
  border-left: 2px solid transparent;
}

.tree-item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
  padding-left: 16px;
}

.tree-item-icon {
  font-size: 14px;
  color: var(--text-muted);
}

.tree-item.active {
  color: var(--accent);
  background: var(--accent-glow);
  border-left-color: var(--accent);
  font-weight: 700;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.1);
  text-shadow: 0 0 8px rgba(6, 182, 212, 0.3);
}

.tree-item.active .tree-item-icon {
  color: var(--accent);
}

/* 3. Account Dropdown Nav Links inside dropdown */
.mobile-nav-links {
  display: none; /* Hidden by default, displayed only on narrow screen via media queries */
}

/* Guest / User Profile drop-down modifications */
#user-profile-dropdown {
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--glass-border);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 16px;
  max-width: calc(100vw - 24px);
}

@media (max-width: 767px) {
  #header-user-badge-container {
    position: static;
  }

  #user-profile-dropdown {
    left: 12px !important;
    right: 12px !important;
    top: 64px !important;
    width: auto !important;
    max-width: none;
    position: fixed !important;
    z-index: 3000 !important;
  }
}

@media (max-width: 480px) {
  header .nav-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  header .nav-link {
    min-height: 48px;
    font-size: 14px;
  }
}

.category-drag-item {
  transition: border-color 0.18s ease, background 0.18s ease, opacity 0.18s ease, transform 0.18s ease;
}

.category-drag-item:hover {
  border-color: rgba(34, 211, 238, 0.4) !important;
  background: rgba(34, 211, 238, 0.08) !important;
}

.category-dragging {
  opacity: 0.55;
  transform: scale(0.985);
}

.category-drop-root-active {
  outline: 2px dashed rgba(34, 211, 238, 0.55);
  outline-offset: 3px;
  background: rgba(34, 211, 238, 0.05) !important;
}

/* 4. Fluid 2-3 Columns Grid Media Queries */
@media (min-width: 1201px) {
  .quizzes-grid,
  .books-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

@media (max-width: 1200px) and (min-width: 768px) {
  .quizzes-grid,
  .books-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* 5. iPad Portrait Media query (< 1025px) */
@media (max-width: 1024px) {
  header .nav-menu {
    display: none !important; /* Hide header menus on iPad / Mobile */
  }
  
  #user-profile-dropdown {
    width: 240px !important;
  }

  #user-profile-dropdown .mobile-nav-links {
    display: flex !important; /* Make nav options appear in profile dropdown */
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 12px;
  }
}

/* 6. Mobile Portrait Media query (< 768px) */
@media (max-width: 767px) {
  .dashboard-split-layout {
    grid-template-columns: 1fr !important;
    gap: 20px;
  }

  .dashboard-sidebar {
    display: block !important;
    width: 100%;
  }

  .mobile-filter-bar {
    display: none !important;
  }

  #user-profile-dropdown {
    left: 12px !important;
    right: 12px !important;
    top: 64px !important;
    width: auto !important;
    max-width: none;
    position: fixed !important;
    z-index: 3000 !important;
  }
}

/* ==========================================================================================================
   EDTECH SAAS SHOP, BOOKSTORE, SUBSCRIPTIONS, MY ACCOUNT & CHECKOUT PAYMENTS
   ========================================================================== */

/* Price Slider & Sidebar Modules */
.sidebar-module {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 20px;
}
.sidebar-title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 16px;
  color: var(--text-primary);
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-collapsible > h3.sidebar-title {
  display: none;
}

.sidebar-collapsible {
  padding: 0;
  overflow: hidden;
}

.sidebar-collapsible .sidebar-summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  list-style: none;
  margin: 0;
  padding: 18px 20px;
  user-select: none;
}

.sidebar-collapsible .sidebar-summary::-webkit-details-marker {
  display: none;
}

.sidebar-collapsible .sidebar-summary::after {
  content: "⌄";
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
  transition: transform 0.2s ease;
}

.sidebar-collapsible[open] .sidebar-summary {
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 14px;
}

.sidebar-collapsible[open] .sidebar-summary::after {
  transform: rotate(180deg);
}

.sidebar-collapsible .category-tree {
  padding: 0 20px 20px;
}

.category-meta {
  align-items: center;
  background: rgba(6, 182, 212, 0.06);
  border: 1px solid rgba(6, 182, 212, 0.16);
  border-radius: 10px;
  color: var(--text-secondary);
  display: flex;
  font-size: 12px;
  gap: 10px;
  justify-content: space-between;
  line-height: 1.4;
  margin: 0 20px 20px;
  padding: 10px 12px;
}

.category-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-meta strong {
  color: var(--accent);
  flex: 0 0 auto;
  font-weight: 800;
}

@media (min-width: 768px) {
  .sidebar-collapsible {
    padding: 20px;
  }

  .sidebar-collapsible .sidebar-summary {
    cursor: default;
    margin-bottom: 16px;
    padding: 0;
    pointer-events: none;
  }

  .sidebar-collapsible .sidebar-summary::after {
    display: none;
  }

  .sidebar-collapsible .category-tree {
    display: flex !important;
    padding: 0;
  }

  .sidebar-collapsible .category-meta {
    margin: 14px 0 0;
  }
}

@media (max-width: 767px) {
  .sidebar-collapsible:not([open]) > :not(summary) {
    display: none !important;
  }

  .sidebar-collapsible[open] .category-meta {
    margin-bottom: 20px;
  }
}
.price-slider-wrapper {
  position: relative;
  margin: 15px 0;
}
.price-slider-wrapper input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 5px;
  outline: none;
  border: 1px solid var(--glass-border);
}
.price-slider-wrapper input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.5);
  transition: all 0.2s ease;
}
.price-slider-wrapper input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: var(--primary-light);
}
.price-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 700;
  margin-top: 10px;
}

/* Shop layout overrides */
.shop-top-bar {
  margin-bottom: 24px;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 20px;
}
.shop-breadcrumbs {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.shop-main-title {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 12px;
  letter-spacing: 0;
  line-height: 1.25;
}
.shop-filter-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.results-count {
  font-size: 13.5px;
  color: var(--text-secondary);
  letter-spacing: 0;
}
.shop-sort-select {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  cursor: pointer;
  outline: none;
}

/* Product Quiz Card Custom style */
.quiz-product-card {
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.quiz-product-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 30px rgba(6, 182, 212, 0.15);
  border-color: rgba(6, 182, 212, 0.4);
}
.quiz-cover-img {
  width: 100%;
  height: 140px;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.1) 0%, rgba(124, 58, 237, 0.15) 100%);
  border-radius: 8px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.quiz-cover-img ion-icon {
  font-size: 48px;
  color: var(--accent);
  opacity: 0.7;
}
.quiz-price-tag {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(6, 182, 212, 0.9);
  color: white;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
  backdrop-filter: blur(5px);
}
.quiz-price-tag.free {
  background: rgba(16, 185, 129, 0.9);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Bookstore Styles */
.bookstore-layout {
  margin-top: 20px;
}
.quizzes-grid,
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  width: 100%;
}
.book-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px;
  background: rgba(17, 24, 39, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  transition: all 0.3s ease;
  position: relative;
}
.book-card:hover {
  transform: translateY(-5px);
  border-color: var(--accent);
  box-shadow: 0 10px 25px rgba(6, 182, 212, 0.15);
}
.book-cover {
  width: 100%;
  aspect-ratio: 3/4;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(236, 72, 153, 0.15) 100%);
  border-radius: 8px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 16px rgba(0,0,0,0.3);
}
.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.book-card:hover .book-cover img {
  transform: scale(1.05);
}
.book-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.4;
}
.book-price {
  font-size: 18px;
  font-weight: 800;
  color: var(--success);
  margin-bottom: 16px;
}

/* Subscription Plan Cards */
.subscription-plans-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  max-width: 1300px;
  margin: 0 auto;
  padding: 10px 0;
}
@media (max-width: 1200px) {
  .subscription-plans-grid {
    grid-template-columns: repeat(2, 1fr);
    max-width: 800px;
  }
}
@media (max-width: 768px) {
  .subscription-plans-grid {
    grid-template-columns: 1fr;
    max-width: 400px;
  }
}
.plan-card {
  padding: 44px 28px;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95) 0%, rgba(30, 41, 59, 0.9) 100%) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}
.plan-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
}
.plan-card.featured {
  border: 2px solid transparent !important;
  background-image: linear-gradient(rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.95)), linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%) !important;
  background-origin: border-box !important;
  background-clip: padding-box, border-box !important;
  box-shadow: 0 20px 40px rgba(245, 158, 11, 0.15), 0 0 30px rgba(245, 158, 11, 0.08), 0 30px 60px rgba(0, 0, 0, 0.4);
}
.plan-card.featured:hover {
  box-shadow: 0 20px 50px rgba(245, 158, 11, 0.25), 0 0 40px rgba(245, 158, 11, 0.15), 0 30px 70px rgba(0, 0, 0, 0.6);
}
.plan-card.teacher {
  border: 2px solid transparent !important;
  background-image: linear-gradient(rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.95)), linear-gradient(135deg, #06b6d4 0%, #0891b2 100%) !important;
  background-origin: border-box !important;
  background-clip: padding-box, border-box !important;
  box-shadow: 0 20px 40px rgba(6, 182, 212, 0.15), 0 0 30px rgba(6, 182, 212, 0.08), 0 30px 60px rgba(0, 0, 0, 0.4);
}
.plan-card.teacher:hover {
  box-shadow: 0 20px 50px rgba(6, 182, 212, 0.25), 0 0 40px rgba(6, 182, 212, 0.15), 0 30px 70px rgba(0, 0, 0, 0.6);
}
.plan-badge {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.08) !important;
  padding: 5px 14px;
  border-radius: 100px;
  width: fit-content;
  margin: 0 auto 20px auto;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  color: rgba(255, 255, 255, 0.8) !important;
  letter-spacing: 0.5px;
}
.plan-badge-hot {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%) !important;
  color: #111827 !important;
  padding: 5px 14px;
  border-radius: 100px;
  width: fit-content;
  margin: 0 auto 20px auto;
  box-shadow: 0 0 15px rgba(251, 191, 36, 0.5);
  letter-spacing: 0.5px;
}
.plan-badge-teacher {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%) !important;
  color: #ffffff !important;
  padding: 5px 14px;
  border-radius: 100px;
  width: fit-content;
  margin: 0 auto 20px auto;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.5);
  letter-spacing: 0.5px;
}
.plan-name {
  font-size: 24px;
  font-weight: 800;
  color: #ffffff !important;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.plan-price {
  font-size: 44px;
  font-weight: 900;
  color: #ffffff !important;
  margin-bottom: 16px;
}
.plan-price span {
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5) !important;
}
.plan-desc {
  font-size: 13.5px;
  color: rgba(255, 255, 255, 0.7) !important;
  margin-bottom: 28px;
  line-height: 1.6;
  min-height: 48px;
  text-align: center;
}
.plan-features {
  list-style: none;
  padding: 0;
  margin: 0 0 36px 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 13.5px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 24px;
}
.plan-features li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.85) !important;
}
.plan-features li ion-icon {
  font-size: 18px;
  color: #10b981;
  flex-shrink: 0;
}
.plan-features li.disabled {
  color: rgba(255, 255, 255, 0.35) !important;
  text-decoration: line-through;
  opacity: 0.6;
}
.plan-features li.disabled ion-icon {
  color: rgba(255, 255, 255, 0.2) !important;
}
.plan-btn {
  margin-top: auto;
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  transition: all 0.3s ease;
  border: none;
}
.plan-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* My Account layout */
.myaccount-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 24px;
}
.myaccount-sidebar {
  padding: 16px;
  height: fit-content;
}
.myaccount-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.myaccount-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14.5px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  width: 100%;
}
.myaccount-menu-item ion-icon {
  font-size: 18px;
}
.myaccount-menu-item:hover, .myaccount-menu-item.active {
  background: rgba(255,255,255,0.04);
  color: var(--accent);
  border-left: 3px solid var(--accent);
  padding-left: 13px;
}
.myaccount-main-content {
  padding: 30px;
}
.myaccount-tab-pane {
  display: none;
}
.myaccount-tab-pane.active {
  display: block;
}
.downloads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.download-item {
  padding: 16px;
  background: rgba(0,0,0,0.15);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

/* Checkout Modal Styling */
.checkout-modal-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}
.checkout-billing-info {
  border-right: none;
}
@media (max-width: 768px) {
  .checkout-modal-grid {
    grid-template-columns: 1fr;
  }
  .myaccount-layout {
    grid-template-columns: 1fr;
  }
}

.detail-main-image-frame {
  cursor: zoom-in;
  position: relative;
}

.detail-main-image-frame #detail-main-img {
  will-change: transform, transform-origin;
}

#modal-checkout-qr .modal-box {
  max-width: min(980px, calc(100vw - 32px)) !important;
  max-height: calc(100vh - 32px) !important;
  display: flex;
  flex-direction: column;
}

#modal-checkout-qr .checkout-modal-grid {
  grid-template-columns: minmax(0, .95fr) minmax(320px, .78fr);
  min-height: 0;
  overflow: hidden;
}

#modal-checkout-qr .checkout-billing-info,
#modal-checkout-qr .checkout-order-summary {
  min-height: 0;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
  justify-content: flex-start !important;
}

#modal-checkout-qr .checkout-order-summary {
  gap: 12px;
}

#modal-checkout-qr #checkout-outtab-warning {
  padding: 8px 10px !important;
  margin-bottom: 10px !important;
  font-size: 11px !important;
}

#modal-checkout-qr #checkout-qr-placeholder {
  min-height: 150px !important;
  padding: 18px 14px !important;
}

#modal-checkout-qr .qr-neon-wrapper {
  margin-bottom: 8px !important;
}

#modal-checkout-qr #checkout-qr-img {
  width: clamp(112px, 18vh, 140px) !important;
  height: clamp(112px, 18vh, 140px) !important;
}

#modal-checkout-qr .transfer-details {
  font-size: 11px !important;
  gap: 2px !important;
}

#modal-checkout-qr .realtime-status-indicator {
  margin-top: 8px !important;
  padding: 6px 8px !important;
}

@media (max-width: 900px) {
  #modal-checkout-qr {
    align-items: flex-start !important;
    overflow-y: auto !important;
    padding: 10px !important;
  }

  #modal-checkout-qr .modal-box {
    width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
  }

  #modal-checkout-qr .checkout-modal-grid {
    grid-template-columns: 1fr !important;
    overflow: visible;
  }

  #modal-checkout-qr .checkout-billing-info,
  #modal-checkout-qr .checkout-order-summary {
    max-height: none !important;
    overflow: visible !important;
    padding: 14px !important;
  }

  #modal-checkout-qr .checkout-order-summary {
    border-left: 0 !important;
    border-top: 1px solid var(--glass-border);
  }
}

/* PRINT ONLY STYLING FOR PARENT REPORT */
@media print {
  body.print-mode-report * {
    visibility: hidden;
  }
  body.print-mode-report #modal-parent-report, body.print-mode-report #modal-parent-report * {
    visibility: visible;
  }
  body.print-mode-report #modal-parent-report {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    background: white !important;
    color: black !important;
  }
  body.print-mode-report #modal-parent-report .glass-card {
    background: white !important;
    color: black !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
  }
  body.print-mode-report #modal-parent-report .modal-box {
    width: 100% !important;
    max-width: 100% !important;
    border: none !important;
    box-shadow: none !important;
  }
  body.print-mode-report #modal-parent-report button, body.print-mode-report #modal-parent-report .theme-toggle-btn {
    display: none !important;
  }
  body.print-mode-report #modal-parent-report h3, body.print-mode-report #modal-parent-report h4, body.print-mode-report #modal-parent-report span, body.print-mode-report #modal-parent-report strong {
    color: black !important;
  }
  body.print-mode-report #modal-parent-report table, body.print-mode-report #modal-parent-report th, body.print-mode-report #modal-parent-report td {
    border: 1px solid black !important;
    color: black !important;
    background: transparent !important;
  }
  body.print-mode-report #modal-parent-report textarea {
    border: 1px solid black !important;
    color: black !important;
    background: transparent !important;
  }
}

/* ==========================================================================
   EXTRA CSS FOR PREMIUM EXAM ARENA, SEPAY CHECKOUT & MOCK GOOGLE AUTH
   ========================================================================== */

/* Custom Option Items in Premium Quiz Arena */
.option-item {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.option-item:hover {
  background: rgba(255, 255, 255, 0.05) !important;
  border-color: rgba(6, 182, 212, 0.3) !important;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.1) !important;
  transform: translateY(-1px);
}

.option-item.selected {
  background: var(--primary-glow) !important;
  border-color: var(--primary-light) !important;
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.2) !important;
}

.option-item.selected .option-key {
  color: var(--primary-light) !important;
  text-shadow: 0 0 8px rgba(167, 139, 250, 0.4);
}

/* Spinner for Loading Buttons */
.loading-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Realtime payment pulse indicator */
@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 12px var(--success); }
  100% { transform: scale(0.9); opacity: 0.6; }
}

.live-dot {
  animation: pulse 1.8s infinite;
}

/* Global Reset for underlines and link styling */
a {
  text-decoration: none !important;
}
a:hover {
  text-decoration: none !important;
}

/* Premium VIP Badge styles */
.quiz-price-tag.premium {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.95) 0%, rgba(139, 92, 246, 0.95) 100%) !important;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.45) !important;
  border: 1px solid rgba(251, 191, 36, 0.45) !important;
  color: #fff !important;
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
}

/* Glassmorphic Pagination styling */
.pagination-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pagination-btn:hover:not(:disabled) {
  background: var(--accent-gradient) !important;
  color: #000 !important;
  border-color: transparent !important;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.4) !important;
}
.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pagination-active {
  background: var(--accent-gradient) !important;
  color: #000 !important;
  border-color: transparent !important;
}

.pagination-wrapper {
  max-width: 100%;
  flex-wrap: wrap;
  overflow: hidden;
}

.cart-toggle-btn {
  position: relative;
}

.cart-toggle-btn #cart-count-badge {
  align-items: center;
  background: var(--danger);
  border: 2px solid var(--bg-primary);
  border-radius: 999px;
  color: #fff;
  display: none;
  font-size: 10px;
  font-weight: 800;
  height: 18px;
  justify-content: center;
  min-width: 18px;
  padding: 0 5px;
  position: absolute;
  right: -5px;
  top: -6px;
}

.sale-campaign-banner {
  align-items: center;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.18), rgba(124, 58, 237, 0.18));
  border-bottom: 1px solid rgba(6, 182, 212, 0.22);
  color: var(--text-primary);
  display: flex;
  gap: 14px;
  justify-content: center;
  padding: 10px 16px;
  position: sticky;
  top: 72px;
  z-index: 900;
}

.sale-campaign-banner strong {
  color: var(--accent);
  display: block;
  font-size: 13px;
}

.sale-campaign-banner span {
  color: var(--text-secondary);
  font-size: 12px;
}

.checkout-items-list,
.cart-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkout-line-item,
.cart-line-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 10px 12px;
}

.checkout-line-item span,
.cart-line-item span {
  color: var(--text-secondary);
  display: block;
  font-size: 11px;
  margin-top: 2px;
}

.checkout-line-item strong,
.cart-line-item strong {
  color: var(--text-primary);
  font-size: 13px;
}

.cart-line-item button {
  align-self: center;
  height: 30px;
}

.voucher-box {
  background: rgba(124, 58, 237, 0.07);
  border: 1px solid rgba(124, 58, 237, 0.18);
  border-radius: 12px;
  margin: 12px 0;
  padding: 10px;
}

.voucher-box label {
  color: var(--text-secondary);
  display: block;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.voucher-input-row {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.voucher-message {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.4;
  margin-top: 6px;
  min-height: 16px;
}

.checkout-total-lines {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.checkout-total-lines > div {
  align-items: center;
  color: var(--text-secondary);
  display: flex;
  font-size: 12.5px;
  justify-content: space-between;
}

.checkout-total-lines strong {
  color: var(--text-primary);
}

.checkout-total-lines .checkout-grand-total {
  border-top: 1px solid rgba(255,255,255,0.08);
  color: var(--success);
  font-size: 15px;
  font-weight: 800;
  margin-top: 4px;
  padding-top: 9px;
}

.checkout-total-lines .checkout-grand-total strong {
  color: var(--success);
}

.cart-modal-box {
  margin-left: auto;
  margin-right: 20px;
  max-height: calc(100vh - 40px);
  max-width: 430px;
  overflow: hidden;
  padding: 0;
  width: min(92vw, 430px);
}

.cart-modal-header,
.cart-modal-footer {
  padding: 18px 20px;
}

.cart-modal-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
}

.cart-modal-header h3 {
  align-items: center;
  color: var(--accent);
  display: flex;
  font-size: 18px;
  font-weight: 800;
  gap: 8px;
}

.cart-modal-header p {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
  margin-top: 4px;
}

.cart-items-list {
  max-height: min(56vh, 460px);
  overflow-y: auto;
  padding: 16px 20px;
}

.cart-modal-footer {
  border-top: 1px solid var(--glass-border);
  display: grid;
  gap: 12px;
}

.cart-modal-footer > div {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.cart-modal-footer span {
  color: var(--text-secondary);
  font-size: 12px;
}

.cart-modal-footer strong {
  color: var(--success);
  font-size: 20px;
  font-weight: 900;
}

body.seasonal-theme::before {
  background:
    radial-gradient(circle at 12% 20%, color-mix(in srgb, var(--seasonal-accent) 20%, transparent), transparent 24%),
    radial-gradient(circle at 88% 12%, color-mix(in srgb, var(--seasonal-primary) 18%, transparent), transparent 28%);
  content: "";
  inset: 0;
  opacity: 0.55;
  pointer-events: none;
  position: fixed;
  z-index: 0;
}

body.seasonal-theme header {
  border-bottom-color: color-mix(in srgb, var(--seasonal-accent) 28%, var(--glass-border));
}

body.seasonal-theme .logo-icon {
  box-shadow: 0 0 24px color-mix(in srgb, var(--seasonal-accent) 45%, transparent);
}

.seasonal-effects,
#seasonal-effects-layer {
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  position: fixed;
  z-index: 2;
}

#seasonal-effects-layer {
  height: 100vh;
  opacity: 0.68;
  width: 100vw;
}

.seasonal-particle {
  color: var(--seasonal-accent);
  filter: none;
  font-size: var(--size);
  font-weight: 800;
  left: var(--x);
  opacity: 0;
  position: absolute;
  top: -8vh;
  transform: translate3d(0, 0, 0);
  user-select: none;
  will-change: transform, opacity;
}

.seasonal-effect-blossom .seasonal-particle,
.seasonal-effect-petal .seasonal-particle,
.seasonal-effect-leaf .seasonal-particle {
  animation: seasonal-fall var(--duration) linear infinite;
  animation-delay: var(--delay);
}

.seasonal-effect-snow .seasonal-particle {
  animation: seasonal-snow var(--duration) linear infinite;
  animation-delay: var(--delay);
  color: #ffffff;
}

.seasonal-effect-rain .seasonal-particle {
  animation: seasonal-rain calc(var(--duration) * .55) linear infinite;
  animation-delay: var(--delay);
  color: color-mix(in srgb, var(--seasonal-accent) 76%, white);
  opacity: .5;
}

.seasonal-effect-float .seasonal-particle,
.seasonal-effect-bubble .seasonal-particle,
.seasonal-effect-lantern .seasonal-particle {
  animation: seasonal-float var(--duration) ease-in-out infinite;
  animation-delay: var(--delay);
  top: auto;
  bottom: -10vh;
}

.seasonal-effect-spark .seasonal-particle,
.seasonal-effect-firework .seasonal-particle,
.seasonal-effect-glow .seasonal-particle,
.seasonal-effect-neon .seasonal-particle,
.seasonal-effect-spooky .seasonal-particle {
  animation: seasonal-spark var(--duration) ease-in-out infinite;
  animation-delay: var(--delay);
  top: var(--y);
}

.seasonal-effect-neon .seasonal-particle {
  color: color-mix(in srgb, var(--seasonal-accent) 86%, white);
  font-family: var(--font-family);
  letter-spacing: 0;
}

.seasonal-effect-spooky .seasonal-particle {
  color: color-mix(in srgb, var(--seasonal-primary) 65%, var(--seasonal-accent));
}

@keyframes seasonal-fall {
  0% { opacity: 0; transform: translate3d(0, -10vh, 0) rotate(0deg); }
  12% { opacity: .75; }
  100% { opacity: 0; transform: translate3d(var(--drift), 112vh, 0) rotate(260deg); }
}

@keyframes seasonal-snow {
  0% { opacity: 0; transform: translate3d(0, -10vh, 0) rotate(0deg) scale(.85); }
  15% { opacity: .85; }
  100% { opacity: 0; transform: translate3d(var(--drift), 112vh, 0) rotate(180deg) scale(1.05); }
}

@keyframes seasonal-rain {
  0% { opacity: 0; transform: translate3d(0, -12vh, 0) rotate(18deg); }
  10% { opacity: .62; }
  100% { opacity: 0; transform: translate3d(calc(var(--drift) * .28), 112vh, 0) rotate(18deg); }
}

@keyframes seasonal-float {
  0% { opacity: 0; transform: translate3d(0, 8vh, 0) scale(.8); }
  16% { opacity: .75; }
  72% { opacity: .6; transform: translate3d(var(--drift), -64vh, 0) scale(1); }
  100% { opacity: 0; transform: translate3d(calc(var(--drift) * 1.5), -110vh, 0) scale(.9); }
}

@keyframes seasonal-spark {
  0%, 100% { opacity: 0; transform: translate3d(0, 0, 0) scale(.6) rotate(0deg); }
  35% { opacity: .85; transform: translate3d(var(--drift), -18px, 0) scale(1.15) rotate(18deg); }
  65% { opacity: .35; transform: translate3d(calc(var(--drift) * -.5), 12px, 0) scale(.85) rotate(-14deg); }
}

@media (prefers-reduced-motion: reduce) {
  .seasonal-effects {
    display: none;
  }
}

/* ==========================================================================
   USER PORTAL RESPONSIVE HARDENING
   Phones + tablets in portrait/landscape. Admin remains desktop-first.
   ========================================================================== */
@media (max-width: 1024px) {
  header .nav-container {
    align-items: stretch;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    overflow: hidden;
  }

  header .logo-section {
    flex: 1 1 auto;
    min-width: 0;
  }

  header .logo-text {
    font-size: 20px;
  }

  header .nav-actions {
    margin-left: auto;
  }

  header .nav-menu {
    display: flex !important;
    order: 3;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 8px;
    padding: 4px 0 2px;
    scrollbar-width: none;
  }

  header .nav-menu::-webkit-scrollbar {
    display: none;
  }

  header .nav-link {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 8px 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--glass-border);
  }

  .app-container {
    padding: 24px 1cm;
    min-height: calc(100vh - 120px);
  }

  .dashboard-split-layout {
    grid-template-columns: 1fr !important;
    gap: 20px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .dashboard-main-content,
  .quizzes-grid-wrapper,
  .quizzes-grid,
  .books-grid {
    min-width: 0;
    max-width: 100%;
  }

  .dashboard-sidebar {
    position: static;
    max-height: none;
    min-width: 0;
  }

  .quizzes-grid,
  .books-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 18px;
  }

  .pagination-wrapper {
    max-width: 100%;
    flex-wrap: wrap;
    overflow: hidden;
  }

  .subscription-plans-grid,
  .myaccount-layout {
    grid-template-columns: 1fr !important;
  }

  .myaccount-main-content {
    padding: 20px;
  }

  #modal-book-detail {
    padding: 16px !important;
  }

  #modal-book-detail .modal-box {
    width: min(96vw, 760px) !important;
    max-height: calc(100vh - 32px) !important;
    grid-template-columns: minmax(220px, 0.85fr) minmax(0, 1fr) !important;
    gap: 22px !important;
    padding: 22px !important;
  }
}

.audio-skip-btn,
.audio-speed-select {
  min-height: 30px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.audio-speed-select {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 0 8px;
  outline: none;
}

.custom-audio-player.audio-loading {
  opacity: .78;
}

.custom-audio-player.audio-loading .play-btn {
  cursor: wait;
}

.form-control.input-valid {
  border-color: rgba(16, 185, 129, .85) !important;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, .12) !important;
}

.form-control.input-invalid {
  border-color: rgba(239, 68, 68, .85) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .12) !important;
}

@media (max-width: 767px) {
  header {
    position: sticky;
  }

  header .nav-container {
    display: grid;
    grid-template-columns: minmax(0, auto) minmax(0, 1fr);
    grid-template-areas:
      "brand actions"
      "nav nav";
    align-items: center;
    gap: 10px 8px;
    justify-content: stretch;
    padding: 10px 12px 12px;
  }

  header .logo-section {
    grid-area: brand;
    min-width: 0;
  }

  header .nav-actions {
    grid-area: actions;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
  }

  header .nav-menu {
    display: grid !important;
    grid-area: nav;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    justify-content: center;
    gap: 8px;
    overflow: visible;
    padding: 0;
    width: 100%;
  }

  header .nav-link {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: 42px;
    padding: 8px 5px;
    text-align: center;
    white-space: nowrap;
    width: 100%;
    font-size: clamp(12px, 3.35vw, 14px);
  }

  .quiz-split-grid {
    grid-template-columns: 1fr !important;
    height: auto !important;
    max-height: none !important;
  }

  .quiz-split-grid .passage-box {
    max-height: 260px !important;
  }

  .custom-audio-player {
    align-items: stretch !important;
    flex-wrap: wrap;
    gap: 8px !important;
  }

  .custom-audio-player > div {
    flex: 1 1 100% !important;
    order: 2;
  }

  .custom-audio-player .audio-time,
  .custom-audio-player .audio-speed-select,
  .custom-audio-player .audio-skip-btn {
    order: 3;
  }

  .logo-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  header .logo-text {
    font-size: 18px;
  }

  header .theme-toggle-btn,
  header .cart-toggle-btn {
    height: 36px;
    width: 36px;
  }

  header .coin-balance-pill {
    min-height: 34px;
    padding: 0 9px;
    font-size: 11px;
  }

  #header-user-badge-container {
    flex: 0 0 auto;
  }

  #header-user-badge-container .user-profile-badge,
  #header-user-badge-container .guest-badge {
    border-radius: 999px !important;
    gap: 0 !important;
    padding: 5px !important;
  }

  #header-user-badge-container .user-profile-badge > div:not(.user-avatar),
  #header-user-badge-container .guest-badge > div:not(.user-avatar),
  #header-user-badge-container .user-name,
  #header-user-badge-container .user-role,
  #header-user-badge-container .user-profile-badge > ion-icon {
    display: none !important;
  }

  #header-user-badge-container .user-avatar {
    height: 32px !important;
    width: 32px !important;
  }

  header .nav-actions > .btn span,
  #header-user-badge-container .user-role {
    display: none;
  }

  .sale-campaign-banner {
    border: 1px solid rgba(6, 182, 212, 0.22);
    border-left: 0;
    border-right: 0;
    flex-wrap: nowrap;
    gap: 10px;
    justify-content: center;
    margin: 0 auto;
    padding: 10px 18px;
    position: static;
    top: auto;
    width: 100%;
    z-index: 1;
  }

  .sale-campaign-banner > div {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
  }

  .sale-campaign-banner strong,
  .sale-campaign-banner span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sale-campaign-banner .btn {
    flex: 0 0 auto;
    min-width: 102px;
    justify-content: center;
  }

  .app-container {
    padding: 18px 1cm;
  }

  .hero-title {
    font-size: 34px;
  }

  .hero-buttons {
    flex-direction: column;
  }

  .hero-buttons .btn {
    width: 100%;
  }

  .dashboard-sidebar {
    display: block !important;
    padding: 16px;
  }

  .mobile-filter-bar {
    display: none !important;
  }

  .quizzes-grid,
  .books-grid,
  .downloads-grid,
  .account-summary-widgets {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }

  .pagination-wrapper {
    justify-content: flex-start !important;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 6px;
    scrollbar-width: thin;
  }

  .quiz-product-card {
    padding: 18px !important;
  }

  .quiz-cover-img {
    height: clamp(130px, 42vw, 190px);
  }

  .shop-main-title {
    font-size: 30px;
  }

  .shop-top-bar {
    margin-bottom: 18px;
  }

  .checkout-modal-grid,
  #modal-book-detail .modal-box {
    grid-template-columns: 1fr !important;
  }

  #modal-book-detail {
    align-items: flex-start !important;
    padding: 10px !important;
    overflow-y: auto !important;
  }

  #modal-book-detail .modal-box {
    width: 100% !important;
    max-height: none !important;
    min-height: auto !important;
    gap: 16px !important;
    padding: 18px !important;
  }

  #modal-book-detail h2 {
    font-size: 20px !important;
  }

  #modal-book-detail #detail-book-cta-container .btn {
    width: 100%;
  }

  #settings-modal .modal-box,
  #auth-modal .modal-box,
  #forgot-password-modal .modal-box,
  #modal-checkout-qr .modal-box {
    width: calc(100vw - 20px) !important;
    max-width: calc(100vw - 20px) !important;
    max-height: calc(100vh - 20px) !important;
    overflow-y: auto !important;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .app-container {
    padding-top: 14px;
  }

  header .nav-container {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  #modal-book-detail {
    align-items: flex-start !important;
    overflow-y: auto !important;
  }

  #modal-book-detail .modal-box {
    grid-template-columns: 220px minmax(0, 1fr) !important;
    max-height: none !important;
    margin: 10px auto !important;
  }

  #modal-book-detail .modal-box > div:first-of-type > div:first-child {
    max-height: 62vh;
  }
}

/* ==========================================================================
   PREMIUM GLASSMORPHIC TABLE DESIGN (.az-table)
   ========================================================================== */
.az-table {
  width: 100%;
  border-collapse: separate !important;
  border-spacing: 0 12px !important; /* Tạo khoảng cách giữa các hàng để làm card */
  text-align: left;
  margin-top: -12px;
}

.az-table th {
  padding: 16px 20px !important;
  font-weight: 700 !important;
  font-size: 12px !important;
  text-transform: uppercase !important;
  letter-spacing: 1px !important;
  color: var(--text-muted) !important;
  border-bottom: 2px solid rgba(255, 255, 255, 0.05) !important;
  background: transparent !important;
}

.az-table tbody tr {
  background: rgba(30, 41, 59, 0.35) !important;
  backdrop-filter: blur(15px) !important;
  -webkit-backdrop-filter: blur(15px) !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.az-table tbody tr:hover {
  background: rgba(30, 41, 59, 0.65) !important;
  transform: translateY(-2px) scale(1.003);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4), 0 0 20px rgba(6, 182, 212, 0.15) !important;
}

.az-table td {
  padding: 20px !important;
  color: var(--text-secondary) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.03) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03) !important;
  vertical-align: middle !important;
}

/* Bo góc tinh tế cho các ô td ở đầu và cuối mỗi hàng */
.az-table tbody tr td:first-child {
  border-left: 1px solid rgba(255, 255, 255, 0.03) !important;
  border-radius: 12px 0 0 12px !important;
}

.az-table tbody tr td:last-child {
  border-right: 1px solid rgba(255, 255, 255, 0.03) !important;
  border-radius: 0 12px 12px 0 !important;
}

/* Hover glowing border thay đổi */
.az-table tbody tr:hover td {
  border-top-color: rgba(6, 182, 212, 0.2) !important;
  border-bottom-color: rgba(6, 182, 212, 0.2) !important;
  color: var(--text-primary) !important;
}

.az-table tbody tr:hover td:first-child {
  border-left-color: rgba(6, 182, 212, 0.3) !important;
}

.az-table tbody tr:hover td:last-child {
  border-right-color: rgba(6, 182, 212, 0.3) !important;
}

/* Glowing Neon Badges */
.badge-student {
  font-size: 11px !important;
  font-weight: 700 !important;
  padding: 4px 10px !important;
  border-radius: 6px !important;
  border: 1px solid rgba(251, 191, 36, 0.25) !important;
  background: rgba(251, 191, 36, 0.04) !important;
  color: #fbbf24 !important;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.06) !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px;
}

.badge-teacher {
  font-size: 11px !important;
  font-weight: 700 !important;
  padding: 4px 10px !important;
  border-radius: 6px !important;
  border: 1px solid rgba(6, 182, 212, 0.25) !important;
  background: rgba(6, 182, 212, 0.04) !important;
  color: #06b6d4 !important;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.06) !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px;
}

/* Premium Action Buttons in Tables */
.btn-action-edit {
  background: rgba(6, 182, 212, 0.08) !important;
  border: 1px solid rgba(6, 182, 212, 0.2) !important;
  color: #06b6d4 !important;
  transition: all 0.2s ease !important;
}

.btn-action-edit:hover {
  background: #06b6d4 !important;
  color: #000000 !important;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.4) !important;
  transform: scale(1.05);
}

.btn-action-delete {
  background: rgba(239, 68, 68, 0.08) !important;
  border: 1px solid rgba(239, 68, 68, 0.2) !important;
  color: #f87171 !important;
  transition: all 0.2s ease !important;
}

.btn-action-delete:hover {
  background: #ef4444 !important;
  color: #ffffff !important;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4) !important;
  transform: scale(1.05);
}

/* Secure Drive Modal Download Container */
.secure-download-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 16px;
  margin-top: 14px;
}

/* ==========================================================================
   WOOCOMMERCE BULK ACTIONS & CHECKBOXES
   ========================================================================== */
.quiz-row-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

.book-card-checkbox-container {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  background: rgba(15, 23, 42, 0.8);
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.book-card-checkbox-container input {
  margin: 0;
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

.admin-book-category-path {
  min-width: 0;
  max-width: 100%;
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: 0.25px;
  text-transform: uppercase;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.category-drag-item,
.tree-folder-header,
.tree-item,
.sidebar-tree-header,
.sidebar-collapsible summary,
.category-tree button,
.category-tree a,
.category-checkbox-tree label {
  min-width: 0;
}

.category-drag-item span,
.tree-folder-header span,
.tree-item span,
.sidebar-tree-header span,
.sidebar-collapsible summary span,
.category-tree button span,
.category-tree a span,
.category-checkbox-tree label span {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bulk-action-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(6, 182, 212, 0.06);
  border: 1px dashed rgba(6, 182, 212, 0.3);
  padding: 10px 16px;
  border-radius: 12px;
  margin-bottom: 20px;
  animation: fadeIn 0.3s ease;
}

.bulk-modal-box {
  width: 100%;
  max-width: 1150px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 24px;
  animation: modalIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  color: var(--text-primary);
}

.bulk-modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.3fr;
  gap: 24px;
  margin: 20px 0;
}

@media (max-width: 1180px) {
  .bulk-modal-box {
    width: min(100%, calc(100vw - 24px));
    padding: 20px;
  }

  .bulk-modal-grid {
    grid-template-columns: minmax(220px, 1fr) minmax(280px, 1.15fr);
    gap: 16px;
  }

  .bulk-modal-col:nth-child(3) {
    grid-column: 1 / -1;
  }
}

@media (max-width: 992px) {
  .bulk-modal-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .bulk-modal-col:nth-child(3) {
    grid-column: auto;
  }
}

@media (max-width: 720px) {
  .bulk-modal-box {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    padding: 16px;
    border-radius: 14px;
  }

  .bulk-selected-item {
    gap: 10px;
  }

  .bulk-selected-item span {
    max-width: min(62vw, 360px);
  }
}

/* Compact mobile shop/test controls */
@media (max-width: 640px) {
  header .nav-container {
    padding: 12px 14px;
    gap: 10px;
  }

  header .logo-section {
    gap: 10px;
  }

  header .logo-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    font-size: 20px;
  }

  header .logo-text {
    max-width: 128px;
    font-size: 23px;
  }

  header .nav-actions {
    gap: 6px;
  }

  header .nav-actions .theme-toggle-btn,
  header .nav-actions .cart-toggle-btn,
  header .nav-actions .cart-btn,
  #header-user-badge-container .user-profile-badge {
    width: 42px;
    height: 42px;
    min-width: 42px;
  }

  #header-user-badge-container .user-avatar {
    width: 30px;
    height: 30px;
    min-width: 30px;
    font-size: 14px;
  }

  .coin-balance-pill,
  #header-coin-balance {
    min-width: 0;
    height: 42px;
    padding: 0 11px;
    font-size: 12px;
    white-space: nowrap;
  }

  header .nav-link {
    min-height: 46px;
    padding: 8px 6px;
    border-radius: 10px;
    font-size: 14px;
  }

  .sale-campaign-banner,
  .promo-banner {
    padding: 10px 14px;
  }

  .sale-campaign-banner {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .sale-campaign-banner strong {
    font-size: 13px;
  }

  .sale-campaign-banner span,
  .promo-banner span {
    font-size: 12px;
  }

  .sale-campaign-banner .btn,
  .promo-banner .btn {
    min-width: 84px;
    height: 38px;
    padding: 0 10px;
  }

  .dashboard-split-layout {
    gap: 14px !important;
  }

  #view-dashboard .dashboard-sidebar,
  #view-bookstore .dashboard-sidebar {
    padding: 10px !important;
    border-radius: 18px;
    margin-bottom: 2px;
  }

  #view-dashboard .dashboard-sidebar .sidebar-module,
  #view-bookstore .dashboard-sidebar .sidebar-module {
    padding: 12px !important;
    margin: 0 !important;
    border-radius: 14px;
  }

  #view-dashboard .dashboard-sidebar > .sidebar-module:first-child,
  #view-bookstore .dashboard-sidebar > .sidebar-module:first-child {
    display: grid;
    grid-template-columns: minmax(92px, auto) minmax(0, 1fr);
    align-items: center;
    gap: 10px;
  }

  #view-dashboard .dashboard-sidebar > .sidebar-module:first-child .sidebar-title,
  #view-bookstore .dashboard-sidebar > .sidebar-module:first-child .sidebar-title {
    margin: 0;
    font-size: 12px;
    line-height: 1.2;
    padding-left: 10px;
  }

  #view-dashboard .dashboard-sidebar > .sidebar-module:first-child .shop-sorting-wrapper,
  #view-bookstore .dashboard-sidebar > .sidebar-module:first-child .shop-sorting-wrapper {
    margin: 0 !important;
  }

  .shop-sort-select,
  #shop-sort-select,
  #bookstore-sort-select {
    height: 40px !important;
    padding: 0 38px 0 12px !important;
    font-size: 12.5px !important;
  }

  .sidebar-collapsible .sidebar-summary {
    min-height: 48px;
    padding: 0 12px !important;
    margin: 0 !important;
    font-size: 13px;
    border-bottom: 0 !important;
  }

  .sidebar-collapsible[open] .sidebar-summary {
    margin-bottom: 8px !important;
    border-bottom: 1px solid var(--glass-border) !important;
  }

  .sidebar-collapsible .category-tree {
    max-height: 34vh;
    overflow-y: auto;
    padding: 0 8px 10px !important;
    -webkit-overflow-scrolling: touch;
  }

  .category-item,
  .category-folder {
    min-height: 38px;
    padding-block: 8px;
    font-size: 12.5px;
  }

  .shop-top-bar {
    margin-top: 4px;
    margin-bottom: 14px !important;
    padding-bottom: 14px;
  }

  .shop-breadcrumbs {
    font-size: 12px;
    margin-bottom: 10px;
  }

  .shop-main-title {
    font-size: 32px !important;
    line-height: 1.08;
  }

  .shop-filter-summary {
    margin-top: 10px !important;
  }
}

@media (max-width: 430px) {
  header .logo-text {
    max-width: 104px;
    font-size: 21px;
  }

  header .nav-actions .theme-toggle-btn,
  header .nav-actions .cart-toggle-btn,
  header .nav-actions .cart-btn,
  #header-user-badge-container .user-profile-badge {
    width: 40px;
    height: 40px;
    min-width: 40px;
  }

  .coin-balance-pill,
  #header-coin-balance {
    height: 40px;
    padding: 0 9px;
    font-size: 11px;
  }
}

/* Vietnamese typography repair: use fonts with full Vietnamese accent coverage and avoid broken marks. */
body,
button,
input,
select,
textarea,
.btn,
.nav-link,
.logo-text,
.shop-main-title,
.sidebar-title,
.sidebar-module,
.sidebar-module *,
.sidebar-summary,
.sidebar-summary *,
.sidebar-tree-header,
.sidebar-tree-header *,
.sidebar-title,
.sidebar-title *,
.sidebar-module,
.sidebar-module *,
.sidebar-summary,
.sidebar-summary *,
.sidebar-collapsible summary,
.sidebar-collapsible summary *,
.category-tree,
.category-tree *,
.quiz-card-title,
.quiz-card-desc,
.quiz-tag,
.card-badge,
.results-count,
.tree-folder-header,
.tree-item,
.form-control,
.modal-content,
.modal-content * {
  font-family: var(--font-family) !important;
  text-rendering: geometricPrecision;
}

.sidebar-tree-header *,
.sidebar-collapsible summary,
.sidebar-collapsible summary *,
.category-tree *,
.quiz-tag,
.card-badge,
.results-count,
.shop-main-title,
.quiz-card-title,
.quiz-card-desc,
.nav-link,
.btn {
  letter-spacing: 0 !important;
}

.sidebar-tree-header,
.sidebar-collapsible summary {
  padding-left: 14px;
}

.sidebar-tree-header::before,
.sidebar-collapsible summary::before {
  left: 0 !important;
}

/* Header/account menu visual repair: keep dropdown above promo bands and use readable UI typography. */
header {
  z-index: 2500 !important;
  overflow: visible !important;
}

header .nav-container,
header .nav-actions,
#header-user-badge-container {
  overflow: visible !important;
}

#header-user-badge-container {
  position: relative !important;
  z-index: 2600 !important;
}

#header-user-badge-container,
#header-user-badge-container *,
#user-profile-dropdown,
#user-profile-dropdown * {
  font-family: var(--font-family) !important;
  letter-spacing: 0 !important;
  text-shadow: none !important;
}

#user-profile-dropdown {
  background: rgba(15, 23, 42, 0.98) !important;
  border: 1px solid rgba(148, 163, 184, 0.22) !important;
  border-radius: 14px !important;
  box-shadow: 0 22px 48px rgba(2, 6, 23, 0.48) !important;
  color: var(--text-primary) !important;
  line-height: 1.35 !important;
  overflow: visible !important;
  width: 244px !important;
  z-index: 5000 !important;
}

#user-profile-dropdown::before {
  display: none !important;
}

#user-profile-dropdown .btn {
  border-radius: 9px !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  min-height: 38px !important;
}

#user-profile-dropdown ion-icon {
  flex: 0 0 auto;
  font-size: 15px !important;
}

.sale-campaign-banner {
  z-index: 800 !important;
}

@media (max-width: 767px) {
  #user-profile-dropdown {
    left: 12px !important;
    right: 12px !important;
    top: 72px !important;
    width: auto !important;
  }
}

/* Header responsive repair for tablet/small desktop: center nav row and never split labels word-by-word. */
@media (max-width: 1180px) {
  header .nav-container {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    grid-template-areas:
      "brand actions"
      "nav nav" !important;
    align-items: center !important;
    gap: 12px 16px !important;
    justify-content: stretch !important;
    max-width: 100% !important;
    overflow: visible !important;
    padding: 14px 18px !important;
    width: 100% !important;
  }

  header .logo-section {
    grid-area: brand !important;
    min-width: 0 !important;
    width: fit-content !important;
  }

  header .logo-text {
    max-width: min(44vw, 260px) !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  header .logo-text span {
    display: inline !important;
    white-space: nowrap !important;
  }

  header .nav-actions {
    grid-area: actions !important;
    justify-content: flex-end !important;
    justify-self: end !important;
    min-width: 0 !important;
    width: auto !important;
  }

  header .nav-menu {
    grid-area: nav !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    justify-content: center !important;
    justify-self: center !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    padding: 2px 8px 0 !important;
    scrollbar-width: none !important;
    text-align: center !important;
    width: 100% !important;
  }

  header .nav-menu::-webkit-scrollbar {
    display: none !important;
  }

  header .nav-link {
    align-items: center !important;
    display: inline-flex !important;
    flex: 0 0 auto !important;
    font-size: 14.5px !important;
    justify-content: center !important;
    line-height: 1.2 !important;
    min-height: 42px !important;
    min-width: 0 !important;
    overflow: visible !important;
    padding: 9px 13px !important;
    text-align: center !important;
    white-space: nowrap !important;
    width: auto !important;
    word-break: keep-all !important;
  }

  body.admin-page header .nav-link {
    font-size: 14px !important;
    padding-inline: 12px !important;
  }
}

@media (max-width: 700px) {
  header .nav-container {
    gap: 10px 8px !important;
    padding: 12px 14px !important;
  }

  header .logo-text {
    max-width: 132px !important;
  }

  header .nav-menu {
    justify-content: center !important;
    padding-inline: 0 !important;
  }

  header .nav-link {
    font-size: 13.5px !important;
    min-height: 40px !important;
    padding: 8px 10px !important;
  }
}

@media (max-width: 520px) {
  header .nav-menu {
    justify-content: flex-start !important;
  }

  header .logo-text {
    max-width: 110px !important;
  }
}

@media (max-width: 900px) {
  .admin-feature-flag-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-height: 760px) {
  .bulk-modal-box {
    max-height: calc(100vh - 14px);
  }

  .bulk-modal-col {
    max-height: 38vh;
  }
}

.bulk-modal-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 18px;
  max-height: 480px;
  overflow-y: auto;
}

.bulk-modal-col::-webkit-scrollbar {
  width: 6px;
}
.bulk-modal-col::-webkit-scrollbar-track {
  background: transparent;
}
.bulk-modal-col::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.bulk-selected-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bulk-selected-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
}

.bulk-selected-item span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 250px;
  font-weight: 700;
}

.bulk-selected-remove {
  color: #ef4444;
  cursor: pointer;
  display: flex;
  align-items: center;
  font-size: 18px;
  transition: transform 0.2s ease;
}

.bulk-selected-remove:hover {
  transform: scale(1.2);
}

.category-checkbox-tree {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.category-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  padding: 2px 0;
}

.category-checkbox-item input {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

@media (max-width: 680px) {
  header .nav-container {
    justify-items: center;
  }

  header .nav-menu {
    justify-content: center;
    text-align: center;
    padding-inline: 8px;
    scroll-padding-inline: 16px;
  }

  header .nav-link {
    min-width: max-content;
    justify-content: center;
    white-space: nowrap;
  }

  header .nav-actions {
    justify-content: center;
    width: 100%;
  }
}

/* Mobile layout repair 2026-06-04 */
@media (max-width: 640px) {
  header .nav-container {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "nav nav";
    gap: 12px;
    align-items: center;
    justify-items: stretch;
    padding: 14px 16px;
  }

  header .logo-section {
    grid-area: brand;
    min-width: 0;
  }

  header .logo-icon {
    width: 54px;
    height: 54px;
    min-width: 54px;
    font-size: 22px;
  }

  header .logo-text {
    font-size: 28px;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  header .nav-actions {
    grid-area: actions;
    width: auto;
    justify-content: flex-end;
    gap: 8px;
  }

  header .nav-actions .theme-toggle-btn,
  header .nav-actions .cart-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
  }

  header .nav-menu {
    grid-area: nav;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 0;
    overflow: visible;
  }

  header .nav-link {
    width: 100%;
    min-width: 0;
    min-height: 54px;
    height: auto;
    padding: 10px 8px;
    justify-content: center;
    text-align: center;
    white-space: normal;
    line-height: 1.15;
    font-size: 15px;
  }

  #header-user-badge-container .user-profile-badge {
    width: 54px;
    height: 54px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
  }

  #header-user-badge-container .user-profile-badge > div:not(.user-avatar),
  #header-user-badge-container .user-profile-badge > ion-icon {
    display: none;
  }

  #header-user-badge-container .user-avatar {
    margin: 0;
  }

  .promo-banner {
    text-align: left;
  }

  .promo-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
  }

  .hero-content {
    text-align: center;
  }

  .hero .btn-group,
  .hero-actions,
  .hero-buttons {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    gap: 12px;
  }

  .hero .btn,
  .hero-actions .btn,
  .hero-buttons .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 380px) {
  header .logo-text {
    font-size: 24px;
  }

  header .nav-link {
    font-size: 14px;
  }
}

@media (max-width: 720px) {
  .admin-layout,
  .admin-main,
  .app-container,
  .main-content {
    max-width: 100%;
    overflow-x: hidden;
  }

  .dashboard-header {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 16px !important;
    align-items: start !important;
  }

  .dashboard-title h1 {
    font-size: clamp(34px, 12vw, 50px) !important;
    line-height: 1.05 !important;
    letter-spacing: 0 !important;
    word-break: normal;
  }

  .dashboard-title p {
    max-width: 100% !important;
    font-size: 18px !important;
    line-height: 1.5 !important;
  }

  #view-quizzes .dashboard-header > div:last-child,
  #view-products .dashboard-header > div:last-child {
    width: 100%;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    justify-content: stretch !important;
  }

  #view-quizzes .dashboard-header .btn,
  #view-products .dashboard-header .btn {
    width: 100%;
    min-height: 48px;
    justify-content: center !important;
    white-space: normal;
    text-align: center;
  }

  .glass-card,
  .control-panel,
  .table-container,
  .admin-card {
    max-width: 100%;
  }

  .table-wrapper,
  .table-responsive,
  .data-table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .data-table,
  .az-table,
  table.admin-table {
    min-width: 720px;
  }

  .data-table th,
  .data-table td,
  .az-table th,
  .az-table td,
  table.admin-table th,
  table.admin-table td {
    padding: 12px 10px;
    font-size: 13px;
    line-height: 1.35;
  }
}

/* Final mobile polish: keep filters useful without covering content */
@media (max-width: 640px) {
  header .nav-container {
    padding: 12px 14px !important;
    gap: 10px !important;
  }

  header .logo-icon {
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    font-size: 20px !important;
  }

  header .logo-text {
    max-width: 128px !important;
    font-size: 23px !important;
  }

  header .nav-actions {
    gap: 6px !important;
  }

  header .nav-actions .theme-toggle-btn,
  header .nav-actions .cart-toggle-btn,
  header .nav-actions .cart-btn,
  #header-user-badge-container .user-profile-badge {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
  }

  .coin-balance-pill,
  #header-coin-balance {
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 10px !important;
    font-size: 11.5px !important;
  }

  header .nav-link {
    min-width: 0 !important;
    min-height: 46px !important;
    padding: 8px 6px !important;
    border-radius: 10px !important;
    font-size: 14px !important;
    white-space: normal !important;
  }

  #view-dashboard .dashboard-sidebar,
  #view-bookstore .dashboard-sidebar {
    padding: 10px !important;
    border-radius: 18px !important;
    margin-bottom: 2px !important;
  }

  #view-dashboard .dashboard-sidebar .sidebar-module,
  #view-bookstore .dashboard-sidebar .sidebar-module {
    padding: 12px !important;
    margin: 0 !important;
    border-radius: 14px !important;
  }

  #view-dashboard .dashboard-sidebar > .sidebar-module:first-child,
  #view-bookstore .dashboard-sidebar > .sidebar-module:first-child {
    display: grid !important;
    grid-template-columns: minmax(88px, auto) minmax(0, 1fr) !important;
    align-items: center !important;
    gap: 10px !important;
  }

  #view-dashboard .dashboard-sidebar > .sidebar-module:first-child .sidebar-title,
  #view-bookstore .dashboard-sidebar > .sidebar-module:first-child .sidebar-title {
    margin: 0 !important;
    padding-left: 10px !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
  }

  #view-dashboard .dashboard-sidebar > .sidebar-module:first-child .shop-sorting-wrapper,
  #view-bookstore .dashboard-sidebar > .sidebar-module:first-child .shop-sorting-wrapper {
    margin: 0 !important;
  }

  #shop-sort-select,
  #bookstore-sort-select,
  .shop-sort-select {
    height: 40px !important;
    padding: 0 34px 0 12px !important;
    font-size: 12.5px !important;
  }

  .sidebar-collapsible .sidebar-summary {
    min-height: 48px !important;
    padding: 0 12px !important;
    margin: 0 !important;
    border-bottom: 0 !important;
    font-size: 13px !important;
  }

  .sidebar-collapsible[open] .sidebar-summary {
    margin-bottom: 8px !important;
    border-bottom: 1px solid var(--glass-border) !important;
  }

  .sidebar-collapsible .category-tree {
    max-height: 34vh !important;
    overflow-y: auto !important;
    padding: 0 8px 10px !important;
  }

  .shop-top-bar {
    margin-top: 4px !important;
    margin-bottom: 14px !important;
    padding-bottom: 14px !important;
  }

  .shop-main-title {
    font-size: 32px !important;
    line-height: 1.08 !important;
  }
}

@media (max-width: 430px) {
  header .logo-text {
    max-width: 104px !important;
    font-size: 21px !important;
  }

  header .nav-actions .theme-toggle-btn,
  header .nav-actions .cart-toggle-btn,
  header .nav-actions .cart-btn,
  #header-user-badge-container .user-profile-badge {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
  }

  .coin-balance-pill,
  #header-coin-balance {
    height: 40px !important;
    min-height: 40px !important;
    padding: 0 8px !important;
    font-size: 11px !important;
  }
}

/* Final Vietnamese typography guard. Keep this at the end of the file. */
body,
button,
input,
select,
textarea,
.btn,
.nav-link,
.logo-text,
.shop-main-title,
.sidebar-title,
.sidebar-title *,
.sidebar-module,
.sidebar-module *,
.sidebar-summary,
.sidebar-summary *,
.sidebar-tree-header,
.sidebar-tree-header *,
.sidebar-collapsible summary,
.sidebar-collapsible summary *,
.category-tree,
.category-tree *,
.quiz-card-title,
.quiz-card-desc,
.quiz-tag,
.card-badge,
.results-count,
.tree-folder-header,
.tree-item,
.form-control,
.modal-content,
.modal-content * {
  font-family: var(--font-family) !important;
  text-rendering: geometricPrecision;
}

.sidebar-title,
.sidebar-title *,
.sidebar-summary,
.sidebar-summary *,
.sidebar-tree-header *,
.sidebar-collapsible summary,
.sidebar-collapsible summary *,
.category-tree *,
.quiz-tag,
.card-badge,
.results-count,
.shop-main-title,
.quiz-card-title,
.quiz-card-desc,
.nav-link,
.btn {
  letter-spacing: 0 !important;
}

.sidebar-title,
.sidebar-summary,
.sidebar-tree-header,
.sidebar-collapsible summary {
  padding-left: 14px;
}

body {
  --theme-primary-glow: var(--primary);
  --theme-accent: var(--accent);
  --theme-bg-secondary: var(--bg-tertiary);
  --theme-glass-bg: rgba(255, 255, 255, 0.03);
  --theme-font-family: var(--font-family);
  --theme-border-radius: 12px;
  --theme-border-style: solid;
  --theme-border-glow: none;
}

body[class*="theme-"] {
  font-family: var(--theme-font-family), var(--font-family) !important;
}

body[class*="theme-"] .glass-card {
  background: var(--theme-glass-bg) !important;
  border-style: var(--theme-border-style) !important;
  border-radius: var(--theme-border-radius) !important;
  box-shadow: var(--theme-border-glow) !important;
}

body[class*="theme-"] .btn-primary {
  background: linear-gradient(135deg, var(--theme-primary-glow), var(--theme-accent)) !important;
  border-radius: var(--theme-border-radius) !important;
}

body[class*="theme-"] .tree-folder-header.active,
body[class*="theme-"] .tree-item.active {
  background: var(--theme-glass-bg) !important;
  border-left: 3px solid var(--theme-accent) !important;
  color: var(--theme-accent) !important;
}

/* Final mobile header guard: keep the four main tabs inside the viewport. */
@media (max-width: 640px) {
  header .nav-container {
    max-width: 100vw !important;
    overflow-x: clip !important;
  }

  header .nav-menu {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    justify-content: stretch !important;
    overflow: visible !important;
    padding: 0 !important;
    width: 100% !important;
  }

  header .nav-link {
    min-width: 0 !important;
    width: 100% !important;
    white-space: normal !important;
    overflow-wrap: normal !important;
    word-break: keep-all !important;
  }

  .seasonal-effects {
    max-width: 100vw !important;
  }
}

/* Mobile scroll behavior and book detail hardening. Keep after prior mobile guards. */
@media (max-width: 640px) {
  header {
    transition: background-color .22s ease, border-color .22s ease, transform .22s ease !important;
  }

  header .nav-menu {
    max-height: 112px !important;
    opacity: 1 !important;
    transform: translateY(0) !important;
    transition: max-height .24s ease, opacity .18s ease, transform .22s ease, margin .22s ease !important;
  }

  body.mobile-nav-collapsed header .nav-container {
    gap: 0 !important;
    padding-bottom: 8px !important;
  }

  body.mobile-nav-collapsed header .nav-menu {
    max-height: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(-8px) !important;
    margin-top: 0 !important;
    overflow: hidden !important;
  }

  #modal-book-detail {
    align-items: stretch !important;
    justify-content: stretch !important;
    padding: 8px !important;
    overflow: hidden !important;
    background: rgba(8, 12, 22, .94) !important;
    backdrop-filter: blur(18px) !important;
    -webkit-backdrop-filter: blur(18px) !important;
  }

  #modal-book-detail .modal-box {
    width: 100% !important;
    max-width: none !important;
    height: calc(100dvh - 16px) !important;
    max-height: calc(100dvh - 16px) !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 16px !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: auto minmax(0, 1fr) !important;
    gap: 14px !important;
    overflow: hidden !important;
    border-radius: 14px !important;
  }

  #modal-book-detail .modal-box > button.theme-toggle-btn {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    z-index: 4 !important;
    background: rgba(15, 23, 42, .9) !important;
  }

  #modal-book-detail .modal-box > div:first-of-type {
    min-height: 0 !important;
    gap: 10px !important;
  }

  #modal-book-detail .detail-main-image-frame {
    aspect-ratio: 16 / 11 !important;
    max-height: 34dvh !important;
    border-radius: 10px !important;
  }

  #modal-book-detail #detail-main-img {
    object-fit: contain !important;
    background: rgba(0, 0, 0, .18) !important;
  }

  #modal-book-detail #detail-thumbnails-container {
    max-height: 56px !important;
    overflow-y: hidden !important;
  }

  #modal-book-detail .modal-box > div:nth-of-type(2) {
    min-height: 0 !important;
    height: 100% !important;
    overflow-y: auto !important;
    padding-right: 2px !important;
    padding-bottom: 4px !important;
    justify-content: flex-start !important;
  }

  #modal-book-detail #detail-book-category {
    margin-right: 42px !important;
  }

  #modal-book-detail h2,
  #modal-book-detail #detail-book-title {
    font-size: 19px !important;
    line-height: 1.22 !important;
    margin-bottom: 10px !important;
    padding-right: 36px !important;
  }

  #modal-book-detail #detail-book-desc {
    font-size: 13px !important;
    line-height: 1.5 !important;
  }

  #modal-book-detail #detail-book-bundle-container {
    margin-bottom: 14px !important;
  }

  #modal-book-detail #detail-book-bundle-container > div:nth-child(2) {
    max-height: min(28dvh, 210px) !important;
  }

  #modal-book-detail .modal-box > div:nth-of-type(2) > div:last-child {
    position: sticky !important;
    bottom: -4px !important;
    z-index: 3 !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    align-items: stretch !important;
    margin-top: 12px !important;
    padding: 12px 0 0 !important;
    background: linear-gradient(180deg, rgba(15, 23, 42, .82), rgba(15, 23, 42, .98) 34%) !important;
  }

  #modal-book-detail #detail-book-price-display {
    font-size: 20px !important;
  }

  #modal-book-detail #detail-book-cta-container,
  #modal-book-detail #detail-book-cta-container > div,
  #modal-book-detail #detail-book-cta-container .btn {
    width: 100% !important;
  }
}

.quiz-group-layout .passage-box {
  width: 100%;
}

@media (min-width: 768px) {
  .quiz-group-layout .passage-box {
    max-height: 320px !important;
  }

  .quiz-group-layout .statements-box {
    max-height: 460px !important;
  }
}

@media (max-width: 767px) {
  .quiz-group-layout {
    grid-template-columns: 1fr !important;
  }

  .quiz-group-layout .passage-box {
    max-height: 46vh !important;
    min-height: 220px !important;
  }

  .quiz-group-layout .statements-box {
    max-height: none !important;
  }
}
