/* ==========================================================================
   MiniMind Design System & Modern Responsive Stylesheet
   Theme: Vibrant Indigo / Deep Violet Slate (Dark/Light mode native)
   ========================================================================== */

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

:root {
  /* Default Theme: Light Mode (Dyslexia Friendly & Accessible) */
  --bg-primary: #F1F5F9;       /* Requested App Background */
  --bg-secondary: #FFFFFF;     /* Container / Card Background */
  --bg-tertiary: #E2E8F0;      /* Secondary Component Background */
  --bg-glass: rgba(241, 245, 249, 0.85);
  --bg-glass-card: rgba(255, 255, 255, 0.92);

  /* Flashcard Specific (Soft Warm Off-white #FFFDF0 & High-Contrast Dyslexia Friendly Text #111827) */
  --card-bg: #FFFDF0;          /* Requested Flashcard Background */
  --card-text: #111827;        /* Requested Flashcard Text Color */
  --card-border: #E2E8F0;
  --card-shadow: 0 10px 30px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);

  --accent-primary: #4F46E5;
  --accent-primary-hover: #4338CA;
  --accent-gradient: linear-gradient(135deg, #4F46E5 0%, #7C3AED 50%, #EC4899 100%);
  --accent-gradient-hover: linear-gradient(135deg, #4338CA 0%, #6D28D9 50%, #DB2777 100%);

  --success: #059669;
  --warning: #D97706;
  --danger: #DC2626;
  --info: #2563EB;

  --text-primary: #1E293B;
  --text-secondary: #475569;
  --text-muted: #64748B;

  --border-color: rgba(0, 0, 0, 0.08);
  --border-color-hover: rgba(79, 70, 229, 0.4);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 16px 36px rgba(15, 23, 42, 0.1);
  --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.25);

  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Explicit Light Theme */
[data-theme="light"] {
  --bg-primary: #F1F5F9;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #E2E8F0;
  --bg-glass: rgba(241, 245, 249, 0.85);
  --bg-glass-card: rgba(255, 255, 255, 0.92);

  --card-bg: #FFFDF0;
  --card-text: #111827;
  --card-border: #E2E8F0;
  --card-shadow: 0 10px 30px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);

  --accent-primary: #4F46E5;
  --accent-primary-hover: #4338CA;
  --accent-gradient: linear-gradient(135deg, #4F46E5 0%, #7C3AED 50%, #EC4899 100%);
  --accent-gradient-hover: linear-gradient(135deg, #4338CA 0%, #6D28D9 50%, #DB2777 100%);

  --success: #059669;
  --warning: #D97706;
  --danger: #DC2626;
  --info: #2563EB;

  --text-primary: #1E293B;
  --text-secondary: #475569;
  --text-muted: #64748B;

  --border-color: rgba(0, 0, 0, 0.08);
  --border-color-hover: rgba(79, 70, 229, 0.4);

  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 16px 36px rgba(15, 23, 42, 0.1);
  --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.25);
}

/* Dark Theme Variables */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-glass: rgba(30, 41, 59, 0.75);
  --bg-glass-card: rgba(30, 41, 59, 0.85);

  --card-bg: #1e293b;
  --card-text: #f8fafc;
  --card-border: rgba(255, 255, 255, 0.1);
  --card-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);

  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
  --accent-gradient-hover: linear-gradient(135deg, #4f46e5 0%, #9333ea 50%, #db2777 100%);

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --border-color: rgba(255, 255, 255, 0.1);
  --border-color-hover: rgba(99, 102, 241, 0.4);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.35);
}

/* Global Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Background Ambient Glow Effects */
body::before {
  content: '';
  position: fixed;
  top: -150px;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 400px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(168, 85, 247, 0.08) 50%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.gradient-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Layout */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.content-area {
  flex: 1;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* Header & Glass Navbar */
.glass-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.logo-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: var(--shadow-glow);
  padding: 6px;
  overflow: hidden;
}

.logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.logo-icon svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
}

