/* =============================================================
   INTERACTIVE VIRTUAL LAB — Area Between Curves
   Style Sheet — Academic Professional Theme
   ============================================================= */

/* ----- CSS Custom Properties ----- */
:root {
    --bg-primary: #f5f6fa;
    --bg-secondary: #eef0f5;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f2f8;
    --border-subtle: #e2e5ed;
    --border-default: #cdd2dd;
    --border-hover: #a8aec0;

    --accent-blue: #2563eb;
    --accent-blue-hover: #1d4ed8;
    --accent-teal: #0d8a7a;
    --accent-teal-hover: #0b7467;
    --accent-red: #dc2626;

    --text-primary: #1e293b;
    --text-secondary: #5a6577;
    --text-muted: #94a0b4;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.04);
    --shadow-elevated: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-btn: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-btn-hover: 0 3px 8px rgba(0, 0, 0, 0.08);

    --transition: 0.18s ease;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 72px;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

::selection {
    background: var(--accent-blue);
    color: #fff;
}

/* ----- Scrollbar ----- */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* ----- Typography ----- */
h1, h2, h3, h4 {
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover {
    color: var(--accent-teal);
}

/* ----- Navigation ----- */
#navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 0 2rem;
    background: rgba(245, 246, 250, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-subtle);
    transition: var(--transition);
}

.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.logo {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.nav-links {
    display: flex;
    gap: 1.75rem;
}

.nav-links a {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    position: relative;
    padding-bottom: 2px;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-blue);
    transition: width var(--transition);
    border-radius: 1px;
}
.nav-links a:hover::after {
    width: 100%;
}
.nav-links a:hover {
    color: var(--text-primary);
}

/* ----- Hero Section ----- */
#hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 6rem 2rem 4rem;
    background:
        radial-gradient(ellipse 80% 55% at 50% 30%, rgba(37, 99, 235, 0.03), transparent);
}

/* Floating math symbols */
.hero-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.float-symbol {
    position: absolute;
    font-size: 1.8rem;
    font-weight: 300;
    color: var(--text-muted);
    opacity: 0.03;
    animation: floatSymbol 24s ease-in-out infinite;
    user-select: none;
}

@keyframes floatSymbol {
    0%, 100% { transform: translateY(0); opacity: 0.03; }
    50% { transform: translateY(-16px); opacity: 0.06; }
}

.hero-content {
    text-align: center;
    max-width: 700px;
    position: relative;
    z-index: 1;
    animation: fadeUp 0.8s ease-out;
}

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

.hero-badge {
    display: inline-block;
    padding: 0.35rem 1.1rem;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-blue);
    border: 1px solid rgba(37, 99, 235, 0.15);
    background: rgba(37, 99, 235, 0.04);
    margin-bottom: 1.25rem;
}

.hero-content h1 {
    font-size: clamp(2.2rem, 5.5vw, 3.6rem);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 0.3rem;
}

.hero-content h2 {
    font-size: clamp(1rem, 2vw, 1.3rem);
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}

.hero-content p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    max-width: 520px;
    margin: 0 auto 2rem;
    line-height: 1.7;
}

.btn-hero {
    display: inline-block;
    padding: 0.75rem 2.25rem;
    border: none;
    border-radius: 40px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent-blue);
    cursor: pointer;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    box-shadow: var(--shadow-btn);
}
.btn-hero:hover {
    background: var(--accent-blue-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-btn-hover);
}
.btn-hero:active {
    transform: translateY(0);
}

.scroll-indicator {
    position: absolute;
    bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-muted);
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    animation: fadeUp 0.8s ease-out 0.5s both;
}

.scroll-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: scrollBounce 2.5s ease-in-out infinite;
}

@keyframes scrollBounce {
    0%, 100% { transform: translateY(0); opacity: 0.4; }
    50% { transform: translateY(5px); opacity: 0.15; }
}

/* ----- Section Shared ----- */
.section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 5rem 2rem;
}

.section-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 3.5rem;
    text-align: center;
}

.section-number {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.section-header h2 {
    font-size: clamp(1.4rem, 3vw, 2rem);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.section-line {
    width: 40px;
    height: 2px;
    border-radius: 1px;
    background: var(--accent-blue);
    opacity: 0.5;
}

/* ----- Card Utility ----- */
.glass {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.glass:hover {
    border-color: var(--border-default);
    box-shadow: var(--shadow-elevated);
}

/* ----- Theory Section ----- */
#theory {
    position: relative;
}

#theory::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 50%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-blue), transparent);
    opacity: 0.2;
}

.theory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}

