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

/* ── Child login / home ───────────────────────────────────────────── */
.child-shell {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem 1rem;
  background: #fdf4ff;
}

.child-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 1.25rem;
  padding: 2.5rem 1.75rem;
  box-shadow: 0 6px 32px rgba(139,92,246,0.12);
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.child-logo {
  font-size: 2.25rem;
  font-weight: 800;
  color: #7c3aed;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.child-tagline {
  color: #6d28d9;
  font-size: 1.1rem;
  margin-bottom: 2rem;
  font-weight: 500;
}

.child-loading { color: #a78bfa; }

.child-form-login {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.child-input {
  width: 100%;
  padding: 1rem 1.125rem;
  font-size: 1.125rem;
  border: 2px solid #ddd6fe;
  border-radius: 0.75rem;
  background: #faf5ff;
  color: #1e293b;
  outline: none;
  text-align: center;
  transition: border-color 0.15s;
}

.child-input:focus { border-color: #7c3aed; background: #fff; }

.child-error {
  color: #dc2626;
  font-size: 0.9rem;
  text-align: center;
}

.child-login-btn {
  width: 100%;
  padding: 1rem;
  font-size: 1.125rem;
  font-weight: 700;
  background: #7c3aed;
  color: #fff;
  border: none;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 0.25rem;
}

.child-login-btn:hover:not(:disabled) { background: #6d28d9; }
.child-login-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.child-parent-link {
  margin-top: 2rem;
  font-size: 0.8rem;
  color: #a78bfa;
  text-decoration: none;
}

.child-parent-link:hover { color: #7c3aed; text-decoration: underline; }

/* ── Child home screen ────────────────────────────────────────────── */
.child-home-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  margin-bottom: 1.5rem;
}

.child-home-avatar { font-size: 2.5rem; }

.child-home-greeting {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1e293b;
}

.child-home-meta { font-size: 0.85rem; color: #64748b; margin-top: 0.2rem; }

.child-placeholder {
  color: #94a3b8;
  font-size: 0.95rem;
  text-align: center;
  margin-bottom: 2rem;
  width: 100%;
}

.child-logout-btn {
  padding: 0.625rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  background: #f3e8ff;
  color: #7c3aed;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
}

.child-logout-btn:hover { background: #ede9fe; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #f8fafc;
  color: #1e293b;
  min-height: 100vh;
}

.app-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 1rem;
}

h1 { font-size: 2.5rem; color: #4f46e5; }

/* ── Parent login / dashboard ─────────────────────────────────────── */
.parent-shell {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem 1rem;
  background: #f1f5f9;
}

.parent-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 1rem;
  padding: 2rem 1.5rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  margin-top: 2rem;
}

.parent-title {
  font-size: 2rem;
  color: #4f46e5;
  text-align: center;
  margin-bottom: 0.25rem;
}

.parent-subtitle {
  text-align: center;
  color: #64748b;
  margin-bottom: 2rem;
  font-size: 1rem;
}

.parent-greeting {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.75rem;
}

.parent-placeholder {
  color: #64748b;
  margin-bottom: 1.5rem;
}

.parent-loading {
  text-align: center;
  color: #94a3b8;
}

.parent-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.parent-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #475569;
  margin-top: 0.5rem;
}

.parent-input {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  border: 1.5px solid #cbd5e1;
  border-radius: 0.5rem;
  background: #f8fafc;
  color: #1e293b;
  outline: none;
  transition: border-color 0.15s;
}

.parent-input:focus {
  border-color: #4f46e5;
  background: #fff;
}

.parent-error {
  color: #dc2626;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.parent-btn {
  width: 100%;
  padding: 0.875rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  margin-top: 1rem;
  transition: opacity 0.15s;
}

.parent-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.parent-btn--primary {
  background: #4f46e5;
  color: #fff;
}

.parent-btn--primary:hover:not(:disabled) { background: #4338ca; }

.parent-btn--secondary {
  background: #f1f5f9;
  color: #475569;
}

.parent-btn--secondary:hover { background: #e2e8f0; }

@media (min-width: 480px) {
  .parent-shell { padding: 2rem 1.5rem; }
  .parent-card { margin-top: 3rem; }
}

/* ── Dashboard ────────────────────────────────────────────────────── */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.dash-logout {
  width: auto;
  padding: 0.5rem 1rem;
  margin-top: 0;
  font-size: 0.875rem;
}

.dash-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
  margin: 1.5rem 0 0.75rem;
}

.dash-empty {
  color: #94a3b8;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

/* ── Child card ───────────────────────────────────────────────────── */
.children-list { display: flex; flex-direction: column; gap: 0.75rem; }

.child-card {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 0.625rem;
}

.child-avatar { font-size: 1.75rem; line-height: 1; flex-shrink: 0; }

.child-info { flex: 1; min-width: 0; }

.child-name { font-weight: 600; color: #1e293b; font-size: 1rem; }

.child-meta { font-size: 0.8rem; color: #64748b; margin-top: 0.125rem; }

.child-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

.child-btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
}

.child-btn--edit { background: #e0e7ff; color: #4338ca; }
.child-btn--edit:hover { background: #c7d2fe; }
.child-btn--delete { background: #fee2e2; color: #dc2626; }
.child-btn--delete:hover { background: #fecaca; }

/* ── Child forms ──────────────────────────────────────────────────── */
.child-form-box {
  background: #f0f9ff;
  border: 1.5px solid #bae6fd;
  border-radius: 0.625rem;
  padding: 1rem;
}

.child-form-title {
  font-weight: 700;
  color: #0369a1;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.child-form { display: flex; flex-direction: column; gap: 0.35rem; }

.child-form-actions { display: flex; gap: 0.75rem; margin-top: 0.5rem; }
.child-form-actions .parent-btn { margin-top: 0; }

/* ── Child home (subject tiles) ───────────────────────────────────── */
.child-home-shell {
  min-height: 100vh;
  background: #fdf4ff;
  display: flex;
  flex-direction: column;
}

.child-home-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: #fff;
  border-bottom: 1.5px solid #ede9fe;
  gap: 0.75rem;
}

.child-home-identity {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.child-home-avatar-sm { font-size: 1.75rem; line-height: 1; }

.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  padding: 1.25rem;
}

.subject-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 160px;
  padding: 1.25rem 0.75rem;
  background: #fff;
  border: 1.5px solid #ede9fe;
  border-radius: 1rem;
  box-shadow: 0 2px 8px rgba(139,92,246,0.08);
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.1s;
  text-align: center;
}

.subject-tile:hover {
  box-shadow: 0 4px 16px rgba(139,92,246,0.18);
  border-color: #c4b5fd;
  transform: translateY(-2px);
}

.subject-tile:active { transform: translateY(0); }

.subject-tile-emoji { font-size: 3rem; line-height: 1; }

.subject-tile-name {
  font-size: 1.125rem;
  font-weight: 700;
  color: #1e293b;
}

.subject-tile-progress {
  font-size: 0.8rem;
  color: #94a3b8;
  line-height: 1.3;
}

.subject-error {
  color: #dc2626;
  font-size: 0.9rem;
}

/* ── Chapter list page ─────────────────────────────────────────────── */
.chapter-list-card {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 1.25rem;
  min-height: 100vh;
}

.chapter-back-btn {
  background: none;
  border: none;
  color: #7c3aed;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0;
  margin-bottom: 1rem;
}

.chapter-back-btn:hover { color: #5b21b6; }

.chapter-subject-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.chapter-subject-emoji { font-size: 2rem; }

.chapter-subject-name {
  font-size: 1.5rem;
  font-weight: 800;
  color: #1e293b;
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chapter-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem 1rem;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 0.625rem;
}

.chapter-seq {
  font-size: 0.875rem;
  color: #94a3b8;
  flex-shrink: 0;
  width: 1.5rem;
  text-align: right;
}

.chapter-name {
  flex: 1;
  font-size: 0.975rem;
  color: #1e293b;
  font-weight: 500;
}

.chapter-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  background: #ede9fe;
  color: #6d28d9;
  border-radius: 9999px;
  flex-shrink: 0;
}

.chapter-row--clickable {
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.chapter-row--clickable:hover {
  background: #faf5ff;
  border-color: #ddd6fe;
}

/* ── Chapter page ──────────────────────────────────────────────────── */
.chapter-page-card {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 1.25rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.chapter-page-context {
  font-size: 0.9rem;
  color: #7c3aed;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.chapter-page-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

.chapter-page-progress {
  font-size: 1rem;
  color: #64748b;
  margin-bottom: 2rem;
}

.chapter-start-btn {
  width: 100%;
  padding: 1.125rem;
  font-size: 1.125rem;
  font-weight: 700;
  background: #7c3aed;
  color: #fff;
  border: none;
  border-radius: 0.875rem;
  cursor: pointer;
  transition: background 0.15s;
}

.chapter-start-btn:hover { background: #6d28d9; }
.chapter-start-btn:active { background: #5b21b6; }

/* ── Question page ─────────────────────────────────────────────────── */
.question-shell {
  min-height: 100vh;
  background: #fdf4ff;
  display: flex;
  flex-direction: column;
}

.question-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: #fff;
  border-bottom: 1.5px solid #ede9fe;
  min-height: 3rem;
}

.question-clock {
  font-family: monospace;
  font-size: 0.875rem;
  color: #94a3b8;
  letter-spacing: 0.05em;
}

.question-breadcrumb {
  font-size: 0.8rem;
  color: #7c3aed;
  font-weight: 600;
  padding: 0.5rem 1.25rem;
  background: #faf5ff;
  border-bottom: 1px solid #ede9fe;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.question-body {
  flex: 1;
  padding: 1.5rem 1.25rem 2rem;
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
}

.question-text {
  font-size: 1.2rem;
  line-height: 1.75;
  color: #1e293b;
  margin-bottom: 2rem;
  word-break: break-word;
}

.question-text .katex-display {
  margin: 1rem 0;
  overflow-x: auto;
}

/* FIB */
.question-fib-area {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.question-input {
  width: 100%;
  height: 48px;
  padding: 0 1rem;
  font-size: 18px;
  border: 2px solid #ddd6fe;
  border-radius: 0.75rem;
  background: #faf5ff;
  color: #1e293b;
  outline: none;
  transition: border-color 0.15s;
}

.question-input:focus { border-color: #7c3aed; background: #fff; }
.question-input:disabled { cursor: not-allowed; opacity: 0.6; }

.question-submit-btn {
  width: 100%;
  padding: 1rem;
  font-size: 1rem;
  font-weight: 700;
  background: #c4b5fd;
  color: #fff;
  border: none;
  border-radius: 0.75rem;
  cursor: not-allowed;
  opacity: 0.7;
}

.question-submit-btn--active {
  background: #7c3aed;
  cursor: pointer;
  opacity: 1;
}

.question-submit-btn--active:hover:not(:disabled) { background: #6d28d9; }
.question-submit-btn--active:disabled { background: #c4b5fd; cursor: not-allowed; opacity: 0.7; }

.question-submit-hint,
.question-mcq-hint {
  font-size: 0.75rem;
  color: #a78bfa;
  text-align: center;
  margin-top: 0.25rem;
}

/* MCQ */
.question-options {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.question-option-card {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 1.5px solid #ddd6fe;
  border-radius: 0.75rem;
  font-size: 1rem;
  color: #1e293b;
  cursor: pointer;
  text-align: left;
  line-height: 1.4;
  transition: background 0.12s, border-color 0.12s;
}

.question-option-card:hover:not(:disabled) {
  background: #faf5ff;
  border-color: #c4b5fd;
}

.question-option-card:disabled { cursor: not-allowed; opacity: 0.65; }

.question-option-card--wrong {
  background: #fff7f7;
  border-color: #fca5a5;
  color: #94a3b8;
  text-decoration: line-through;
}

.question-option-card--correct {
  background: #f0fdf4;
  border-color: #4ade80;
  color: #166534;
}

.question-option-letter {
  font-weight: 700;
  color: #7c3aed;
  margin-right: 0.25rem;
  flex-shrink: 0;
}

/* Previous wrong attempts */
.question-prev-attempts {
  margin-top: 1.5rem;
  font-size: 0.875rem;
  color: #64748b;
  background: #f8fafc;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
}

.question-prev-attempts strong { display: block; margin-bottom: 0.25rem; color: #475569; }
.question-prev-attempts ul { margin: 0; padding-left: 1.25rem; }
.question-prev-attempts li { margin-top: 0.2rem; }

/* Wrong / error feedback */
.question-wrong-msg {
  margin-top: 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #c2410c;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 0.5rem;
  padding: 0.625rem 0.875rem;
}

.question-submit-error {
  margin-top: 0.625rem;
  font-size: 0.875rem;
  color: #dc2626;
  text-align: center;
}

/* Correct result panel */
.question-result-panel {
  margin-top: 1.5rem;
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  border-radius: 1rem;
  padding: 1.25rem;
}

.question-result-correct {
  font-size: 1.25rem;
  font-weight: 800;
  color: #166534;
  margin-bottom: 0.75rem;
}

.question-result-explanation {
  font-size: 0.975rem;
  color: #1e293b;
  line-height: 1.6;
  margin-bottom: 0.75rem;
  background: #fff;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
}

.question-levelup-badge {
  font-size: 0.95rem;
  font-weight: 700;
  color: #7c3aed;
  background: #ede9fe;
  border-radius: 0.5rem;
  padding: 0.5rem 0.875rem;
  margin-top: 0.5rem;
  display: inline-block;
}

/* Band crossing overlay */
.band-crossing-overlay {
  position: fixed;
  inset: 0;
  background: rgba(124, 58, 237, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: pointer;
  animation: fadeInOverlay 0.3s ease;
}

@keyframes fadeInOverlay {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

.band-crossing-content {
  text-align: center;
  color: #fff;
  padding: 2rem;
}

.band-crossing-emoji { font-size: 5rem; line-height: 1; margin-bottom: 1rem; }
.band-crossing-title { font-size: 1.25rem; font-weight: 500; opacity: 0.85; }
.band-crossing-band  { font-size: 2.5rem; font-weight: 900; letter-spacing: -0.02em; margin: 0.25rem 0; }
.band-crossing-level { font-size: 1.1rem; opacity: 0.8; margin-top: 0.5rem; }

/* Plain level-up toast */
.levelup-toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: #7c3aed;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.625rem 1.25rem;
  border-radius: 9999px;
  box-shadow: 0 4px 16px rgba(124,58,237,0.35);
  z-index: 100;
  animation: slideDownToast 0.3s ease;
  white-space: nowrap;
}

@keyframes slideDownToast {
  from { opacity: 0; transform: translateX(-50%) translateY(-1rem); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (min-width: 600px) {
  .question-text { font-size: 1.3rem; }
  .question-body { padding: 2rem 1.5rem 3rem; }
}

/* ── Flag button on question page ── */
.flag-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.375rem 0;
  margin-top: 0.75rem;
}
.flag-btn:hover { color: #64748b; }
.flag-btn--done { color: #f59e0b; cursor: default; }

/* Flag modal */
.flag-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.flag-modal {
  background: #fff;
  border-radius: 1rem;
  padding: 1.5rem;
  width: min(90vw, 380px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}
.flag-modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 1rem;
}
.flag-modal-textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1.5px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.625rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  resize: none;
  margin-bottom: 1rem;
}
.flag-modal-textarea:focus { outline: none; border-color: #7c3aed; }
.flag-modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }
.flag-modal-cancel {
  background: none;
  border: 1.5px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  color: #64748b;
}
.flag-modal-cancel:hover { border-color: #cbd5e1; }
.flag-modal-send {
  background: #7c3aed;
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.flag-modal-send:disabled { opacity: 0.6; cursor: not-allowed; }

/* Flag toast */
.flag-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 1.25rem;
  border-radius: 9999px;
  z-index: 200;
  animation: slideUpToast 0.3s ease;
  white-space: nowrap;
}
@keyframes slideUpToast {
  from { opacity: 0; transform: translateX(-50%) translateY(1rem); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Flag type selection cards ── */
.flag-type-options { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.75rem; }
.flag-type-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem;
  border: 2px solid #e2e8f0; border-radius: 0.75rem; padding: 0.75rem 1rem;
  background: #fff; cursor: pointer; text-align: left; transition: border-color 0.15s;
  width: 100%;
}
.flag-type-card:hover { border-color: #94a3b8; }
.flag-type-card--selected { border-color: #7c3aed; background: #faf5ff; }
.flag-type-icon { font-size: 1.1rem; }
.flag-type-label { font-size: 0.95rem; font-weight: 600; color: #1e293b; }
.flag-type-desc  { font-size: 0.8rem; color: #64748b; }

/* ── Challenge validator states ── */
.challenge-spinner { font-size: 2.5rem; margin-bottom: 1rem; animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.challenge-checking { font-size: 1.2rem; font-weight: 700; color: #1e293b; margin-bottom: 0.5rem; }
.challenge-sub { font-size: 0.9rem; color: #64748b; }
.challenge-result-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.challenge-result-title { font-size: 1.2rem; font-weight: 700; color: #1e293b; margin-bottom: 0.5rem; }
.challenge-result-sub { font-size: 0.9rem; color: #475569; margin-bottom: 1rem; max-width: 36rem; margin-left: auto; margin-right: auto; }
.challenge-result-cta { font-size: 0.85rem; color: #7c3aed; font-weight: 600; }

/* ── PIN reveal ── */
.reveal-link {
  display: block; margin-top: 1.5rem; background: none; border: none;
  color: #94a3b8; font-size: 0.8rem; cursor: pointer; text-decoration: underline;
  padding: 0; text-align: left;
}
.reveal-link:hover { color: #64748b; }
.reveal-result-panel {
  margin-top: 1.5rem; background: #eff6ff; border: 1.5px solid #bfdbfe;
  border-radius: 0.75rem; padding: 1.25rem;
}
.reveal-result-label { font-size: 0.75rem; color: #3b82f6; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.4rem; }
.reveal-result-answer { font-size: 1.2rem; font-weight: 700; color: #1e40af; margin-bottom: 0.75rem; }
.reveal-result-explanation { font-size: 0.9rem; color: #1e3a8a; line-height: 1.6; }

/* ── Tappable child card ── */
.child-card--tappable { cursor: pointer; transition: background 0.15s; }
.child-card--tappable:hover { background: #f8fafc; }

/* ── Child detail page ── */
.child-detail-back {
  background: none;
  border: none;
  color: #7c3aed;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0;
  margin-bottom: 1.25rem;
  display: block;
}
.child-detail-header { margin-bottom: 1.5rem; }
.child-detail-name { font-size: 1.4rem; font-weight: 800; color: #1e293b; }
.child-detail-meta { font-size: 0.875rem; color: #64748b; margin-top: 0.25rem; }

/* Flag queue */
.flag-queue-section {
  background: #fffbeb;
  border: 1.5px solid #fcd34d;
  border-radius: 1rem;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.flag-queue-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 1rem;
}
.flag-card {
  background: #fff;
  border: 1px solid #fde68a;
  border-radius: 0.75rem;
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.flag-card:last-child { margin-bottom: 0; }
.flag-card-preview {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
}
.flag-card-meta { font-size: 0.775rem; color: #64748b; margin-bottom: 0.5rem; }
.flag-card-note {
  font-size: 0.85rem;
  color: #78350f;
  font-style: italic;
  background: #fef3c7;
  border-radius: 0.375rem;
  padding: 0.375rem 0.625rem;
  margin-bottom: 0.75rem;
}
.flag-card-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.flag-action-btn {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.375rem 0.75rem;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
}
.flag-action-btn--keep    { background: #dcfce7; color: #166534; }
.flag-action-btn--deactivate { background: #fee2e2; color: #991b1b; }
.flag-action-btn--dismiss { background: #f1f5f9; color: #475569; }
.flag-action-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.flag-help-text { font-size: 0.7rem; color: #94a3b8; margin-top: 0.5rem; }

/* Chapter progress rows */
.detail-section { margin-bottom: 1.5rem; }
.detail-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-bottom: 0.75rem;
}
.chapter-progress-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: #f8fafc;
  border-radius: 0.625rem;
  margin-bottom: 0.5rem;
}
.chapter-progress-info { flex: 1; min-width: 0; }
.chapter-progress-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chapter-progress-sub { font-size: 0.775rem; color: #64748b; margin-top: 0.125rem; }
.chapter-progress-right { text-align: right; flex-shrink: 0; }
.chapter-level-badge { font-size: 0.85rem; font-weight: 700; color: #7c3aed; }
.chapter-time { font-size: 0.725rem; color: #94a3b8; }

/* Recent activity list */
.attempt-row {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid #f1f5f9;
}
.attempt-row:last-child { border-bottom: none; }
.attempt-icon { font-size: 1rem; flex-shrink: 0; margin-top: 0.15rem; font-weight: 700; }
.attempt-icon--correct { color: #16a34a; }
.attempt-icon--wrong   { color: #dc2626; }
.attempt-info { flex: 1; min-width: 0; }
.attempt-chapter { font-size: 0.75rem; font-weight: 600; color: #64748b; }
.attempt-preview {
  font-size: 0.875rem;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attempt-tags { display: flex; gap: 0.375rem; margin-top: 0.25rem; flex-wrap: wrap; }
.attempt-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.125rem 0.375rem;
  border-radius: 9999px;
}
.attempt-tag--levelup { background: #ede9fe; color: #5b21b6; }
.attempt-tag--flagged { background: #fef3c7; color: #92400e; }
.attempt-time { font-size: 0.725rem; color: #94a3b8; flex-shrink: 0; text-align: right; line-height: 1.5; }

/* ── Celebration flag card + child detail additions ── */
.flag-card--celebration { background: #fffbeb; border-color: #fcd34d; }
.flag-card-type-label { font-size: 0.72rem; font-weight: 700; color: #7c3aed; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.25rem; }
.flag-card-validator { font-size: 0.82rem; color: #475569; margin: 0.4rem 0; font-style: italic; }
.flag-card-suggested { font-size: 0.85rem; color: #166534; margin: 0.25rem 0 0.5rem; }
.correction-inline { margin-top: 0.5rem; }
.celebration-section .detail-section-title { color: #b45309; }
.reveals-week-badge { font-size: 0.7rem; font-weight: 400; color: #94a3b8; text-transform: none; letter-spacing: 0; }
.child-detail-back { background: none; border: none; color: #7c3aed; font-size: 0.9rem; cursor: pointer; padding: 0 0 1rem; }

/* ── Correction notification banner ── */
.correction-banner {
  display: flex; align-items: flex-start; gap: 0.75rem;
  background: #fffbeb; border: 1.5px solid #fcd34d; border-radius: 0.75rem;
  padding: 0.9rem 1rem; margin: 0.75rem 1rem 0;
}
.correction-banner-star { font-size: 1.3rem; flex-shrink: 0; }
.correction-banner-body { flex: 1; }
.correction-banner-title { font-size: 0.9rem; font-weight: 700; color: #92400e; margin-bottom: 0.2rem; }
.correction-banner-text { font-size: 0.82rem; color: #78350f; line-height: 1.5; }
.correction-banner-dismiss {
  background: none; border: none; color: #b45309; font-size: 1rem;
  cursor: pointer; padding: 0; flex-shrink: 0;
}

/* ── Refresher block ──────────────────────────────────────────────── */
.refresher-block {
  width: 100%;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 0.75rem;
  padding: 1rem 1.1rem;
  margin: 1rem 0;
}
.refresher-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}
.refresher-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #1d4ed8;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
.refresher-hide-btn {
  background: none;
  border: none;
  color: #3b82f6;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.refresher-content {
  font-size: 0.9rem;
  color: #1e3a5f;
  line-height: 1.65;
}
.refresher-content p { margin-bottom: 0.55rem; }
.refresher-content ul, .refresher-content ol {
  padding-left: 1.25rem;
  margin-bottom: 0.55rem;
}
.refresher-content li { margin-bottom: 0.25rem; }
.refresher-content strong { color: #1e40af; }
.refresher-content .katex { font-size: 1em; }
.refresher-show-link {
  display: inline-block;
  background: none;
  border: none;
  color: #3b82f6;
  font-size: 0.88rem;
  cursor: pointer;
  padding: 0.4rem 0;
  margin: 0.5rem 0;
  text-decoration: underline;
}

/* ── Curriculum page ──────────────────────────────────────────────── */
.curriculum-link {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
  margin-bottom: 0.5rem;
  text-decoration: underline;
}
.curriculum-child-section { margin-bottom: 1.5rem; }
.curriculum-child-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 0.5rem;
}
.curriculum-child-meta { font-weight: 400; color: #6b7280; font-size: 0.82rem; margin-left: 0.4rem; }
.curriculum-subject-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.4rem;
  cursor: pointer;
  text-align: left;
}
.curriculum-subject-row:hover { background: #f3f4f6; }
.curriculum-subject-emoji { font-size: 1.1rem; }
.curriculum-subject-name { flex: 1; font-size: 0.9rem; color: #111827; }
.curriculum-subject-count { font-size: 0.8rem; color: #6b7280; }

.curriculum-chapter-list { margin-top: 0.5rem; }
.curriculum-chapter-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid #f3f4f6;
  align-items: flex-start;
}
.curriculum-chapter-num { color: #9ca3af; font-size: 0.85rem; min-width: 1.5rem; padding-top: 0.1rem; }
.curriculum-chapter-info { display: flex; flex-direction: column; }
.curriculum-chapter-name { font-size: 0.88rem; color: #111827; }
.curriculum-chapter-unit { font-size: 0.75rem; color: #6b7280; margin-top: 0.1rem; }

/* ── Chapter correction flow ──────────────────────────────────────── */
.correction-instructions {
  font-size: 0.875rem;
  color: #4b5563;
  line-height: 1.55;
  margin-bottom: 1rem;
}
.correction-file-chosen {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 0.5rem;
  padding: 0.6rem 0.85rem;
  margin-top: 0.75rem;
}
.correction-file-name { flex: 1; font-size: 0.85rem; color: #166534; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.correction-file-change { background: none; border: none; color: #16a34a; font-size: 0.8rem; cursor: pointer; text-decoration: underline; }

.correction-spinner {
  width: 2.5rem; height: 2.5rem;
  border: 3px solid #e5e7eb;
  border-top-color: #6366f1;
  border-radius: 50%;
  margin: 0 auto;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.correction-review-card { max-width: 900px !important; }

.correction-review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin: 1rem 0;
}
@media (max-width: 640px) {
  .correction-review-grid { grid-template-columns: 1fr; }
}

.correction-col { display: flex; flex-direction: column; gap: 0.3rem; }
.correction-col-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  margin-bottom: 0.4rem;
}

.correction-existing-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  background: #f9fafb;
  border-radius: 0.35rem;
  align-items: flex-start;
}
.correction-seq { color: #9ca3af; font-size: 0.8rem; min-width: 1.5rem; padding-top: 0.15rem; }
.correction-name { font-size: 0.85rem; color: #374151; }
.correction-unit { font-size: 0.75rem; color: #9ca3af; }

.correction-extracted-row {
  display: flex;
  gap: 0.4rem;
  align-items: flex-start;
  margin-bottom: 0.4rem;
}
.correction-seq-input {
  width: 3rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid #d1d5db;
  border-radius: 0.35rem;
  font-size: 0.8rem;
  text-align: center;
}
.correction-extracted-fields { flex: 1; display: flex; flex-direction: column; gap: 0.25rem; }
.correction-name-input, .correction-unit-input {
  width: 100%;
  padding: 0.3rem 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.35rem;
  font-size: 0.82rem;
}
.correction-unit-input { font-size: 0.78rem; color: #6b7280; }
.correction-delete-btn {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.2rem;
  margin-top: 0.2rem;
  line-height: 1;
}
.correction-add-row-btn {
  background: none;
  border: 1px dashed #d1d5db;
  color: #6b7280;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 0.35rem;
  margin-top: 0.25rem;
  width: 100%;
}
.correction-add-row-btn:hover { border-color: #9ca3af; color: #374151; }

.correction-confirm-box {
  border-top: 1px solid #e5e7eb;
  padding-top: 1.25rem;
  margin-top: 0.5rem;
}
.correction-confirm-explainer {
  font-size: 0.8rem;
  color: #6b7280;
  line-height: 1.5;
  margin-bottom: 1rem;
}

/* ── Daily activity grid ──────────────────────────────────────────── */
.daily-activity-list { display: flex; flex-direction: column; gap: 0.25rem; }
.daily-day-row {
  border-radius: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
}
.daily-day-row--empty {
  background: transparent;
  border-color: transparent;
  padding-top: 0.3rem;
  padding-bottom: 0.3rem;
}
.daily-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.daily-day-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
}
.daily-day-total {
  font-size: 0.8rem;
  color: #6366f1;
  font-weight: 600;
}
.daily-day-none {
  font-size: 0.78rem;
  color: #d1d5db;
}
.daily-subject-rows {
  margin-top: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.daily-subject-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding-left: 0.25rem;
}
.daily-subject-emoji { font-size: 0.85rem; }
.daily-subject-name { flex: 1; font-size: 0.82rem; color: #4b5563; }
.daily-subject-count {
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
  min-width: 1.5rem;
  text-align: right;
}

/* ── Activity detail / attempt expansion ─────────────────────────────── */
.chapter-progress-row--tappable {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  padding: 0.625rem 0;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
.chapter-progress-row--tappable:hover { background: #f9fafb; border-radius: 0.5rem; }
.chapter-progress-row--tappable:last-child { border-bottom: none; }

.attempt-row--tappable { cursor: pointer; }
.attempt-row--tappable:hover { background: #f9fafb; border-radius: 0.5rem; }
.attempt-row--expanded { background: #f8fafc; border-radius: 0.5rem; padding: 0.625rem 0.5rem; }
.attempt-expand-hint { font-size: 0.65rem; color: #cbd5e1; }

.attempt-detail {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e2e8f0;
}
.attempt-detail-loading { font-size: 0.82rem; color: #94a3b8; }
.attempt-detail-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  margin-bottom: 0.3rem;
}
.attempt-detail-question {
  font-size: 0.9rem;
  color: #1e293b;
  line-height: 1.55;
  margin-bottom: 0.75rem;
  white-space: pre-wrap;
}
.attempt-detail-row {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  margin-bottom: 0.2rem;
  font-size: 0.85rem;
}
.attempt-detail-value { color: #374151; font-weight: 600; }
.attempt-detail-answer-box {
  margin: 0.75rem 0;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 0.5rem;
  padding: 0.6rem 0.75rem;
}
.attempt-detail-answer {
  font-size: 0.95rem;
  font-weight: 700;
  color: #991b1b;
  margin: 0.25rem 0;
}
.attempt-detail-explanation {
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.5;
  margin-top: 0.35rem;
  white-space: pre-wrap;
}
.attempt-detail-history { margin-top: 0.75rem; }
.attempt-detail-hist-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  padding: 0.2rem 0;
  color: #374151;
}
.attempt-detail-hist-row--current { font-weight: 700; }
.attempt-hist-icon { font-size: 0.8rem; font-weight: 700; flex-shrink: 0; }
.attempt-hist-num { color: #9ca3af; min-width: 1.25rem; }
.attempt-hist-answer { flex: 1; }
.attempt-hist-time { color: #64748b; }
.attempt-hist-level { color: #a78bfa; font-size: 0.78rem; }
.attempt-hist-current-marker { color: #6366f1; font-size: 0.75rem; }

.activity-load-more-btn {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.6rem;
  background: none;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  color: #6b7280;
  cursor: pointer;
  min-height: 44px;
}
.activity-load-more-btn:hover:not(:disabled) { background: #f9fafb; color: #374151; }
.activity-load-more-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── ChapterActivityPage ──────────────────────────────────────────────── */
.chap-activity-summary {
  font-size: 0.82rem;
  color: #6b7280;
  margin-bottom: 0.75rem;
}
.chap-activity-count { color: #9ca3af; }

.q-card {
  border: 1px solid #e5e7eb;
  border-radius: 0.625rem;
  padding: 0.75rem 0.875rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  position: relative;
  background: #fff;
  min-height: 44px;
}
.q-card:hover { background: #f9fafb; }
.q-card--expanded { border-color: #a5b4fc; background: #f8f9ff; }
.q-card-header { display: flex; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.25rem; }
.q-card-preview {
  flex: 1;
  font-size: 0.875rem;
  color: #1e293b;
  line-height: 1.45;
}
.q-card-meta { font-size: 0.75rem; color: #9ca3af; margin-bottom: 0.1rem; }
.q-card-toggle {
  position: absolute;
  bottom: 0.5rem;
  right: 0.875rem;
  font-size: 0.65rem;
  color: #cbd5e1;
}
.q-card-body {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e2e8f0;
}

.q-status-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge--challenge { background: #fef9c3; color: #92400e; }
.badge--reveal    { background: #ede9fe; color: #4c1d95; }
.badge--flagged   { background: #fef3c7; color: #92400e; }
.badge--correct   { background: #dcfce7; color: #166534; }
.badge--eventual  { background: #f0fdf4; color: #166534; }
.badge--wrong     { background: #fef2f2; color: #991b1b; }

@media (max-width: 600px) {
  .q-card-header { flex-direction: column; gap: 0.3rem; }
  .q-status-badge { align-self: flex-start; }
  .attempt-detail-row { flex-wrap: wrap; }
}

/* ── App version badge ─────────────────────────────────────────────────────── */
.app-version {
  display: block;
  text-align: center;
  font-size: 0.7rem;
  color: #cbd5e1;
  margin-top: 0.75rem;
  letter-spacing: 0.04em;
}

/* ── Random Quiz ───────────────────────────────────────────────────────────── */
.random-quiz-banner {
  padding: 1.25rem 1.25rem 0;
}

.random-quiz-btn {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  width: 100%;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #6d28d9 0%, #7c3aed 100%);
  border: none;
  border-radius: 1rem;
  cursor: pointer;
  color: #fff;
  text-align: left;
  box-shadow: 0 4px 16px rgba(109,40,217,0.28);
  transition: box-shadow 0.15s, transform 0.1s;
}

.random-quiz-btn:hover {
  box-shadow: 0 6px 24px rgba(109,40,217,0.38);
  transform: translateY(-2px);
}

.random-quiz-btn:active { transform: translateY(0); }

.random-quiz-btn-dice {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}

.random-quiz-btn-label {
  font-size: 1.125rem;
  font-weight: 700;
  display: block;
  line-height: 1.2;
}

.random-quiz-btn-sub {
  font-size: 0.8rem;
  opacity: 0.82;
  display: block;
  margin-top: 0.15rem;
}

.random-quiz-chapter-reveal {
  margin-top: 1rem;
  padding: 0.625rem 0.875rem;
  background: #f5f3ff;
  border-left: 3px solid #7c3aed;
  border-radius: 0.375rem;
  font-size: 0.9rem;
  color: #5b21b6;
  font-weight: 500;
}

.random-quiz-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.random-quiz-actions .random-quiz-keep-going {
  flex: 1;
  min-width: 140px;
}

.random-quiz-home-btn {
  flex: 0 0 auto;
  padding: 0.875rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
  border: 1.5px solid #e2e8f0;
  border-radius: 0.625rem;
  cursor: pointer;
  transition: background 0.15s;
}

.random-quiz-home-btn:hover { background: #e2e8f0; }
