/* =========================================================
   AptiVerse — Design System
   Dark-mode-first, glassmorphism, mobile-app-like UI.
   Tokens are seeded from the blueprint defaults but overridden
   at runtime by /api/settings/get.php?group=theme (see app.js
   applyThemeFromServer()), so Admin → Settings → Theme changes
   apply without touching this file.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;600;700;800&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --pri: #5B5CFF;
  --sec: #8B5CF6;
  --acc: #00D4FF;
  --acc2: #FF6B9D;
  --warn: #FFB800;
  --bg: #0B1020;
  --ok: #10E898;
  --err: #FF4D6D;

  --bg-elevated: #131a2e;
  --bg-card: rgba(255, 255, 255, 0.04);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --text-primary: #F5F6FA;
  --text-secondary: #9AA3B8;
  --text-muted: #636d84;

  --radius-sm: 16px;
  --radius-md: 24px;
  --radius-lg: 32px;

  --font-display: 'Sora', system-ui, sans-serif;
  --font-body: 'Outfit', system-ui, sans-serif;

  --shadow-glow: 0 8px 32px rgba(91, 92, 255, 0.25);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

[data-theme="light"] {
  --bg: #F5F6FB;
  --bg-elevated: #FFFFFF;
  --bg-card: rgba(20, 22, 40, 0.04);
  --border-subtle: rgba(20, 22, 40, 0.08);
  --text-primary: #14162A;
  --text-secondary: #565E77;
  --text-muted: #8891a8;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  transition: background 0.3s ease, color 0.3s ease;
}
h1, h2, h3, h4, .font-display { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* Ambient gradient background behind everything */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(600px circle at 15% 0%, rgba(91,92,255,0.18), transparent 55%),
    radial-gradient(500px circle at 100% 20%, rgba(0,212,255,0.12), transparent 55%),
    radial-gradient(500px circle at 20% 100%, rgba(255,107,157,0.10), transparent 55%);
  pointer-events: none;
  z-index: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(84px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
}
@media (min-width: 768px) {
  .app-shell { max-width: 720px; }
}
@media (min-width: 1024px) {
  .app-shell { max-width: 960px; }
}

/* ---------------- Sticky header ---------------- */
.sticky-header {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: calc(14px + var(--safe-top)) 20px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(11, 16, 32, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
}
[data-theme="light"] .sticky-header { background: rgba(245, 246, 251, 0.78); }

.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; }
.brand .logo-dot {
  width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(135deg, var(--pri), var(--acc));
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; box-shadow: var(--shadow-glow);
}

.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--sec), var(--acc2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; color: #fff;
  border: 2px solid var(--border-subtle);
  cursor: pointer;
}

