/* ===== RESET & VARIABLES ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --primary: #1a4b8c;
    --primary-light: #e8f0fe;
    --primary-dark: #0d2b52;
    --accent: #e67e22;
    --text: #1f2937;
    --text-light: #6b7280;
    --text-muted: #9ca3af;
    --border: #d1d5db;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --info: #3b82f6;
    --info-bg: #eff6ff;
    --shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --radius: 10px;
    --radius-sm: 6px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-math: 'Cambria', 'Times New Roman', serif;
    --step-bg: #f0f7ff;
    --step-border: #bfdbfe;
    --reason-bg: #fefce8;
    --trap-bg: #fef2f2;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    font-size: 16px;
}

/* ===== EDUNUDGE LOGO IN HEADER ===== */

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-logo {
    width: 170px;
    max-width: 170px;
    height: auto;
    display: block;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

/* Mobile adjustment */
@media (max-width: 768px) {
    .brand {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 8px;
    }

    .brand-logo {
        width: 150px;
        max-width: 150px;
    }
}

/* ===== HEADER ===== */
header {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
    padding: 18px 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

header .inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

header .brand h1 {
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

header .brand h1 span.icon {
    font-size: 1.5rem;
}

header .brand .sub {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-top: -2px;
}

header .mode-toggle {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 3px;
}

header .mode-toggle button {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.2s;
}

header .mode-toggle button.active {
    background: white;
    color: var(--primary);
}

header .mode-toggle button:hover:not(.active) {
    color: white;
}

/* ===== CONTAINER ===== */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 16px;
}

/* ===== SEARCH ===== */
.search-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 14px 18px;
    box-shadow: var(--shadow);
    margin-bottom: 14px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.search-section input {
    flex: 1;
    min-width: 150px;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: border 0.2s;
}

.search-section input:focus {
    outline: none;
    border-color: var(--primary);
}

.search-section .btn {
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

/* ===== NAVIGATION ===== */
.nav-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
    margin-bottom: 14px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    align-items: end;
}

.nav-section .field label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    margin-bottom: 4px;
}

.nav-section .field select {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: white;
    cursor: pointer;
    transition: border 0.2s;
}

.nav-section .field select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ===== PROGRESS ===== */
.progress-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 12px 18px;
    box-shadow: var(--shadow);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.progress-section .label {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.progress-section .track {
    flex: 1;
    min-width: 80px;
    height: 10px;
    background: #e5e7eb;
    border-radius: 5px;
    overflow: hidden;
}

.progress-section .track .fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), #22c55e);
    border-radius: 5px;
    transition: width 0.5s ease;
    width: 0%;
}

.progress-section .count {
    font-size: 0.8rem;
    color: var(--text-light);
    white-space: nowrap;
}

/* ===== QUESTION CARD ===== */
.question-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    margin-bottom: 16px;
}

.question-card .q-header {
    padding: 16px 20px 12px;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.question-card .q-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
}