.brand-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-item {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: var(--transition-fast);
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.nav-item:hover, .nav-item.active {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.nav-item.active {
  color: var(--accent-primary);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Language Switcher */
.lang-selector-dropdown {
  position: relative;
}

.btn-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 1.1rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-theme-toggle:hover {
  border-color: var(--accent-primary);
  background: var(--bg-tertiary);
  transform: scale(1.05);
}

.btn-lang {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-lang:hover {
  border-color: var(--accent-primary);
}

.lang-menu {
  position: absolute;
  top: 110%;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  min-width: 160px;
  overflow: hidden;
  z-index: 1000;
}

.lang-menu.show {
  display: flex;
}

.lang-menu button {
  padding: 0.65rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lang-menu button:hover {
  background: var(--bg-tertiary);
  color: var(--accent-primary);
}

/* Buttons System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition-normal);
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: var(--accent-gradient-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-secondary);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.btn-outline {
  background: transparent;
  color: var(--accent-primary);
  border: 1.5px solid var(--accent-primary);
}

.btn-outline:hover {
  background: rgba(99, 102, 241, 0.1);
}

.btn-sm {
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.1rem;
  border-radius: var(--radius-lg);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-indigo { background: rgba(99, 102, 241, 0.15); color: #818cf8; border: 1px solid rgba(99, 102, 241, 0.3); }
.badge-green  { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-amber  { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-rose   { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }

/* Glass Cards */
.glass-card {
  background: var(--bg-glass-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  transition: var(--transition-normal);
}

.glass-card:hover {
  border-color: var(--border-color-hover);
}

/* Landing Page / Portal Switcher Hero */
.hero-section {
  text-align: center;
  padding: 3rem 1rem 2rem;
  max-width: 800px;
  margin: 0 auto;
}

.hero-title {
  font-size: 3rem;
  line-height: 1.15;
  margin-bottom: 1rem;
}

.hero-subtitle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 2.5rem;
}

.portal-switch-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.75rem;
  margin-top: 2rem;
}

.portal-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  border: 2px solid var(--border-color);
  transition: var(--transition-normal);
}

.portal-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow);
  border-color: var(--accent-primary);
}

.portal-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.portal-title {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.portal-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

/* Form Styles */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.2rem;
}

.form-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Form Dropdown Option Styling for Dark Theme */
.form-input option, .form-select option, select option {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  padding: 0.5rem;
}

/* Modal Windows */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 540px;
  width: 100%;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal-box {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.5rem;
}

.modal-close:hover { color: var(--text-primary); }

/* Dashboard Grids */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-val {
  font-size: 1.8rem;
  font-family: var(--font-heading);
  font-weight: 800;
  line-height: 1.1;
}

.stat-lbl {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Flashcard Study Area & FSRS Engine UI */
.study-container {
  max-width: 680px;
  margin: 0 auto;
}

.study-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 2rem;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent-gradient);
  width: 0%;
  transition: width 0.3s ease;
}

/* 3D Flip Card Effect */
.card-perspective {
  perspective: 1000px;
  -webkit-perspective: 1000px;
  width: 100%;
  min-height: 320px;
  margin-bottom: 1.25rem;
}

.flashcard-3d {
  width: 100%;
  height: 100%;
  min-height: 320px;
  position: relative;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.flashcard-3d.flipped {
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
}

/* WebKit / Safari iOS & iPadOS 3D Card Flip Bleed-Through Bug Fix */
.flashcard-3d.flipped .card-front {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  z-index: 1 !important;
}

.flashcard-3d.flipped .card-front * {
  visibility: hidden !important;
  animation: none !important;
}

.flashcard-3d.flipped .card-back {
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  z-index: 2 !important;
}

.flashcard-3d:not(.flipped) .card-back {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  z-index: 1 !important;
}

.flashcard-3d:not(.flipped) .card-back * {
  visibility: hidden !important;
  animation: none !important;
}

.flashcard-3d:not(.flipped) .card-front {
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  z-index: 2 !important;
}

@keyframes cardShakeError {
  0%, 100% { transform: rotateY(180deg) translateX(0); }
  15%, 45%, 75% { transform: rotateY(180deg) translateX(-12px) rotate(-1.5deg); }
  30%, 60%, 90% { transform: rotateY(180deg) translateX(12px) rotate(1.5deg); }
}

.flashcard-3d.shake-error {
  animation: cardShakeError 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.flashcard-3d.shake-error .card-face {
  box-shadow: 0 0 35px rgba(239, 68, 68, 0.6) !important;
  border-color: #ef4444 !important;
}

.flashcard-3d.glow-success .card-face {
  box-shadow: 0 0 35px rgba(16, 185, 129, 0.6) !important;
  border-color: #10b981 !important;
}

.flashcard-3d.glow-warning .card-face {
  box-shadow: 0 0 35px rgba(245, 158, 11, 0.6) !important;
  border-color: #f59e0b !important;
}

/* Visual Splitsboom / Number Bond Component */
.splitsboom-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0.5rem 0;
  width: 100%;
}

.splitsboom-top-box {
  width: 72px;
  height: 60px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-family: var(--font-heading);
  font-weight: 800;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.25);
}

