/* ═══════════════════════════════════════════════════════════════
   SchoolBell — Premium Dark UI
   Base: Obsidian #0B0F1A | Surface: #161B26 | Accent: Indigo #818CF8
════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

/* ── Design Tokens ───────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-base:      #0B0F1A;
  --bg-surface:   #161B26;
  --bg-elevated:  #1E2433;
  --bg-input:     #0F1420;

  /* Borders */
  --border:        rgba(255,255,255,.08);
  --border-hover:  rgba(255,255,255,.16);
  --border-bright: rgba(255,255,255,.24);

  /* Text */
  --text-primary:   #E2E8F0;
  --text-secondary: #94A3B8;
  --text-muted:     #64748B;

  /* Accent – indigo (student & default) */
  --indigo:      #818CF8;
  --indigo-dark: #6366F1;
  --indigo-glow: rgba(129,140,248,.18);
  --indigo-bg:   rgba(129,140,248,.08);

  /* Accent – cyan */
  --cyan:      #22D3EE;
  --cyan-glow: rgba(34,211,238,.12);

  /* Status */
  --emerald:      #34D399;
  --emerald-glow: rgba(52,211,153,.12);
  --emerald-bg:   rgba(52,211,153,.08);

  --amber:      #FBBF24;
  --amber-glow: rgba(251,191,36,.12);
  --amber-bg:   rgba(251,191,36,.08);

  --rose:      #F87171;
  --rose-glow: rgba(248,113,113,.12);
  --rose-bg:   rgba(248,113,113,.08);

  /* Parent theme – orange */
  --orange:      #FB923C;
  --orange-dark: #EA7316;
  --orange-glow: rgba(251,146,60,.18);
  --orange-bg:   rgba(251,146,60,.08);

  /* Shared */
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;
  --radius-xl:  20px;

  --shadow:    0 4px 16px rgba(0,0,0,.35);
  --shadow-lg: 0 20px 50px rgba(0,0,0,.40);

  --transition: .18s cubic-bezier(.4,0,.2,1);
}

/* ── Base ────────────────────────────────────────────────────── */
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  /* Subtle mesh grain */
  background-image: radial-gradient(ellipse at 20% 50%, rgba(129,140,248,.04) 0%, transparent 60%),
                    radial-gradient(ellipse at 80% 20%, rgba(34,211,238,.03) 0%, transparent 60%);
  background-attachment: fixed;
}

a { color: var(--indigo); text-decoration: none; transition: color var(--transition); }
a:hover { color: #a5b4fc; text-decoration: none; }
img { max-width: 100%; }

/* ── Page-load fade-in ───────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
main { animation: fadeInUp .4s cubic-bezier(.4,0,.2,1) both; }

/* ── Navbar ──────────────────────────────────────────────────── */
.navbar {
  background: rgba(11,15,26,.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 200;
}
.navbar-brand {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -.3px;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.navbar-brand:hover { color: var(--indigo); }
.navbar-spacer { flex: 1; }
.navbar-links { display: flex; align-items: center; gap: .25rem; }
.nav-link {
  color: var(--text-secondary);
  padding: .45rem .8rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--transition);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: var(--text-primary); }
.nav-link.active { background: var(--indigo-bg); color: var(--indigo); }

/* ── Hamburger ───────────────────────────────────────────────── */
.nav-toggle {
  display: none;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: .5rem .65rem;
  border-radius: var(--radius-sm);
  line-height: 1;
  min-height: 44px;
  transition: background var(--transition);
}
.nav-toggle:hover { background: rgba(255,255,255,.12); }

/* ── Flash Messages ──────────────────────────────────────────── */
.flash-container {
  position: fixed;
  top: 72px;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-width: 380px;
  pointer-events: none;
}
.alert {
  padding: .85rem 1.1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  border: 1px solid;
  backdrop-filter: blur(16px);
  pointer-events: all;
  animation: slideInRight .3s ease both;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
.alert-success { background: rgba(52,211,153,.12); border-color: rgba(52,211,153,.3); color: var(--emerald); }
.alert-danger  { background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.3); color: var(--rose); }
.alert-warning { background: rgba(251,191,36,.12);  border-color: rgba(251,191,36,.3);  color: var(--amber); }
.alert-info    { background: rgba(129,140,248,.12); border-color: rgba(129,140,248,.3); color: var(--indigo); }

/* ── Main Content ────────────────────────────────────────────── */
main { max-width: 1100px; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }

/* ── Page Header ─────────────────────────────────────────────── */
.page-header {
  border-radius: var(--radius-lg);
  margin-bottom: 1.75rem;
  padding: 1.75rem 2rem;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.page-header::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: .15;
}
.page-header h1 { font-size: 1.65rem; font-weight: 800; letter-spacing: -.4px; position: relative; }
.page-header .subtitle { font-size: .9rem; margin-top: .3rem; position: relative; opacity: .75; }

.student-header {
  background: linear-gradient(135deg, rgba(52,211,153,.12) 0%, rgba(129,140,248,.06) 100%);
  border-color: rgba(52,211,153,.2);
}
.student-header::before {
  background: radial-gradient(ellipse at top left, var(--emerald) 0%, transparent 60%);
}
.student-header h1, .student-header .subtitle { color: var(--text-primary); }

.parent-header {
  background: linear-gradient(135deg, rgba(251,146,60,.12) 0%, rgba(129,140,248,.06) 100%);
  border-color: rgba(251,146,60,.22);
}
.parent-header::before {
  background: radial-gradient(ellipse at top left, var(--orange) 0%, transparent 60%);
}
.parent-header h1, .parent-header .subtitle { color: var(--text-primary); }

/* ── Cards & Grid ────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.card-grid.three-col { grid-template-columns: repeat(3, 1fr); }
.card-grid.four-col  { grid-template-columns: repeat(4, 1fr); }

/* ── Stat Cards ──────────────────────────────────────────────── */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-top: 1px solid rgba(129,140,248,.3);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top center, var(--indigo-glow), transparent 70%);
  pointer-events: none;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg), var(--shadow); border-color: rgba(129,140,248,.4); }
