/* ============================================
   CHAPTER LEARNING PAGE — Premium Dark Theme
   Situ Math Platform
   ============================================ */

:root {
    --ch-bg: #0f0f1a;
    --ch-surface: #1a1a2e;
    --ch-surface-2: #16213e;
    --ch-border: rgba(255, 255, 255, 0.08);
    --ch-text: #f1f5f9;
    --ch-text-secondary: rgba(255, 255, 255, 0.6);
    --ch-accent: #6366f1;
    --ch-accent-light: #818cf8;
    --ch-accent-soft: rgba(99, 102, 241, 0.15);
    --ch-green: #10b981;
    --ch-green-soft: rgba(16, 185, 129, 0.15);
    --ch-orange: #f59e0b;
    --ch-orange-soft: rgba(245, 158, 11, 0.15);
    --ch-red: #ef4444;
    --ch-red-soft: rgba(239, 68, 68, 0.15);
    --ch-blue: #3b82f6;
    --ch-blue-soft: rgba(59, 130, 246, 0.15);
    --ch-purple: #a855f7;
    --ch-purple-soft: rgba(168, 85, 247, 0.15);
    --ch-radius: 16px;
    --ch-radius-sm: 10px;
    --ch-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ====== BASE ====== */
body.chapter-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #0f0f1a 100%);
    color: var(--ch-text);
    font-family: 'Inter', 'Poppins', sans-serif;
}

.chapter-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 24px 60px;
}

/* ====== BACK LINK ====== */
.chapter-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ch-text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 20px;
    transition: var(--ch-transition);
}

.chapter-back:hover {
    color: var(--ch-accent-light);
}

/* ====== CHAPTER HERO (DIGITAL CLASSROOM) ====== */
.chapter-hero {
    background: var(--ch-surface);
    border: 1px solid var(--ch-border);
    border-radius: 20px;
    padding: 0;
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hero-overlay {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 90% 10%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 10% 90%, rgba(168, 85, 247, 0.1) 0%, transparent 40%);
    z-index: 1;
}

.chapter-hero-content {
    position: relative;
    z-index: 2;
    padding: 32px 40px;
    max-width: 800px;
}

/* Badge */
.chapter-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.class-tag {
    background: var(--ch-accent);
    color: white;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.subject-tag {
    color: var(--ch-text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
}

/* Title */
.chapter-hero h1 {
    font-size: 2.8rem;
    font-weight: 800;
    color: white;
    margin: 0 0 24px;
    line-height: 1.1;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Teacher Emotional Hook */
.teacher-hook {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 32px;
    animation: slideUp 0.6s ease-out 0.2s backwards;
}

.teacher-avatar-sm {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--ch-accent-light);
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.teacher-avatar-sm img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hook-bubble {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0 16px 16px 16px;
    padding: 14px 20px;
    max-width: 500px;
    position: relative;
}

.hook-bubble p {
    font-family: 'Caveat', cursive;
    font-size: 1.35rem;
    color: var(--ch-accent-light);
    line-height: 1.4;
    margin: 0;
}

/* Mastery System (Progress) */
.mastery-system {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 16px;
    padding: 20px 24px;
    border: 1px solid var(--ch-border);
    max-width: 500px;
    backdrop-filter: blur(4px);
}

.mastery-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ch-text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mastery-header span:last-child {
    color: var(--ch-accent-light);
}

.progress-track {
    height: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50px;
    position: relative;
    cursor: help;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--ch-accent), var(--ch-purple));
    border-radius: 50px;
    position: absolute;
    top: 0;
    left: 0;
    transition: width 1s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.5);
}

.milestone {
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    position: absolute;
    top: 3px;
    transform: translateX(-50%);
    z-index: 2;
}

/* Continue Button */
.continue-btn {
    position: absolute;
    bottom: 40px;
    right: 40px;
    background: white;
    color: var(--ch-accent);
    padding: 14px 28px;
    border-radius: 50px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--ch-transition);
    z-index: 3;
    animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.5s backwards;
}