.splitsboom-legs-svg {
  width: 170px;
  height: 40px;
  margin: 0.15rem 0;
}

.splitsboom-bottom-row {
  display: flex;
  justify-content: space-between;
  width: 190px;
}

.splitsboom-bottom-box {
  width: 68px;
  height: 56px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-family: var(--font-heading);
  font-weight: 800;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.splitsboom-bottom-box.missing {
  border: 2px dashed var(--accent-primary);
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-primary);
}

.splitsboom-bottom-box.filled-solution {
  border: 2px solid var(--success);
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.5);
}

/* Bridge Math Visual Component */
.bridge-math-container {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 0.8rem;
  width: 100%;
}

.bridge-math-inline-term {
  font-size: 2.5rem;
  font-family: var(--font-heading);
  font-weight: 800;
  color: var(--text-primary);
  height: 44px;
  line-height: 44px;
  display: flex;
  align-items: center;
}

.bridge-splitsboom {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  margin: 0 0.1rem;
  width: auto !important;
}

.splitsboom-top-box.bridge-top {
  width: 50px;
  height: 44px;
  font-size: 1.8rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 3px 10px rgba(99, 102, 241, 0.3);
}

.splitsboom-legs-svg.bridge-svg {
  width: 100px;
  height: 28px;
  margin: 0.05rem 0;
}

.splitsboom-bottom-row.bridge-row {
  width: 108px;
  gap: 0.5rem;
  justify-content: center;
}

.splitsboom-bottom-box.bridge-box.bridge-input {
  width: 44px;
  height: 38px;
  font-size: 1.35rem;
  font-family: var(--font-heading);
  font-weight: 800;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  border: 2px dashed var(--accent-primary);
  color: var(--text-primary);
  text-align: center;
  outline: none;
  cursor: text;
  transition: all 0.2s ease;
}

.splitsboom-bottom-box.bridge-box.bridge-input::placeholder {
  color: var(--accent-primary);
  opacity: 0.6;
}

@keyframes activeBoxPulse {
  0% {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.6), 0 0 14px rgba(99, 102, 241, 0.6);
    transform: scale(1.06);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(168, 85, 247, 0.85), 0 0 24px rgba(168, 85, 247, 0.9);
    transform: scale(1.13);
  }
  100% {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.6), 0 0 14px rgba(99, 102, 241, 0.6);
    transform: scale(1.06);
  }
}

.splitsboom-bottom-box.bridge-box.active-target,
.math-inline-box.active-target {
  border-style: solid !important;
  border-width: 3px !important;
  border-color: #6366f1 !important;
  background: rgba(99, 102, 241, 0.28) !important;
  color: #ffffff !important;
  animation: activeBoxPulse 1.5s infinite ease-in-out !important;
  z-index: 10;
}

/* Inline Math Answer Box for Equations */
.math-inline-box {
  min-width: 64px;
  height: 56px;
  padding: 0 0.8rem;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2.1rem;
  font-family: var(--font-heading);
  font-weight: 800;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.math-inline-box.missing {
  border: 2px dashed var(--accent-primary);
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-primary);
}

.math-inline-box.filled-solution {
  border: 2px solid var(--success);
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.5);
}

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--card-bg);
  color: var(--card-text);
  border: 2px solid var(--card-border);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  box-sizing: border-box;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.card-face::-webkit-scrollbar {
  display: none;
}

