/* ═══════════════════════════════════════════════════════════
   Scholar's Quest — Main Stylesheet
   ═══════════════════════════════════════════════════════════ */

:root {
  --primary: #1B4FD8;
  --primary-light: #EFF6FF;
  --primary-dark: #1440B3;
  --accent: #F59E0B;
  --accent-light: #FFFBEB;
  --success: #059669;
  --success-light: #ECFDF5;
  --danger: #DC2626;
  --danger-light: #FEF2F2;
  --surface: #F8FAFC;
  --border: #E2E8F0;
  --text: #0F172A;
  --text-muted: #64748B;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--surface);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

/* ─── Typography ─────────────────────────────────────────── */
h1, h2, h3 {
  font-family: 'Georgia', 'Times New Roman', serif;
  line-height: 1.25;
  color: var(--text);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }

p { margin-bottom: 0.75rem; }
p:last-child { margin-bottom: 0; }

/* ─── Layout ──────────────────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.container--narrow {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ─── Header / Nav ───────────────────────────────────────── */
.site-header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 0.875rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.site-logo-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.site-logo-text {
  font-family: 'Georgia', serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-link {
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover, .nav-link.active {
  background: var(--primary-light);
  color: var(--primary);
  text-decoration: none;
}

/* ─── Page layout ────────────────────────────────────────── */
.page {
  padding: 2rem 0 4rem;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  margin-bottom: 0.25rem;
}

.page-header p {
  color: var(--text-muted);
  font-size: 1rem;
}

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card--hover {
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
}

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

/* ─── Child Profile Cards ────────────────────────────────── */
.children-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
}

.child-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
  position: relative;
}

.child-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.child-avatar {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 0.75rem;
  display: block;
}

.child-name {
  font-family: 'Georgia', serif;
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.child-level-badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  margin-bottom: 0.875rem;
}

.child-card-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
}

/* ─── XP Bar ──────────────────────────────────────────────── */
.xp-bar-wrap {
  margin-bottom: 0.5rem;
}

.xp-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.xp-bar {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #F97316);
  border-radius: 999px;
  transition: width 0.6s ease;
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1.125rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); color: white; text-decoration: none; }

.btn-accent {
  background: var(--accent);
  color: white;
}
.btn-accent:hover { background: #D97706; color: white; text-decoration: none; }

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { background: #047857; color: white; text-decoration: none; }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface); color: var(--text); text-decoration: none; }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #B91C1C; color: white; text-decoration: none; }

.btn-lg {
  padding: 0.75rem 1.75rem;
  font-size: 1rem;
  border-radius: var(--radius);
}

.btn-sm {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ─── Forms ──────────────────────────────────────────────── */
.form-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--text);
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 79, 216, 0.12);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

/* ─── Radio Groups (subject + difficulty) ───────────────── */
.radio-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.radio-option {
  flex: 1;
  min-width: 100px;
}

.radio-option input[type="radio"] {
  display: none;
}

.radio-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  padding: 0.875rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
  font-weight: 600;
  font-size: 0.875rem;
}

.radio-label:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.radio-option input[type="radio"]:checked + .radio-label {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.radio-label .icon {
  font-size: 1.5rem;
  line-height: 1;
}

/* ─── Difficulty Stars ───────────────────────────────────── */
.difficulty-group {
  display: flex;
  gap: 0.75rem;
}

.difficulty-option input[type="radio"] { display: none; }

.difficulty-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.75rem 1.25rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 80px;
  text-align: center;
}

.difficulty-label .stars { font-size: 1.1rem; letter-spacing: 1px; }

.difficulty-option input:checked + .difficulty-label {
  border-color: var(--accent);
  background: var(--accent-light);
  color: #92400E;
}

/* ─── Avatar Picker ──────────────────────────────────────── */
.avatar-group {
  display: flex;
  gap: 0.75rem;
}

.avatar-option input[type="radio"] { display: none; }

.avatar-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.6rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s;
  font-size: 0.8rem;
  text-align: center;
}

.avatar-label .avi { font-size: 1.75rem; }

.avatar-option input:checked + .avatar-label {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* ─── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  transform: translateY(16px);
  transition: transform 0.2s;
}

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

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