.continue-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.3);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ====== TAB NAVIGATION ====== */
.chapter-tabs {
    display: flex;
    gap: 4px;
    background: var(--ch-surface);
    border: 1px solid var(--ch-border);
    border-radius: var(--ch-radius);
    padding: 6px;
    margin-bottom: 24px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.chapter-tabs::-webkit-scrollbar {
    display: none;
}

.chapter-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: transparent;
    border: none;
    border-radius: var(--ch-radius-sm);
    color: var(--ch-text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--ch-transition);
    font-family: inherit;
}

.chapter-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.chapter-tab.active {
    background: var(--ch-accent);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.chapter-tab i {
    font-size: 0.8rem;
}

.chapter-tab .tab-badge {
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 700;
}

/* ====== TAB PANELS ====== */
.chapter-panel {
    display: none;
    animation: fadeInPanel 0.3s ease;
}

.chapter-panel.active {
    display: block;
}

@keyframes fadeInPanel {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ====== DIGITAL CLASSROOM CONTENT ====== */
.classroom-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 900px;
    margin: 0 auto;
}

/* Concept Card */
.concept-card {
    background: var(--ch-surface);
    border: 1px solid var(--ch-border);
    border-radius: 20px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: fadeInPanel 0.4s ease backwards;
}

.concept-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.1);
}

.concept-header {
    background: rgba(255, 255, 255, 0.03);
    padding: 18px 24px;
    border-bottom: 1px solid var(--ch-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.concept-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
}

.concept-num {
    background: var(--ch-accent);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 800;
}

.concept-body {
    padding: 24px 32px;
}

/* Teacher Says (Conversational) */
.teacher-says {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    background: rgba(99, 102, 241, 0.05);
    /* Very subtle accent tint */
    padding: 16px;
    border-radius: 12px;
    border: 1px dashed rgba(99, 102, 241, 0.2);
}

.teacher-avatar-xs {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin-top: 4px;
    border: 2px solid var(--ch-accent-light);
}

.teacher-text {
    font-size: 0.95rem;
    color: #e2e8f0;
    line-height: 1.6;
}

.teacher-text strong {
    color: var(--ch-accent-light);
}

/* Concept Notes */
.concept-notes ul {
    list-style: none;
    padding: 0;
    margin: 0 0 24px 0;
}

.concept-notes li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 10px;
    color: var(--ch-text-secondary);
    line-height: 1.6;
}

.concept-notes li::before {
    content: '•';
    color: var(--ch-accent);
    font-weight: bold;
    position: absolute;
    left: 0;
}

/* Magic Formula Box */
.magic-box {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(6, 95, 70, 0.2));
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.magic-box-label {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: #065f46;
    color: #a7f3d0;
    padding: 2px 12px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.magic-formula {
    font-size: 1.25rem;
    color: white;
    font-family: 'Times New Roman', serif;
    margin: 8px 0;
}

/* Interactive Demo Button */
.interactive-demo-btn {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--ch-border);
    border-radius: 10px;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 600;
    margin-top: 10px;
}

.interactive-demo-btn:hover {
    background: var(--ch-accent);
    border-color: var(--ch-accent);
    transform: translateY(-2px);
}

.interactive-demo-btn i {
    color: var(--ch-accent-light);
}

.interactive-demo-btn:hover i {
    color: white;
}

/* ====== SECTION 2: SOLVED EXAMPLES ====== */
.example-card {
    background: var(--ch-surface);
    border: 1px solid var(--ch-border);
    border-radius: var(--ch-radius);
    margin-bottom: 16px;
    overflow: hidden;
    transition: var(--ch-transition);
}

.example-card:hover {
    border-color: rgba(168, 85, 247, 0.3);
}

.example-question {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22px 28px;
    cursor: pointer;
}

.example-question h4 {
    font-size: 1rem;
    font-weight: 600;
    color: white;
    margin: 0;
    flex: 1;
}

