/* ── Reset & base ───────────────────────────────────────────────
   Table of contents
   1. Reset & base
   2. Header & nav
   3. Flash messages
   4. Home menu
   5. Quiz page
   6. Map
   7. Legend
   8. Answer section (side panel)
   9. Buttons
  10. Score banner (legacy, kept for reference)
  11. Quiz body layout (map + side panel)
  12. Side panel
  13. Auth pages (login / register / add-child)
  14. Dashboard — parent overview
  15. Dashboard — child detail (charts + history table)
  16. Custom topics — parent views
  17. Custom topics — child learn views
  18. Responsive
  19. Maths worksheet
  20. Answer checking (AI feedback + parent marking)
  21. Sources / multi-topic wizard
─────────────────────────────────────────────────────────────── */

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

:root {
    --color-bg: #faf8f5;
    --color-surface: #ffffff;
    --color-text: #2d2418;
    --color-muted: #7a6e5e;
    --color-border: #ddd5c8;
    --color-accent: #2563eb;
    --color-green: #059669;
    --color-red: #dc2626;
    --color-amber: #d97706;
    --font-body: Georgia, 'Times New Roman', serif;
    --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius: 8px;
}

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
}

/* ── Header & nav ──────────────────────────────────────────────── */
header {
    padding: 14px 24px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.header-brand { text-align: left; }

header h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.header-link {
    text-decoration: none;
    color: inherit;
}

.subtitle {
    font-size: 12px;
    color: var(--color-muted);
    margin-top: 1px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.nav-link {
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    color: var(--color-accent);
    text-decoration: none;
}

.nav-link:hover { text-decoration: underline; }

.nav-logout { color: var(--color-muted); }

.nav-register {
    padding: 5px 14px;
    border: 1px solid var(--color-accent);
    border-radius: 4px;
    color: var(--color-accent);
}

.nav-register:hover {
    background: var(--color-accent);
    color: white;
    text-decoration: none;
}

.nav-user {
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}

/* ── Flash messages ─────────────────────────────────────────────── */
.flash-messages {
    max-width: 1100px;
    margin: 12px auto 0;
    padding: 0 24px;
}

.flash {
    padding: 10px 16px;
    border-radius: var(--radius);
    font-family: var(--font-ui);
    font-size: 14px;
    margin-bottom: 8px;
}

.flash-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.flash-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.flash-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

main {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 16px 60px;
}

/* ── Home menu ─────────────────────────────────────────────────── */
.group {
    margin-bottom: 28px;
}

.group h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--color-border);
}

.quiz-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.quiz-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--color-text);
    transition: all 0.15s ease;
}

.quiz-card:hover {
    border-color: var(--color-accent);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
    transform: translateY(-1px);
}

.quiz-title {
    font-weight: 600;
    font-size: 15px;
}

.quiz-count {
    font-size: 13px;
    color: var(--color-muted);
    font-family: var(--font-ui);
}

/* ── Quiz page ─────────────────────────────────────────────────── */
.quiz-header {
    margin-bottom: 16px;
}

.quiz-header h2 {
    font-size: 22px;
    margin-bottom: 4px;
}

.quiz-description {
    font-size: 14px;
    color: var(--color-muted);
}

.back-link {
    display: inline-block;
    font-size: 13px;
    font-family: var(--font-ui);
    color: var(--color-accent);
    text-decoration: none;
    margin-bottom: 8px;
}

.back-link:hover { text-decoration: underline; }

/* ── Map ───────────────────────────────────────────────────────── */
#map {
    width: 100%;
    height: 450px;
    border-radius: var(--radius) var(--radius) 0 0;
    border: 1px solid var(--color-border);
    border-bottom: none;
}

.map-controls {
    display: flex;
    justify-content: flex-end;
    padding: 6px 10px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0 0 var(--radius) var(--radius);
    margin-bottom: 8px;
}