.question-card .q-header .badge {
    font-size: 0.65rem;
    padding: 3px 12px;
    border-radius: 20px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge.easy {
    background: var(--success-bg);
    color: #166534;
}

.badge.medium {
    background: var(--warning-bg);
    color: #92400e;
}

.badge.hard {
    background: var(--danger-bg);
    color: #991b1b;
}

.question-card .q-text {
    padding: 18px 20px 14px;
    font-size: 1rem;
    border-bottom: 1px dashed var(--border);
    line-height: 1.8;
}

.question-card .q-text .math {
    font-family: var(--font-math);
    font-style: italic;
}

/* ===== STEPS ===== */
.steps-area {
    padding: 12px 20px 8px;
}

.step {
    background: var(--step-bg);
    border-left: 4px solid var(--step-border);
    padding: 0;
    margin-bottom: 12px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    display: none;
    overflow: hidden;
    animation: slideDown 0.35s ease;
}

.step.visible {
    display: block;
}

.step .step-head {
    padding: 12px 16px 8px;
    font-weight: 700;
    color: var(--primary);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.step .step-head .num {
    background: var(--primary);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.step .step-body {
    padding: 0 16px 12px;
    font-size: 0.95rem;
    line-height: 1.8;
}

.step .step-body .katex-container {
    margin: 6px 0;
    font-size: 1.05rem;
}

/* Reasoning box */
.step .reasoning {
    margin: 8px 16px 12px;
    padding: 10px 14px;
    background: var(--reason-bg);
    border-left: 3px solid var(--warning);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.85rem;
}

.step .reasoning .label {
    font-weight: 700;
    color: #92400e;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 2px;
}

/* Trap box */
.step .trap {
    margin: 8px 16px 12px;
    padding: 10px 14px;
    background: var(--trap-bg);
    border-left: 3px solid var(--danger);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.85rem;
}

.step .trap .label {
    font-weight: 700;
    color: #991b1b;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 2px;
}

/* Final step */
.step.final {
    background: var(--success-bg);
    border-left-color: var(--success);
}

.step.final .step-head {
    color: var(--success);
}

.step.final .step-head .num {
    background: var(--success);
}

/* Visual aid container */
.step .visual-aid {
    margin: 10px 16px 12px;
    padding: 14px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    overflow-x: auto;
}

.step .visual-aid .va-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== BUTTON GROUP ===== */
.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 20px 14px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    background: #93b8e8;
    cursor: not-allowed;
    transform: none;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #15803d;
}

.btn-success.active {
    background: #15803d;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.2);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-accent {
    background: var(--accent);
    color: white;
}

.btn-accent:hover {
    background: #c96d1a;
}

.btn-sm {
    padding: 7px 14px;
    font-size: 0.78rem;
}

/* ===== PAGER ===== */
.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 0 20px 18px;
    flex-wrap: wrap;
}

.pager .info {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ===== PRACTICE MODE ===== */
.practice-section {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    overflow: hidden;
    display: none;
}

.practice-section.open {
    display: block;
}

.practice-section .p-header {
    padding: 14px 20px;
    background: linear-gradient(135deg, #fefce8, #fef9c3);
    border-bottom: 1px solid #fde68a;
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.practice-section .p-header:hover {
    background: #fef9c3;
}

.practice-section .p-body {
    padding: 16px 20px 20px;
}

.practice-section .p-body .p-question {
    font-size: 1rem;
    margin-bottom: 12px;
    padding: 12px 16px;
    background: #f9fafb;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--accent);
}

.practice-section .p-body .p-input-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.practice-section .p-body .p-input-group input {
    flex: 1;
    min-width: 120px;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: var(--font);
}

.practice-section .p-body .p-input-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.practice-section .p-body .p-feedback {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    display: none;
}

.practice-section .p-body .p-feedback.correct {
    display: block;
    background: var(--success-bg);
    color: #166534;
}

.practice-section .p-body .p-feedback.wrong {
    display: block;
    background: var(--danger-bg);
    color: #991b1b;
}

.practice-section .p-body .p-feedback .p-answer {
    font-weight: 400;
    margin-top: 4px;
    font-size: 0.85rem;
}

/* ===== FORMULA REFERENCE ===== */
.formula-ref {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    overflow: hidden;
}

.formula-ref .fr-header {
    padding: 12px 20px;
    background: #f3f4f6;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background 0.2s;
}

.formula-ref .fr-header:hover {
    background: #e5e7eb;
}

.formula-ref .fr-body {
    padding: 12px 20px 16px;
    display: none;
    font-size: 0.9rem;
}

.formula-ref .fr-body.open {
    display: block;
}

.formula-ref .fr-body ul {
    list-style: none;
    padding: 0;
}

.formula-ref .fr-body li {
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.formula-ref .fr-body li:last-child {
    border-bottom: none;
}

.formula-ref .fr-body .f-bullet {
    color: var(--primary);
    flex-shrink: 0;
}

/* ===== RESET ===== */
.reset-area {
    text-align: center;
    padding: 4px 0 16px;
}

.reset-area .btn {
    font-size: 0.78rem;
}

/* ===== FOOTER ===== */
footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.78rem;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

/* ===== VISUAL AIDS ===== */
.factor-tree {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    font-family: var(--font-math);
    font-size: 1rem;
}

.factor-tree .root {
    font-weight: 700;
    padding: 6px 14px;
    background: var(--primary-light);
    border: 2px solid var(--primary);
    border-radius: 6px;
    margin-bottom: 4px;
}

.factor-tree .branches {
    display: flex;
    gap: 40px;
    position: relative;
}

.factor-tree .branches::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    width: 2px;
    height: 8px;
    background: var(--text-light);
}

.factor-tree .branch {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.factor-tree .branch::before {
    content: '';
    position: absolute;
    top: -4px;
    width: 100%;
    height: 2px;
    background: var(--text-light);
}

.factor-tree .branch:first-child::before {
    right: 50%;
    width: 50%;
}

.factor-tree .branch:last-child::before {
    left: 50%;
    width: 50%;
}

.factor-tree .branch .node {
    padding: 4px 12px;
    background: #f0fdf4;
    border: 2px solid var(--success);
    border-radius: 6px;
    font-weight: 600;
    margin-top: 4px;
}

.factor-tree .branch .node.prime {
    background: #fef2f2;
    border-color: var(--danger);
}

.factor-tree .branch .subtree {
    display: flex;
    gap: 30px;
    position: relative;
    margin-top: 2px;
}

/* Number line */
.number-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 8px 0;
    position: relative;
}

.number-line .axis {
    width: 80%;
    height: 3px;
    background: var(--text-light);
    position: relative;
    border-radius: 2px;
}

.number-line .tick {
    position: absolute;
    top: -8px;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.number-line .tick .mark {
    width: 2px;
    height: 12px;
    background: var(--text-light);
}

.number-line .tick .val {
    font-size: 0.7rem;
    margin-top: 2px;
    color: var(--text-light);
}

.number-line .point {
    position: absolute;
    top: -18px;
    transform: translateX(-50%);
    font-size: 1.2rem;
    color: var(--danger);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    header .inner {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    header .mode-toggle {
        justify-content: center;
    }

    header .brand h1 {
        justify-content: center;
        font-size: 1rem;
    }

    .nav-section {
        grid-template-columns: 1fr;
    }

    .btn-group .btn {
        flex: 1;
        text-align: center;
        justify-content: center;
        font-size: 0.78rem;
        padding: 8px 12px;
    }

    .pager {
        flex-direction: column;
    }

    .pager .btn {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    .search-section {
        flex-direction: column;
    }

    .search-section .btn {
        width: 100%;
        text-align: center;
    }

    .step .visual-aid {
        padding: 8px;
        font-size: 0.8rem;
    }

    .factor-tree {
        font-size: 0.85rem;
    }

    .factor-tree .branches {
        gap: 20px;
    }

    .factor-tree .branch .subtree {
        gap: 16px;
    }
}

/* ===== PRINT ===== */
@media print {

    header,
    .search-section,
    .nav-section,
    .progress-section,
    .btn-group,
    .pager,
    .practice-section,
    .formula-ref,
    .reset-area,
    footer {
        display: none !important;
    }

    .step {
        display: block !important;
        break-inside: avoid;
    }

    .question-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .step .visual-aid {
        break-inside: avoid;
    }

    body {
        font-size: 12px;
    }
}

/* ===== LOADING OVERLAY ===== */
.loading {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    z-index: 999;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary);
}

.loading.show {
    display: flex;
}

.loading .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 12px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ================================================================
   BASIC MATH COACH — Interactive Coaching UI
   Add this block at the END of math.css
   ================================================================ */

.coach-intro {
    margin-top: 16px;
    padding: 14px 16px;
    background: #eef6ff;
    border-left: 4px solid var(--primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.92rem;
    line-height: 1.7;
}

.coach-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary);
    margin-bottom: 4px;
}

.method-check {
    margin-top: 14px;
    padding: 14px 16px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: var(--radius-sm);
}

.method-title {
    font-weight: 800;
    color: #9a3412;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 6px;
}

.method-prompt {
    font-size: 0.95rem;
    margin-bottom: 10px;
}

.method-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.method-option {
    border: 2px solid #fed7aa;
    background: white;
    color: var(--text);
    border-radius: 8px;
    padding: 8px 12px;
    font-weight: 650;
    font-size: 0.84rem;
    cursor: pointer;
    transition: all 0.2s;
}

.method-option:hover {
    border-color: var(--accent);
    color: #9a3412;
}

.method-option.selected {
    transform: scale(0.98);
}

.method-option.correct {
    border-color: var(--success);
    background: var(--success-bg);
    color: #166534;
}

.method-option.wrong {
    border-color: var(--danger);
    background: var(--danger-bg);
    color: #991b1b;
}

.method-feedback {
    display: none;
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 650;
}

.method-feedback.correct {
    display: block;
    background: var(--success-bg);
    color: #166534;
}

.method-feedback.wrong {
    display: block;
    background: var(--danger-bg);
    color: #991b1b;
}

.coach-step {
    border-left-color: #93c5fd;
}

.coach-prompt-box {
    margin: 10px 16px 12px;
    padding: 14px;
    background: #f8fafc;
    border: 1px solid #dbeafe;
    border-radius: var(--radius-sm);
}

.coach-prompt-title {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.coach-prompt-text {
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 10px;
}

.coach-response-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.coach-answer {
    flex: 1;
    min-width: 170px;
    padding: 9px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-family: var(--font);
}

.coach-answer:focus {
    outline: none;
    border-color: var(--primary);
}

.coach-hint {
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--warning-bg);
    border-left: 3px solid var(--warning);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.86rem;
    color: #92400e;
}

.coach-feedback {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 650;
}

.coach-feedback.correct {
    background: var(--success-bg);
    color: #166534;
}

.coach-feedback.wrong {
    background: var(--danger-bg);
    color: #991b1b;
}

.reveal-area {
    background: rgba(255, 255, 255, 0.55);
    border-top: 1px dashed #bfdbfe;
    margin-top: 4px;
    padding-top: 12px;
}

.final-check-box {
    margin: 14px 0 18px;
    padding: 14px 16px;
    background: #ecfdf5;
    border-left: 4px solid var(--success);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.92rem;
    line-height: 1.7;
}

/* Mobile tuning for coaching UI */
@media (max-width: 600px) {
    .method-options {
        flex-direction: column;
    }

    .method-option {
        width: 100%;
        text-align: left;
    }

    .coach-response-row {
        flex-direction: column;
        align-items: stretch;
    }

    .coach-answer,
    .coach-response-row .btn {
        width: 100%;
    }

    .coach-prompt-box {
        margin-left: 10px;
        margin-right: 10px;
    }
}

/* ================================================================
   LEFT SIDEBAR LAYOUT — Basic Math Coach
   Add this block at the END of math.css
   For 14-chapter navigation + future Graph Practice
   ================================================================ */

/* Wider header to match the new two-column app shell */
header .inner {
    max-width: 1320px;
}

.app-shell {
    display: flex;
    align-items: flex-start;
    gap: 0;
    max-width: 1320px;
    margin: 0 auto;
    padding: 16px;
}

.chapter-sidebar {
    width: 290px;
    flex: 0 0 290px;
    position: sticky;
    top: 92px;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
    margin-right: 16px;
}

.sidebar-title {
    font-size: 0.98rem;
    font-weight: 800;
    color: var(--primary-dark);
    line-height: 1.3;
}

.sidebar-subtitle {
    font-size: 0.74rem;
    color: var(--text-light);
    margin: 2px 0 12px;
}

.chapter-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.chapter-btn {
    width: 100%;
    border: 1px solid transparent;
    background: #f8fafc;
    color: var(--text);
    border-radius: 9px;
    padding: 9px 10px;
    display: flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    text-align: left;
    font-family: var(--font);
    transition: all 0.18s ease;
}

.chapter-btn:hover {
    background: var(--primary-light);
    border-color: #bfdbfe;
    transform: translateX(2px);
}

.chapter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
    box-shadow: 0 3px 10px rgba(26, 75, 140, 0.22);
}

.chapter-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: white;
    color: var(--primary);
    font-weight: 800;
    font-size: 0.76rem;
    border: 1px solid #dbeafe;
}

.chapter-btn.active .chapter-number {
    background: white;
    color: var(--primary-dark);
    border-color: white;
}

.chapter-name {
    font-size: 0.82rem;
    font-weight: 650;
    line-height: 1.25;
}

.sidebar-section-title {
    margin: 14px 4px 6px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
}

.chapter-btn.tool-btn {
    background: #fff7ed;
    border-color: #fed7aa;
}

.chapter-btn.tool-btn:hover {
    background: #ffedd5;
    border-color: var(--accent);
}

.chapter-btn.tool-btn.active {
    background: var(--accent);
    color: white;
    border-color: #c96d1a;
}

.coach-main {
    flex: 1;
    min-width: 0;
    max-width: none;
    margin: 0;
    padding: 0;
}

.compact-nav {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.hidden-field {
    display: none !important;
}

/* Make long KaTeX / solutions behave better in the wider layout */
.katex-container,
.formula-ref .fr-body li,
.step-body {
    overflow-x: auto;
}

/* Sidebar scrollbar */
.chapter-sidebar::-webkit-scrollbar {
    width: 8px;
}

.chapter-sidebar::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.chapter-sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.chapter-sidebar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Tablet layout */
@media (max-width: 980px) {
    .app-shell {
        flex-direction: column;
        padding: 12px;
    }

    .chapter-sidebar {
        position: static;
        width: 100%;
        flex: none;
        max-height: none;
        margin: 0 0 14px 0;
    }

    .chapter-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .chapter-btn:hover {
        transform: none;
    }

    .coach-main {
        width: 100%;
    }
}

/* Mobile layout */
@media (max-width: 600px) {
    .app-shell {
        padding: 10px;
    }

    .chapter-sidebar {
        padding: 12px;
        border-radius: 12px;
    }

    .chapter-list {
        grid-template-columns: 1fr;
    }

    .chapter-btn {
        padding: 10px;
    }

    .chapter-name {
        font-size: 0.84rem;
    }

    .compact-nav {
        grid-template-columns: 1fr;
    }
}

/* Print: hide sidebar along with navigation controls */
@media print {

    .chapter-sidebar,
    .app-shell>.chapter-sidebar {
        display: none !important;
    }

    .app-shell {
        display: block;
        max-width: none;
        padding: 0;
    }

    .coach-main {
        max-width: none;
    }
}

/* Graph task wrapper inside question card */

.graph-task-box {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #ffffff;
    padding: 14px;
}

.graph-task-title {
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 6px;
}

.graph-task-instruction {
    color: var(--text);
    font-weight: 650;
    margin-bottom: 12px;
}

/* ================================================================
   VISUAL AIDS — SVG diagrams inside normal lesson questions
   ================================================================ */

.visual-aid-box {
    margin-top: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.visual-aid-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.visual-aid-title {
    font-weight: 800;
    color: var(--primary-dark);
    font-size: 0.95rem;
}

.visual-aid-subtitle {
    margin-top: 3px;
    color: var(--text-light);
    font-size: 0.82rem;
    line-height: 1.35;
}

.visual-aid-badge {
    flex-shrink: 0;
    background: #eff6ff;
    color: var(--primary-dark);
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 0.72rem;
    font-weight: 800;
}

.visual-aid-canvas {
    padding: 12px;
    background: #ffffff;
    text-align: center;
}

.visual-aid-note {
    padding: 9px 14px;
    background: #fff7ed;
    border-top: 1px solid #fed7aa;
    color: #9a3412;
    font-size: 0.82rem;
    font-weight: 700;
}

.va-svg {
    width: 100%;
    max-width: 520px;
    height: auto;
    display: block;
    margin: 0 auto;
}

.va-circle,
.va-ellipse {
    fill: #ffffff;
    stroke: #1e293b;
    stroke-width: 2.2;
}

.va-line {
    stroke: #1e293b;
    stroke-width: 2.2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.va-line.strong {
    stroke-width: 2.8;
}

.va-line.tangent {
    stroke: #2563eb;
    stroke-width: 2.8;
}

.va-line.dashed {
    stroke-dasharray: 6 5;
    stroke: #64748b;
}

.va-line.parallel {
    stroke: #2563eb;
    stroke-width: 3;
}

.va-line.ground {
    stroke: #64748b;
}

.va-line.sight {
    stroke: #dc2626;
    stroke-width: 2.8;
}

.va-triangle,
.va-rect {
    fill: #ffffff;
    stroke: #1e293b;
    stroke-width: 2.2;
}

.va-shade {
    fill: #dbeafe;
    stroke: #2563eb;
    stroke-width: 2;
    opacity: 0.85;
}

.va-arc {
    fill: none;
    stroke: #dc2626;
    stroke-width: 2.2;
}

.va-point {
    fill: #dc2626;
    stroke: #ffffff;
    stroke-width: 1.5;
}

.va-text {
    font-family: Arial, sans-serif;
    font-size: 13px;
    fill: #0f172a;
    font-weight: 700;
}

.va-right-angle {
    fill: none;
    stroke: #dc2626;
    stroke-width: 2;
}

.va-arrow-fill {
    fill: #dc2626;
}

.va-building {
    fill: #e2e8f0;
    stroke: #334155;
    stroke-width: 2;
}

.va-curve {
    fill: none;
    stroke: #1e293b;
    stroke-width: 2.4;
}

.va-curve.strong {
    stroke: #2563eb;
    stroke-width: 3;
}

.va-spinner-slice {
    fill: #dbeafe;
    stroke: #ffffff;
    stroke-width: 2;
}

.va-spinner-slice.alt {
    fill: #fef3c7;
}

.va-label {
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 8px;
    text-align: center;
}

@media (max-width: 600px) {
    .visual-aid-header {
        flex-direction: column;
    }

    .visual-aid-badge {
        align-self: flex-start;
    }

    .va-text {
        font-size: 12px;
    }
}