.example-toggle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--ch-purple-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ch-purple);
    font-size: 0.8rem;
    transition: var(--ch-transition);
    flex-shrink: 0;
}

.example-card.open .example-toggle {
    transform: rotate(180deg);
}

.example-steps {
    display: none;
    padding: 0 28px 24px;
    border-top: 1px solid var(--ch-border);
}

.example-card.open .example-steps {
    display: block;
}

.example-step {
    padding: 14px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.93rem;
    color: var(--ch-text-secondary);
    line-height: 1.7;
}

.example-step:last-child {
    border-bottom: none;
}

.example-step .step-label {
    display: inline-block;
    padding: 2px 10px;
    background: var(--ch-accent-soft);
    color: var(--ch-accent-light);
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 700;
    margin-right: 10px;
}

.example-answer {
    background: var(--ch-green-soft);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--ch-radius-sm);
    padding: 16px 20px;
    margin-top: 12px;
    color: var(--ch-green);
    font-weight: 600;
}

.example-answer i {
    margin-right: 8px;
}

/* ====== GUIDED PRACTICE SECTION ====== */
.practice-container {
    max-width: 900px;
    margin: 0 auto;
}

/* Roadmap (Level Selector) */
.practice-roadmap {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 36px;
    position: relative;
}

.roadmap-step {
    background: var(--ch-surface);
    border: 2px solid var(--ch-border);
    border-radius: 12px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
    min-width: 160px;
}

.roadmap-step.active {
    background: var(--ch-surface);
    border-color: var(--ch-accent);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
    transform: translateY(-2px);
}

.roadmap-step:hover:not(.active) {
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--ch-surface-2);
    color: var(--ch-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    transition: var(--ch-transition);
}

.roadmap-step.active .step-num {
    background: var(--ch-accent);
    color: white;
}

.step-content {
    text-align: left;
}

.step-content span {
    display: block;
    font-weight: 700;
    font-size: 0.95rem;
    color: white;
}

.step-content small {
    display: block;
    font-size: 0.75rem;
    color: var(--ch-text-secondary);
}

.roadmap-line {
    flex: 1;
    height: 2px;
    background: var(--ch-border);
    margin: 0 10px;
    max-width: 60px;
}

.roadmap-step.active+.roadmap-line,
.roadmap-step.completed+.roadmap-line {
    background: var(--ch-accent);
}

/* Practice Cards */
.practice-card {
    background: var(--ch-surface);
    border: 1px solid var(--ch-border);
    border-radius: 20px;
    padding: 32px;
    position: relative;
    overflow: hidden;
    animation: fadeInPanel 0.4s ease backwards;
}

/* Level 1: Watch Me */
.watch-me-header {
    margin-bottom: 24px;
    border-bottom: 1px solid var(--ch-border);
    padding-bottom: 16px;
}

.watch-me-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.problem-text {
    font-size: 1.15rem;
    color: white;
    line-height: 1.6;
}

.step-reveal-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.reveal-step-card {
    border: 1px solid var(--ch-border);
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.02);
}

.reveal-btn {
    width: 100%;
    padding: 14px 20px;
    background: transparent;
    border: none;
    color: var(--ch-text-secondary);
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.reveal-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.step-content-hidden {
    padding: 20px;
    background: var(--ch-surface-2);
    border-top: 1px solid var(--ch-border);
    display: none;
    animation: slideDown 0.3s ease;
}

.step-content-hidden.visible {
    display: block;
}

/* Level 2: Try It (Scaffolded) */
.scaffold-input-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    background: rgba(255, 255, 255, 0.03);
    padding: 12px 16px;
    border-radius: 8px;
}

.scaffold-input {
    background: var(--ch-surface);
    border: 1px solid var(--ch-border);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    width: 120px;
    text-align: center;
}

.scaffold-input:focus {
    border-color: var(--ch-accent);
    outline: none;
}

.check-btn-sm {
    background: var(--ch-accent);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Level 3: Challenge */
.challenge-tools {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--ch-border);
}