/* Mobile Responsive Scaling for Math & Language Cards */
@media (max-width: 640px) {
  body.view-study {
    overflow: hidden !important;
  }

  .study-header {
    margin-bottom: 0.4rem !important;
  }

  .progress-bar-container {
    margin-bottom: 0.5rem !important;
  }

  .card-perspective, .flashcard-3d {
    min-height: 220px !important;
    margin-bottom: 0.4rem !important;
  }

  .card-face {
    padding: 0.4rem 0.6rem !important;
    justify-content: center !important;
    overflow: hidden !important;
  }

  .card-prompt-word {
    font-size: 1.6rem !important;
    margin-bottom: 0.15rem !important;
  }

  .card-hint-badge {
    font-size: 0.75rem !important;
    padding: 0.15rem 0.5rem !important;
    margin-bottom: 0.25rem !important;
  }

  .card-sentence-context {
    font-size: 0.78rem !important;
    margin-top: 0.25rem !important;
  }

  .splitsboom-container {
    margin: 0.15rem 0 !important;
  }

  .splitsboom-top-box {
    width: 64px !important;
    height: 50px !important;
    font-size: 1.75rem !important;
  }

  .splitsboom-legs-svg {
    width: 140px !important;
    height: 32px !important;
    margin: 0.05rem 0 !important;
  }

  .splitsboom-bottom-row {
    width: 155px !important;
  }

  .splitsboom-bottom-box {
    width: 56px !important;
    height: 46px !important;
    font-size: 1.55rem !important;
  }

  .math-inline-box {
    min-width: 54px !important;
    height: 48px !important;
    font-size: 1.8rem !important;
  }
}

.card-face.card-back {
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
  border-color: var(--accent-primary);
}

.card-prompt-word {
  font-family: var(--font-heading);
  font-size: 2.4rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
  word-break: break-word;
}

.card-hint-badge {
  font-size: 0.85rem;
  color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.12);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.card-sentence-context {
  font-style: italic;
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 90%;
  margin-top: 0.5rem;
}

/* FSRS Rating Buttons (Again, Hard, Good, Easy) */
.fsrs-button-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  width: 100%;
}

.btn-rating {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.85rem 0.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-rating:hover {
  transform: translateY(-2px);
}

.btn-rating.again { border-color: var(--danger); }
.btn-rating.again:hover { background: rgba(239, 68, 68, 0.15); }
.btn-rating.hard  { border-color: var(--warning); }
.btn-rating.hard:hover  { background: rgba(245, 158, 11, 0.15); }
.btn-rating.good  { border-color: var(--accent-primary); }
.btn-rating.good:hover  { background: rgba(99, 102, 241, 0.15); }
.btn-rating.easy  { border-color: var(--success); }
.btn-rating.easy:hover  { background: rgba(16, 185, 129, 0.15); }

.rating-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 0.2rem; }
.rating-interval { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }

/* Tables */
.custom-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.custom-table th, .custom-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.custom-table th {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 2000;
}

.toast {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  animation: slideIn 0.3s ease;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error   { border-left: 4px solid var(--danger); }
.toast-info    { border-left: 4px solid var(--info); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* Responsive Media Queries */
@media (max-width: 768px), (max-height: 720px) {
  .hero-title { font-size: 2.2rem; }
  .fsrs-button-grid { grid-template-columns: repeat(2, 1fr); }
  .glass-header { padding: 0.6rem 1rem; }
  .nav-links { display: none; }
  .content-area { padding: 1rem 0.75rem 2rem; }

  /* Mobile Flashcard Compact Adaptations for Virtual Keyboards */
  .study-container { padding: 0 0.25rem; }
  .progress-bar-container { margin-bottom: 0.75rem; height: 6px; }
  .study-header { margin-bottom: 0.6rem; }
  .card-perspective, .flashcard-3d { min-height: 180px; margin-bottom: 0.85rem; }
  .card-face { padding: 1rem 0.75rem; }
  .card-prompt-word { font-size: 1.8rem; margin-bottom: 0.2rem; }
  .card-hint-badge { font-size: 0.78rem; padding: 0.15rem 0.6rem; margin-bottom: 0.35rem; }
  .card-sentence-context { font-size: 0.82rem; margin-top: 0.35rem; max-width: 95%; }
  .card-face p[style*="margin-top:2rem"] { margin-top: 0.5rem !important; font-size: 0.78rem !important; }

  /* Input box & button compactness */
  .glass-card { padding: 0.9rem !important; margin-bottom: 0.85rem !important; }
  .form-group { margin-bottom: 0.4rem !important; }
  .form-input { padding: 0.5rem 0.75rem !important; font-size: 0.95rem !important; }
}

/* ==========================================================================
   Hoe Werkt MiniMind? (Science-Based Learning & Forgetting Curve Styles)
   ========================================================================== */

.how-it-works-page {
  padding-bottom: 4rem;
  animation: fadeIn 0.3s ease;
}

.hiw-container {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 0 1rem;
  box-sizing: border-box;
}

/* Sub-nav breadcrumbs & quick anchors */
.hiw-subnav {
  position: sticky;
  top: 72px;
  z-index: 90;
  margin-bottom: 2rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.hiw-subnav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.hiw-anchors {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.hiw-anchors a {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition-fast);
}

.hiw-anchors a:hover {
  color: var(--accent-primary);
}

/* Hero Section */
.hiw-hero {
  padding: 2.5rem 0 3.5rem;
}

.hiw-hero-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 2.5rem;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
}

.hiw-hero-content {
  min-width: 0;
  box-sizing: border-box;
}

.hiw-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  margin-bottom: 1.25rem;
}

.hiw-eyebrow-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-primary);
  animation: pulse 2s infinite;
}