.stat-icon   { font-size: 1.75rem; margin-bottom: .4rem; }
.stat-number { font-size: 2.2rem; font-weight: 800; color: var(--text-primary); letter-spacing: -.5px; }
.stat-label  { font-size: .8rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; margin-top: .15rem; }

/* ── Subject Cards (student) ─────────────────────────────────── */
.subject-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-top: 1px solid rgba(34,211,238,.25);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  color: var(--text-primary);
  position: relative;
  overflow: hidden;
}
.subject-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top center, rgba(34,211,238,.05), transparent 70%);
  pointer-events: none;
}
.subject-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg), 0 0 30px rgba(34,211,238,.08);
  border-color: rgba(34,211,238,.4);
  text-decoration: none;
}
.subject-icon   { font-size: 2.5rem; margin-bottom: .6rem; }
.subject-name   { font-size: 1rem; font-weight: 700; color: var(--text-primary); letter-spacing: -.2px; }
.subject-meta   { font-size: .78rem; color: var(--text-muted); margin-top: .3rem; }
.subject-action { font-size: .82rem; color: var(--cyan); margin-top: .6rem; font-weight: 600; }

/* ── Action Cards (parent quick actions) ─────────────────────── */
.action-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1rem;
  text-align: center;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  color: var(--text-primary);
  transition: all var(--transition);
  active: transform scale(.97);
}
.action-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-hover);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
  color: var(--text-primary);
}
.action-icon  { font-size: 1.75rem; }
.action-label { font-size: .82rem; font-weight: 600; color: var(--text-secondary); }

/* ── Feature Card (Teaching Mode) ───────────────────────────── */
.feature-card {
  background: linear-gradient(135deg, rgba(99,102,241,.2) 0%, rgba(129,140,248,.08) 100%);
  border: 1px solid rgba(129,140,248,.25);
  border-top: 1px solid rgba(129,140,248,.5);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow), 0 0 40px rgba(129,140,248,.06);
  position: relative;
  overflow: hidden;
}
.feature-card::after {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(129,140,248,.15), transparent 70%);
  pointer-events: none;
}
.feature-icon { font-size: 3rem; flex-shrink: 0; }
.feature-body { flex: 1; }
.feature-body h2 { font-size: 1.2rem; font-weight: 700; color: var(--text-primary); margin-bottom: .3rem; }
.feature-body p  { color: var(--text-secondary); font-size: .875rem; }
.btn-white {
  background: var(--indigo);
  color: #fff;
  font-weight: 600;
  padding: .65rem 1.35rem;
  border-radius: var(--radius);
  white-space: nowrap;
  transition: all var(--transition);
  border: none;
  display: inline-flex;
  align-items: center;
}
.btn-white:hover { background: var(--indigo-dark); box-shadow: 0 0 20px var(--indigo-glow); text-decoration: none; color: #fff; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .55rem 1.2rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  letter-spacing: -.1px;
  gap: .4rem;
}
.btn:active { transform: scale(.97); }
.btn:hover  { text-decoration: none; }

.btn-primary {
  background: var(--indigo);
  color: #fff;
  border-color: var(--indigo);
}
.btn-primary:hover {
  background: var(--indigo-dark);
  border-color: var(--indigo-dark);
  box-shadow: 0 0 20px var(--indigo-glow);
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-hover);
}
.btn-outline:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border-bright); }

.btn-teach {
  background: var(--orange-bg);
  color: var(--orange);
  border-color: rgba(251,146,60,.3);
}
.btn-teach:hover { background: var(--orange); color: #fff; border-color: var(--orange); box-shadow: 0 0 16px var(--orange-glow); }

.btn-mistakes {
  background: var(--rose-bg);
  color: var(--rose);
  border-color: rgba(248,113,113,.3);
}
.btn-mistakes:hover { background: var(--rose); color: #fff; border-color: var(--rose); box-shadow: 0 0 14px rgba(248,113,113,.35); }

.btn-danger {
  background: var(--rose-bg);
  color: var(--rose);
  border-color: rgba(248,113,113,.3);
}
.btn-danger:hover { background: var(--rose); color: #fff; border-color: var(--rose); }

.btn-disabled { background: rgba(255,255,255,.05); color: var(--text-muted); cursor: not-allowed; border-color: var(--border); }
.btn-quiz-ready {
  display: block;
  width: 100%;
  background: linear-gradient(135deg, var(--emerald), #10B981);
  color: #fff;
  border: none;
  padding: .9rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  border-radius: var(--radius);
  transition: all var(--transition);
  box-shadow: 0 0 20px var(--emerald-glow);
}
.btn-quiz-ready:hover { filter: brightness(1.1); text-decoration: none; color: #fff; box-shadow: 0 0 30px var(--emerald-glow); }

.btn-lg  { padding: .75rem 1.6rem; font-size: 1rem; }
.btn-sm  { padding: .3rem .75rem;  font-size: .8rem; border-radius: var(--radius-sm); }
.ml-1    { margin-left: .5rem; }
.mt-1    { margin-top: .5rem; }
.mt-2    { margin-top: 1rem; }
.mb-2    { margin-bottom: 1rem; }
.w-full  { width: 100%; }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin-bottom: 1.75rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  -webkit-mask-image: linear-gradient(to right, black calc(100% - 40px), transparent 100%);
          mask-image: linear-gradient(to right, black calc(100% - 40px), transparent 100%);
}
.table-wrap:has(:not(:last-child)) { -webkit-mask-image: none; mask-image: none; }
.table-wrap { -webkit-mask-image: none; mask-image: none; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-surface);
  font-size: .875rem;
}
.data-table thead {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-hover);
}
.data-table th {
  padding: .75rem 1rem;
  text-align: left;
  font-weight: 700;
  font-size: .75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
}
.data-table td {
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(255,255,255,.025); }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2rem .65rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .2px;
}
.badge-success { background: var(--emerald-bg); color: var(--emerald); border: 1px solid rgba(52,211,153,.2); }
.badge-danger  { background: var(--rose-bg);    color: var(--rose);    border: 1px solid rgba(248,113,113,.2); }
.badge-warning { background: var(--amber-bg);   color: var(--amber);   border: 1px solid rgba(251,191,36,.2); }
.badge-info    { background: var(--indigo-bg);  color: var(--indigo);  border: 1px solid rgba(129,140,248,.2); }
.badge-muted   { background: rgba(255,255,255,.05); color: var(--text-muted); border: 1px solid var(--border); }

/* Score Badges */
.score-badge { display: inline-block; padding: .2rem .65rem; border-radius: 99px; font-weight: 700; font-size: .82rem; }
.score-good  { background: var(--emerald-bg); color: var(--emerald); border: 1px solid rgba(52,211,153,.2); }
.score-ok    { background: var(--amber-bg);   color: var(--amber);   border: 1px solid rgba(251,191,36,.2); }
.score-poor  { background: var(--rose-bg);    color: var(--rose);    border: 1px solid rgba(248,113,113,.2); }

/* ── Forms ───────────────────────────────────────────────────── */
.form-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-top: 1px solid rgba(129,140,248,.25);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
  max-width: 560px;
  position: relative;
}
.form-group   { margin-bottom: 1.25rem; }
.form-label   { display: block; font-weight: 600; font-size: .82rem; margin-bottom: .45rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .4px; }
.form-control {
  width: 100%;
  padding: .65rem .9rem;
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  font-size: .925rem;
  color: var(--text-primary);
  background: var(--bg-input);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-glow);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control option  { background: var(--bg-elevated); color: var(--text-primary); }