/* ---------------- Glass card / gradient card ---------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  backdrop-filter: blur(10px);
}
.card-gradient {
  border-radius: var(--radius-md);
  padding: 20px;
  background: linear-gradient(135deg, var(--pri), var(--sec));
  color: #fff;
  box-shadow: var(--shadow-glow);
  position: relative;
  overflow: hidden;
}
.card-gradient::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(200px circle at 90% 0%, rgba(255,255,255,0.25), transparent 60%);
}

.section { padding: 16px 20px; }
.section-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  margin: 4px 0 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.section-title .link { font-family: var(--font-body); font-size: 0.8rem; color: var(--acc); font-weight: 500; }

/* ---------------- Grid helpers ---------------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-tile { text-align: center; padding: 14px 8px; }
.stat-tile .stat-value { font-family: var(--font-display); font-size: 1.4rem; font-weight: 800; }
.stat-tile .stat-label { font-size: 0.72rem; color: var(--text-secondary); margin-top: 2px; }

/* ---------------- Category cards ---------------- */
.category-card {
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.category-card:active { transform: scale(0.97); }
.category-card .cat-icon { font-size: 1.6rem; }
.category-card .cat-name { font-weight: 600; font-size: 0.9rem; }
.category-card .cat-count { font-size: 0.72rem; color: var(--text-secondary); }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: var(--radius-sm);
  padding: 14px 20px; font-weight: 600; font-size: 0.92rem;
  cursor: pointer; transition: transform 0.12s ease, opacity 0.12s ease;
  width: 100%;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: linear-gradient(135deg, var(--pri), var(--sec)); color: #fff; box-shadow: var(--shadow-glow); }
.btn-secondary { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border-subtle); }
.btn-ghost { background: transparent; color: var(--acc); }
.btn-danger { background: var(--err); color: #fff; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { padding: 9px 14px; font-size: 0.8rem; width: auto; }

/* ---------------- Forms ---------------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 13px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle); background: var(--bg-card);
  color: var(--text-primary); font-family: var(--font-body); font-size: 0.95rem;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--pri); outline-offset: 1px;
}
.field-error { color: var(--err); font-size: 0.75rem; margin-top: 6px; }

/* OTP boxes */
.otp-row { display: flex; gap: 10px; justify-content: center; }
.otp-box {
  width: 46px; height: 54px; text-align: center; font-size: 1.3rem; font-weight: 700;
  border-radius: 14px; border: 1px solid var(--border-subtle); background: var(--bg-card); color: var(--text-primary);
}
.otp-box:focus { outline: 2px solid var(--pri); }

/* ---------------- Bottom navigation ---------------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  max-width: 480px; margin: 0 auto;
  display: flex; justify-content: space-around; align-items: center;
  padding: 10px 6px calc(10px + var(--safe-bottom));
  background: rgba(19, 26, 46, 0.85);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border-subtle);
}
[data-theme="light"] .bottom-nav { background: rgba(255,255,255,0.85); }
@media (min-width: 768px) { .bottom-nav { max-width: 720px; } }
@media (min-width: 1024px) { .bottom-nav { max-width: 960px; } }

.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 0.65rem; color: var(--text-muted); padding: 6px 12px; border-radius: 14px;
  cursor: pointer; transition: color 0.15s ease;
}
.nav-item .nav-icon { font-size: 1.25rem; }
.nav-item.active { color: var(--acc); }

/* ---------------- Bottom sheet (paywall, modals) ---------------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
  background: var(--bg-elevated); border-radius: 28px 28px 0 0;
  padding: 10px 20px calc(24px + var(--safe-bottom));
  transform: translateY(100%); transition: transform 0.28s cubic-bezier(.2,.9,.3,1);
  border-top: 1px solid var(--border-subtle);
}
.sheet-backdrop.open .sheet { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--border-subtle); margin: 8px auto 16px; }

/* ---------------- Progress / rings ---------------- */
.progress-bar { height: 6px; border-radius: 6px; background: var(--bg-card); overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--pri), var(--acc)); transition: width 0.3s ease; }

/* ---------------- Toasts ---------------- */
.toast-stack {
  position: fixed; top: calc(16px + var(--safe-top)); left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px);
}
.toast {
  padding: 13px 16px; border-radius: 16px; font-size: 0.85rem; font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-elevated); border: 1px solid var(--border-subtle);
  animation: fadeUp 0.25s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.toast.success { border-color: var(--ok); }
.toast.error { border-color: var(--err); }
.toast.warning { border-color: var(--warn); }

/* ---------------- Skeletons ---------------- */
.skeleton { background: linear-gradient(90deg, var(--bg-card) 25%, rgba(255,255,255,0.09) 37%, var(--bg-card) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius-sm); }

/* ---------------- Animations ---------------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes glowPulse { 0%, 100% { box-shadow: 0 0 0 rgba(91,92,255,0); } 50% { box-shadow: 0 0 24px rgba(91,92,255,0.45); } }
@keyframes shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(2px); } 30%, 50%, 70% { transform: translateX(-4px); } 40%, 60% { transform: translateX(4px); } }
.fade-up { animation: fadeUp 0.35s ease; }
.scale-in { animation: scaleIn 0.25s ease; }
.shake { animation: shake 0.4s ease; }

/* ---------------- Utility ---------------- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
.pill {
  display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 999px;
  font-size: 0.7rem; font-weight: 600; background: var(--bg-card); border: 1px solid var(--border-subtle);
}
.pill-ok { color: var(--ok); border-color: var(--ok); }
.pill-warn { color: var(--warn); border-color: var(--warn); }
.pill-err { color: var(--err); border-color: var(--err); }

/* Responsive tables -> cards on mobile (used inside admin panel too) */
@media (max-width: 767px) {
  table.responsive-table { display: none; }
  .responsive-cards { display: flex; flex-direction: column; gap: 10px; }
}
@media (min-width: 768px) {
  .responsive-cards { display: none; }
}