.hiw-title {
  font-family: var(--font-heading);
  font-size: clamp(2.2rem, 3.8vw, 3.2rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin: 0 0 1.25rem;
}

.hiw-title em {
  font-style: normal;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hiw-lead {
  font-size: 1.1rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1.75rem;
}

.hiw-buttons {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.hiw-note {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Forgetting Curve Interactive Card */
.hiw-curve-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.hiw-card-head {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.85rem;
}

.hiw-kicker {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-primary);
  margin-bottom: 0.15rem;
}

.hiw-card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 0.2rem;
}

.hiw-card-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

.hiw-status-bar {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
}

.hiw-status {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
  transition: var(--transition-normal);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .hiw-status {
  border-color: rgba(255, 255, 255, 0.1);
}

/* Chart Canvas Area */
.hiw-chart-wrap {
  margin-top: 1.25rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.hiw-chart {
  height: 270px;
  position: relative;
  border-left: 2px solid var(--border-color);
  border-bottom: 2px solid var(--border-color);
  background: repeating-linear-gradient(to top, transparent 0, transparent 53px, rgba(0, 0, 0, 0.03) 54px);
  cursor: crosshair;
  border-radius: 0 0 0 4px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

[data-theme="dark"] .hiw-chart {
  background: repeating-linear-gradient(to top, transparent 0, transparent 53px, rgba(255, 255, 255, 0.04) 54px);
}

.hiw-chart svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.hiw-axis-y {
  position: absolute;
  left: -34px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
}

.hiw-axis-y-100 {
  top: -6px;
}

.hiw-axis-y-75 {
  top: 33.33%;
  transform: translateY(-50%);
}

.hiw-axis-y-50 {
  top: 66.67%;
  transform: translateY(-50%);
}

.hiw-axis-y-25 {
  bottom: -6px;
}

.hiw-axis-x-container {
  position: relative;
  margin-top: 6px;
  padding-bottom: 0.5rem;
  width: 100%;
  box-sizing: border-box;
}

.hiw-axis-x-ticks {
  position: relative;
  width: 100%;
  height: 18px;
}

.hiw-tick {
  position: absolute;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

.hiw-tick:first-child {
  transform: translateX(0);
  align-items: flex-start;
}

.hiw-tick:last-child {
  transform: translateX(-100%);
  align-items: flex-end;
}

.hiw-axis-x-label {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

.hiw-tooltip {
  position: absolute;
  display: none;
  transform: translate(-50%, -115%);
  background: #111827;
  color: #ffffff;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.15);
  z-index: 10;
}

#hiw-slider-halo {
  animation: hiwPulse 2s infinite ease-in-out;
  transform-origin: center;
}

@keyframes hiwPulse {
  0% { r: 10; opacity: 0.8; }
  50% { r: 16; opacity: 0.25; }
  100% { r: 10; opacity: 0.8; }
}

#hiw-slider-dot {
  filter: drop-shadow(0 2px 6px rgba(239, 68, 68, 0.6));
}

.hiw-legend {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.hiw-legend span {
  display: flex;
  align-items: center;
}

.hiw-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.4rem;
}

.hiw-controls {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  box-sizing: border-box;
}

.hiw-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
  font-weight: 700;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.hiw-controls input[type="range"] {
  width: 100%;
  accent-color: var(--accent-primary);
  cursor: pointer;
  margin: 0.4rem 0;
}

.hiw-slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 0.25rem;
}

/* Sections General */
.hiw-section {
  padding: 4.5rem 0;
  border-top: 1px solid var(--border-color);
}

.hiw-section-head {
  max-width: 800px;
  margin-bottom: 2.75rem;
}

.hiw-section-head h2 {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 3.2vw, 2.5rem);
  line-height: 1.15;
  margin: 0.4rem 0 0.85rem;
}

.hiw-section-head h2 em {
  font-style: normal;
  color: var(--accent-primary);
}

.hiw-section-head p {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

/* Cards Grid */
.hiw-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 1.5rem;
  width: 100%;
  box-sizing: border-box;
}

.hiw-info-card {
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  box-sizing: border-box;
}

.hiw-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 1.25rem;
}

.hiw-info-card h3 {
  font-size: 1.25rem;
  margin: 0 0 0.6rem;
  font-weight: 700;
}

.hiw-info-card p {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 0 0 1.25rem;
}

.hiw-card-footer-metric {
  margin-top: auto;
}

/* Dark Engine Section */
.hiw-dark-section {
  background: #0f172a;
  color: #ffffff;
}

[data-theme="dark"] .hiw-dark-section {
  background: #090d16;
}

.hiw-dark-section .hiw-section-head h2 {
  color: #ffffff;
}

.hiw-dark-section .hiw-section-head p {
  color: #94a3b8;
}

.hiw-engine-grid {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 2rem;
  width: 100%;
  box-sizing: border-box;
}

.hiw-engine-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: var(--radius-lg);
  padding: 2rem;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.hiw-engine-card h3 {
  font-size: 1.5rem;
  color: #ffffff;
  margin: 0.4rem 0 0.85rem;
}

.hiw-engine-card p {
  color: #cbd5e1;
  font-size: 0.92rem;
  line-height: 1.55;
}

.hiw-metrics-list {
  margin-top: 1.5rem;
}

.hiw-metric-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 0;
  border-top: 1px solid #334155;
  min-width: 0;
  box-sizing: border-box;
}

.hiw-metric-row:first-of-type {
  border-top: none;
}

.hiw-metric-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.hiw-metric-row strong {
  display: block;
  font-size: 0.95rem;
  color: #ffffff;
}

.hiw-metric-row small {
  color: #94a3b8;
  font-size: 0.82rem;
  line-height: 1.35;
  display: block;
}

.hiw-memory-card {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.hiw-memory-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.hiw-progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.hiw-progress-bar span {
  display: block;
  height: 100%;
  background: var(--accent-primary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.hiw-review-timeline {
  margin-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  padding-top: 0.75rem;
}

.hiw-timeline-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.88rem;
  min-width: 0;
  gap: 0.5rem;
}

.hiw-timeline-item:last-child {
  border-bottom: none;
}

.hiw-timeline-item small {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* Age Grid */
.hiw-age-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 1.5rem;
  width: 100%;
  box-sizing: border-box;
}

.hiw-age-card {
  padding: 1.75rem;
  min-width: 0;
  box-sizing: border-box;
}

.hiw-age-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  color: #6366f1;
  background: rgba(99, 102, 241, 0.1);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  margin-bottom: 0.75rem;
}

.hiw-age-card h3 {
  font-size: 1.3rem;
  margin: 0 0 0.5rem;
}

.hiw-age-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0 0 1.25rem;
}

.hiw-mockup-box {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.hiw-mockup-header {
  font-weight: 700;
  font-size: 0.88rem;
  margin-bottom: 0.4rem;
}

.hiw-mockup-emojis {
  font-size: 1.5rem;
  margin: 0.6rem 0;
  text-align: center;
}

.hiw-mockup-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.82rem;
  gap: 0.5rem;
}

.hiw-mockup-row:last-child {
  border-bottom: none;
}

/* Teacher Grid */
.hiw-teacher-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 1.75rem;
  width: 100%;
  box-sizing: border-box;
}