.form-hint    { font-size: .78rem; color: var(--text-muted); margin-top: .35rem; display: block; }
.form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-top: 1.5rem; }
.optional     { color: var(--text-muted); font-weight: 400; }
.form-control-sm { padding: .4rem .65rem; font-size: .82rem; }

/* Range Slider */
.range-slider { width: 100%; accent-color: var(--indigo); cursor: pointer; }
.range-labels { display: flex; justify-content: space-between; font-size: .78rem; color: var(--text-muted); margin-top: .3rem; }

/* File Drop Zone */
.file-drop-zone {
  position: relative;
  border: 1.5px dashed var(--border-hover);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  text-align: center;
  background: var(--bg-input);
  transition: all var(--transition);
  cursor: pointer;
}
.file-drop-zone:hover { border-color: var(--indigo); background: var(--indigo-bg); }
.file-drop-icon  { font-size: 2rem; margin-bottom: .5rem; }
.file-drop-text  { color: var(--text-secondary); font-size: .9rem; }
.file-chosen-name { margin-top: .5rem; font-size: .85rem; color: var(--emerald); font-weight: 600; }

/* Steps Row */
.steps-row { display: flex; align-items: center; gap: .5rem; margin-bottom: 1.75rem; font-size: .82rem; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: .35rem; color: var(--text-muted); }
.step.active { color: var(--indigo); font-weight: 600; }
.step-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 700;
  border: 1px solid var(--border-hover);
}
.step.active .step-num { background: var(--indigo); color: #fff; border-color: var(--indigo); }
.step-divider { color: var(--text-muted); }

/* ── Login Page ──────────────────────────────────────────────── */
.login-wrap {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-top: 1px solid rgba(129,140,248,.35);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), 0 0 60px rgba(129,140,248,.06);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
}
.login-logo  { text-align: center; font-size: 2.5rem; margin-bottom: .5rem; }
.login-title { text-align: center; font-size: 1.35rem; font-weight: 800; color: var(--text-primary); margin-bottom: 1.5rem; letter-spacing: -.4px; }

/* ── Section Titles ──────────────────────────────────────────── */
.section-title {
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-muted);
  margin: 1.75rem 0 .75rem;
  text-transform: uppercase;
  letter-spacing: .8px;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
}