/* =========================================================
   Supplementary components — Home/Learn/Test/Leaderboard/
   Profile/Paywall views (app.php). Reuses the tokens defined
   above; adds the additional class names those views use.
   ========================================================= */

.app-header {
  position: sticky; top: 0; z-index: 50;
  padding: calc(14px + var(--safe-top)) 20px 14px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(11, 16, 32, 0.72);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
}
[data-theme="light"] .app-header { background: rgba(245, 246, 251, 0.78); }

.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border-subtle);
  background: var(--bg-card); color: var(--text-primary); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 1rem;
}
.avatar-sm {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--sec), var(--acc2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem; color: #fff;
}
.avatar-lg {
  width: 76px; height: 76px; border-radius: 50%;
  background: linear-gradient(135deg, var(--sec), var(--acc2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.8rem; color: #fff;
}
.mx-auto { margin-left: auto; margin-right: auto; }
.text-right { text-align: right; }

.view { min-height: 60vh; }
.greeting { font-size: 1.5rem; margin: 4px 0 16px; }

.gradient-card {
  border-radius: var(--radius-md); padding: 20px; color: #fff;
  background: linear-gradient(135deg, var(--pri), var(--sec));
  box-shadow: var(--shadow-glow); position: relative; overflow: hidden;
}
.gradient-card::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(200px circle at 90% 0%, rgba(255,255,255,0.25), transparent 60%);
}
.glass { background: var(--bg-card); border: 1px solid var(--border-subtle); backdrop-filter: blur(10px); border-radius: var(--radius-sm); }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 768px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card { text-align: center; padding: 16px 8px; }
.stat-value { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; }
.stat-label { font-size: 0.72rem; color: var(--text-secondary); margin-top: 4px; }

.sub-banner {
  padding: 12px 16px; border-radius: var(--radius-sm); font-size: 0.85rem; margin-bottom: 16px;
  background: var(--bg-card); border: 1px solid var(--border-subtle);
}
.sub-banner a { text-decoration: underline; font-weight: 600; }

.category-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 768px) { .category-grid { grid-template-columns: repeat(5, 1fr); } }
.category-card {
  border-radius: var(--radius-sm); padding: 18px; text-align: left; cursor: pointer;
  border: 1px solid var(--border-subtle); background: var(--bg-card); color: var(--text-primary);
  transition: transform 0.15s ease;
}
.category-card:active { transform: scale(0.97); }
.category-icon { font-size: 1.6rem; margin-bottom: 6px; }
.category-name { font-weight: 600; font-size: 0.9rem; }

.list-row {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 14px 16px; border-radius: var(--radius-sm); border: none; cursor: pointer;
  color: var(--text-primary); text-align: left; font-family: var(--font-body); font-size: 0.9rem;
}
.list-row.me-highlight { border: 1px solid var(--pri); background: rgba(91,92,255,0.1); }