.theory-card {
    padding: 1.75rem 1.5rem;
    text-align: center;
}

.card-icon {
    width: 44px;
    height: 44px;
    margin: 0 auto 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    border-radius: var(--radius-md);
    background: rgba(59, 130, 246, 0.06);
    border: 1px solid var(--border-subtle);
    color: var(--accent-blue);
}

.theory-card h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.theory-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.theory-card .MathJax {
    font-size: 1rem !important;
}

.card-formula {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.card-formula::-webkit-scrollbar {
    display: none;
}

.card-formula .MathJax {
    font-size: 0.9rem !important;
}

.formula-highlight {
    padding: 1.75rem 1.5rem;
    text-align: center;
    border: 1px solid var(--border-default);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

.formula-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.formula-display {
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    margin-bottom: 0.75rem;
    overflow-x: auto;
    color: var(--text-primary);
}

.formula-highlight p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ----- Interactive Lab ----- */
#lab {
    position: relative;
}

.lab-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1.5rem;
    align-items: start;
}

.lab-controls {
    padding: 1.5rem 1.25rem;
    position: sticky;
    top: 80px;
}

.lab-controls h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border-subtle);
}

.control-group {
    margin-bottom: 0.9rem;
}

.control-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.control-label-inline {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.label-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.label-dot.blue { background: #3b82f6; }
.label-dot.teal { background: #14b8a6; }

.input-wrapper {
    position: relative;
}

.input-wrapper input[type="text"],
.input-wrapper input[type="number"] {
    width: 100%;
    padding: 0.5rem 0.7rem;
    background: #fff;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrapper input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.input-wrapper input[type="number"] {
    font-family: var(--font-sans);
}

.input-hint {
    display: block;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.control-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 1.1rem 0;
}

.control-btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0;
}

.btn-primary {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition);
    background: var(--accent-blue);
    color: #fff;
    box-shadow: var(--shadow-btn);
}
.btn-primary:hover {
    background: var(--accent-blue-hover);
    box-shadow: var(--shadow-btn-hover);
}

.btn-secondary {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
    background: var(--bg-card);
    color: var(--text-secondary);
}
.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-default);
    color: var(--text-primary);
}

.btn-solution {
    width: 100%;
    margin-top: 1rem;
    padding: 0.6rem;
    background: var(--accent-teal);
    font-size: 0.85rem;
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition);
    box-shadow: var(--shadow-btn);
}
.btn-solution:hover {
    background: var(--accent-teal-hover);
    box-shadow: var(--shadow-btn-hover);
}

/* ----- Graph Section ----- */
.lab-graph {
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    background: #ffffff;
    box-shadow: var(--shadow-card);
}

#desmos-calculator {
    width: 100%;
    height: 600px;
}

/* ----- Solution Section ----- */
#solution {
    position: relative;
}

#solution-placeholder {
    padding: 3.5rem 2rem;
    text-align: center;
    max-width: 520px;
    margin: 0 auto;
}

.placeholder-icon {
    font-size: 2.5rem;
    margin-bottom: 0.85rem;
    opacity: 0.6;
}

#solution-placeholder h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

#solution-placeholder p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* ----- Solution Steps (generated by JS) ----- */
.solution-wrapper {
    max-width: 760px;
    margin: 0 auto;
}

.solution-step {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.4rem 1.6rem;
    margin-bottom: 1rem;
    animation: fadeUp 0.4s ease-out both;
    transition: border-color var(--transition), background var(--transition);
}

.solution-step:hover {
    border-color: var(--border-default);
}

.solution-step-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent-blue);
    font-size: 0.78rem;
    font-weight: 600;
    flex-shrink: 0;
}

.step-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.solution-step p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-left: 2.6rem;
}

.solution-step .MathJax {
    font-size: 1rem !important;
}

.solution-answer {
    background: rgba(37, 99, 235, 0.02);
    border: 1px solid rgba(37, 99, 235, 0.12);
}

.solution-answer .step-number {
    background: rgba(13, 138, 122, 0.08);
    color: var(--accent-teal);
}

.solution-answer .step-title {
    color: var(--accent-teal);
}

.solution-answer p {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
}