/* ── XP / Level Bar ──────────────────────────────────────────── */
.xp-bar-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  padding: .7rem 1.2rem;
  margin-bottom: 1.5rem;
}
.xp-level-badge {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}
.xp-level-icon { font-size: 1.5rem; line-height: 1; }
.xp-level-text  { display: flex; flex-direction: column; line-height: 1.2; }
.xp-level-name  { font-weight: 700; color: var(--text-primary); font-size: .9rem; }
.xp-level-num   {
  font-size: .7rem; font-weight: 700; color: var(--indigo);
  background: var(--indigo-bg); border: 1px solid rgba(129,140,248,.25);
  border-radius: 99px; padding: .05rem .45rem; align-self: flex-start;
  margin-top: .15rem;
}
.xp-bar-track {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,.07);
  border-radius: 99px;
  overflow: hidden;
}
.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--indigo-dark), var(--indigo));
  border-radius: 99px;
  transition: width 1.2s cubic-bezier(.4,0,.2,1);
}
.xp-bar-label {
  font-size: .72rem;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── XP Gained (quiz complete) ───────────────────────────────── */
.xp-gained-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .55rem;
  margin: 1rem 0 .5rem;
}
.xp-gained-pill {
  background: linear-gradient(135deg, var(--indigo-dark), var(--indigo));
  color: #fff;
  font-weight: 800;
  font-size: 1.05rem;
  padding: .3rem 1.1rem;
  border-radius: 99px;
  box-shadow: 0 0 22px var(--indigo-glow);
  animation: xp-pop .5s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes xp-pop {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.xp-level-line {
  display: flex;
  align-items: center;
  gap: .65rem;
  font-size: .8rem;
  color: var(--text-secondary);
}
.xp-bar-mini { width: 110px; flex: none; }

/* ── AI Message Card ─────────────────────────────────────────── */
.ai-message-wrap {
  margin: 1rem 0 .5rem;
  min-height: 52px;
  display: flex;
  justify-content: center;
}
.ai-message-loading {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: var(--text-muted);
  font-size: .82rem;
}
.ai-thinking-dots { display: flex; gap: 4px; }
.ai-thinking-dots span {
  width: 6px; height: 6px;
  background: var(--indigo);
  border-radius: 50%;
  animation: bounce-dot .9s ease-in-out infinite;
}
.ai-thinking-dots span:nth-child(2) { animation-delay: .15s; }
.ai-thinking-dots span:nth-child(3) { animation-delay: .30s; }
@keyframes bounce-dot {
  0%, 80%, 100% { transform: scale(0.7); opacity: .45; }
  40%           { transform: scale(1.1); opacity: 1; }
}
.ai-message-card {
  background: var(--indigo-bg);
  border: 1px solid rgba(129,140,248,.2);
  border-radius: var(--radius-lg);
  padding: .9rem 1.25rem;
  font-size: .9rem;
  color: var(--text-primary);
  line-height: 1.65;
  text-align: center;
  max-width: 520px;
  width: 100%;
}
.fade-in { animation: fade-in .5s ease both; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Badge Shelf ─────────────────────────────────────────────── */
.badge-shelf {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: .5rem;
}
.badge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  min-width: 80px;
  cursor: default;
  transition: transform var(--transition), box-shadow var(--transition);
}
.badge-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(129,140,248,.2);
  border-color: var(--indigo);
}
.badge-icon { font-size: 1.6rem; line-height: 1; }
.badge-name { font-size: .72rem; font-weight: 700; color: var(--text-secondary); text-align: center; }

/* ── Empty States ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.empty-icon { font-size: 3rem; margin-bottom: .75rem; opacity: .5; }
.empty-state h3 { font-size: 1.05rem; color: var(--text-primary); margin-bottom: .5rem; font-weight: 700; }
.empty-state p  { color: var(--text-muted); font-size: .875rem; }

/* ── Chapter Info / AI note ──────────────────────────────────── */
.chapter-info-box {
  background: var(--orange-bg);
  border: 1px solid rgba(251,146,60,.2);
  border-left: 3px solid var(--orange);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.chapter-info-title { font-weight: 700; font-size: 1rem; color: var(--text-primary); }
.chapter-info-meta  { font-size: .82rem; color: var(--text-secondary); margin-top: .2rem; }
.ai-note {
  background: var(--indigo-bg);
  border: 1px solid rgba(129,140,248,.2);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  font-size: .875rem;
  color: var(--indigo);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}
.ai-icon { flex-shrink: 0; }
.action-bar { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ── Parent Specific ─────────────────────────────────────────── */
.two-col-layout { display: grid; grid-template-columns: 1fr 380px; gap: 1.5rem; }
.col-main, .col-side { }

.grade-group { margin-bottom: 1.25rem; }
.grade-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: .5rem;
}
.subject-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 0;
  border-bottom: 1px solid var(--border);
}
.subject-row-name { flex: 1; font-weight: 600; color: var(--text-primary); }
.subject-row-meta { color: var(--text-muted); font-size: .82rem; }

/* ── Question table ──────────────────────────────────────────── */
.questions-table .q-index { color: var(--text-muted); font-weight: 700; width: 36px; }
.questions-table .q-text  { max-width: 380px; color: var(--text-primary); }
.answer-tag {
  display: inline-flex;
  width: 24px; height: 24px;
  background: var(--emerald);
  color: #fff;
  border-radius: 50%;
  text-align: center;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: .8rem;
  font-weight: 700;
}
.answer-option-text { font-size: .82rem; color: var(--text-muted); margin-left: .4rem; }
.topic-tag-cell { font-size: .8rem; color: var(--text-muted); }
.chapter-num { color: var(--text-muted); font-weight: 600; }

/* ── Spinner ─────────────────────────────────────────────────── */
.spinner-overlay {
  position: absolute; inset: 0;
  background: rgba(22,27,38,.92);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  z-index: 10;
  backdrop-filter: blur(4px);
}
.form-card { position: relative; }
.spinner-box { text-align: center; }
.spinner-ring {
  width: 48px; height: 48px;
  border: 3px solid var(--border-hover);
  border-top-color: var(--indigo);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto .75rem;
}
.spinner-text    { font-weight: 700; color: var(--text-primary); }
.spinner-subtext { font-size: .82rem; color: var(--text-muted); margin-top: .25rem; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Quiz Container ──────────────────────────────────────────── */
.quiz-progress-wrap {
  height: 3px;
  background: var(--border-hover);
}
.quiz-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--indigo), var(--cyan));
  transition: width .4s ease;
}
.quiz-container {
  max-width: 740px;
  margin: 1.75rem auto;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
}
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: .5rem;
}
.quiz-chapter-name { font-size: .82rem; color: var(--text-muted); font-weight: 500; }
.quiz-counter { font-weight: 700; color: var(--text-primary); font-size: .9rem; }
.quiz-timer {
  font-size: .85rem;
  font-weight: 700;
  color: var(--emerald);
  background: var(--emerald-bg);
  border: 1px solid rgba(52,211,153,.2);
  padding: .3rem .8rem;
  border-radius: 99px;
  min-width: 5rem;
  text-align: center;
  white-space: nowrap;
}
.quiz-timer.timer-danger { color: var(--rose); background: var(--rose-bg); border-color: rgba(248,113,113,.2); }
.question-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.55;
  margin-bottom: 1.5rem;
  letter-spacing: -.2px;
}
.question-diagram {
  display: flex;
  justify-content: center;
  margin: -.5rem 0 1.25rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
  overflow: hidden;
}
.question-diagram svg {
  max-width: 100%;
  height: auto;
  display: block;
}
.question-diagram-sm {
  margin: .5rem 0 0;
  padding: .5rem;
  max-width: 260px;
}
.fc-diagram {
  width: 100%;
  display: flex;
  justify-content: center;
  margin: .25rem 0;
}
.fc-diagram svg {
  max-width: 100%;
  max-height: 90px;
  height: auto;
}