.hiw-perspective-card {
  padding: 2rem;
  min-width: 0;
  box-sizing: border-box;
}

.hiw-perspective-card h3 {
  font-size: 1.4rem;
  margin: 0.35rem 0 0.75rem;
}

.hiw-perspective-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0 0 1.25rem;
}

.hiw-quote-box {
  background: rgba(99, 102, 241, 0.08);
  border-left: 4px solid var(--accent-primary);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-weight: 600;
  font-size: 0.9rem;
}

/* CTA Section */
.hiw-cta-section {
  padding: 4rem 0 2rem;
}

.hiw-cta-box {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(168, 85, 247, 0.08));
  border: 2px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-lg);
  padding: 3.5rem 2rem;
  text-align: center;
  min-width: 0;
  box-sizing: border-box;
}

.hiw-cta-box h2 {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 3.5vw, 2.75rem);
  margin: 0 auto 0.85rem;
  max-width: 700px;
  line-height: 1.15;
}

.hiw-cta-box p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 2rem;
}

.hiw-cta-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Home View Banner Card */
.how-it-works-banner {
  cursor: pointer;
  margin-top: 2.25rem;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  border: 1.5px solid rgba(99, 102, 241, 0.25);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(168, 85, 247, 0.05));
  padding: 1.5rem 1.75rem;
  transition: var(--transition-normal);
  width: 100%;
  box-sizing: border-box;
}