.tool-btn {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--ch-border);
    border-radius: 10px;
    background: transparent;
    color: var(--ch-text-secondary);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.tool-btn i {
    font-size: 1.2rem;
    color: var(--ch-accent-light);
}

.quiz-area {
    background: var(--ch-surface);
    border: 1px solid var(--ch-border);
    border-radius: var(--ch-radius);
    padding: 32px;
}

.quiz-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    margin-bottom: 24px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--ch-accent), var(--ch-purple));
    border-radius: 3px;
    transition: width 0.4s ease;
}

.quiz-question-num {
    font-size: 0.8rem;
    color: var(--ch-text-secondary);
    margin-bottom: 12px;
}

.quiz-question-text {
    font-size: 1.15rem;
    color: white;
    line-height: 1.7;
    margin-bottom: 24px;
    font-weight: 500;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quiz-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    border: 2px solid var(--ch-border);
    border-radius: var(--ch-radius-sm);
    background: rgba(255, 255, 255, 0.02);
    color: white;
    cursor: pointer;
    transition: var(--ch-transition);
    font-size: 0.95rem;
    font-family: inherit;
}

.quiz-option:hover:not(.disabled) {
    border-color: var(--ch-accent-light);
    background: rgba(99, 102, 241, 0.08);
}

.quiz-option .option-letter {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.quiz-option.correct {
    border-color: var(--ch-green);
    background: var(--ch-green-soft);
}

.quiz-option.correct .option-letter {
    background: var(--ch-green);
}

.quiz-option.wrong {
    border-color: var(--ch-red);
    background: var(--ch-red-soft);
}

.quiz-option.wrong .option-letter {
    background: var(--ch-red);
}

.quiz-option.disabled {
    cursor: default;
    opacity: 0.7;
}

.quiz-explanation {
    background: var(--ch-surface-2);
    border: 1px solid var(--ch-border);
    border-radius: var(--ch-radius-sm);
    padding: 18px 22px;
    margin-top: 18px;
    font-size: 0.9rem;
    color: var(--ch-text-secondary);
    line-height: 1.7;
}

.quiz-explanation i {
    color: var(--ch-accent-light);
    margin-right: 8px;
}

.quiz-nav-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
}

.quiz-btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--ch-radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--ch-transition);
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
}

.quiz-btn-next {
    background: var(--ch-accent);
    color: white;
}

.quiz-btn-next:hover {
    background: var(--ch-accent-light);
    transform: translateY(-1px);
}

.quiz-btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--ch-text-secondary);
}

.quiz-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
}

/* Quiz Results */
.quiz-results {
    text-align: center;
    padding: 40px 20px;
}

.quiz-results-score {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 0 auto 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 800;
    color: white;
}

.quiz-results-score.pass {
    background: var(--ch-green-soft);
    border: 3px solid var(--ch-green);
}

.quiz-results-score.fail {
    background: var(--ch-red-soft);
    border: 3px solid var(--ch-red);
}

.quiz-results h3 {
    font-size: 1.3rem;
    color: white;
    margin-bottom: 8px;
}

.quiz-results p {
    color: var(--ch-text-secondary);
    margin-bottom: 24px;
}

.quiz-results-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 28px;
}

.quiz-results-stat {
    text-align: center;
}

.quiz-results-stat .val {
    font-size: 1.4rem;
    font-weight: 700;
    display: block;
}

.quiz-results-stat .label {
    font-size: 0.8rem;
    color: var(--ch-text-secondary);
}

.quiz-results-stat.correct-stat .val {
    color: var(--ch-green);
}

.quiz-results-stat.wrong-stat .val {
    color: var(--ch-red);
}

/* ====== SECTION 4: AI DOUBT SOLVER ====== */
.doubt-solver {
    background: var(--ch-surface);
    border: 1px solid var(--ch-border);
    border-radius: var(--ch-radius);
    height: 600px;
    /* Taller for better chat */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.doubt-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--ch-border);
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255, 255, 255, 0.02);
}