.options-grid { display: flex; flex-direction: column; gap: .65rem; margin-bottom: 1.5rem; }
.option-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .9rem 1.1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  font-size: .925rem;
  transition: all var(--transition);
  color: var(--text-primary);
}
.option-btn:hover   { border-color: var(--indigo); background: var(--indigo-bg); transform: translateX(2px); }
.option-btn.selected { border-color: var(--indigo); background: var(--indigo-bg); box-shadow: 0 0 0 1px var(--indigo); }
.option-label {
  min-width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--border-hover);
  color: var(--text-secondary);
  border-radius: 50%;
  font-weight: 700;
  font-size: .82rem;
  flex-shrink: 0;
  transition: all var(--transition);
}
.option-btn.selected .option-label { background: var(--indigo); color: #fff; }
.option-text { color: var(--text-secondary); line-height: 1.4; }
.option-btn.selected .option-text { color: var(--text-primary); }
.quiz-actions { text-align: right; }

/* ── Quiz Feedback ───────────────────────────────────────────── */
.option-btn:disabled { cursor: default; transform: none; }
.option-correct {
  border-color: var(--emerald) !important;
  background: var(--emerald-bg) !important;
  animation: correctPop .35s ease;
}
.option-correct .option-label { background: var(--emerald) !important; color: #fff !important; }
.option-wrong {
  border-color: var(--rose) !important;
  background: var(--rose-bg) !important;
}
.option-wrong .option-label { background: var(--rose) !important; color: #fff !important; }

@keyframes correctPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.feedback-panel {
  margin-top: 1.5rem;
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  animation: slideUp .3s ease;
  border: 1px solid;
}
.feedback-correct { background: var(--emerald-bg); border-color: rgba(52,211,153,.3); }
.feedback-wrong   { background: var(--rose-bg);    border-color: rgba(248,113,113,.3); }
.feedback-top { display: flex; align-items: center; gap: .75rem; margin-bottom: .6rem; }
.feedback-big-icon { font-size: 2rem; flex-shrink: 0; }
.feedback-title { font-size: 1.05rem; font-weight: 700; }
.feedback-correct .feedback-title { color: var(--emerald); }
.feedback-wrong   .feedback-title { color: var(--rose); }
.feedback-explanation {
  font-size: .875rem;
  color: var(--text-secondary);
  line-height: 1.55;
  background: rgba(255,255,255,.04);
  border-radius: var(--radius);
  padding: .65rem .9rem;
  margin-top: .5rem;
  border: 1px solid var(--border);
}

/* Bouncing stars */
.celebration-wrap {
  display: flex;
  justify-content: center;
  gap: .6rem;
  font-size: 1.6rem;
  margin: .6rem 0 0;
}
.celebration-wrap span { animation: bounce .55s infinite alternate; }
.celebration-wrap span:nth-child(2) { animation-delay: .08s; }
.celebration-wrap span:nth-child(3) { animation-delay: .16s; }
.celebration-wrap span:nth-child(4) { animation-delay: .24s; }
.celebration-wrap span:nth-child(5) { animation-delay: .32s; }

/* Star burst */
.star-burst {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.5rem;
  pointer-events: none;
  z-index: 998;
  opacity: 0;
  display: none;
  white-space: nowrap;
}
.burst-animate { animation: burstOut 1.8s ease-out forwards; }
@keyframes burstOut {
  0%   { opacity: 1; transform: translate(-50%,-50%) scale(.4); }
  50%  { opacity: 1; transform: translate(-50%,-50%) scale(2.2); }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(3.5); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes bounce {
  from { transform: translateY(0); }
  to   { transform: translateY(-14px); }
}

/* ── Flashcards ──────────────────────────────────────────────── */
.btn-fc {
  background: var(--amber-bg);
  color: var(--amber);
  border-color: rgba(251,191,36,.3);
}
.btn-fc:hover { background: var(--amber); color: #0B0F1A; border-color: var(--amber); }

.fc-page {
  max-width: 520px;
  margin: 0 auto;
  padding-bottom: 3rem;
}
.fc-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.fc-title-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.fc-subject-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--amber);
}
.fc-chapter-label {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fc-progress-wrap {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .6rem;
}
.fc-progress-track {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,.07);
  border-radius: 99px;
  overflow: hidden;
}
.fc-progress-known {
  height: 100%;
  background: linear-gradient(90deg, var(--emerald), #10B981);
  border-radius: 99px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
  width: 0%;
}
.fc-counter { font-size: .75rem; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
.fc-stats-row { display: flex; gap: .6rem; margin-bottom: 1.1rem; }
.fc-pill {
  font-size: .72rem;
  font-weight: 700;
  padding: .2rem .7rem;
  border-radius: 99px;
}
.fc-pill-known { background: var(--emerald-bg); color: var(--emerald); border: 1px solid rgba(52,211,153,.2); }
.fc-pill-rem   { background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border); }

/* The 3-D card */
.fc-scene {
  perspective: 1100px;
  width: 100%;
}
.fc-card {
  position: relative;
  width: 100%;
  height: 260px;
  transform-style: preserve-3d;
  transition: transform .45s cubic-bezier(.4,0,.2,1);
  cursor: pointer;
  user-select: none;
}
.fc-card.fc-flipped { transform: rotateY(180deg); }
.fc-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.75rem 1.5rem 1.25rem;
  text-align: center;
  gap: .6rem;
}
.fc-front {
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  box-shadow: var(--shadow);
}
.fc-back {
  background: linear-gradient(145deg, rgba(129,140,248,.1), rgba(129,140,248,.04));
  border: 1px solid rgba(129,140,248,.25);
  box-shadow: 0 0 30px var(--indigo-glow);
  transform: rotateY(180deg);
}
.fc-type-label {
  font-size: .65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--text-muted);
  background: rgba(255,255,255,.06);
  padding: .15rem .6rem;
  border-radius: 99px;
  flex-shrink: 0;
}
.fc-type-answer { color: var(--indigo); background: var(--indigo-bg); }
.fc-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.45;
  overflow-y: auto;
  max-height: 140px;
  width: 100%;
}
.fc-back-text { font-size: 1rem; font-weight: 500; }
.fc-tap-hint {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: auto;
}
.fc-flip-back {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .7rem;
  color: var(--text-muted);
  margin-top: auto;
  padding: .25rem .5rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}
.fc-flip-back:hover { color: var(--indigo); }

/* Buttons */
.fc-skip-row { display: flex; justify-content: center; margin: .75rem 0 .25rem; }
.fc-skip-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .78rem;
  color: var(--text-muted);
  padding: .3rem .75rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}
