/* ============================================================================
   LESSON PLAYER STYLES
   ============================================================================ */

/* Font size scale - can be adjusted by students */
:root {
    --lesson-font-scale: 1;
}

.student-container {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

/* ============================================================================
   LOGIN SCREEN
   ============================================================================ */

.login-card, .topic-card, .complete-card {
    max-width: 600px;
    margin: 60px auto;
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

.login-card h1, .topic-card h2, .complete-card h1 {
    text-align: center;
    margin-bottom: 32px;
    color: var(--text-primary);
}

/* ============================================================================
   LESSON PLAYER
   ============================================================================ */

.lesson-header {
    background: white;
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
}

.lesson-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.lesson-info h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

/* Font size control */
.font-size-control {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-alt);
    padding: 6px 12px;
    border-radius: 20px;
}

.font-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: white;
    color: var(--text-primary);
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.font-btn:hover {
    background: var(--primary);
    color: white;
}

.font-size-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.student-info {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-secondary);
}

.progress-container {
    width: 100%;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--bg-alt);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
    transition: width 0.5s ease;
    width: 0%;
}

.progress-text {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ============================================================================
   VIRTUAL TEACHER
   ============================================================================ */

.virtual-teacher {
    background: white;
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.teacher-avatar {
    font-size: 2.5rem;
    flex-shrink: 0;
}

.teacher-message {
    flex: 1;
    padding: 16px;
    background: var(--bg-alt);
    border-radius: 8px;
    font-size: calc(1.15rem * var(--lesson-font-scale));
    line-height: 1.7;
    color: var(--text-primary);
}

/* ============================================================================
   CONTENT AREA
   ============================================================================ */

/* Main lesson content wrapper */
.lesson-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.content-area {
    background: white;
    padding: 32px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
    min-height: 300px;
    font-size: calc(1.1rem * var(--lesson-font-scale));
    line-height: 1.7;
}

/* Explanation */
.explanation-block {
    font-size: calc(1.15rem * var(--lesson-font-scale));
    line-height: 1.8;
}

.explanation-text {
    margin-bottom: 24px;
}

.explanation-text code {
    background: var(--bg-alt);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
}

.code-example {
    margin-top: 20px;
}

.code-example pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Code blocks from markdown */
.code-block {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px 20px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 16px 0;
	/* CRITICAL: Preserves indentation and newlines exactly as generated */
    white-space: pre; 
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    tab-size: 4;
}

/* Fix for syntax highlighting background conflict */
.explanation-text .code-block code,
.code-block code {
    background: transparent !important; /* Forces transparency over the generic code style */
    padding: 0;
    color: inherit; /* Uses the light text color defined in .code-block */
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    border: none;
    box-shadow: none;
}

/* ============================================================================
   DIAGRAMS & VISUAL CONTENT
   ============================================================================ */

.diagram-container {
    margin: 24px 0;
    padding: 20px;
    background: var(--bg-alt);
    border-radius: 12px;
    border: 1px solid var(--border);
    text-align: center;
}

.diagram-caption {
    margin-top: 12px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* SVG Diagrams */
.svg-diagram {
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: #fafafa;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
}

.svg-diagram svg {
    max-width: 100%;
    width: auto;
    height: auto;
    min-height: 150px;
    max-height: 450px;
    display: block;
}

/* Ensure text in SVGs is readable */
.svg-diagram svg text {
    font-family: Arial, sans-serif;
}

/* Fix for spreadsheet/table SVGs - ensure cells don't overlap */
.svg-diagram svg rect {
    vector-effect: non-scaling-stroke;
}

.svg-diagram svg line {
    vector-effect: non-scaling-stroke;
}

/* Chart.js Diagrams */
.chart-diagram {
    max-width: 100%;
    max-height: 350px;
}

/* Function Plot Diagrams */
.function-plot-diagram {
    display: flex;
    justify-content: center;
    overflow-x: auto;
}

.function-plot-diagram svg {
    max-width: 100%;
}

/* Physics Diagrams */
.physics-diagram {
    display: flex;
    justify-content: center;
    align-items: center;
}

.physics-diagram svg {
    max-width: 100%;
    height: auto;
    min-height: 150px;
    max-height: 350px;
}

/* Mermaid Diagrams */
.mermaid-diagram {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100px;
    overflow-x: auto;
}

.mermaid-diagram svg {
    max-width: 100%;
    height: auto;
}

/* ASCII Art Diagrams */
.ascii-diagram {
    font-family: 'Courier New', Consolas, monospace;
    font-size: 0.95rem;
    line-height: 1.4;
    background: #1e293b;
    color: #e2e8f0;
    padding: 20px;
    border-radius: 8px;
    text-align: left;
    display: inline-block;
    white-space: pre;
    overflow-x: auto;
    max-width: 100%;
}

/* Text Description Diagrams (for concepts without visual templates) */
.diagram-description {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 12px;
    padding: 20px;
    text-align: left;
    margin: 16px auto;
    max-width: 600px;
}

.diagram-description .description-content {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.diagram-description .description-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.diagram-description .description-content p {
    margin: 0;
    line-height: 1.7;
    color: #0c4a6e;
    font-size: 1rem;
}

/* Physics-specific diagram styles */
.diagram-container .force-arrow {
    stroke-width: 3;
}

.diagram-container .object {
    fill: #e2e8f0;
    stroke: #64748b;
    stroke-width: 2;
}

.diagram-container .label {
    font-size: 14px;
    font-weight: 500;
}

/* Interactive diagram hints */
.diagram-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 16px;
    background: #eff6ff;
    border-radius: 20px;
    font-size: 0.85rem;
    color: #1e40af;
}

.diagram-hint::before {
    content: "💡";
}

/* Responsive diagrams */
@media (max-width: 600px) {
    .diagram-container {
        padding: 12px;
        margin: 16px 0;
    }
    
    .svg-diagram svg {
        min-height: 120px;
        max-height: 300px;
    }
    
    .ascii-diagram {
        font-size: 0.8rem;
        padding: 12px;
    }
}

/* Better explanation text formatting */
.explanation-text {
    font-size: calc(1.15rem * var(--lesson-font-scale));
    line-height: 1.8;
}

.explanation-text p {
    margin-bottom: 16px;
}

.explanation-text h3 {
    font-size: calc(1.3rem * var(--lesson-font-scale));
    margin: 20px 0 12px 0;
    color: var(--text-primary);
}

.explanation-text ul {
    margin: 12px 0;
    padding-left: 24px;
}

.explanation-text li {
    margin-bottom: 8px;
}

.explanation-text code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 0.9em;
    color: #e11d48;
}

/* MCQ */
.mcq-container .question-text {
    font-size: calc(1.2rem * var(--lesson-font-scale));
    margin-bottom: 24px;
    font-weight: 500;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-btn {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px 20px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    font-size: calc(1.1rem * var(--lesson-font-scale));
    width: 100%;
}

.option-btn .option-letter {
    margin-top: 4px;
}

.option-btn:hover {
    border-color: var(--primary);
    background: var(--bg-alt);
}

.option-btn.selected {
    border-color: var(--primary);
    background: #eff6ff;
}

.option-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-weight: 600;
    flex-shrink: 0;
}

.option-text {
    flex: 1;
    font-size: calc(1.1rem * var(--lesson-font-scale));
    line-height: 1.5;
}

/* Tables in multiple choice options */
.option-table {
    border-collapse: collapse;
    font-size: calc(0.95rem * var(--lesson-font-scale));
    background: #f8fafc;
    border-radius: 6px;
    overflow: hidden;
    margin: 4px 0;
}

.option-table th,
.option-table td {
    padding: 8px 16px;
    text-align: center;
    border: 1px solid #e2e8f0;
}

.option-table th {
    background: #e2e8f0;
    font-weight: 600;
    color: #334155;
}

.option-table td {
    background: white;
}

.option-table tr:nth-child(even) td {
    background: #f8fafc;
}

.option-btn:hover .option-table th {
    background: #cbd5e1;
}

.option-btn.selected .option-table th {
    background: #bfdbfe;
}

.option-btn.selected .option-table td {
    background: #eff6ff;
}

.option-btn.selected .option-table tr:nth-child(even) td {
    background: #dbeafe;
}

/* Short Answer */
.short-answer-container .question-text {
    font-size: calc(1.2rem * var(--lesson-font-scale));
    margin-bottom: 20px;
    font-weight: 500;
}

.answer-input {
    font-family: inherit;
    font-size: calc(1.1rem * var(--lesson-font-scale));
    line-height: 1.6;
}

/* Code Editor Styling */
.code-editor {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: calc(1rem * var(--lesson-font-scale));
    line-height: 1.5;
    background: #1e293b;
    color: #e2e8f0;
    border: 2px solid #334155;
    border-radius: 8px;
    padding: 16px;
    width: 100%;
    min-height: 150px;
    resize: vertical;
    tab-size: 4;
    -moz-tab-size: 4;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.code-editor:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.code-editor::placeholder {
    color: #64748b;
}

/* Code Fill-In */
.code-fill-container {
    margin: 16px 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #334155;
    background: #1e293b;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #0f172a;
    border-bottom: 1px solid #334155;
}

.code-header-small {
    background: #0f172a;
    color: #64748b;
    font-size: 0.75rem;
    padding: 4px 12px;
    border-radius: 8px 8px 0 0;
    border-bottom: 1px solid #334155;
    text-transform: uppercase;
    font-weight: 600;
    width: fit-content; /* Only wrap the text */
}

/* Adjust code block to look attached to the header */
.code-example .code-block {
    margin-top: 0;
    border-top-left-radius: 0;
}

.code-language-badge {
    background: #3b82f6;
    color: white;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.code-hint {
    color: #94a3b8;
    font-size: 0.85rem;
}

.code-editor-wrapper {
    display: flex;
    overflow-x: auto;
}

.line-numbers {
    display: flex;
    flex-direction: column;
    padding: 16px 0;
    background: #0f172a;
    border-right: 1px solid #334155;
    text-align: right;
    user-select: none;
    min-width: 40px;
}

.line-numbers span {
    padding: 0 12px;
    color: #64748b;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.8;
}

.code-template {
    flex: 1;
    background: #1e293b;
    color: #e2e8f0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: calc(1rem * var(--lesson-font-scale));
    line-height: 1.8;
    margin: 0;
    padding: 16px 20px;
    /* CRITICAL: Ensures blank inputs flow correctly with code */
    white-space: pre-wrap; 
    overflow-x: auto;
    tab-size: 4;
}

/* Syntax highlighting */
.syntax-keyword {
    color: #c792ea;
    font-weight: 500;
}

.syntax-string {
    color: #c3e88d;
}

.syntax-comment {
    color: #676e95;
    font-style: italic;
}

.syntax-function {
    color: #82aaff;
}

.syntax-number {
    color: #f78c6c;
}

.syntax-attribute {
    color: #ffcb6b;
}

/* Code blanks */
.blank-wrapper {
    position: relative;
    display: inline-block;
}

.code-blank {
    background: #0f172a;
    border: 2px solid #60a5fa;
    border-radius: 4px;
    padding: 4px 12px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: calc(1rem * var(--lesson-font-scale));
    min-width: 60px;
    color: #fbbf24;
    transition: all 0.2s ease;
	vertical-align: baseline; 
    margin: 0 2px;
}

.code-blank:focus {
    outline: none;
    border-color: #34d399;
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.3);
    background: #1e293b;
}

.code-blank.blank-correct {
    border-color: #34d399;
    background: rgba(52, 211, 153, 0.1);
}

.blank-number {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #3b82f6;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.code-shortcuts-hint {
    display: flex;
    gap: 20px;
    padding: 8px 16px;
    background: #f8fafc;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: #64748b;
}

/* ============================================================================
   INTERACTION AREA
   ============================================================================ */

.interaction-area {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
}

.feedback-area {
    min-height: 60px;
    margin-bottom: 16px;
}

.feedback {
    padding: 16px 20px;
    border-radius: 8px;
    font-size: calc(1.1rem * var(--lesson-font-scale));
    line-height: 1.6;
    animation: fadeIn 0.3s ease;
}

.feedback.success {
    background: #f0fdf4;
    border: 2px solid #bbf7d0;
    color: #166534;
}

.feedback.error {
    background: #fef2f2;
    border: 2px solid #fecaca;
    color: #991b1b;
}

.feedback.info {
    background: #eff6ff;
    border: 2px solid #bfdbfe;
    color: #1e40af;
}

.feedback.warning {
    background: #fffbeb;
    border: 2px solid #fde68a;
    color: #92400e;
}

.controls-area {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    align-items: center;
}

.controls-left {
    display: flex;
    gap: 12px;
    align-items: center;
}

.controls-right {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Tutor button inline style */
.btn-tutor {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn-tutor:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-tutor.active {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* ============================================================================
   LESSON COMPLETE
   ============================================================================ */

.celebration {
    font-size: 5rem;
    text-align: center;
    margin-bottom: 24px;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

/* New simplified completion screen */
.lesson-complete-summary {
    text-align: center;
}

.encouragement {
    margin-bottom: 32px;
}

.encouragement-emoji {
    font-size: 4rem;
    display: block;
    margin-bottom: 16px;
}

.encouragement-message {
    font-size: 1.25rem;
    color: var(--text-primary);
    font-weight: 500;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: 32px 0;
}

.stat {
    text-align: center;
    padding: 20px;
    background: var(--bg-alt);
    border-radius: 12px;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 8px;
}

.stat-value .stat-unit {
    font-size: 1rem;
    font-weight: normal;
    color: var(--text-secondary);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Concepts practiced */
.concepts-practiced {
    margin: 32px 0;
    padding: 24px;
    background: var(--bg-alt);
    border-radius: 12px;
}

.concepts-practiced h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-weight: 500;
}

.concept-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.concept-tag {
    background: white;
    color: var(--primary);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid var(--border);
}

/* Collapsible mastery section */
.mastery-section {
    margin-top: 24px;
}

.mastery-toggle {
    width: 100%;
    padding: 16px 20px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
    color: var(--text-primary);
    transition: var(--transition);
}

.mastery-toggle:hover {
    background: #f1f5f9;
}

.toggle-icon {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.mastery-details {
    margin-top: 16px;
    padding: 20px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.mastery-details.hidden {
    display: none;
}

.no-mastery {
    color: var(--text-secondary);
    text-align: center;
    padding: 20px;
}

.mastery-display {
    margin: 32px 0;
}

.mastery-item {
    display: grid;
    grid-template-columns: 1fr 2fr auto;
    align-items: center;
    gap: 16px;
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 8px;
    background: var(--bg-alt);
}

.concept-name {
    font-weight: 500;
}

.mastery-bar {
    height: 12px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

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

.mastery-item.strong .mastery-fill {
    background: #10b981;
}

.mastery-item.okay .mastery-fill {
    background: #f59e0b;
}

.mastery-item.needs-work .mastery-fill {
    background: #ef4444;
}

.mastery-percentage {
    font-weight: 600;
    min-width: 48px;
    text-align: right;
}

.action-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 32px;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    .student-container {
        padding: 12px;
    }
    
    .login-card, .topic-card, .complete-card {
        padding: 24px;
        margin: 30px auto;
    }
    
    .lesson-header, .virtual-teacher, .content-area, .interaction-area {
        padding: 16px;
    }
    
    .lesson-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .controls-area {
        flex-direction: column;
        gap: 12px;
    }
    
    .controls-left {
        width: 100%;
        flex-direction: column;
    }
    
    .controls-right {
        width: 100%;
    }
    
    .controls-area .btn,
    .controls-left .btn,
    .controls-right .btn {
        width: 100%;
    }
    
    .summary-stats {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .action-buttons .btn {
        width: 100%;
    }
    
    .mastery-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

/* ============================================================================
   MATH INPUT TOOLS
   ============================================================================ */

.math-input-tools {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.symbol-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.symbol-tab {
    padding: 6px 12px;
    background: var(--bg-alt, #f5f5f5);
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s ease;
    color: var(--text, #333);
}

.symbol-tab:hover {
    background: var(--border, #e0e0e0);
}

.symbol-tab.active {
    background: var(--primary, #6366f1);
    color: white;
    border-color: var(--primary, #6366f1);
}

.symbol-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.symbol-palette.hidden {
    display: none !important;
}

.symbol-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.symbol-btn:hover {
    background: var(--bg-alt);
    border-color: var(--primary);
}

.symbol-btn.fraction-btn {
    width: auto;
    padding: 0 12px;
    font-size: 0.9rem;
    font-weight: 500;
}

.scratchpad-btn {
    padding: 10px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.scratchpad-btn:hover {
    background: var(--primary-dark);
}

/* ============================================================================
   SCRATCHPAD MODAL
   ============================================================================ */

.scratchpad-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.scratchpad-content {
    background: white;
    border-radius: 16px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.scratchpad-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.scratchpad-header h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin: 0;
}

.close-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-alt);
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition);
}

.close-btn:hover {
    background: #fee2e2;
    color: #991b1b;
}

.scratchpad-tools {
    display: flex;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
}

.tool-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.tool-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.tool-btn:hover {
    background: var(--bg-alt);
    border-color: var(--primary);
}

.tool-btn.active {
    background: var(--primary);
    border-color: var(--primary);
}

#pen-color {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    padding: 2px;
}

.canvas-container {
    padding: 20px;
    background: white;
}

#scratchpad-canvas {
    width: 100%;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: white;
    cursor: crosshair;
    touch-action: none;
}

.scratchpad-actions {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.scratchpad-status {
    min-height: 24px;
    font-size: 0.95rem;
}

.recognition-result {
    color: var(--success);
}

.scratchpad-actions .action-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.scratchpad-hint {
    padding: 12px 24px 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    margin: 0;
}

/* Mobile adjustments for scratchpad */
@media (max-width: 600px) {
    .scratchpad-modal {
        padding: 10px;
    }
    
    .scratchpad-content {
        max-height: 95vh;
    }
    
    .scratchpad-tools {
        flex-direction: column;
        gap: 12px;
    }
    
    .math-input-tools {
        flex-direction: column;
        align-items: stretch;
    }
    
    .symbol-palette {
        justify-content: center;
    }
    
    .scratchpad-btn {
        width: 100%;
    }
    
    .scratchpad-actions .action-buttons {
        flex-direction: column;
    }
    
    .scratchpad-actions .btn {
        width: 100%;
    }
}

/* ============================================================================
   RESUME LESSON MODAL
   ============================================================================ */
.resume-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.resume-modal-content {
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
}

.modal-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.modal-close-btn:hover {
    background: var(--surface, #f1f5f9);
    color: var(--text-primary, #1e293b);
}

.resume-modal-content h2 {
    margin: 0 0 16px 0;
    font-size: 1.5rem;
    color: var(--text-primary, #1e293b);
}

.resume-modal-content p {
    margin: 0 0 16px 0;
    color: var(--text-secondary, #64748b);
}

.resume-lesson-info {
    background: var(--surface, #f8fafc);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.resume-lesson-info strong {
    font-size: 1.1rem;
    color: var(--text-primary, #1e293b);
}

.resume-progress {
    color: var(--primary, #4f46e5);
    font-weight: 600;
}

.resume-date {
    font-size: 0.9rem;
    color: var(--text-secondary, #64748b);
}

.resume-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.resume-buttons .btn {
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.resume-buttons .btn-primary {
    background: var(--primary, #4f46e5);
    color: white;
    border: none;
}

.resume-buttons .btn-primary:hover {
    background: var(--primary-dark, #4338ca);
    transform: translateY(-2px);
}

.resume-buttons .btn-outline {
    background: white;
    color: var(--text-secondary, #64748b);
    border: 1px solid var(--border, #e2e8f0);
}

.resume-buttons .btn-outline:hover {
    background: var(--surface, #f8fafc);
    color: var(--text-primary, #1e293b);
    border-color: var(--text-secondary, #94a3b8);
}

.resume-secondary-action {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border, #e2e8f0);
}

.resume-secondary-action a {
    font-size: 0.85rem;
    color: var(--text-secondary, #94a3b8);
    text-decoration: none;
}

.resume-secondary-action a:hover {
    color: var(--error, #ef4444);
    text-decoration: underline;
}

/* ============================================================================
   LESSON TABS & ASSIGNED LESSONS
   ============================================================================ */

.lesson-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0;
}

.tab-btn {
    flex: 1;
    padding: 14px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 1rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: #1e293b;
    background: #f8fafc;
}

.tab-btn.active {
    color: var(--primary, #4f46e5);
    border-bottom-color: var(--primary, #4f46e5);
    background: transparent;
}

.tab-badge {
    background: var(--primary, #4f46e5);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
}

.tab-btn:not(.active) .tab-badge {
    background: #94a3b8;
}

.tab-content {
    animation: fadeIn 0.3s ease;
}

.tab-content:not(.active) {
    display: none;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: #64748b;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--primary, #4f46e5);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.empty-state p {
    margin: 0 0 8px 0;
    color: #64748b;
}

.empty-state p:first-child {
    font-size: 1.25rem;
    color: #1e293b;
}

.empty-hint {
    font-size: 0.9rem;
    max-width: 300px;
    margin-bottom: 16px !important;
}

/* Lessons Grid */
.lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.assigned-lesson-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.assigned-lesson-card:hover {
    border-color: var(--primary, #4f46e5);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
    transform: translateY(-2px);
}

.lesson-card-header {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.lesson-subject-badge,
.lesson-level-badge {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 16px;
    font-weight: 500;
}

.lesson-subject-badge {
    background: #f0f9ff;
    color: #0369a1;
}

.lesson-level-badge {
    background: #f5f3ff;
    color: #6d28d9;
}

.lesson-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
    line-height: 1.4;
    flex: 1;
}

.lesson-card-meta {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    color: #64748b;
}

.btn-start-lesson {
    margin-top: auto;
    width: 100%;
}

/* Responsive */
@media (max-width: 600px) {
    .lesson-tabs {
        gap: 4px;
    }
    
    .tab-btn {
        padding: 12px 12px;
        font-size: 0.9rem;
    }
    
    .lessons-grid {
        grid-template-columns: 1fr;
    }
    
    .assigned-lesson-card {
        padding: 16px;
    }
}

/* ============================================================================
   STREAMING STATUS INDICATOR
   ============================================================================ */

.streaming-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pulse-dot {
    width: 10px;
    height: 10px;
    background: var(--primary, #4f46e5);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

.status-message.info .streaming-status {
    color: #1e40af;
}

/* ============================================================================
   RETEACH TRANSITION UI
   ============================================================================ */

.reteach-transition {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
    animation: fadeIn 0.3s ease;
}

.correct-answer-reveal {
    background: white;
    border-left: 4px solid var(--primary, #4f46e5);
    padding: 16px 20px;
    margin-bottom: 20px;
    border-radius: 0 8px 8px 0;
}

.reveal-header {
    font-size: 0.9rem;
    color: #64748b;
    margin-bottom: 12px;
}

.correct-answer {
    font-size: 1.1rem;
    color: #1e293b;
    margin-bottom: 8px;
}

.correct-answer strong {
    color: var(--primary, #4f46e5);
}

.answer-explanation {
    font-size: 0.95rem;
    color: #475569;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.reteach-prompt {
    color: #64748b;
    font-size: 0.95rem;
    margin-bottom: 20px;
    font-style: italic;
}

.reteach-continue-btn {
    width: 100%;
    padding: 16px 24px;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.reteach-continue-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

@media (max-width: 480px) {
    .reteach-transition {
        padding: 16px;
    }
    
    .correct-answer-reveal {
        padding: 12px 16px;
    }
}

/* ============================================================================
   STUDENT PROGRESS DASHBOARD
   ============================================================================ */

#progress-tab {
    padding: 0;
}

.progress-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px 16px;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.stat-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 4px;
}

.progress-section {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.progress-section h3 {
    font-size: 1.1rem;
    color: #1e293b;
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h3 {
    margin: 0;
}

/* Mastery Chart */
.mastery-chart-container {
    height: 250px;
    margin-bottom: 20px;
}

.empty-chart-message,
.empty-list-message {
    text-align: center;
    color: #64748b;
    padding: 40px 20px;
    font-style: italic;
}

/* Mastery List */
.mastery-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mastery-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 8px;
    border-left: 4px solid #94a3b8;
}

.mastery-list-item.strong {
    border-left-color: #22c55e;
    background: #f0fdf4;
}

.mastery-list-item.medium {
    border-left-color: #f59e0b;
    background: #fffbeb;
}

.mastery-list-item.weak {
    border-left-color: #ef4444;
    background: #fef2f2;
}

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

.mastery-list-label {
    display: block;
    font-weight: 500;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mastery-list-level {
    font-size: 0.75rem;
    color: #64748b;
}

.mastery-list-bar-container {
    width: 100px;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.mastery-list-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.mastery-list-item.strong .mastery-list-bar {
    background: #22c55e;
}

.mastery-list-item.medium .mastery-list-bar {
    background: #f59e0b;
}

.mastery-list-item.weak .mastery-list-bar {
    background: #ef4444;
}

.mastery-list-percentage {
    font-weight: 600;
    font-size: 0.9rem;
    color: #475569;
    min-width: 40px;
    text-align: right;
}

/* Lesson History */
.lesson-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.history-item.completed {
    border-left: 4px solid #22c55e;
}

.history-item.in-progress {
    border-left: 4px solid #f59e0b;
}

.history-item-main {
    flex: 1;
    min-width: 0;
}

.history-item-topic {
    font-weight: 500;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.history-item-meta {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: #64748b;
}

.history-item-stats {
    display: flex;
    align-items: center;
    gap: 12px;
}

.history-item-score {
    font-weight: 600;
    font-size: 1.1rem;
    color: #1e293b;
}

.history-item-status {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 500;
}

.history-item-status.completed {
    background: #dcfce7;
    color: #166534;
}

.history-item-status.in-progress {
    background: #fef3c7;
    color: #92400e;
}

.history-item-actions {
    flex-shrink: 0;
}

.empty-state-small {
    text-align: center;
    padding: 30px 20px;
    color: #64748b;
}

/* ============================================================================
   SKILL SUMMARY CARDS
   ============================================================================ */
.skill-summary {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.skill-summary-card {
    flex: 1;
    min-width: 140px;
    padding: 16px;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.skill-summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.skill-summary-card.weak {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 1px solid #fecaca;
}

.skill-summary-card.medium {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #fde68a;
}

.skill-summary-card.strong {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 1px solid #bbf7d0;
}

.skill-summary-count {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.skill-summary-card.weak .skill-summary-count { color: #dc2626; }
.skill-summary-card.medium .skill-summary-count { color: #d97706; }
.skill-summary-card.strong .skill-summary-count { color: #16a34a; }

.skill-summary-label {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
}

.skill-summary-action {
    margin-top: 10px;
    font-size: 0.8rem;
    padding: 6px 12px;
    border-radius: 6px;
    background: white;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.skill-summary-card.weak .skill-summary-action {
    color: #dc2626;
}

.skill-summary-card.weak .skill-summary-action:hover {
    background: #fecaca;
}

/* ============================================================================
   COLLAPSIBLE SKILL GROUPS
   ============================================================================ */
.skill-groups {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skill-group {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    background: white;
}

.skill-group-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: #f8fafc;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: #1e293b;
    transition: background 0.2s;
}

.skill-group-header:hover {
    background: #f1f5f9;
}

.skill-group-header[aria-expanded="true"] .skill-group-toggle {
    transform: rotate(180deg);
}

.skill-group-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.skill-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.skill-dot.weak { background: #ef4444; }
.skill-dot.medium { background: #f59e0b; }
.skill-dot.strong { background: #22c55e; }

.skill-group-count {
    font-weight: 400;
    color: #64748b;
    font-size: 0.85rem;
}

.skill-group-toggle {
    transition: transform 0.3s ease;
    color: #64748b;
    font-size: 0.8rem;
}

.skill-group-content {
    padding: 0;
    max-height: 300px;
    overflow-y: auto;
}

.skill-group-content .skill-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
}

.skill-group-content .skill-item:first-child {
    border-top: none;
}

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

.skill-item-name {
    font-weight: 500;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
}

.skill-item-bar {
    width: 80px;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.skill-item-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.skill-item-bar-fill.weak { background: #ef4444; }
.skill-item-bar-fill.medium { background: #f59e0b; }
.skill-item-bar-fill.strong { background: #22c55e; }

.skill-item-percentage {
    font-weight: 600;
    font-size: 0.85rem;
    color: #64748b;
    min-width: 40px;
    text-align: right;
}

/* ============================================================================
   PAGINATION CONTROLS
   ============================================================================ */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

.page-info {
    font-size: 0.9rem;
    color: #64748b;
}

.section-count {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 400;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.section-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================================================
   RESPONSIVE - PROGRESS DASHBOARD
   ============================================================================ */
@media (max-width: 768px) {
    .progress-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .skill-summary {
        flex-direction: column;
    }
    
    .skill-summary-card {
        min-width: 100%;
    }
    
    .history-item {
        flex-wrap: wrap;
    }
    
    .history-item-main {
        width: 100%;
    }
    
    .history-item-stats {
        width: 100%;
        justify-content: space-between;
        margin-top: 8px;
    }
    
    .skill-item-bar {
        display: none;
    }
}

@media (max-width: 480px) {
    .progress-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-card {
        padding: 14px 10px;
    }
    
    .stat-value {
        font-size: 1.4rem;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .pagination-controls {
        flex-wrap: wrap;
    }
}

/* Streaming progress bar (optional enhancement) */
.streaming-progress {
    width: 100%;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.streaming-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary, #4f46e5), #818cf8);
    border-radius: 2px;
    animation: streamingProgress 2s ease-in-out infinite;
    width: 30%;
}

@keyframes streamingProgress {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(400%);
    }
}

/* ============================================================================
   SOCRATIC TUTOR CHAT
   Chat panel that opens from inline button
   ============================================================================ */

/* Chat container */
#tutor-chat-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 500px;
    max-height: calc(100vh - 100px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#tutor-chat-container.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* Chat header */
.tutor-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tutor-chat-header .tutor-avatar {
    font-size: 32px;
}

.tutor-chat-header .tutor-info {
    flex: 1;
}

.tutor-chat-header .tutor-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.tutor-chat-header .tutor-info p {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.tutor-chat-header .close-chat {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.tutor-chat-header .close-chat:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Chat messages area */
#tutor-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
}

/* Chat message */
.chat-message {
    display: flex;
    gap: 10px;
    max-width: 90%;
    animation: messageSlideIn 0.3s ease;
}

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

.chat-message.student {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-message.tutor {
    align-self: flex-start;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.chat-message.tutor .chat-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.chat-bubble {
    background: white;
    padding: 12px 16px;
    border-radius: 16px;
    border-top-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    font-size: calc(1rem * var(--lesson-font-scale, 1));
    line-height: 1.5;
    color: #1e293b;
}

.chat-message.student .chat-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 16px;
    border-top-right-radius: 4px;
}

.chat-bubble code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: calc(0.9rem * var(--lesson-font-scale, 1));
}

.chat-message.student .chat-bubble code {
    background: rgba(255, 255, 255, 0.2);
}

/* Typing indicator */
.chat-bubble.typing {
    display: flex;
    gap: 4px;
    padding: 16px 20px;
}

.chat-bubble.typing .dot {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out;
}

.chat-bubble.typing .dot:nth-child(1) { animation-delay: 0s; }
.chat-bubble.typing .dot:nth-child(2) { animation-delay: 0.2s; }
.chat-bubble.typing .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* Chat input area */
.tutor-chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
    background: white;
    display: flex;
    gap: 10px;
}

#tutor-chat-input {
    flex: 1;
    border: 2px solid #e2e8f0;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: calc(1rem * var(--lesson-font-scale, 1));
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease;
    max-height: 100px;
}

#tutor-chat-input:focus {
    border-color: #667eea;
}

#tutor-chat-input::placeholder {
    color: #94a3b8;
}

.send-chat-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: transform 0.2s ease, opacity 0.2s ease;
    flex-shrink: 0;
}

.send-chat-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.send-chat-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Quick suggestion chips */
.chat-suggestions {
    padding: 8px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.suggestion-chip {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 6px 12px;
    font-size: calc(0.85rem * var(--lesson-font-scale, 1));
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion-chip:hover {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

/* Mobile responsive */
@media (max-width: 480px) {
    #tutor-chat-container {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 8px;
        height: calc(100vh - 100px);
        max-height: none;
        border-radius: 12px;
    }
}

/* Chat visibility controlled by JS */
#tutor-chat-container.hidden {
    display: none !important;
}

/* ============================================================================
   MERMAID DIAGRAM ERROR FALLBACK
   ============================================================================ */

.mermaid-fallback {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 100%);
    border: 2px dashed #a0b4d4;
    border-radius: 12px;
    color: #4a5568;
}

.mermaid-fallback .fallback-icon {
    font-size: 48px;
    opacity: 0.7;
}

.mermaid-fallback .fallback-text strong {
    display: block;
    font-size: 1.1rem;
    color: #2d3748;
    margin-bottom: 4px;
}

.mermaid-fallback .fallback-text p {
    margin: 0;
    font-size: 0.9rem;
    color: #718096;
}

.mermaid-diagram.mermaid-error {
    min-height: auto;
}

.mermaid-diagram.mermaid-rendered svg {
    max-width: 100%;
    height: auto;
}

/* ============================================================================
   ACCESSIBILITY STYLES
   High Contrast, Reduced Motion, TTS, Screen Reader Support
   ============================================================================ */

/* Screen reader only content */
.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;
}

/* Live region for announcements */
#sr-announcer {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus indicators - enhanced for accessibility */
:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* Skip link for keyboard users */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #667eea;
    color: white;
    padding: 8px 16px;
    z-index: 10000;
    text-decoration: none;
    font-weight: 600;
    border-radius: 0 0 8px 0;
}

.skip-link:focus {
    top: 0;
}

/* ============================================================================
   ACCESSIBILITY TOOLBAR
   ============================================================================ */

.a11y-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.a11y-btn {
    background: transparent;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.a11y-btn:hover {
    background: #f1f5f9;
    border-color: #667eea;
    color: #667eea;
}

.a11y-btn:focus-visible {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

.a11y-btn.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

/* TTS button states */
#tts-toggle-btn.active {
    background: #10b981;
    border-color: #10b981;
    color: white;
    animation: pulse-speaking 1.5s infinite;
}

@keyframes pulse-speaking {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
}

/* TTS language support indicator */
.tts-supported {
    color: #10b981;
    font-size: 12px;
}

.tts-unsupported {
    color: #94a3b8;
    font-size: 12px;
}

/* ============================================================================
   ACCESSIBILITY SETTINGS PANEL
   ============================================================================ */

#accessibility-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    width: 400px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 64px);
    overflow: auto;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#accessibility-panel.open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
}

.a11y-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 16px 16px 0 0;
}

.a11y-panel-header h2 {
    margin: 0;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.a11y-panel-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.a11y-panel-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.a11y-panel-content {
    padding: 24px;
}

.a11y-section {
    margin-bottom: 24px;
}

.a11y-section:last-child {
    margin-bottom: 0;
}

.a11y-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 12px 0;
}

.a11y-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

.a11y-option:last-child {
    border-bottom: none;
}

.a11y-option-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.a11y-option-label span {
    font-weight: 500;
    color: #1e293b;
}

.a11y-option-label small {
    color: #64748b;
    font-size: 0.8rem;
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    width: 52px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-switch input:focus-visible + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

/* Rate slider */
.rate-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rate-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    outline: none;
}

.rate-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
}

.rate-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
}

.rate-display {
    min-width: 40px;
    text-align: center;
    font-weight: 600;
    color: #667eea;
}

/* Keyboard shortcuts section */
.shortcuts-list {
    display: grid;
    gap: 8px;
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.shortcut-key {
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.8rem;
    color: #475569;
}

/* Backdrop */
.a11y-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.a11y-backdrop.open {
    opacity: 1;
    visibility: visible;
}

/* ============================================================================
   HIGH CONTRAST MODE
   ============================================================================ */

body.high-contrast {
    --text-primary: #000000;
    --text-secondary: #1a1a1a;
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-alt: #e5e5e5;
    --border-color: #000000;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
}

body.high-contrast .student-container {
    background: #000000;
}

body.high-contrast .login-card,
body.high-contrast .topic-card,
body.high-contrast .lesson-header,
body.high-contrast .virtual-teacher,
body.high-contrast .content-area,
body.high-contrast .interaction-area,
body.high-contrast .complete-card {
    background: #ffffff;
    border: 3px solid #000000;
}

body.high-contrast .btn {
    border: 2px solid #000000;
}

body.high-contrast .btn-primary {
    background: #000000;
    color: #ffffff;
}

body.high-contrast .btn-primary:hover {
    background: #333333;
}

body.high-contrast .btn-secondary {
    background: #ffffff;
    color: #000000;
    border: 2px solid #000000;
}

body.high-contrast .btn-secondary:hover {
    background: #e5e5e5;
}

body.high-contrast .progress-bar {
    background: #e5e5e5;
    border: 2px solid #000000;
}

body.high-contrast .progress-fill {
    background: #000000;
}

body.high-contrast a {
    color: #0000EE;
    text-decoration: underline;
}

body.high-contrast a:visited {
    color: #551A8B;
}

body.high-contrast .feedback.success {
    background: #ffffff;
    border: 3px solid #006600;
    color: #006600;
}

body.high-contrast .feedback.error {
    background: #ffffff;
    border: 3px solid #990000;
    color: #990000;
}

body.high-contrast input,
body.high-contrast textarea,
body.high-contrast select {
    border: 2px solid #000000;
    background: #ffffff;
    color: #000000;
}

body.high-contrast input:focus,
body.high-contrast textarea:focus,
body.high-contrast select:focus {
    outline: 3px solid #0066cc;
    outline-offset: 2px;
}

body.high-contrast .option-card {
    border: 2px solid #000000;
}

body.high-contrast .option-card.selected {
    border: 4px solid #000000;
    background: #e5e5e5;
}

body.high-contrast .option-card:hover {
    border-color: #0066cc;
}

body.high-contrast #tutor-chat-container {
    border: 3px solid #000000;
}

body.high-contrast .chat-bubble {
    border: 2px solid #000000;
}

body.high-contrast .btn-tutor {
    background: #000000;
    color: #ffffff;
    border: 2px solid #000000;
}

/* ============================================================================
   REDUCED MOTION MODE
   ============================================================================ */

body.reduced-motion,
body.reduced-motion * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
}

body.reduced-motion .celebration {
    animation: none;
}

body.reduced-motion .progress-fill {
    transition: none;
}

body.reduced-motion #tutor-chat-container {
    transition: none;
}

body.reduced-motion .chat-message {
    animation: none;
}

body.reduced-motion .typing .dot {
    animation: none;
}

/* Respect system preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* ============================================================================
   TTS SPEAKING INDICATOR
   ============================================================================ */

body.tts-speaking .content-area {
    position: relative;
}

body.tts-speaking .content-area::before {
    content: '🔊 Reading...';
    position: absolute;
    top: -30px;
    right: 0;
    background: #10b981;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/* ============================================================================
   MOBILE ACCESSIBILITY
   ============================================================================ */

@media (max-width: 480px) {
    #accessibility-panel {
        width: calc(100vw - 16px);
        max-height: calc(100vh - 32px);
        border-radius: 12px;
    }
    
    .a11y-toolbar {
        flex-wrap: wrap;
    }
    
    .a11y-btn {
        padding: 6px 10px;
        font-size: 13px;
    }
    
    .shortcut-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

/* Waiting for streaming content */
.waiting-for-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    min-height: 200px;
}

.waiting-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e2e8f0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 24px;
}

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

.waiting-for-content h3 {
    margin: 0 0 12px 0;
    font-size: 1.5rem;
    color: #1e293b;
}

.waiting-for-content p {
    margin: 0;
    color: #64748b;
    font-size: 1.1rem;
}

.waiting-for-content .waiting-hint {
    margin-top: 8px;
    font-size: 0.9rem;
    color: #94a3b8;
}

/* Reduced motion - disable spinner animation */
body.reduced-motion .waiting-spinner {
    animation: none;
    border-top-color: #667eea;
    border-right-color: #667eea;
}

@media (prefers-reduced-motion: reduce) {
    .waiting-spinner {
        animation: none;
        border-top-color: #667eea;
        border-right-color: #667eea;
    }
}

/* ============================================================================
   KATEX MATH RENDERING OVERRIDES
   ============================================================================ */

.katex {
    font-size: 1.1em;
}

.katex-display {
    margin: 1em 0;
    text-align: center;
}

.katex-display > .katex {
    display: inline-block;
    text-align: initial;
}

/* Math error styling */
.math-error {
    color: #cc0000;
    background: #fff0f0;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
}

/* Ensure math in options displays correctly */
.option-text .katex {
    font-size: 1em;
}

/* Math in feedback */
.feedback .katex {
    font-size: 1em;
}

/* ============================================================================
   SYMBOL PALETTE ACCESSIBILITY
   ============================================================================ */

/* Focus visibility for symbol tabs and buttons */
.symbol-tab:focus,
.symbol-btn:focus {
    outline: 2px solid var(--primary, #6366f1);
    outline-offset: 2px;
}

.symbol-tab:focus:not(:focus-visible),
.symbol-btn:focus:not(:focus-visible) {
    outline: none;
}

.symbol-tab:focus-visible,
.symbol-btn:focus-visible {
    outline: 2px solid var(--primary, #6366f1);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .symbol-btn {
        border-width: 2px;
    }
    
    .symbol-tab.active {
        outline: 2px solid currentColor;
    }
    
    .katex {
        font-weight: 500;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .symbol-btn,
    .symbol-tab {
        transition: none;
    }
}

/* ============================================================================
   QA FIXES - CSS ADDITIONS
   Addresses items: #16, #21, #23
   ============================================================================ */

/* ============================================================================
   FIX #21: UNIFIED TOAST NOTIFICATION SYSTEM
   ============================================================================ */

.toast-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text-primary, #1e293b);
    color: white;
    padding: 14px 20px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 400px;
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.toast-notification.toast-visible {
    transform: translateY(0);
    opacity: 1;
}

.toast-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.toast-message {
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    margin-left: 8px;
}

.toast-close:hover {
    color: white;
}

/* Toast type variants */
.toast-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.toast-success .toast-icon {
    background: rgba(255, 255, 255, 0.2);
}

.toast-error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.toast-error .toast-icon {
    background: rgba(255, 255, 255, 0.2);
}

.toast-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.toast-warning .toast-icon {
    background: rgba(255, 255, 255, 0.2);
}

.toast-info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.toast-info .toast-icon {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================================================================
   FIX #16: RATE LIMIT COUNTDOWN IN TUTOR CHAT
   ============================================================================ */

.rate-limit-countdown {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 0 0 12px 12px;
    z-index: 10;
}

.countdown-icon {
    font-size: 1.1rem;
    animation: pulse-slow 2s ease-in-out infinite;
}

@keyframes pulse-slow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Ensure input area can contain the countdown */
.tutor-chat-input-area {
    position: relative;
}

/* Disable input when rate limited */
.tutor-chat-input-area:has(.rate-limit-countdown) textarea {
    opacity: 0.5;
    pointer-events: none;
}

.tutor-chat-input-area:has(.rate-limit-countdown) .send-chat-btn {
    opacity: 0.5;
    pointer-events: none;
}

/* ============================================================================
   FIX #23: DIAGRAM FALLBACK STYLES
   ============================================================================ */

.diagram-fallback,
.mermaid-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    text-align: center;
    min-height: 150px;
}

.fallback-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.7;
}

.fallback-text {
    color: var(--text-secondary, #64748b);
}

.fallback-text strong {
    display: block;
    color: var(--text-primary, #1e293b);
    font-size: 1rem;
    margin-bottom: 4px;
}

.fallback-text p {
    margin: 0;
    font-size: 0.875rem;
}

/* Function plot error state */
.function-plot-error {
    background: #fef2f2;
    border-color: #fecaca;
}

.function-plot-error .fallback-icon {
    color: #ef4444;
}

/* Mermaid error state */
.mermaid-error {
    background: #fffbeb;
    border-color: #fde68a;
}

.mermaid-error .fallback-icon {
    color: #f59e0b;
}

/* ============================================================================
   FIX #10: ACCESSIBILITY PANEL IMPROVEMENTS
   ============================================================================ */

/* Prevent interaction during transition */
#accessibility-panel.open {
    pointer-events: auto;
}

#accessibility-panel:not(.open) {
    pointer-events: none;
}

/* Backdrop improvements */
#a11y-backdrop {
    transition: opacity 0.3s ease;
}

#a11y-backdrop:not(.open) {
    pointer-events: none;
}

/* ============================================================================
   RESPONSIVE: Toast on mobile
   ============================================================================ */

@media (max-width: 480px) {
    .toast-notification {
        left: 16px;
        right: 16px;
        bottom: 16px;
        max-width: none;
    }
    
    .rate-limit-countdown {
        font-size: 0.85rem;
        padding: 8px 12px;
    }
}

/* ============================================================================
   MULTI-CLASS ASSIGNMENT STYLES (for teacher dashboard)
   These can be moved to teacher.css
   ============================================================================ */

.class-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
    padding: 12px;
    background: var(--surface-secondary, #f8fafc);
    border-radius: 8px;
    border: 1px solid var(--border-color, #e2e8f0);
}

.class-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.class-checkbox:hover {
    background: var(--surface-hover, #f1f5f9);
}

.class-checkbox:has(input:checked) {
    background: var(--primary-light, #eff6ff);
    border-color: var(--primary, #2563eb);
}

.class-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary, #2563eb);
}

.class-checkbox span {
    flex: 1;
    font-size: 0.95rem;
    color: var(--text-primary, #1e293b);
}

/* Class tags on lesson cards */
.lesson-classes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.class-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--primary-light, #eff6ff);
    color: var(--primary-dark, #1e40af);
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 500;
}

.class-tag.unassigned {
    background: var(--surface-secondary, #f1f5f9);
    color: var(--text-muted, #64748b);
}

.class-tag:before {
    content: '📚';
    font-size: 0.7rem;
}

.class-tag.unassigned:before {
    content: '📁';
}

/* Empty state in checkbox group */
.class-checkbox-group .empty-hint {
    text-align: center;
    padding: 20px;
    color: var(--text-muted, #94a3b8);
    font-size: 0.9rem;
}

/* Inline spinner for buttons */
.spinner-inline {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

/* ============================================================================
   SMART DIAGRAM SYSTEM - Semantically-driven visuals
   ============================================================================ */

.smart-diagram {
    padding: 24px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    border: 1px solid var(--border, #e2e8f0);
}

.smart-diagram-title {
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-primary, #1e293b);
}

.smart-diagram-formula {
    font-family: 'Times New Roman', serif;
    font-size: 1.1rem;
    text-align: center;
    margin-top: 16px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border, #e2e8f0);
}

/* Height Reference Diagram (for PE, projectile motion, etc.) */
.height-diagram .height-visual {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 20px;
    min-height: 200px;
    padding: 20px;
    position: relative;
}

.height-diagram .height-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 150px;
}

.height-diagram .height-label {
    font-weight: 600;
    color: #3b82f6;
    font-size: 1rem;
    margin-bottom: 8px;
}

.height-diagram .height-line {
    width: 3px;
    flex: 1;
    background: linear-gradient(to bottom, #3b82f6, #3b82f6 45%, transparent 45%, transparent 55%, #3b82f6 55%);
    background-size: 100% 10px;
    position: relative;
}

.height-diagram .height-line::before,
.height-diagram .height-line::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
}

.height-diagram .height-line::before {
    top: 0;
    border-bottom: 10px solid #3b82f6;
}

.height-diagram .height-line::after {
    bottom: 0;
    border-top: 10px solid #3b82f6;
}

.height-diagram .height-object {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 24px;
    background: white;
    border: 2px solid #64748b;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.height-diagram .object-emoji {
    font-size: 2rem;
    margin-bottom: 8px;
}

.height-diagram .object-label {
    font-weight: 500;
    color: var(--text-primary, #1e293b);
}

.height-diagram .ground-line {
    position: absolute;
    bottom: 20px;
    left: 10%;
    right: 10%;
    height: 4px;
    background: repeating-linear-gradient(
        90deg,
        #22c55e,
        #22c55e 10px,
        #16a34a 10px,
        #16a34a 20px
    );
    border-radius: 2px;
}

.height-diagram .ground-label {
    position: absolute;
    right: -60px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    color: #16a34a;
    font-weight: 500;
    white-space: nowrap;
}

/* Energy Transfer Diagram */
.energy-transfer-diagram .energy-states-row {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 16px;
    min-height: 200px;
    padding: 20px 0;
}

.energy-transfer-diagram .energy-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.energy-transfer-diagram .state-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.energy-transfer-diagram .state-bars {
    display: flex;
    gap: 4px;
    align-items: flex-end;
    height: 120px;
    padding: 8px;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border, #e2e8f0);
}

.energy-transfer-diagram .state-bar {
    width: 40px;
    min-height: 10px;
    border-radius: 4px 4px 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: 4px;
    transition: height 0.3s ease;
}

.energy-transfer-diagram .bar-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.energy-transfer-diagram .bar-value {
    font-size: 0.7rem;
    color: white;
    font-weight: 500;
}

.energy-transfer-diagram .state-label {
    margin-top: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
    color: var(--text-muted, #64748b);
}

.energy-transfer-diagram .state-arrow {
    font-size: 2rem;
    color: #94a3b8;
    padding-bottom: 60px;
}

.energy-transfer-diagram .total-energy-note {
    text-align: center;
    margin-top: 16px;
    padding: 8px 16px;
    background: #fef3c7;
    border-radius: 8px;
    font-weight: 500;
    color: #92400e;
    font-size: 0.9rem;
}

/* Object with Arrow Diagram */
.object-arrow-diagram .object-arrow-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 40px 20px;
    min-height: 150px;
}

.object-arrow-diagram .central-object {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 32px;
    background: white;
    border: 3px solid #64748b;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1;
}

.object-arrow-diagram .central-object .object-emoji {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.object-arrow-diagram .central-object .object-label {
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}

.object-arrow-diagram .diagram-arrow {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.object-arrow-diagram .diagram-arrow .arrow-symbol {
    font-size: 2.5rem;
}

.object-arrow-diagram .diagram-arrow .arrow-label {
    font-size: 0.9rem;
}

.object-arrow-diagram .diagram-arrow.left {
    flex-direction: row-reverse;
}

.object-arrow-diagram .diagram-arrow.left .arrow-symbol {
    transform: rotate(180deg);
}

.object-arrow-diagram .diagram-arrow.up {
    flex-direction: column-reverse;
}

.object-arrow-diagram .diagram-arrow.up .arrow-symbol {
    transform: rotate(-90deg);
}

.object-arrow-diagram .diagram-arrow.down {
    flex-direction: column;
}

.object-arrow-diagram .diagram-arrow.down .arrow-symbol {
    transform: rotate(90deg);
}

/* Concept Card */
.concept-card {
    text-align: center;
}

.concept-card .concept-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
}

.concept-card .concept-emoji {
    font-size: 2.5rem;
}

.concept-card .concept-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}

.concept-card .concept-description {
    font-size: 1rem;
    color: var(--text-muted, #64748b);
    line-height: 1.6;
    margin-bottom: 16px;
}

.concept-card .concept-formula {
    font-family: 'Times New Roman', serif;
    font-size: 1.2rem;
    padding: 12px 24px;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border, #e2e8f0);
    display: inline-block;
}

.concept-card .concept-bullets {
    text-align: left;
    list-style: none;
    padding: 0;
    margin: 16px auto;
    max-width: 400px;
}

.concept-card .concept-bullets li {
    padding: 8px 0 8px 24px;
    position: relative;
    color: var(--text-muted, #64748b);
}

.concept-card .concept-bullets li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #22c55e;
    font-weight: bold;
}

/* Side by Side Comparison */
.side-by-side-diagram .side-by-side-content {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 16px;
    padding: 20px;
}

.side-by-side-diagram .side-panel {
    flex: 1;
    max-width: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    border-radius: 12px;
    border: 2px solid;
    text-align: center;
}

.side-by-side-diagram .panel-emoji {
    font-size: 2rem;
    margin-bottom: 12px;
}

.side-by-side-diagram .panel-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.side-by-side-diagram .panel-description {
    font-size: 0.85rem;
    color: var(--text-muted, #64748b);
    line-height: 1.4;
}

.side-by-side-diagram .connector {
    display: flex;
    align-items: center;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-muted, #64748b);
}

/* Diagram description fallback */
.diagram-description {
    padding: 24px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px dashed var(--border, #e2e8f0);
}

.diagram-description .description-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.diagram-description .description-icon {
    font-size: 1.5rem;
}

.diagram-description .description-content p {
    margin: 0;
    color: var(--text-muted, #64748b);
    font-style: italic;
    line-height: 1.5;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .side-by-side-diagram .side-by-side-content {
        flex-direction: column;
    }
    
    .side-by-side-diagram .side-panel {
        max-width: 100%;
    }
    
    .side-by-side-diagram .connector {
        transform: rotate(90deg);
        padding: 8px 0;
    }
    
    .energy-transfer-diagram .energy-states-row {
        flex-wrap: wrap;
    }
    
    .height-diagram .height-visual {
        flex-direction: column;
        align-items: center;
    }
}