/* ----- Footer ----- */
footer {
    margin-top: 3rem;
    padding: 2rem;
    border-top: 1px solid var(--border-subtle);
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

footer p {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.footer-small {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ----- Responsive ----- */
@media (max-width: 968px) {
    .lab-layout {
        grid-template-columns: 1fr;
    }
    .lab-controls {
        position: static;
    }
    #desmos-calculator {
        height: 450px;
    }
    .section {
        padding: 4rem 1.5rem;
    }
}

@media (max-width: 640px) {
    #navbar {
        padding: 0 1rem;
    }
    .nav-links {
        gap: 1rem;
    }
    .nav-links a {
        font-size: 0.8rem;
    }
    .section {
        padding: 3rem 1rem;
    }
    #hero {
        padding: 5rem 1rem 3rem;
    }
    .hero-content p {
        font-size: 0.9rem;
    }
    .theory-grid {
        grid-template-columns: 1fr;
    }
    .formula-display {
        font-size: 0.92rem;
    }
    .control-btn-group {
        grid-template-columns: 1fr;
    }
    #desmos-calculator {
        height: 320px;
    }
    .solution-step {
        padding: 1.1rem;
    }
    .solution-step p {
        margin-left: 0;
        margin-top: 0.4rem;
    }
    .lab-controls {
        padding: 1.25rem 1rem;
    }
}

/* ----- Focus-visible for accessibility ----- */
:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

/* =============================================================
   QUIZ SECTION
   ============================================================= */

#quiz-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 1.5rem;
    align-items: start;
}

#quiz-palette {
    padding: 1.25rem;
    position: sticky;
    top: 80px;
}

#quiz-palette h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border-subtle);
}

#palette-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.palette-btn {
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

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

.palette-btn.active {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(37,99,235,0.2);
}

.palette-btn.state-visited {
    background: #7c3aed;
    color: #fff;
    border-color: #7c3aed;
}

.palette-btn.state-answered {
    background: #22c55e;
    color: #fff;
    border-color: #22c55e;
}

.palette-btn.state-marked {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
}

.palette-legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid var(--border-default);
}

.legend-dot.dot-white { background: #fff; }
.legend-dot.dot-violet { background: #7c3aed; border-color: #7c3aed; }
.legend-dot.dot-green { background: #22c55e; border-color: #22c55e; }
.legend-dot.dot-red { background: #ef4444; border-color: #ef4444; }

#quiz-panel {
    padding: 1.5rem 1.75rem;
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

#q-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border-subtle);
}

#q-number {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-blue);
    background: rgba(37,99,235,0.08);
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
}

.q-status-marked {
    font-size: 0.7rem;
    font-weight: 600;
    color: #ef4444;
    background: rgba(239,68,68,0.1);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#q-text {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.7;
    margin-bottom: 1.5rem;
}

#q-text .MathJax {
    font-size: 1rem !important;
}

#q-options {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

.q-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    color: var(--text-primary);
}

.q-option:hover {
    border-color: var(--accent-blue);
    background: rgba(37,99,235,0.03);
}

.q-option.selected {
    border-color: var(--accent-blue);
    background: rgba(37,99,235,0.06);
    box-shadow: 0 0 0 1px rgba(37,99,235,0.15);
}

.q-option .option-radio {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--border-default);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.q-option.selected .option-radio {
    border-color: var(--accent-blue);
    background: var(--accent-blue);
}

.q-option .option-radio::after {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    opacity: 0;
    transition: var(--transition);
}

.q-option.selected .option-radio::after {
    opacity: 1;
}

.q-option .option-label {
    font-weight: 500;
    color: var(--text-muted);
    flex-shrink: 0;
}

.q-option.selected .option-label {
    color: var(--accent-blue);
}

#quiz-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
}

#quiz-nav .btn-primary,
#quiz-nav .btn-secondary {
    padding: 0.45rem 1.1rem;
    font-size: 0.8rem;
}

#q-timer {
    margin-left: auto;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-primary);
    background: rgba(37,99,235,0.06);
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
    letter-spacing: 0.03em;
}

#q-timer.warning {
    color: #ef4444;
    background: rgba(239,68,68,0.1);
    animation: pulse 1s ease-in-out infinite;
}

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

#quiz-nav .btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#quiz-nav .btn-primary.btn-submit-final {
    background: var(--accent-teal);
}

#quiz-nav .btn-primary.btn-submit-final:hover {
    background: var(--accent-teal-hover);
}

#btn-next {
    margin-left: auto;
}

/* ----- Quiz Analysis ----- */
#quiz-analysis {
    max-width: 760px;
    margin: 2rem auto 0;
}

.analysis-header {
    text-align: center;
    padding: 2rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    margin-bottom: 1.5rem;
}

.analysis-header .score {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-blue);
}