.fc-skip-btn:hover { color: var(--text-secondary); }
.fc-actions {
  display: flex;
  gap: .75rem;
  justify-content: center;
  margin: .9rem 0 .25rem;
}
.btn-fc-nope {
  background: var(--rose-bg);
  color: var(--rose);
  border: 1px solid rgba(248,113,113,.3);
  border-radius: var(--radius);
  padding: .6rem 1.4rem;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-fc-nope:hover { background: var(--rose); color: #fff; }
.btn-fc-got {
  background: var(--emerald-bg);
  color: var(--emerald);
  border: 1px solid rgba(52,211,153,.3);
  border-radius: var(--radius);
  padding: .6rem 1.4rem;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-fc-got:hover { background: var(--emerald); color: #0B0F1A; }

.fc-key-hint {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin-top: .5rem;
}
.fc-key-hint span {
  font-size: .68rem;
  color: var(--text-muted);
}

/* Done screen */
.fc-done {
  text-align: center;
  padding: 2.5rem 1rem;
}
.fc-done-icon  { font-size: 3rem; margin-bottom: .5rem; }
.fc-done-title { font-size: 1.3rem; font-weight: 800; margin-bottom: .4rem; }
.fc-done-msg   { color: var(--text-secondary); font-size: .9rem; }
.fc-done-actions { display: flex; gap: .75rem; justify-content: center; margin-top: 1.5rem; flex-wrap: wrap; }

@media (max-width: 480px) {
  .fc-card   { height: 230px; }
  .fc-text   { font-size: .95rem; }
  .fc-actions { gap: .5rem; }
  .btn-fc-nope, .btn-fc-got { padding: .55rem 1rem; font-size: .85rem; }
  .fc-key-hint { display: none; }
}

/* ── Quiz Complete ───────────────────────────────────────────── */
.quiz-complete-wrap { max-width: 740px; margin: 0 auto; }
.score-circle-wrap  { text-align: center; padding: 2rem 0 1rem; }
.score-circle {
  width: 140px; height: 140px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  box-shadow: var(--shadow-lg);
}
.score-great { background: linear-gradient(135deg, var(--emerald), #10B981); box-shadow: 0 0 40px rgba(52,211,153,.3); }
.score-ok    { background: linear-gradient(135deg, var(--amber), #F59E0B);   box-shadow: 0 0 40px rgba(251,191,36,.3); }
.score-poor  { background: linear-gradient(135deg, var(--rose), #EF4444);    box-shadow: 0 0 40px rgba(248,113,113,.3); }
.score-percent  { font-size: 2rem; }
.score-message  { font-size: 1.2rem; font-weight: 700; color: var(--text-primary); letter-spacing: -.3px; }
.result-stats   { display: flex; justify-content: center; gap: 2.5rem; padding: 1rem 0 1.5rem; }
.result-stat    { text-align: center; }
.result-stat-num   { font-size: 2rem; font-weight: 800; color: var(--text-primary); }
.result-stat-label { font-size: .78rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.correct { color: var(--emerald); }
.wrong   { color: var(--rose); }
.result-actions { text-align: center; margin-bottom: 2rem; }
.review-section h3 { font-size: 1.05rem; margin-bottom: 1rem; color: var(--text-primary); font-weight: 700; }
.review-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: .75rem;
  display: flex;
  gap: 1rem;
  border-left: 3px solid var(--border);
}
.review-correct { border-left-color: var(--emerald); }
.review-wrong   { border-left-color: var(--rose); }
.review-q-num   { font-weight: 700; color: var(--text-muted); flex-shrink: 0; }
.review-question { font-weight: 600; margin-bottom: .5rem; color: var(--text-primary); }
.review-answers  { font-size: .875rem; margin-bottom: .25rem; }
.review-label    { color: var(--text-muted); margin-right: .4rem; }
.answer-correct  { color: var(--emerald); font-weight: 600; }
.answer-wrong    { color: var(--rose);    font-weight: 600; }
.review-explanation {
  font-size: .82rem;
  background: var(--indigo-bg);
  color: var(--indigo);
  padding: .5rem .75rem;
  border-radius: var(--radius-sm);
  margin-top: .5rem;
  border: 1px solid rgba(129,140,248,.15);
}

/* Perfect glow */
.perfect-glow {
  box-shadow: 0 0 0 6px rgba(52,211,153,.2), 0 0 60px rgba(52,211,153,.4);
  animation: perfectPulse 1.4s ease-in-out infinite alternate;
}
@keyframes perfectPulse {
  from { box-shadow: 0 0 0 4px rgba(52,211,153,.15), 0 0 40px rgba(52,211,153,.3); }
  to   { box-shadow: 0 0 0 12px rgba(52,211,153,.2), 0 0 80px rgba(52,211,153,.45); }
}
.celebration-big {
  display: flex; justify-content: center; gap: .75rem; font-size: 2rem; margin: .75rem 0;
}
.celebration-big span { animation: bounce .6s infinite alternate; }
.celebration-big span:nth-child(2) { animation-delay: .1s; }
.celebration-big span:nth-child(3) { animation-delay: .2s; }
.celebration-big span:nth-child(4) { animation-delay: .3s; }
.celebration-big span:nth-child(5) { animation-delay: .4s; }
.celebration-big span:nth-child(6) { animation-delay: .5s; }
.celebration-big span:nth-child(7) { animation-delay: .6s; }
.celebration-big span:nth-child(8) { animation-delay: .7s; }

/* ── Performance Page ────────────────────────────────────────── */
.mini-progress { width: 120px; height: 6px; background: var(--border-hover); border-radius: 99px; overflow: hidden; }
.mini-bar      { height: 100%; border-radius: 99px; transition: width .5s ease; }
.bar-green  { background: var(--emerald); }
.bar-orange { background: var(--amber); }
.bar-red    { background: var(--rose); }
.weak-topics-grid { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.5rem; }
.weak-topic-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .9rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.topic-name { font-weight: 600; font-size: .875rem; color: var(--text-primary); }
.weak-topic-list { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }

/* ── Teaching Mode ───────────────────────────────────────────── */
.teach-layout {
  display: flex;
  height: calc(100vh - 60px);
  overflow: hidden;
}
.pdf-panel {
  flex: 0 0 70%;
  background: #0a0a0f;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.pdf-canvas-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.25rem;
  position: relative;
}
.pdf-canvas-wrap canvas { display: block; box-shadow: 0 8px 40px rgba(0,0,0,.7); }
.pdf-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--text-muted);
  font-size: .9rem;
}
.pdf-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .65rem 1rem;
  background: rgba(0,0,0,.5);
  border-top: 1px solid rgba(255,255,255,.06);
  flex-wrap: wrap;
}
.pdf-btn {
  background: rgba(255,255,255,.08);
  color: var(--text-secondary);
  border: 1px solid rgba(255,255,255,.1);
  padding: .4rem .85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .82rem;
  transition: all var(--transition);
  min-height: 36px;
}
.pdf-btn:hover { background: rgba(255,255,255,.14); color: var(--text-primary); }
.page-indicator { color: var(--text-secondary); font-size: .82rem; padding: 0 .5rem; white-space: nowrap; }
.zoom-label     { color: var(--text-muted); font-size: .78rem; min-width: 3rem; text-align: center; }
.pdf-ctrl-sep   { width: 1px; height: 18px; background: rgba(255,255,255,.08); margin: 0 .25rem; }

.teach-panel {
  flex: 0 0 30%;
  background: var(--bg-surface);
  overflow-y: auto;
  padding: 1.5rem;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.teach-chapter-info { border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
.teach-subject-tag  { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--orange); margin-bottom: .25rem; }
.teach-chapter-title{ font-size: 1rem; font-weight: 700; color: var(--text-primary); line-height: 1.35; }
.teach-section      { border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
.teach-label        { font-size: .72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: .4rem; display: block; }
.teach-notes        { width: 100%; border: 1px solid var(--border-hover); border-radius: var(--radius); padding: .6rem .8rem; font-size: .875rem; resize: vertical; background: var(--bg-input); color: var(--text-primary); }
.teach-notes:focus  { outline: none; border-color: var(--indigo); box-shadow: 0 0 0 2px var(--indigo-glow); }
.notes-status       { font-size: .72rem; color: var(--emerald); margin-top: .25rem; height: 1rem; }
.collapsible-toggle {
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-size: .82rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  margin-bottom: .5rem;
  transition: color var(--transition);
}
.collapsible-toggle:hover { color: var(--text-primary); }
.questions-list { max-height: 250px; overflow-y: auto; }
.teach-q-item { display: flex; gap: .5rem; align-items: flex-start; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.teach-q-num  { min-width: 22px; height: 22px; border-radius: 50%; background: var(--indigo-bg); color: var(--indigo); font-size: .68rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; border: 1px solid rgba(129,140,248,.2); }
.teach-q-text { font-size: .8rem; color: var(--text-secondary); line-height: 1.45; }
.no-questions { font-size: .82rem; color: var(--text-muted); }
.teach-cta    { display: flex; flex-direction: column; align-items: stretch; margin-top: auto; gap: .5rem; }
.back-link    { text-align: center; font-size: .82rem; color: var(--text-muted); }

/* ── Footer ──────────────────────────────────────────────────── */
footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  text-align: center;
  padding: 1rem;
  font-size: .78rem;
}

/* ── Cheatsheet ──────────────────────────────────────────────── */
.cs-toolbar {
  display: flex;
  gap: .75rem;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.cs-page {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  margin-bottom: 1.5rem;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  page-break-inside: avoid;
  break-inside: avoid;
}
.cs-page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.cs-chapter-badge {
  background: var(--indigo-bg);
  color: var(--indigo);
  border: 1px solid rgba(129,140,248,.2);
  border-radius: var(--radius-sm);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: .25rem .6rem;
  flex-shrink: 0;
  white-space: nowrap;
}
.cs-chapter-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  flex: 1;
}
.cs-body { padding: 1.25rem; }
.cs-section { margin-bottom: 1rem; }
.cs-section:last-child { margin-bottom: 0; }
.cs-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: .5rem;
}
.cs-overview-text {
  font-size: .9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin: 0;
}
.cs-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
.cs-right-col { display: flex; flex-direction: column; gap: .75rem; }
.cs-concepts { display: flex; flex-direction: column; gap: .4rem; }
.cs-concept-row {
  display: flex;
  gap: .6rem;
  font-size: .85rem;
  padding: .35rem .5rem;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  align-items: flex-start;
}
.cs-term {
  font-weight: 700;
  color: var(--indigo);
  min-width: 90px;
  flex-shrink: 0;
  font-size: .82rem;
}
.cs-def { color: var(--text-secondary); line-height: 1.4; font-size: .82rem; }
.cs-list {
  list-style: none;
  padding: 0; margin: 0;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.cs-list li {
  font-size: .85rem;
  color: var(--text-secondary);
  padding: .35rem .5rem .35rem .9rem;
  position: relative;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  line-height: 1.4;
}
.cs-list li::before {
  content: '•';
  position: absolute;
  left: .35rem;
  color: var(--emerald);
  font-weight: 700;
}
.cs-tips-section { background: var(--amber-bg, rgba(251,191,36,.06)); border: 1px solid rgba(251,191,36,.15); border-radius: var(--radius); padding: .6rem .75rem; }
.cs-tips-list li::before { color: var(--amber); }
.cs-empty {
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: .9rem;
}
.cs-overview-section { border-bottom: 1px solid var(--border); padding-bottom: 1rem; margin-bottom: 1rem; }
.cs-print-header { display: none; }

/* ── Focus styles (keyboard nav) ─────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 3px;
}
.btn:focus-visible, .nav-link:focus-visible, .option-btn:focus-visible, .pdf-btn:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 3px;
}
.form-control:focus-visible {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-glow);
}

/* ── Reduced-motion ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  main { animation: none; }
}

/* ── Print ───────────────────────────────────────────────────── */
@media print {
  .navbar, .nav-toggle, footer, .form-actions, .result-actions,
  .btn, #confetti-canvas, .no-print { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
  main { max-width: 100%; padding: 0; }
  .data-table { border: 1px solid #ccc; box-shadow: none; }
  .score-circle { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .review-card  { break-inside: avoid; }

  /* Cheatsheet print header */
  .cs-print-header {
    display: block !important;
    text-align: center;
    border-bottom: 2px solid #333;
    padding-bottom: .5cm;
    margin-bottom: .6cm;
  }
  .cs-print-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: #000;
  }
  .cs-print-sub {
    font-size: .9rem;
    color: #555;
    margin-top: .15rem;
  }

  /* Cheatsheet print styles */
  .cs-page {
    background: #fff !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    break-inside: avoid;
    margin-bottom: 1cm;
  }
  .cs-page-header { background: #f5f5f5 !important; }
  .cs-chapter-badge { background: #e8e8f0 !important; color: #3730a3 !important; border-color: #ccc !important; }
  .cs-overview-text, .cs-concept-row, .cs-list li { background: #fafafa !important; border-color: #ddd !important; }
  .cs-term { color: #3730a3 !important; }
  .cs-def, .cs-list li, .cs-overview-text { color: #333 !important; }
  .cs-tips-section { background: #fffbeb !important; border-color: #fde68a !important; }
  .cs-columns { grid-template-columns: 1fr 1fr; }
  .page-header, .cs-toolbar { display: none !important; }
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .card-grid.three-col { grid-template-columns: repeat(2, 1fr); }
  .card-grid.four-col  { grid-template-columns: repeat(2, 1fr); }
  .two-col-layout      { grid-template-columns: 1fr; }
  .teach-layout { flex-direction: column; height: auto; overflow: visible; }
  .pdf-panel    { height: 60vh; flex: none; }
  .teach-panel  { flex: none; height: auto; }
}

@media (max-width: 700px) {
  .cs-columns { grid-template-columns: 1fr; }
  .nav-toggle { display: block; }
  .navbar-links {
    display: none;
    position: absolute;
    top: 60px;
    right: 0; left: 0;
    background: rgba(11,15,26,.97);
    backdrop-filter: blur(20px);
    flex-direction: column;
    padding: .5rem 0;
    border-bottom: 1px solid var(--border);
    z-index: 100;
  }
  .navbar-links.open { display: flex; }
  .navbar-links .nav-link {
    padding: .8rem 1.25rem;
    border-radius: 0;
    font-size: .95rem;
    border-bottom: 1px solid var(--border);
    min-height: 48px;
  }
  .card-grid.three-col { grid-template-columns: 1fr; }
  .feature-card { flex-direction: column; text-align: center; }
  .page-header h1     { font-size: 1.3rem; }
  .page-header .subtitle { font-size: .85rem; }
  .login-wrap  { flex-direction: column; align-items: stretch; padding: 1rem; gap: 1rem; }
  .login-card  { max-width: 100%; padding: 1.75rem 1.25rem; }
  .form-card   { max-width: 100%; padding: 1.5rem 1.25rem; }
  .data-table th, .data-table td { padding: .55rem .65rem; font-size: .82rem; }
  .steps-row { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  main { padding: 1rem .75rem 2.5rem; }
  .xp-bar-wrap { flex-wrap: wrap; gap: .6rem; }
  .xp-bar-label { width: 100%; text-align: center; }
  .card-grid.four-col { grid-template-columns: repeat(2, 1fr); }
  .card-grid          { gap: .75rem; }
  .quiz-container { padding: 1.1rem 1rem; }
  .form-card      { padding: 1.25rem 1rem; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; justify-content: center; }
  .option-btn { padding: .8rem .9rem; font-size: .9rem; }
  .result-stats { gap: 1.25rem; flex-wrap: wrap; }
  .hide-mobile { display: none !important; }
  .page-header { padding: 1.1rem 1.25rem; }
  .page-header h1 { font-size: 1.1rem; }
  .stat-number { font-size: 1.75rem; }
  .score-circle { width: 110px; height: 110px; font-size: 1.7rem; }
  .score-percent { font-size: 1.6rem; }
  .flash-container { right: .5rem; left: .5rem; max-width: 100%; }
}