.how-it-works-banner:hover {
  transform: translateY(-3px);
  border-color: var(--accent-primary) !important;
  box-shadow: var(--shadow-glow);
}

.hiw-banner-content {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-width: 0;
}

.hiw-banner-icon {
  font-size: 2.4rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-primary);
  flex-shrink: 0;
}

.hiw-banner-text {
  min-width: 0;
}

.hiw-banner-text h3 {
  margin: 0.2rem 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.hiw-banner-text p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.45;
}

.hiw-banner-action {
  flex-shrink: 0;
}

.hiw-banner-action .btn {
  pointer-events: none;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .hiw-hero-grid,
  .hiw-engine-grid,
  .hiw-cards-grid,
  .hiw-age-grid,
  .hiw-teacher-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    width: 100%;
  }

  .hiw-anchors {
    display: none;
  }

  .hiw-hero {
    padding: 1.5rem 0 2rem;
  }

  .hiw-section {
    padding: 2.5rem 0;
  }

  .hiw-card,
  .hiw-engine-card,
  .hiw-memory-card,
  .hiw-curve-card,
  .hiw-info-card,
  .hiw-age-card,
  .hiw-perspective-card,
  .hiw-cta-box {
    padding: 1.25rem 1rem !important;
    border-radius: var(--radius-md);
  }

  .hiw-engine-card h3 {
    font-size: 1.3rem;
  }

  .hiw-metric-row {
    gap: 0.75rem;
    padding: 0.65rem 0;
  }

  .hiw-timeline-item {
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: flex-start;
  }

  .hiw-cta-box {
    padding: 2rem 1rem !important;
  }

  .hiw-cta-box h2 {
    font-size: 1.6rem;
  }

  .hiw-title {
    font-size: clamp(1.8rem, 6vw, 2.4rem);
  }

  .hiw-section-head h2 {
    font-size: 1.6rem;
  }

  .hiw-legend {
    gap: 0.75rem;
    font-size: 0.75rem;
  }

  .hiw-controls {
    padding: 0.85rem;
  }

  .hiw-subnav {
    top: 60px;
    padding: 0.5rem 0.85rem;
  }

  .how-it-works-banner {
    flex-direction: column;
    align-items: stretch;
    padding: 1.25rem 1rem !important;
    gap: 1rem;
  }

  .hiw-banner-content {
    align-items: flex-start;
    gap: 0.85rem;
  }

  .hiw-banner-icon {
    width: 42px;
    height: 42px;
    font-size: 1.8rem;
  }

  .hiw-banner-action {
    width: 100%;
  }

  .hiw-banner-action .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ==========================================================================
   QR Scanner & Camera Viewfinder Component
   ========================================================================== */
#qr-reader {
  width: 100% !important;
  border: none !important;
}

#qr-reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  border-radius: 10px;
}

#qr-reader__scan_region {
  min-height: 220px;
  background: transparent !important;
}

#qr-reader__dashboard {
  padding: 0.5rem !important;
}

.qr-scanner-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  pointer-events: none;
  z-index: 10;
}

.qr-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: #6366f1;
  border-style: solid;
}

.qr-corner.top-left {
  top: 0;
  left: 0;
  border-width: 4px 0 0 4px;
  border-top-left-radius: 8px;
}

.qr-corner.top-right {
  top: 0;
  right: 0;
  border-width: 4px 4px 0 0;
  border-top-right-radius: 8px;
}