.doubt-header-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ch-accent), var(--ch-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.doubt-header-info h3 {
    font-size: 0.95rem;
    color: white;
    margin: 0;
}

.doubt-header-info p {
    font-size: 0.75rem;
    color: var(--ch-text-secondary);
    margin: 0;
}

.doubt-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.doubt-msg {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 0.93rem;
    line-height: 1.7;
}

.doubt-msg.user {
    align-self: flex-end;
    background: var(--ch-accent);
    color: white;
    border-bottom-right-radius: 4px;
}

.doubt-msg.ai {
    align-self: flex-start;
    background: var(--ch-surface-2);
    color: var(--ch-text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--ch-border);
}

.doubt-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 14px 18px;
    background: var(--ch-surface-2);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}

.doubt-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ch-text-secondary);
    animation: doubt-dot 1.4s infinite ease-in-out both;
}

.doubt-typing span:nth-child(2) {
    animation-delay: 0.16s;
}

.doubt-typing span:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes doubt-dot {

    0%,
    80%,
    100% {
        transform: scale(0.5);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.doubt-input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--ch-border);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.doubt-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--ch-border);
    border-radius: 12px;
    padding: 12px 16px;
    color: white;
    font-size: 0.9rem;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    outline: none;
    transition: var(--ch-transition);
}

.doubt-input:focus {
    border-color: var(--ch-accent);
    background: rgba(255, 255, 255, 0.08);
}

.doubt-input::placeholder {
    color: var(--ch-text-secondary);
}

.doubt-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--ch-accent);
    border: none;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--ch-transition);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.doubt-send-btn:hover {
    background: var(--ch-accent-light);
    transform: translateY(-1px);
}

/* ====== SECTION 5: QUICK REVISION ====== */
.revision-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: white;
    margin: 0 0 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.revision-section-title i {
    color: var(--ch-accent-light);
}

.formula-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
    margin-bottom: 32px;
}

.formula-card {
    background: var(--ch-surface);
    border: 1px solid var(--ch-border);
    border-radius: var(--ch-radius-sm);
    padding: 20px;
    transition: var(--ch-transition);
}

.formula-card:hover {
    border-color: var(--ch-accent);
}

.formula-card-name {
    font-size: 0.82rem;
    color: var(--ch-text-secondary);
    font-weight: 600;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.formula-card-content {
    font-size: 1.1rem;
    color: white;
    text-align: center;
    padding: 10px 0;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Key points checklist */
.key-points-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.key-point-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    background: var(--ch-surface);
    border: 1px solid var(--ch-border);
    border-radius: var(--ch-radius-sm);
    margin-bottom: 8px;
    transition: var(--ch-transition);
    cursor: pointer;
}

.key-point-item:hover {
    border-color: var(--ch-green);
}

.key-point-item.checked {
    background: var(--ch-green-soft);
    border-color: rgba(16, 185, 129, 0.3);
}

.key-point-check {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2px solid var(--ch-border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.7rem;
    color: transparent;
    transition: var(--ch-transition);
    margin-top: 1px;
}

.key-point-item.checked .key-point-check {
    background: var(--ch-green);
    border-color: var(--ch-green);
    color: white;
}

.key-point-text {
    font-size: 0.9rem;
    color: var(--ch-text-secondary);
    line-height: 1.6;
}

.key-point-item.checked .key-point-text {
    color: var(--ch-green);
}

/* ====== SECTION 6: PYQ ====== */
.pyq-filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.pyq-year-btn {
    padding: 8px 16px;
    border: 1px solid var(--ch-border);
    border-radius: 50px;
    background: transparent;
    color: var(--ch-text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--ch-transition);
    font-family: inherit;
}

.pyq-year-btn:hover {
    border-color: var(--ch-orange);
    color: white;
}

.pyq-year-btn.active {
    background: var(--ch-orange-soft);
    border-color: var(--ch-orange);
    color: var(--ch-orange);
}

.pyq-card {
    background: var(--ch-surface);
    border: 1px solid var(--ch-border);
    border-radius: var(--ch-radius);
    margin-bottom: 12px;
    overflow: hidden;
}

.pyq-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    cursor: pointer;
}

.pyq-card-header h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    margin: 0;
    flex: 1;
}