.modal-header h2 { font-size: 1.25rem; }

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

/* ─── Tables ─────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  text-align: left;
  padding: 0.6rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface); }

/* ─── Badge Cabinet ──────────────────────────────────────── */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.75rem;
}

.badge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  padding: 0.875rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.badge-item.earned {
  background: var(--accent-light);
  border-color: var(--accent);
}

.badge-item.locked {
  opacity: 0.4;
  filter: grayscale(100%);
}

.badge-icon { font-size: 2rem; line-height: 1; }
.badge-name { font-size: 0.7rem; font-weight: 600; color: var(--text-muted); line-height: 1.3; }
.badge-item.earned .badge-name { color: #92400E; }

/* ─── Leaderboard ────────────────────────────────────────── */
.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1.25rem;
  box-shadow: var(--shadow);
}

.leaderboard-row.rank-1 { border-color: #F59E0B; background: #FFFBEB; }
.leaderboard-row.rank-2 { border-color: #94A3B8; background: #F8FAFC; }
.leaderboard-row.rank-3 { border-color: #D97706; background: #FEF3C7; }

.rank-number {
  font-family: 'Georgia', serif;
  font-size: 1.25rem;
  font-weight: 700;
  min-width: 2rem;
  text-align: center;
}

.rank-1 .rank-number { color: #D97706; }
.rank-2 .rank-number { color: #64748B; }
.rank-3 .rank-number { color: #B45309; }

.lb-avatar { font-size: 2rem; line-height: 1; }

.lb-info { flex: 1; }
.lb-name { font-weight: 700; font-size: 1rem; }
.lb-level { font-size: 0.8rem; color: var(--text-muted); }

.lb-xp {
  font-family: 'Georgia', serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.lb-xp span { font-size: 0.75rem; font-weight: 400; color: var(--text-muted); font-family: system-ui; }

/* ─── Subject mastery bars ───────────────────────────────── */
.mastery-bar-item {
  margin-bottom: 1rem;
}

.mastery-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.mastery-bar {
  height: 10px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.mastery-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s ease;
}

.mastery-bar-fill.math { background: linear-gradient(90deg, #1B4FD8, #60A5FA); }
.mastery-bar-fill.english { background: linear-gradient(90deg, #059669, #34D399); }
.mastery-bar-fill.science { background: linear-gradient(90deg, #7C3AED, #A78BFA); }

/* ─── Activity Feed ──────────────────────────────────────── */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 1rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.activity-icon { font-size: 1.25rem; }
.activity-text { flex: 1; }
.activity-text strong { font-weight: 600; }
.activity-meta { color: var(--text-muted); font-size: 0.8rem; }
.activity-xp { color: var(--accent); font-weight: 700; white-space: nowrap; }

/* ─── Spinner ─────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

.spinner--dark {
  border-color: rgba(0,0,0,0.15);
  border-top-color: var(--primary);
}

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

/* ─── Loading State ───────────────────────────────────────── */
.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 200px;
  color: var(--text-muted);
}

.loading-overlay .spinner { width: 2.5rem; height: 2.5rem; border-width: 3px; }

/* ─── Alerts / Notices ───────────────────────────────────── */
.alert {
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  display: flex;
  gap: 0.625rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.alert-error { background: var(--danger-light); color: #991B1B; border: 1px solid #FECACA; }
.alert-success { background: var(--success-light); color: #065F46; border: 1px solid #A7F3D0; }
.alert-info { background: var(--primary-light); color: #1E40AF; border: 1px solid #BFDBFE; }

/* ─── Score / Celebration ─────────────────────────────────── */
.celebration {
  text-align: center;
  padding: 2.5rem 1rem;
}

.celebration-icon { font-size: 4rem; margin-bottom: 1rem; }

.xp-gained {
  display: inline-block;
  background: var(--accent-light);
  border: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 1rem 2rem;
  margin: 1.5rem 0;
}

.xp-gained-number {
  font-family: 'Georgia', serif;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.xp-gained-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.level-up-banner {
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  color: white;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  text-align: center;
}

.level-up-banner h2 {
  color: white;
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.new-badges-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1rem;
}

.new-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0.35rem 0.875rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #92400E;
}

/* ─── Pending badge ───────────────────────────────────────── */
.pending-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--danger);
  color: white;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.25rem;
}

/* ─── Subject chips ───────────────────────────────────────── */
.subject-chip {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.subject-chip.math { background: #DBEAFE; color: #1E40AF; }
.subject-chip.english { background: #D1FAE5; color: #065F46; }
.subject-chip.science { background: #EDE9FE; color: #5B21B6; }

/* ─── Score display ───────────────────────────────────────── */
.score-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  font-weight: 700;
}

.score-pct {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ─── Profile Stats ───────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
}

.stat-number {
  font-family: 'Georgia', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ─── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.empty-state h3 { font-size: 1.125rem; margin-bottom: 0.5rem; color: var(--text); }

/* ─── Grid helpers ────────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.25rem; }

/* ─── Utility ─────────────────────────────────────────────── */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
.font-bold { font-weight: 700; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

/* ─── Section heading ─────────────────────────────────────── */
.section-title {
  font-family: 'Georgia', serif;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ─── Worksheet preview on screen ────────────────────────── */
.worksheet-preview {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.worksheet-header-block {
  border-bottom: 2px solid var(--text);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.worksheet-meta { font-size: 0.875rem; color: var(--text-muted); }

.question-block {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px dashed var(--border);
}

.question-block:last-of-type { border-bottom: none; }

.question-number {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.375rem;
}

.question-marks {
  float: right;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.question-text {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  clear: both;
}

.options-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.options-list li { font-size: 0.9375rem; }

.answer-line {
  border-bottom: 1px solid #999;
  height: 1.5rem;
  width: 100%;
  margin-top: 0.5rem;
  display: block;
}

.answer-line + .answer-line { margin-top: 0.375rem; }

.score-tracker-block {
  border-top: 2px solid var(--text);
  margin-top: 2rem;
  padding-top: 1.25rem;
}

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }

  .children-grid { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .three-col { grid-template-columns: 1fr 1fr; }

  .radio-group { gap: 0.5rem; }
  .difficulty-group { gap: 0.5rem; }

  .leaderboard-row { flex-wrap: wrap; }
  .lb-xp { width: 100%; text-align: right; }

  .modal { padding: 1.5rem; }

  .site-nav .nav-link { padding: 0.375rem 0.5rem; font-size: 0.8rem; }
}

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

/* AVATAR PICKER */
.avatar-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.avatar-pick-btn {
  width: 44px; height: 44px;
  font-size: 1.4rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, transform 0.1s;
  line-height: 1;
}
.avatar-pick-btn:hover { border-color: var(--primary); transform: scale(1.1); }
.avatar-pick-btn.active { border-color: var(--primary); background: var(--primary-light); }

/* ═══════════════════════════════════════════════════════════
   ONLINE WORKSHEETS — New styles
   ═══════════════════════════════════════════════════════════ */

/* ─── Status pills ───────────────────────────────────────── */
.status-pill {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.65rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em; white-space: nowrap;
}
.status-pill.assigned   { background: #F1F5F9; color: #64748B; }
.status-pill.in-progress{ background: #DBEAFE; color: #1E40AF; }
.status-pill.completed  { background: #D1FAE5; color: #065F46; }
.status-pill.reviewed   { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }

/* ─── Tabs ───────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; }
.tab-btn {
  padding: 0.625rem 1.25rem; background: none; border: none;
  border-bottom: 2.5px solid transparent; margin-bottom: -2px;
  cursor: pointer; font-size: 0.9375rem; font-weight: 600;
  color: var(--text-muted); transition: color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:hover:not(.active) { color: var(--text); }

/* ─── Worksheet cards (my-worksheets list) ───────────────── */
.ws-list { display: flex; flex-direction: column; gap: 0.75rem; }
.ws-card {
  background: white; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.25rem; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 1rem;
}
.ws-card-icon { font-size: 1.75rem; flex-shrink: 0; line-height: 1; }
.ws-card-body { flex: 1; min-width: 0; }
.ws-card-title { font-weight: 700; font-size: 0.9375rem; margin-bottom: 0.25rem; }
.ws-card-meta { font-size: 0.8rem; color: var(--text-muted); }
.ws-card-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* ─── Child login grid ───────────────────────────────────── */
.login-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1.25rem; max-width: 760px; margin: 0 auto 2rem;
}
.login-child-card {
  background: white; border: 2.5px solid var(--border); border-radius: var(--radius-lg);
  padding: 2rem 1rem 1.5rem; text-align: center; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.login-child-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.login-child-card.selected { border-color: var(--primary); box-shadow: var(--shadow-md); }
.login-child-avatar { font-size: 3.5rem; line-height: 1; margin-bottom: 0.625rem; }
.login-child-name { font-weight: 700; font-size: 1rem; margin-bottom: 0.2rem; }
.login-child-grade { font-size: 0.8rem; color: var(--text-muted); }

/* ─── PIN pad ────────────────────────────────────────────── */
.pin-display { display: flex; gap: 0.875rem; justify-content: center; margin-bottom: 1.5rem; }
.pin-dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid var(--border); background: transparent;
  transition: background 0.12s, border-color 0.12s;
}
.pin-dot.filled { background: var(--primary); border-color: var(--primary); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.625rem; max-width: 260px; margin: 0 auto; }
.pin-btn {
  padding: 0.9rem 0; border: 1.5px solid var(--border); border-radius: var(--radius);
  background: white; cursor: pointer; font-size: 1.375rem; font-weight: 700;
  font-family: inherit; transition: background 0.12s, border-color 0.12s;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.pin-btn:hover:not(.empty) { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.pin-btn:active:not(.empty) { transform: scale(0.94); }
.pin-btn.action { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.03em; }
.pin-btn.confirm { background: var(--primary); color: white; border-color: var(--primary); }
.pin-btn.confirm:hover { background: var(--primary-dark); }
.pin-btn.empty { opacity: 0; cursor: default; pointer-events: none; border-color: transparent; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
.shake { animation: shake 0.38s ease; }

/* ─── Progress dots (online worksheet) ──────────────────── */
.progress-dots { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 1.25rem; }
.progress-dot {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border);
  background: white; cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 0.6rem; font-weight: 700; color: var(--text-muted);
  transition: all 0.15s; flex-shrink: 0;
}
.progress-dot:hover { border-color: var(--primary); }
.progress-dot.answered { background: var(--primary); border-color: var(--primary); color: white; }
.progress-dot.current { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.progress-dot.current.answered { background: var(--primary-dark); border-color: var(--primary-dark); }

/* ─── Timer bar ──────────────────────────────────────────── */
.timer-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.3rem; font-size: 0.8rem; font-weight: 600; }
.timer-bar-wrap { height: 6px; background: var(--border); border-radius: 3px; margin-bottom: 1.25rem; overflow: hidden; }
.timer-bar-fill { height: 100%; background: var(--success); border-radius: 3px; transition: width 1s linear, background 0.3s; }
.timer-bar-fill.amber { background: var(--accent); }
.timer-bar-fill.red { background: var(--danger); }
.timer-label { color: var(--text-muted); }
.timer-label.amber { color: #92400E; }
.timer-label.red { color: var(--danger); font-weight: 700; }

/* ─── Online question UI ─────────────────────────────────── */
.question-card { background: white; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.75rem; box-shadow: var(--shadow); }
.question-card-number { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 0.5rem; }
.question-card-text { font-size: 1.0625rem; line-height: 1.6; margin-bottom: 1.25rem; }
.question-card-marks { font-size: 0.8rem; color: var(--text-muted); background: var(--surface); padding: 0.2rem 0.5rem; border-radius: 999px; display: inline-block; margin-bottom: 1rem; }

.option-btns { display: flex; flex-direction: column; gap: 0.625rem; }
.option-btn {
  display: flex; align-items: center; gap: 1rem; padding: 0.875rem 1.125rem;
  border: 2px solid var(--border); border-radius: var(--radius);
  background: white; cursor: pointer; text-align: left; font-size: 0.9375rem;
  transition: border-color 0.15s, background 0.15s; font-family: inherit;
}
.option-btn:hover:not([disabled]) { border-color: var(--primary); background: var(--primary-light); }
.option-btn.selected { border-color: var(--primary); background: var(--primary-light); }
.option-btn.correct  { border-color: var(--success); background: var(--success-light); }
.option-btn.incorrect{ border-color: var(--danger);  background: var(--danger-light); }
.option-letter {
  width: 32px; height: 32px; border-radius: 50%; background: var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.875rem; flex-shrink: 0;
}
.option-btn.selected  .option-letter { background: var(--primary); color: white; }
.option-btn.correct   .option-letter { background: var(--success); color: white; }
.option-btn.incorrect .option-letter { background: var(--danger);  color: white; }

.tf-btns { display: flex; gap: 1rem; }
.tf-btn {
  flex: 1; padding: 1.125rem; border: 2px solid var(--border); border-radius: var(--radius);
  background: white; cursor: pointer; font-size: 1.0625rem; font-weight: 700;
  font-family: inherit; transition: border-color 0.15s, background 0.15s;
}
.tf-btn:hover:not([disabled]) { border-color: var(--primary); background: var(--primary-light); }
.tf-btn.selected  { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.tf-btn.correct   { border-color: var(--success); background: var(--success-light); color: var(--success); }
.tf-btn.incorrect { border-color: var(--danger);  background: var(--danger-light);  color: var(--danger); }

.online-text-input {
  width: 100%; padding: 0.75rem 1rem; border: 2px solid var(--border); border-radius: var(--radius-sm);
  font-size: 1rem; font-family: inherit; transition: border-color 0.15s, box-shadow 0.15s;
}
.online-text-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(27,79,216,0.12); }

/* ─── Online worksheet navigation ───────────────────────── */
.ws-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 1.5rem; gap: 0.75rem; }
.ws-nav-center { display: flex; align-items: center; gap: 0.75rem; }

/* ─── Autosave indicator ─────────────────────────────────── */
.save-indicator {
  position: fixed; bottom: 1.25rem; right: 1.25rem;
  background: white; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.35rem 0.875rem; box-shadow: var(--shadow); font-size: 0.8rem; color: var(--success);
  opacity: 0; pointer-events: none; transition: opacity 0.3s; z-index: 50;
}
.save-indicator.visible { opacity: 1; }

/* ─── Results screen ─────────────────────────────────────── */
.result-score-display {
  text-align: center; padding: 2rem 1rem 1.5rem;
  border-bottom: 1px solid var(--border); margin-bottom: 1.5rem;
}
.result-score-number { font-family: 'Georgia', serif; font-size: 3rem; font-weight: 700; line-height: 1; }
.result-score-number.green { color: var(--success); }
.result-score-number.amber { color: var(--accent); }
.result-score-number.red   { color: var(--danger); }
.result-score-label { font-size: 0.875rem; color: var(--text-muted); margin-top: 0.25rem; }

.result-item { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.875rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.result-item:last-child { border-bottom: none; }
.result-indicator { font-size: 1.25rem; flex-shrink: 0; margin-top: 1px; }
.result-body { flex: 1; }
.result-q-text { margin-bottom: 0.2rem; }
.result-answer { font-size: 0.8rem; color: var(--text-muted); }
.result-answer .wrong { color: var(--danger); text-decoration: line-through; }
.result-answer .right  { color: var(--success); font-weight: 600; }
.result-marks { font-weight: 700; font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; margin-top: 2px; }

.weak-areas-box { background: #FFF7ED; border: 1px solid #FED7AA; border-radius: var(--radius); padding: 1rem 1.25rem; }
.weak-areas-box h3 { color: #9A3412; font-size: 0.9rem; margin-bottom: 0.375rem; }
.weak-areas-box p { font-size: 0.875rem; color: #C2410C; margin-bottom: 0; }

/* ─── Parent review panel ────────────────────────────────── */
.review-panel { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.25rem 1.5rem; background: var(--surface); margin-top: 0.25rem; }
.review-q-row { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.75rem 0; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.review-q-row:last-of-type { border-bottom: none; }
.review-q-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.review-q-body { flex: 1; }
.review-q-text { margin-bottom: 0.2rem; }
.review-q-answers { font-size: 0.8rem; color: var(--text-muted); }
.review-q-marks { font-weight: 700; font-size: 0.8rem; white-space: nowrap; flex-shrink: 0; }

/* ─── Nav auth area ──────────────────────────────────────── */
.nav-auth-area { display: flex; align-items: center; gap: 0.625rem; margin-left: 0.5rem; padding-left: 0.75rem; border-left: 1px solid var(--border); }
.nav-user-name { font-size: 0.8125rem; color: var(--text-muted); white-space: nowrap; }

/* ═══════════════════════════════════════════════════════════
   KID MODE — Pages, navigation, cards
   ═══════════════════════════════════════════════════════════ */

/* ─── Kid header ─────────────────────────────────────────── */
.kid-header {
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  border-bottom: none;
  padding: 0.875rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(27, 79, 216, 0.25);
}

.kid-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.kid-header .site-logo-text { color: white; }
.kid-header .site-logo-icon { color: white; }

.kid-header .btn-ghost {
  color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.kid-header .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  text-decoration: none;
}

/* ─── Kid select grid ────────────────────────────────────── */
.kid-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.5rem;
  max-width: 820px;
  margin: 0 auto;
}

.kid-select-card {
  background: white;
  border: 3px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.25rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.2s, transform 0.15s;
  user-select: none;
}

.kid-select-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.kid-select-card:active { transform: scale(0.97); }

.kid-select-avatar { font-size: 4rem; line-height: 1; margin-bottom: 0.625rem; }
.kid-select-name { font-family: 'Georgia', serif; font-weight: 700; font-size: 1.125rem; margin-bottom: 0.2rem; }
.kid-select-grade { font-size: 0.8rem; color: var(--text-muted); }
.kid-select-level {
  display: inline-block;
  margin-top: 0.5rem;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
}

/* ─── Kid hero card (dashboard) ──────────────────────────── */
.kid-hero-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  box-shadow: var(--shadow-md);
}

.kid-hero-avatar { font-size: 4.5rem; line-height: 1; flex-shrink: 0; }

.kid-hero-greeting {
  font-family: 'Georgia', serif;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.2rem;
}

.kid-hero-level {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* ─── Kid nav cards (dashboard) ──────────────────────────── */
.kid-nav-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.kid-nav-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 1rem;
  text-decoration: none;
  color: var(--text);
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.2s, transform 0.15s;
  box-shadow: var(--shadow);
  cursor: pointer;
  min-height: 140px;
}

.kid-nav-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  text-decoration: none;
  color: var(--text);
}

.kid-nav-card:active { transform: scale(0.97); }

.kid-nav-icon { font-size: 2.5rem; line-height: 1; }
.kid-nav-label { font-family: 'Georgia', serif; font-size: 1.0625rem; font-weight: 700; }
.kid-nav-sub { font-size: 0.775rem; color: var(--text-muted); }

/* ─── Leaderboard "You" tag ──────────────────────────────── */
.lb-me { border-color: var(--primary) !important; background: var(--primary-light) !important; }
.lb-me-tag {
  display: inline-block;
  background: var(--primary);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 0.25rem;
}

/* ─── Kid Mode button on parent dashboard ────────────────── */
.btn-kid-mode {
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  color: white;
  border: none;
  font-size: 1rem;
  padding: 0.625rem 1.375rem;
}

.btn-kid-mode:hover {
  background: linear-gradient(135deg, var(--primary-dark), #6D28D9);
  color: white;
  text-decoration: none;
}

/* ─── Kid bottom navigation bar ─────────────────────────── */
.kid-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 80;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}

.kid-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-muted);
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.kid-nav-item:hover { text-decoration: none; color: var(--text); }
.kid-nav-item.active { color: var(--primary); }
.kid-nav-item-icon { font-size: 1.375rem; line-height: 1; }
.kid-nav-item-label { font-size: 11px; font-weight: 600; letter-spacing: 0.01em; }

/* ─── Responsive kid layout ──────────────────────────────── */
@media (max-width: 640px) {
  .kid-nav-grid { grid-template-columns: 1fr 1fr; }
  .kid-nav-card { min-height: 120px; padding: 1.5rem 0.75rem; }
  .kid-nav-icon { font-size: 2rem; }
  .kid-nav-label { font-size: 0.9rem; }

  .kid-hero-card { flex-direction: column; text-align: center; }
  .kid-hero-greeting { font-size: 1.5rem; }

  .kid-select-grid { grid-template-columns: 1fr 1fr; gap: 1rem; }
}