.filter-row, .chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.select {
  padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-subtle);
  background: var(--bg-card); color: var(--text-primary); font-family: var(--font-body); flex: 1;
}
.chip {
  padding: 9px 16px; border-radius: 999px; border: 1px solid var(--border-subtle);
  background: var(--bg-card); color: var(--text-secondary); cursor: pointer; font-weight: 600; font-size: 0.82rem;
}
.chip.active { background: linear-gradient(135deg, var(--pri), var(--sec)); color: #fff; border-color: transparent; }

.btn-light { background: rgba(255,255,255,0.18); color: #fff; }
[data-theme="light"] .btn-light { background: rgba(20,22,40,0.08); color: var(--text-primary); }

/* ---------------- Modal overlay / sheet (learn, daily challenge, paywall) ---------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 150; background: rgba(0,0,0,0.55);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 768px) { .modal-overlay { align-items: center; } }
.modal-sheet {
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
  background: var(--bg-elevated); border-radius: 28px 28px 0 0;
  padding: 18px 20px calc(24px + var(--safe-bottom));
  border-top: 1px solid var(--border-subtle);
}
@media (min-width: 768px) { .modal-sheet { border-radius: 28px; } }

.question-text { font-size: 1.05rem; font-weight: 600; line-height: 1.5; }
.options-list { display: flex; flex-direction: column; gap: 10px; }
.option-btn {
  text-align: left; padding: 14px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle); background: var(--bg-card); color: var(--text-primary);
  cursor: pointer; font-family: var(--font-body); font-size: 0.9rem; transition: all 0.15s ease;
}
.option-btn:disabled { cursor: default; }
.option-btn.option-selected { border-color: var(--pri); background: rgba(91,92,255,0.12); }
.option-btn.option-correct { border-color: var(--ok); background: rgba(16,232,152,0.12); color: var(--ok); }
.option-btn.option-wrong { border-color: var(--err); background: rgba(255,77,109,0.12); color: var(--err); }
.option-btn.option-faded { opacity: 0.45; }

.explanation-box {
  padding: 14px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-subtle); font-size: 0.85rem;
}
.explanation-box p { margin: 6px 0 0; color: var(--text-secondary); }
.explanation-box.exp-correct { border-color: var(--ok); }
.explanation-box.exp-wrong { border-color: var(--err); }

/* ---------------- Test mode ---------------- */
.test-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 20px 8px; position: sticky; top: 0; z-index: 40;
  background: var(--bg);
}
.test-timer { font-weight: 800; font-family: var(--font-display); }
.test-timer.timer-danger { color: var(--err); animation: shake 0.4s ease infinite; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--pri), var(--acc)); transition: width 0.3s ease; border-radius: 6px; }
#test-active-section .progress-bar { margin: 0 20px; }

.palette-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
@media (max-width: 400px) { .palette-grid { grid-template-columns: repeat(6, 1fr); } }
.palette-cell {
  aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--border-subtle);
  background: var(--bg-card); color: var(--text-secondary); font-size: 0.75rem; font-weight: 700; cursor: pointer;
}
.palette-cell.answered { background: rgba(16,232,152,0.15); border-color: var(--ok); color: var(--ok); }
.palette-cell.current { border-color: var(--pri); box-shadow: 0 0 0 2px rgba(91,92,255,0.35); }

/* ---------------- Score ring (results) ---------------- */
.score-ring {
  width: 160px; height: 160px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: conic-gradient(var(--ring-color, var(--acc)) calc(var(--pct, 0) * 1%), var(--bg-card) 0);
}
.score-ring-inner {
  width: 128px; height: 128px; border-radius: 50%; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.score-pct { font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; }
.score-grade { font-size: 0.85rem; color: var(--text-secondary); }

.weak-bar-row { display: grid; grid-template-columns: 90px 1fr 70px; align-items: center; gap: 10px; font-size: 0.82rem; }
.weak-bar { height: 8px; border-radius: 8px; background: var(--bg-card); overflow: hidden; }
.weak-bar-fill { height: 100%; background: linear-gradient(90deg, var(--warn), var(--err)); }

/* ---------------- Bottom nav (this build's naming) ---------------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  max-width: 480px; margin: 0 auto;
  display: flex; justify-content: space-around; align-items: center;
  padding: 10px 6px calc(10px + var(--safe-bottom));
  background: rgba(19, 26, 46, 0.85);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border-subtle);
}
[data-theme="light"] .bottom-nav { background: rgba(255,255,255,0.85); }
@media (min-width: 768px) { .bottom-nav { max-width: 720px; } }
@media (min-width: 1024px) { .bottom-nav { max-width: 960px; } }
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 0.65rem; color: var(--text-muted); padding: 6px 12px; border-radius: 14px;
  background: none; border: none; cursor: pointer;
}
.nav-btn span { font-size: 1.25rem; }
.nav-btn.active { color: var(--acc); }

/* ---------------- Achievements ---------------- */
.achievement-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.achievement-badge {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 4px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-subtle); background: var(--bg-card);
  opacity: 0.35; filter: grayscale(1);
}
.achievement-badge.earned { opacity: 1; filter: none; border-color: var(--warn); }