.pyq-card-meta {
    display: flex;
    gap: 10px;
    align-items: center;
}

.pyq-marks-badge {
    padding: 4px 10px;
    background: var(--ch-orange-soft);
    color: var(--ch-orange);
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 700;
}

.pyq-year-badge {
    padding: 4px 10px;
    background: var(--ch-purple-soft);
    color: var(--ch-purple);
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 700;
}

.pyq-card-body {
    display: none;
    padding: 0 24px 20px;
    border-top: 1px solid var(--ch-border);
}

.pyq-card.open .pyq-card-body {
    display: block;
}

.pyq-answer-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--ch-green);
    margin: 14px 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pyq-answer-content {
    font-size: 0.9rem;
    color: var(--ch-text-secondary);
    line-height: 1.7;
}

/* ====== SECTION 7: AI MINI TEST ====== */
.mini-test-launcher {
    text-align: center;
    padding: 60px 20px;
    background: var(--ch-surface);
    border: 1px solid var(--ch-border);
    border-radius: var(--ch-radius);
}

.mini-test-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, var(--ch-accent), var(--ch-purple));
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
}

.mini-test-launcher h3 {
    font-size: 1.4rem;
    color: white;
    margin-bottom: 8px;
}

.mini-test-launcher p {
    color: var(--ch-text-secondary);
    max-width: 400px;
    margin: 0 auto 28px;
    font-size: 0.95rem;
    line-height: 1.6;
}

.mini-test-specs {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 28px;
}

.mini-test-spec {
    text-align: center;
}

.mini-test-spec .val {
    display: block;
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
}

.mini-test-spec .label {
    font-size: 0.78rem;
    color: var(--ch-text-secondary);
}

.mini-test-generate-btn {
    padding: 16px 40px;
    background: linear-gradient(135deg, var(--ch-accent), var(--ch-purple));
    border: none;
    border-radius: var(--ch-radius-sm);
    color: white;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--ch-transition);
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.mini-test-generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.35);
}

.mini-test-generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.mini-test-generate-btn .spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: none;
}

.mini-test-generate-btn.loading .spinner {
    display: block;
}

.mini-test-generate-btn.loading .btn-text {
    display: none;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ====== EMPTY STATE ====== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--ch-text-secondary);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--ch-text);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.9rem;
}

/* ====== LOADING STATES ====== */
.chapter-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    gap: 16px;
}

.chapter-loading .loader {
    width: 40px;
    height: 40px;
    border: 3px solid var(--ch-border);
    border-top-color: var(--ch-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.chapter-loading p {
    color: var(--ch-text-secondary);
    font-size: 0.9rem;
}

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
    .chapter-container {
        padding: 16px 16px 40px;
    }

    .chapter-hero {
        padding: 24px 20px;
    }

    .chapter-hero h1 {
        font-size: 1.5rem;
    }

    .chapter-hero-top {
        flex-direction: column;
    }

    .chapter-stats {
        gap: 16px;
    }

    .chapter-tabs {
        padding: 4px;
        gap: 2px;
    }

    .chapter-tab {
        padding: 10px 14px;
        font-size: 0.78rem;
    }

    .chapter-tab span {
        display: none;
    }

    .practice-level-bar {
        flex-direction: column;
    }

    .quiz-area {
        padding: 20px;
    }

    .formula-grid {
        grid-template-columns: 1fr;
    }

    .doubt-solver {
        height: 400px;
    }

    .mini-test-specs {
        gap: 20px;
    }

    .quiz-results-stats {
        gap: 24px;
    }

    .pyq-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}