.analysis-header .score-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.analysis-header .score-detail {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.analysis-question {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    background: var(--bg-card);
}

.analysis-question.correct {
    border-left: 3px solid #22c55e;
}

.analysis-question.incorrect {
    border-left: 3px solid #ef4444;
}

.analysis-q-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.analysis-q-num {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.analysis-q-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.analysis-q-badge.correct {
    background: rgba(34,197,94,0.1);
    color: #22c55e;
}

.analysis-q-badge.incorrect {
    background: rgba(239,68,68,0.1);
    color: #ef4444;
}

.analysis-q-text {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.analysis-q-text .MathJax {
    font-size: 0.95rem !important;
}

.analysis-q-answer {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.analysis-q-answer strong {
    color: var(--text-primary);
}

.analysis-q-explanation {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-subtle);
    margin-top: 0.5rem;
}

.analysis-q-explanation .MathJax {
    font-size: 0.95rem !important;
}

.analysis-score-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.analysis-score-bar span {
    padding: 0.15rem 0.6rem;
    border-radius: 10px;
}

.analysis-score-bar .sc-correct { background: rgba(34,197,94,0.1); color: #22c55e; }
.analysis-score-bar .sc-incorrect { background: rgba(239,68,68,0.1); color: #ef4444; }
.analysis-score-bar .sc-unattempted { background: rgba(148,160,180,0.15); color: #6b7a93; }

.analysis-percentage {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.analysis-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    text-align: center;
    padding: 1rem 0.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.3;
}

.stat-card small {
    display: block;
    font-size: 0.68rem;
    font-weight: 500;
    margin-top: 0.2rem;
    opacity: 0.75;
}

.stat-card.stat-correct { border-left: 3px solid #22c55e; color: #22c55e; }
.stat-card.stat-incorrect { border-left: 3px solid #ef4444; color: #ef4444; }
.stat-card.stat-unattempted { border-left: 3px solid #94a0b4; color: #6b7a93; }
.stat-card.stat-marked { border-left: 3px solid #7c3aed; color: #7c3aed; }

.analysis-q-options {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 0.5rem 0;
}

.analysis-q-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.7rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    border: 1px solid transparent;
    transition: none;
}

.analysis-q-option.opt-correct {
    background: rgba(34,197,94,0.08);
    border-color: rgba(34,197,94,0.25);
}

.analysis-q-option.opt-wrong {
    background: rgba(239,68,68,0.08);
    border-color: rgba(239,68,68,0.25);
}

.analysis-q-option .option-marker {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 600;
}

.analysis-q-option .opt-icon {
    font-size: 0.75rem;
}

.analysis-q-option.opt-correct .opt-icon { color: #22c55e; }
.analysis-q-option.opt-wrong .opt-icon { color: #ef4444; }
.analysis-q-option .opt-letter { color: var(--text-muted); }

.analysis-q-option .option-text {
    color: var(--text-primary);
}

.analysis-q-option .option-text .MathJax {
    font-size: 0.9rem !important;
}

.analysis-q-badge.unattempted {
    background: rgba(148,160,180,0.15);
    color: #6b7a93;
}

.analysis-question.unattempted {
    border-left: 3px solid #94a0b4;
}

/* ----- Quiz Intro Screen ----- */
#quiz-intro {
    max-width: 540px;
    margin: 0 auto;
    padding: 2.5rem 2.25rem;
    text-align: center;
}

#quiz-intro .intro-icon {
    font-size: 2rem;
    margin-bottom: 0.65rem;
    color: var(--accent-blue);
}

#quiz-intro h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

#quiz-intro .intro-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 1.25rem;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}

.intro-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
    margin-bottom: 1.25rem;
}

.intro-detail {
    display: flex;
    flex-direction: column;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    gap: 0.2rem;
}

.intro-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.intro-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.intro-instructions {
    text-align: left;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    padding: 1rem 1.15rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.intro-instructions strong {
    color: var(--text-primary);
    font-size: 0.8rem;
    display: block;
    margin-bottom: 0.4rem;
    letter-spacing: 0.03em;
}

.intro-instructions ul {
    margin: 0;
    padding-left: 1.15rem;
    list-style: disc;
}

.intro-instructions li {
    margin-bottom: 0.3rem;
    line-height: 1.6;
}

.intro-instructions li:last-child {
    margin-bottom: 0;
}

.btn-start-quiz {
    padding: 0.65rem 2.5rem;
    font-size: 0.9rem;
}

@media (max-width: 640px) {
    .intro-details {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
    #quiz-intro {
        padding: 2rem 1.25rem;
    }
    .intro-detail {
        padding: 0.55rem 0.65rem;
    }
}

@media (max-width: 968px) {
    #quiz-layout {
        grid-template-columns: 1fr;
    }
    #quiz-palette {
        position: static;
    }
}