/* ---------------- Settings toggle ---------------- */
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }
.settings-row + .settings-row { border-top: 1px solid var(--border-subtle); }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 24px; transition: 0.2s; }
.slider::before { content: ''; position: absolute; height: 18px; width: 18px; left: 2px; bottom: 2px; background: #fff; border-radius: 50%; transition: 0.2s; }
.switch input:checked + .slider { background: var(--pri); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ---------------- Paywall / plans ---------------- */
.feature-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.feature-pill {
  padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg-card);
  border: 1px solid var(--border-subtle); font-size: 0.78rem; text-align: center;
}
.plan-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-subtle);
  cursor: pointer; background: var(--bg-card);
}
.plan-card input { display: none; }
.plan-card.selected { border-color: var(--pri); background: rgba(91,92,255,0.1); }
.rank-medal { font-size: 1.1rem; width: 28px; text-align: center; }

/* ---------------- Confetti ---------------- */
#confetti-root { position: fixed; inset: 0; pointer-events: none; z-index: 300; overflow: hidden; }
.confetti-piece {
  position: absolute; top: -10px; width: 8px; height: 14px; opacity: 0.9;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(360deg); opacity: 0; }
}

/* =========================================================
   Auth pages (login / register / forgot-password) — premium
   mobile-app-like presentation with floating gradient blobs,
   glass card entrance animation, icon inputs, password toggle,
   button loading spinner, animated step transitions.
   ========================================================= */

.auth-shell {
  position: relative;
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 20px calc(24px + var(--safe-bottom));
  overflow: hidden;
}

/* Floating ambient blobs behind the auth card */
.auth-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.45;
  z-index: 0;
  animation: floatBlob 10s ease-in-out infinite;
  pointer-events: none;
}
.auth-blob.b1 { width: 260px; height: 260px; top: -80px; left: -60px; background: var(--pri); animation-delay: 0s; }
.auth-blob.b2 { width: 220px; height: 220px; bottom: -60px; right: -60px; background: var(--acc); animation-delay: 2s; }
.auth-blob.b3 { width: 180px; height: 180px; top: 40%; right: -80px; background: var(--acc2); animation-delay: 4s; opacity: 0.3; }
@keyframes floatBlob {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(20px, -30px) scale(1.08); }
}
@media (prefers-reduced-motion: reduce) {
  .auth-blob { animation: none; }
}

.auth-card {
  position: relative;
  z-index: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px 26px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  animation: authCardIn 0.5s cubic-bezier(.2,.9,.3,1);
}
@keyframes authCardIn {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-logo {
  width: 56px; height: 56px; border-radius: 18px;
  background: linear-gradient(135deg, var(--pri), var(--acc));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; margin: 0 auto 18px;
  box-shadow: var(--shadow-glow);
  animation: authLogoPulse 3s ease-in-out infinite;
}
@keyframes authLogoPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(91,92,255,0.35); }
  50% { box-shadow: 0 0 0 10px rgba(91,92,255,0); }
}

.auth-title { text-align: center; font-size: 1.5rem; margin: 0 0 4px; }
.auth-subtitle { text-align: center; color: var(--text-secondary); font-size: 0.88rem; margin: 0 0 26px; }

/* Icon-prefixed inputs */
.input-icon-wrap { position: relative; }
.input-icon-wrap .field-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: 1rem; opacity: 0.6; pointer-events: none;
}
.input-icon-wrap input { padding-left: 42px; }
.input-icon-wrap .field-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-secondary); cursor: pointer;
  font-size: 1rem; padding: 6px; line-height: 1;
}
.input-icon-wrap .field-toggle:hover { color: var(--text-primary); }