.qr-corner.bottom-left {
  bottom: 0;
  left: 0;
  border-width: 0 0 4px 4px;
  border-bottom-left-radius: 8px;
}

.qr-corner.bottom-right {
  bottom: 0;
  right: 0;
  border-width: 0 4px 4px 0;
  border-bottom-right-radius: 8px;
}

@keyframes scanLaser {
  0% { top: 6px; opacity: 0.2; }
  50% { opacity: 1; }
  100% { top: 190px; opacity: 0.2; }
}

.qr-laser-line {
  position: absolute;
  left: 4px;
  right: 4px;
  height: 3px;
  background: linear-gradient(90deg, transparent, #6366f1, #a855f7, transparent);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.9);
  animation: scanLaser 2s ease-in-out infinite;
  border-radius: 999px;
}

/* ==========================================================================
   Teacher QR Sticker Sheet Generator & Printable Card System
   ========================================================================== */
.sticker-sheet-page {
  display: grid;
  gap: 12px;
  width: 100%;
}

.sticker-sheet-page.grid-2x4 {
  grid-template-columns: repeat(2, 1fr);
}

.sticker-sheet-page.grid-3x7 {
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.sticker-sheet-page.cards {
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

@media (max-width: 768px) {
  .sticker-sheet-page.grid-2x4,
  .sticker-sheet-page.grid-3x7,
  .sticker-sheet-page.cards {
    grid-template-columns: 1fr;
  }
}

.sticker-card {
  background: #ffffff;
  color: #0f172a;
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  position: relative;
  overflow: hidden;
}

.sticker-card.is-cutout-card {
  border: 1.5px dashed #94a3b8;
  padding: 14px;
  border-radius: 10px;
}

.sticker-card.is-compact {
  padding: 6px 8px;
}

.sticker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 4px;
  margin-bottom: 6px;
}

.sticker-brand {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sticker-logo-dot {
  font-size: 0.95rem;
}

.sticker-app-name {
  font-weight: 800;
  font-size: 0.85rem;
  color: #4f46e5;
  letter-spacing: -0.02em;
}

.sticker-class-tag {
  font-size: 0.72rem;
  font-weight: 700;
  background: #e0e7ff;
  color: #3730a3;
  padding: 2px 6px;
  border-radius: 4px;
}

.sticker-body {
  display: flex;
  gap: 10px;
  align-items: center;
}

.sticker-qr-wrap {
  background: #ffffff;
  padding: 4px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sticker-qr-wrap img,
.sticker-qr-wrap canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.sticker-info {
  flex: 1;
  min-width: 0;
}

.sticker-student-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.sticker-card.is-compact .sticker-student-name {
  font-size: 0.8rem;
}

.sticker-creds-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 0.72rem;
  line-height: 1.35;
}

.sticker-card.is-compact .sticker-creds-box {
  padding: 2px 4px;
  font-size: 0.65rem;
  line-height: 1.25;
}

.sticker-cred-row {
  display: flex;
  gap: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cred-label {
  color: #64748b;
  font-weight: 500;
}

.cred-val {
  color: #0f172a;
  font-family: monospace;
}

.sticker-footer {
  margin-top: 6px;
  padding-top: 4px;
  border-top: 1px dashed #e2e8f0;
  font-size: 0.65rem;
  color: #64748b;
  text-align: center;
}

/* ==========================================================================
   Print Specific Stylesheet (@media print)
   ========================================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 8mm;
  }

  /* Hide entire web application UI on print */
  body {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body > *:not(#printable-sticker-sheet) {
    display: none !important;
  }

  #printable-sticker-sheet {
    display: block !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    background: #ffffff !important;
    visibility: visible !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #printable-sticker-sheet * {
    visibility: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .sticker-sheet-page {
    display: grid !important;
    width: 100% !important;
    page-break-after: auto;
  }

  .sticker-sheet-page.grid-2x4 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8mm !important;
  }

  .sticker-sheet-page.grid-3x7 {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 4mm !important;
  }

  .sticker-sheet-page.cards {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10mm !important;
  }

  .sticker-card {
    border: 1px solid #94a3b8 !important;
    box-shadow: none !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  .sticker-card.is-cutout-card {
    border: 1.5px dashed #64748b !important;
  }

  .sticker-class-tag {
    background: #e0e7ff !important;
    color: #3730a3 !important;
  }

  .sticker-creds-box {
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
  }
}