.btn-labels {
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-labels:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.btn-labels.active {
    background: #fef3c7;
    border-color: var(--color-amber);
    color: #92400e;
}

/* Override leaflet's default marker styling */
.numbered-marker {
    background: none !important;
    border: none !important;
}

/* ── Legend ─────────────────────────────────────────────────────── */
.legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    padding: 8px 0 16px;
    font-size: 13px;
    font-family: var(--font-ui);
    color: var(--color-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.legend-dot.city,
.legend-dot.capital  { background: #2563eb; }
.legend-dot.country  { background: #059669; }
.legend-dot.river    { background: #0891b2; }
.legend-dot.mountain,
.legend-dot.upland   { background: #92400e; }
.legend-dot.sea      { background: #6366f1; }
.legend-dot.desert   { background: #d97706; }

/* ── Answer section ────────────────────────────────────────────── */
.answer-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
}

.answer-section h3 {
    font-size: 16px;
    margin-bottom: 14px;
}

.answer-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
}

.answer-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 6px;
    transition: background 0.2s;
}

.answer-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #5c4f3d;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.answer-type {
    font-size: 11px;
    font-family: var(--font-ui);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
    min-width: 65px;
    text-align: center;
    color: white;
    font-weight: 600;
}

.answer-type.city,
.answer-type.capital  { background: #2563eb; }
.answer-type.country  { background: #059669; }
.answer-type.river    { background: #0891b2; }
.answer-type.mountain,
.answer-type.upland   { background: #92400e; }
.answer-type.sea      { background: #6366f1; }
.answer-type.desert   { background: #d97706; }

.answer-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-bg);
    transition: border-color 0.15s;
}

.answer-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.answer-input:disabled {
    opacity: 0.7;
}

.answer-result {
    font-size: 14px;
    font-weight: 600;
    min-width: 20px;
    flex-shrink: 0;
}

.answer-result.tick {
    color: var(--color-green);
    font-size: 20px;
}

.answer-result.correction {
    color: var(--color-red);
    font-size: 13px;
    font-family: var(--font-ui);
    max-width: 180px;
}

.answer-result.shown {
    color: var(--color-muted);
}

/* Row states after checking */
.answer-row.correct {
    background: #ecfdf5;
}

.answer-row.wrong {
    background: #fef2f2;
}

/* ── Buttons ───────────────────────────────────────────────────── */
.button-row {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn {
    padding: 10px 28px;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
}

.btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.btn-check {
    background: var(--color-accent);
    color: white;
}

.btn-check:hover:not(:disabled) {
    background: #1d4ed8;
}

.btn-show {
    background: var(--color-surface);
    color: var(--color-muted);
    border: 1px solid var(--color-border);
}

.btn-show:hover:not(:disabled) {
    background: var(--color-bg);
}

.btn-retry {
    background: white;
    color: var(--color-text);
    border: 1px solid rgba(255,255,255,0.5);
    font-size: 13px;
    padding: 6px 18px;
}

.btn-retry:hover {
    background: rgba(255,255,255,0.9);
}

/* ── Score banner ──────────────────────────────────────────────── */
.score-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 14px 20px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 17px;
    font-weight: 700;
    background: #fee2e2;
    color: #991b1b;
    animation: slideDown 0.3s ease;
}

.score-banner.good {
    background: #dbeafe;
    color: #1e40af;
}

.score-banner.perfect {
    background: #d1fae5;
    color: #065f46;
}

.score-banner.hidden {
    display: none;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Quiz body layout (map + side panel) ────────────────────────── */
.quiz-body {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.map-column {
    flex: 1;
    min-width: 0;
}

/* ── Side panel ─────────────────────────────────────────────────── */
.side-panel {
    width: 280px;
    flex-shrink: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    min-height: 450px; /* matches map height */
}

.panel-progress {
    padding: 10px 16px;
    border-bottom: 1px solid var(--color-border);
    font-size: 13px;
    font-family: var(--font-ui);
    font-weight: 600;
    color: var(--color-muted);
}

.panel-body {
    padding: 16px;
    flex: 1;
}

.panel-prompt {
    font-size: 14px;
    color: var(--color-muted);
    line-height: 1.5;
}

.panel-marker-number {
    font-size: 12px;
    font-family: var(--font-ui);
    color: var(--color-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.panel-field {
    margin-bottom: 12px;
}

.panel-label {
    display: block;
    font-size: 11px;
    font-family: var(--font-ui);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-muted);
    margin-bottom: 4px;
}

.panel-input {
    width: 100%;
}

.panel-submit {
    width: 100%;
    margin-top: 4px;
}

/* ── Panel result states ─────────────────────────────────────────── */
.panel-result {
    text-align: center;
    padding: 16px 12px;
    border-radius: var(--radius);
}

.panel-result.correct { background: #ecfdf5; }
.panel-result.wrong   { background: #fef2f2; }

.result-icon {
    font-size: 30px;
    line-height: 1;
    margin-bottom: 4px;
}

.panel-result.correct .result-icon { color: var(--color-green); }
.panel-result.wrong   .result-icon { color: var(--color-red);   }

.result-label {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 8px;
}

.panel-result.correct .result-label { color: var(--color-green); }
.panel-result.wrong   .result-label { color: var(--color-red);   }

.result-correct-label {
    font-size: 11px;
    font-family: var(--font-ui);
    color: var(--color-muted);
    margin-bottom: 2px;
}

.result-answer {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
}

/* ── Panel complete ──────────────────────────────────────────────── */
.panel-complete {
    text-align: center;
    padding: 24px 12px;
}

.complete-emoji {
    font-size: 40px;
    margin-bottom: 12px;
}

.complete-score {
    font-size: 30px;
    font-weight: 700;
    color: var(--color-text);
}

.complete-pct {
    font-size: 14px;
    color: var(--color-muted);
    font-family: var(--font-ui);
    margin-top: 4px;
}

/* ── Auth pages (login / register / add-child) ──────────────────── */
.auth-page {
    display: flex;
    justify-content: center;
    padding: 40px 16px;
}

.auth-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 420px;
}

.auth-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--color-muted);
    margin-bottom: 20px;
    line-height: 1.5;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 20px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-field label {
    font-size: 13px;
    font-family: var(--font-ui);
    font-weight: 600;
    color: var(--color-text);
}

.form-field input {
    padding: 9px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-bg);
    transition: border-color 0.15s;
}

.form-field input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.field-hint {
    font-weight: 400;
    color: var(--color-muted);
    font-size: 12px;
}

.field-error {
    font-size: 12px;
    font-family: var(--font-ui);
    color: var(--color-red);
}

.auth-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: var(--font-ui);
    margin-bottom: 4px;
}

.auth-submit {
    width: 100%;
    margin-top: 4px;
}

.auth-footer {
    margin-top: 20px;
    font-size: 13px;
    font-family: var(--font-ui);
    color: var(--color-muted);
    text-align: center;
}

.auth-footer a {
    color: var(--color-accent);
    text-decoration: none;
}

.auth-footer a:hover { text-decoration: underline; }

/* ── Dashboard — shared ─────────────────────────────────────────── */
.dash-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.dash-header h2 {
    font-size: 22px;
    font-weight: 700;
}

.dash-subtitle {
    font-size: 14px;
    color: var(--color-muted);
    margin-top: 2px;
    font-family: var(--font-ui);
}

.dash-empty {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    color: var(--color-muted);
    font-size: 15px;
}

/* ── Dashboard — parent overview ────────────────────────────────── */
.child-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.child-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    transition: box-shadow 0.15s;
}

.child-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.child-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.child-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--color-accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    flex-shrink: 0;
}

.child-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
}

.child-username {
    font-size: 12px;
    font-family: var(--font-ui);
    color: var(--color-muted);
    margin-top: 1px;
}

.child-stats {
    display: flex;
    gap: 0;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    overflow: hidden;
}

.stat {
    flex: 1;
    text-align: center;
    padding: 10px 6px;
    border-right: 1px solid var(--color-border);
}

.stat:last-child { border-right: none; }

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}

.stat-date { font-size: 14px; }

.stat-label {
    font-size: 10px;
    font-family: var(--font-ui);
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.child-view-btn {
    width: 100%;
    text-align: center;
    font-size: 14px;
    padding: 8px;
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    text-decoration: none;
    display: block;
}

.child-view-btn:hover {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
}

/* ── Dashboard — child detail ────────────────────────────────────── */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 28px;
}

.chart-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
}

.chart-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 2px;
}

.chart-subtitle {
    font-size: 12px;
    color: var(--color-muted);
    font-family: var(--font-ui);
    margin-bottom: 16px;
}

.chart-wrap {
    position: relative;
    height: 240px;
}

.chart-wrap canvas {
    max-height: 240px;
}

.attempts-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
}

.section-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.section-hint {
    font-size: 13px;
    color: var(--color-muted);
    font-family: var(--font-ui);
    margin-bottom: 16px;
}

.attempts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.attempts-table th {
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    text-align: left;
    padding: 6px 10px;
    border-bottom: 2px solid var(--color-border);
}

.attempt-row {
    cursor: pointer;
    transition: background 0.1s;
}

.attempt-row:hover { background: var(--color-bg); }

.attempt-row td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.col-date {
    font-family: var(--font-ui);
    font-size: 13px;
    color: var(--color-muted);
}

.expand-icon {
    color: var(--color-muted);
    font-size: 10px;
    text-align: right;
    transition: transform 0.15s;
}

.pct-badge {
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

.pct-perfect { background: #d1fae5; color: #065f46; }
.pct-good    { background: #dbeafe; color: #1e40af; }
.pct-low     { background: #fee2e2; color: #991b1b; }

/* Expandable detail rows */
.detail-row td {
    padding: 0 0 12px 0;
    border-bottom: 1px solid var(--color-border);
}

.detail-row.hidden { display: none; }

.detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin: 0 10px;
    width: calc(100% - 20px);
    background: var(--color-bg);
    border-radius: 6px;
    overflow: hidden;
}

.detail-table th {
    font-family: var(--font-ui);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    padding: 6px 10px;
    text-align: left;
}

.detail-table td {
    padding: 7px 10px;
    border-top: 1px solid var(--color-border);
    vertical-align: middle;
}

.detail-correct { background: #f0fdf4; }
.detail-wrong   { background: #fff5f5; }

.col-answer { font-family: var(--font-ui); }

.col-result { text-align: center; }

.result-tick  { color: var(--color-green); font-size: 16px; font-weight: 700; }
.result-cross { color: var(--color-red);   font-size: 16px; font-weight: 700; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .chart-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .quiz-body {
        flex-direction: column;
    }

    .side-panel {
        width: 100%;
        min-height: auto;
    }

    .dash-header {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 600px) {
    #map { height: 320px; }

    .col-date { display: none; }
}


/* ── 16. Custom topics — parent views ──────────────────────────── */

.topic-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 0 40px;
}

.topic-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.topic-card-info {
    flex: 1 1 200px;
}

.topic-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 4px;
}

.topic-meta {
    font-size: 13px;
    color: var(--color-muted);
    font-family: var(--font-ui);
}

.topic-card-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.topic-card-actions {
    display: flex;
    gap: 8px;
}

.topic-status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 99px;
    font-size: 12px;
    font-family: var(--font-ui);
    font-weight: 600;
    text-transform: capitalize;
}

.status-draft     { background: #fef9c3; color: #854d0e; }
.status-published { background: #d1fae5; color: #065f46; }
.status-generating { background: #e0f2fe; color: #075985; }
.status-error     { background: #fee2e2; color: #7f1d1d; }

.topic-generating {
    font-size: 13px;
    color: var(--color-muted);
    font-family: var(--font-ui);
}

.topic-error-hint {
    font-size: 13px;
    color: var(--color-red);
    font-family: var(--font-ui);
}

/* Info banner (draft notice on review page) */
.info-banner {
    background: #fef9c3;
    border: 1px solid #fde047;
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 14px;
    font-family: var(--font-ui);
    color: #713f12;
    margin-bottom: 24px;
}

/* Review questions */
.review-questions {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 32px;
}

.review-qcard {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    gap: 16px;
}

.review-qnum {
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 14px;
    color: var(--color-muted);
    min-width: 32px;
    padding-top: 2px;
}

.review-qbody {
    flex: 1;
}

.review-question {
    font-size: 1rem;
    margin-bottom: 10px;
    line-height: 1.5;
}

.review-answer-label {
    font-size: 12px;
    font-family: var(--font-ui);
    font-weight: 600;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.review-answer {
    font-size: 0.95rem;
    color: var(--color-green);
    line-height: 1.5;
    background: #f0fdf4;
    border-left: 3px solid var(--color-green);
    padding: 8px 12px;
    border-radius: 4px;
}

/* Assign section */
.assign-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 32px;
}

.assign-form {
    margin-top: 12px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-label {
    font-family: var(--font-ui);
    font-size: 14px;
    cursor: pointer;
    color: var(--color-text);
}

/* Results page */
.results-child-block {
    margin-bottom: 32px;
}

.results-child-name {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
}

.results-session {
    margin-bottom: 24px;
}

.results-session-header {
    font-size: 14px;
    font-family: var(--font-ui);
    color: var(--color-muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.results-table {
    width: 100%;
}

.results-table th,
.results-table td {
    vertical-align: top;
}

.col-num { width: 36px; text-align: center; }
.col-model-answer { color: var(--color-green); }
.muted { color: var(--color-muted); font-style: italic; }


/* ── 17. Custom topics — child learn views ────────────────────── */

.learn-page {
    max-width: 680px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

/* Progress bar */
.learn-progress-wrap {
    height: 6px;
    background: var(--color-border);
    border-radius: 99px;
    margin-bottom: 28px;
    overflow: hidden;
}

.learn-progress-bar {
    height: 100%;
    background: var(--color-accent);
    border-radius: 99px;
    transition: width 0.3s ease;
}

/* Question card */
.learn-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 28px 32px;
}

.learn-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 20px;
    gap: 12px;
}

.learn-topic-name {
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.learn-counter {
    font-family: var(--font-ui);
    font-size: 13px;
    color: var(--color-muted);
    white-space: nowrap;
}

.learn-question {
    font-size: 1.2rem;
    line-height: 1.6;
    margin-bottom: 24px;
}

.learn-form textarea {
    width: 100%;
    padding: 12px 14px;
    font-family: var(--font-body);
    font-size: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    resize: vertical;
    min-height: 100px;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

.learn-form textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.learn-submit {
    margin-top: 14px;
    width: 100%;
}

/* Completion screen */
.complete-card {
    text-align: center;
    padding: 32px;
    margin-bottom: 28px;
}

.complete-emoji {
    font-size: 3rem;
    margin-bottom: 12px;
}

.complete-title {
    font-size: 1.6rem;
    margin-bottom: 8px;
}

.complete-subtitle {
    font-size: 1rem;
    color: var(--color-muted);
    margin-bottom: 20px;
    line-height: 1.5;
}

/* Q&A review list on completion page */
.complete-qa-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.complete-qcard {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    gap: 16px;
}

.complete-qnum {
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 14px;
    color: var(--color-muted);
    min-width: 32px;
    padding-top: 2px;
}

.complete-qbody {
    flex: 1;
}

.complete-answers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}

@media (max-width: 600px) {
    .complete-answers { grid-template-columns: 1fr; }
    .learn-card { padding: 20px 18px; }
}

.complete-answer-block {
    border-radius: 6px;
    padding: 10px 14px;
}

.complete-answer-block p {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-top: 4px;
}

.answer-block-label {
    font-size: 11px;
    font-family: var(--font-ui);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-muted);
}

.your-answer {
    background: #f1f5f9;
    border-left: 3px solid var(--color-accent);
}

.model-answer {
    background: #f0fdf4;
    border-left: 3px solid var(--color-green);
}

/* Screen-reader only helper */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ── 19. Maths worksheet ───────────────────────────────────────── */
.maths-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.maths-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 12px 14px;
}

.maths-prompt {
    font-size: 1.1rem;
    white-space: nowrap;
}

.maths-num {
    color: var(--color-muted);
    font-family: var(--font-ui);
    font-size: 0.85rem;
    margin-right: 2px;
}

.maths-input {
    width: 5.5rem;
    margin-left: auto;
    text-align: center;
    font-size: 1.1rem;
}

/* ── 20. Answer checking (AI feedback + parent marking) ────────── */
.ai-feedback {
    border-radius: var(--radius);
    padding: 8px 12px;
    margin: 10px 0;
    font-family: var(--font-ui);
}
.ai-feedback-label { font-weight: 700; font-size: 0.9rem; }
.ai-feedback p { margin-top: 4px; font-size: 0.9rem; }
.ai-correct   { background: #f0fdf4; border-left: 3px solid var(--color-green); }
.ai-incorrect { background: #fef2f2; border-left: 3px solid var(--color-red); }
.ai-pending   { background: #f8fafc; border-left: 3px solid var(--color-muted); }

.mark-input {
    width: 3.2rem;
    text-align: center;
    padding: 4px 6px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-family: var(--font-ui);
}
.mark-max  { color: var(--color-muted); font-size: 0.85rem; margin-left: 4px; }
.mark-conf { color: var(--color-muted); font-size: 0.8rem; margin-left: 4px; }
.mark-reason { font-size: 0.85rem; color: var(--color-muted); margin-top: 4px; }
.results-mode {
    font-family: var(--font-ui);
    font-size: 0.75rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-left: 6px;
}

/* ── 21. Sources / multi-topic wizard ──────────────────────────── */
.topic-build-list { display: flex; flex-direction: column; gap: 10px; }

.topic-build-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 12px 14px;
}

.topic-build-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topic-build-head .checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.topic-build-title {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 15px;
}

.topic-build-n { width: 4rem; text-align: center; padding: 6px; }

.topic-build-desc {
    font-size: 13px;
    color: var(--color-muted);
    margin: 6px 0 6px 26px;
}

.topic-build-instr {
    width: 100%;
    margin-top: 6px;
    padding: 6px 8px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-family: var(--font-ui);
    font-size: 13px;
}

.gen-title { flex: 1; font-weight: 600; }
.gen-links { margin-top: 6px; font-size: 13px; }

.btn-danger-link {
    background: none;
    border: none;
    color: var(--color-red);
    font-family: var(--font-ui);
    font-size: 13px;
    cursor: pointer;
    padding: 0 4px;
}
.btn-danger-link:hover { text-decoration: underline; }