.auth-link-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.8rem; margin-top: -6px; margin-bottom: 16px;
}
.auth-link-row a { color: var(--acc); font-weight: 600; }

/* Button loading spinner state */
.btn .btn-spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.btn.is-loading .btn-label { opacity: 0; }
.btn.is-loading { position: relative; }
.btn.is-loading .btn-spinner { position: absolute; left: 50%; top: 50%; margin: -8px 0 0 -8px; }

/* Step transitions (register / forgot-password multi-step) */
.auth-step { animation: authStepIn 0.35s ease; }
@keyframes authStepIn {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Stepper dots (forgot-password progress) */
.step-dots { display: flex; justify-content: center; gap: 8px; margin-bottom: 22px; }
.step-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-subtle); transition: all 0.25s ease; }
.step-dot.active { width: 22px; background: linear-gradient(90deg, var(--pri), var(--acc)); }
.step-dot.done { background: var(--ok); }

.password-strength { height: 4px; border-radius: 4px; background: var(--bg-card); overflow: hidden; margin-top: 8px; }
.password-strength-fill { height: 100%; width: 0%; transition: width 0.25s ease, background 0.25s ease; }

.success-check {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 16px;
  background: rgba(16,232,152,0.12); border: 2px solid var(--ok);
  display: flex; align-items: center; justify-content: center; font-size: 1.8rem;
  animation: scaleIn 0.4s cubic-bezier(.2,.9,.3,1);
}

/* =========================================================
   Full-screen quiz modals (Learn Mode question view, Daily
   Challenge) — replaces the half-screen bottom-sheet style for
   any "taking a quiz" experience, which should feel like its
   own dedicated screen rather than a small popup.
   ========================================================= */

.modal-overlay.fullscreen {
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  background: var(--bg);
}
.modal-overlay.fullscreen .modal-sheet {
  width: 100%;
  max-width: none;
  height: 100dvh;
  max-height: none;
  border-radius: 0;
  border: none;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--bg);
}

.quiz-fullscreen-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + var(--safe-top)) 20px 14px;
  background: rgba(11, 16, 32, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
}
[data-theme="light"] .quiz-fullscreen-header { background: rgba(245, 246, 251, 0.9); }
.quiz-fullscreen-header .quiz-title { font-weight: 700; font-size: 0.95rem; }
.quiz-fullscreen-header .quiz-progress-label { font-size: 0.78rem; color: var(--text-secondary); }

.quiz-fullscreen-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px calc(24px + var(--safe-bottom));
}

.quiz-fullscreen-footer {
  position: sticky;
  bottom: 0;
  padding: 14px 20px calc(14px + var(--safe-bottom));
  background: rgba(11, 16, 32, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
[data-theme="light"] .quiz-fullscreen-footer { background: rgba(245, 246, 251, 0.9); }

/* ---------------- Learn Mode phase cards ---------------- */
.phase-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-subtle);
  background: var(--bg-card); text-align: left; width: 100%;
}
.phase-card.completed { border-color: var(--ok); background: rgba(16,232,152,0.08); }
.phase-card.locked { opacity: 0.45; cursor: not-allowed; }
.phase-card .phase-icon { font-size: 1.4rem; width: 40px; text-align: center; }
.phase-card .phase-progress-mini {
  height: 6px; border-radius: 6px; background: var(--bg-card); overflow: hidden; width: 100%; margin-top: 6px;
}
.phase-card .phase-progress-mini-fill { height: 100%; background: linear-gradient(90deg, var(--pri), var(--acc)); }

/* ---------------- Challenge card completion status ---------------- */
.challenge-card { transition: border-color 0.2s ease, background 0.2s ease; }
.challenge-card.completed { border: 1px solid var(--ok) !important; box-shadow: 0 0 0 1px rgba(16,232,152,0.25); }
.challenge-card.pending { border: 1px solid var(--err) !important; }
.challenge-card.gradient-card.completed { background: linear-gradient(135deg, var(--ok), #0bc77f); }
.challenge-card.gradient-card.pending { background: linear-gradient(135deg, var(--err), #c53a55); }
