/* Outfit font — bundled locally (no Google Fonts dependency).
   Works offline, no third-party tracking, no CDN failure modes. */
@font-face {
    font-family: 'Outfit';
    src: url('./lib/outfit-400.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Outfit';
    src: url('./lib/outfit-600.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Outfit';
    src: url('./lib/outfit-800.woff2') format('woff2');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --bg-dark: #0f172a;
    --panel-bg: rgba(15, 23, 42, 0.75);
    --text-main: #f8fafc;
    --text-muted: #cbd5e1;
    --success: #10b981;
    --border: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body,
html {
    width: 100%;
    height: 100%;
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-x: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* Prevent white flash on page navigation (Capacitor iOS) */
body {
    animation: pageFadeIn 0.18s ease-out both;
}

@keyframes pageFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Loader */
.loader-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.app-container {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
}

.left-column {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    position: relative;
}

.camera-section {
    position: relative;
    flex-grow: 1;
    min-height: 50vh;
}

canvas#canvasOutput {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

.ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.missing-panel {
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 15px;
    padding-bottom: calc(15px + env(safe-area-inset-bottom));
    padding-left: calc(15px + env(safe-area-inset-left));
    padding-right: calc(15px + env(safe-area-inset-right));
}

.right-column {
    position: relative;
}

header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 20px;
    padding-top: calc(20px + env(safe-area-inset-top));
    padding-left: calc(20px + env(safe-area-inset-left));
    padding-right: calc(20px + env(safe-area-inset-right));
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 12px;
}

.header-start {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.header-end {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

/* keep old .header-left in case other pages use it */
.header-left {
    display: flex;
    align-items: center;
    gap: 30px;
}

.class-selector-container {
    display: flex;
    align-items: center;
    gap: 15px;
    pointer-events: auto;
}

.class-select {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 16px;
    font-family: inherit;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

/* Settings (gear) icon button — replaces the old "Manage Classes" link */
.settings-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    text-decoration: none;
    transition: background .2s, color .2s, transform .12s;
    cursor: pointer;
    pointer-events: auto;
}

.settings-icon-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
}

.settings-icon-btn:active {
    transform: scale(0.94);
}

.settings-icon-btn svg {
    width: 20px;
    height: 20px;
}

h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: -webkit-linear-gradient(45deg, #4f46e5, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.status-indicator {
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
}

/* Camera Guide — viewfinder always visible (also on the black idle screen)
   so the teacher knows where cards will be picked up. */
.camera-guide {
    position: absolute;
    top: 6%;
    left: 22%;
    right: 22%;
    height: 46%;
    pointer-events: none;
    z-index: 12;
}

.camera-guide .corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 4px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.5);
}

.camera-guide .corner.tl {
    top: 0;
    left: 0;
    border-right: none;
    border-bottom: none;
    border-radius: 10px 0 0 0;
}

.camera-guide .corner.tr {
    top: 0;
    right: 0;
    border-left: none;
    border-bottom: none;
    border-radius: 0 10px 0 0;
}

.camera-guide .corner.bl {
    bottom: 0;
    left: 0;
    border-right: none;
    border-top: none;
    border-radius: 0 0 0 10px;
}

.camera-guide .corner.br {
    bottom: 0;
    right: 0;
    border-left: none;
    border-top: none;
    border-radius: 0 0 10px 0;
}

/* Scan Overlay Animation */
.scan-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

.scan-overlay.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.scan-content {
    background: rgba(16, 185, 129, 0.9);
    border: 2px solid #34d399;
    border-radius: 24px;
    padding: 20px 40px;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 0 40px rgba(16, 185, 129, 0.4);
    backdrop-filter: blur(8px);
}

.scan-id {
    font-size: 1.2rem;
    font-weight: 600;
    color: #ecfdf5;
    margin-bottom: 5px;
}

.scan-answer {
    font-size: 4rem;
    font-weight: 800;
    color: white;
    line-height: 1;
}

/* Floating Scan Toggle Button (sits on the camera) */
.scan-toggle {
    position: absolute;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    width: 110px;
    height: 110px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.45);
    background: rgba(16, 185, 129, 0.55);
    color: white;
    font-family: inherit;
    font-weight: 800;
    font-size: 0.9rem;
    cursor: pointer;
    pointer-events: auto;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow:
        0 8px 28px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.15) inset,
        0 0 40px rgba(16, 185, 129, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: transform 0.15s ease, background 0.25s ease, box-shadow 0.25s ease;
    z-index: 50;
    user-select: none;
    -webkit-user-select: none;
}

.scan-toggle:active {
    transform: translateX(-50%) scale(0.94);
}

.scan-toggle.scanning {
    background: rgba(239, 68, 68, 0.55);
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(255, 255, 255, 0.15) inset,
        0 0 60px rgba(239, 68, 68, 0.4);
    animation: scanPulse 1.6s ease-in-out infinite;
}

@keyframes scanPulse {

    0%,
    100% {
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.15) inset, 0 0 50px rgba(239, 68, 68, 0.35);
    }

    50% {
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.15) inset, 0 0 90px rgba(239, 68, 68, 0.6);
    }
}

.scan-toggle-icon {
    font-size: 1.8rem;
    line-height: 1;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.scan-toggle-text {
    font-size: 0.8rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.3px;
}

/* Next-Question button (lives in the Live Results panel header) */
.next-q-btn {
    background: var(--primary);
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s, transform 0.12s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
    line-height: 1;
}

.next-q-btn:hover {
    background: var(--primary-hover);
}

.next-q-btn:active {
    transform: scale(0.95);
}

.next-q-icon {
    font-weight: 900;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}

.next-q-num {
    background: rgba(255, 255, 255, 0.22);
    color: white;
    border-radius: 999px;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 800;
    line-height: 1;
}

/* Total-score badge inside each result row */
.student-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.student-total {
    background: rgba(79, 70, 229, 0.18);
    color: #c7d2fe;
    border: 1px solid rgba(79, 70, 229, 0.32);
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 0.85rem;
    font-weight: 800;
    min-width: 32px;
    text-align: center;
    line-height: 1.1;
}

.student-total.zero {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    border-color: rgba(255, 255, 255, 0.08);
}

/* Questions Panel */
.questions-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 18px 20px;
    padding-left: calc(20px + env(safe-area-inset-left));
    padding-right: calc(20px + env(safe-area-inset-right));
    border-radius: 24px 24px 0 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Collapsible Questions panel */
.questions-panel-header {
    cursor: pointer;
    user-select: none;
    margin-bottom: 0 !important;
}
.questions-header-left {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.questions-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted, #94a3b8);
    transition: transform 0.25s ease;
}
.questions-panel.collapsed .questions-chevron {
    transform: rotate(-90deg);
}
[dir="rtl"] .questions-panel.collapsed .questions-chevron {
    transform: rotate(-90deg);
}
.questions-panel-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
    max-height: 1200px;
    transition: max-height 0.3s ease, opacity 0.25s ease, margin 0.25s ease;
}
.questions-panel.collapsed .questions-panel-body {
    max-height: 0;
    opacity: 0;
    margin: 0;
    pointer-events: none;
}

.manage-q-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(79, 70, 229, 0.18);
    color: #c7d2fe;
    border: 1px solid rgba(79, 70, 229, 0.32);
    border-radius: 10px;
    padding: 6px 12px;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.82rem;
    text-decoration: none;
    cursor: pointer;
    transition: background .2s, transform .12s;
}

.manage-q-btn:hover {
    background: rgba(79, 70, 229, 0.28);
}

.manage-q-btn:active {
    transform: scale(0.96);
}

.manage-q-btn svg {
    flex-shrink: 0;
}

.question-picker {
    display: flex;
    width: 100%;
}

.question-picker .class-select {
    width: 100%;
    cursor: pointer;
}

.question-display {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.question-display.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 18px 16px;
}

.question-empty {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0;
}

.question-text {
    font-size: 1rem;
    font-weight: 700;
    color: white;
    line-height: 1.5;
    margin: 0;
}

.question-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.question-option {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 0.88rem;
    color: var(--text-main);
    min-width: 0;
}

.question-option .opt-letter {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(79, 70, 229, 0.25);
    color: #c7d2fe;
    font-weight: 800;
    border-radius: 6px;
    font-size: 0.78rem;
}

.question-option .opt-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.question-option.correct {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.35);
}

.question-option.correct .opt-letter {
    background: rgba(16, 185, 129, 0.4);
    color: #d1fae5;
}

@media (max-width: 480px) {
    .question-options {
        grid-template-columns: 1fr;
    }
}

/* Results Panel */
.results-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    padding-left: calc(20px + env(safe-area-inset-left));
    padding-right: calc(20px + env(safe-area-inset-right));
    border-radius: 24px 24px 0 0;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

/* Missing Grid Styles
   Flex-wrap layout: each chip grows to fit its name. Short IDs stay at the
   minimum width so the grid still reads as a grid; long names get a wider
   pill rather than overflowing. */
.missing-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 5px;
    max-height: 200px;
}

.missing-cell {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    border-radius: 8px;
    text-align: center;
    padding: 8px 14px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    min-width: 36px;
    max-width: 100%;
    box-sizing: border-box;
    white-space: nowrap;
    /* keep the name on a single line */
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
}

.missing-cell.found {
    display: none;
}

/* Desktop / iPad Dashboard Layout */
@media (min-width: 768px) {

    /* The whole app fits the viewport — no page scrolling. */
    html,
    body {
        height: 100vh;
        overflow: hidden;
    }

    .app-container {
        display: grid;
        grid-template-columns: 2fr 1fr;
        grid-template-rows: auto 1fr;
        gap: 20px;
        padding: 20px;
        padding-top: calc(20px + env(safe-area-inset-top));
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
        padding-left: calc(20px + env(safe-area-inset-left));
        padding-right: calc(20px + env(safe-area-inset-right));
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        box-sizing: border-box;
        overflow: hidden;
    }

    /* Header now spans the full width above both columns. */
    header {
        grid-column: 1 / -1;
        grid-row: 1;
        position: relative;
        /* not sticky on iPad — already pinned by grid */
        top: auto;
        background: rgba(15, 23, 42, 0.55);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border: 1px solid var(--border);
        border-bottom: 1px solid var(--border);
        border-radius: 18px;
        padding: 14px 22px;
    }

    /* Left column: camera (flex) + missing panel (auto with cap). */
    .left-column {
        grid-column: 1;
        grid-row: 2;
        display: grid;
        grid-template-rows: 1fr auto;
        gap: 16px;
        min-height: 0;
        height: 100%;
        overflow: hidden;
    }

    .camera-section {
        border-radius: 24px;
        overflow: hidden;
        min-height: 0;
        height: 100%;
    }

    .missing-panel {
        display: flex;
        flex-direction: column;
        background: var(--panel-bg);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border: 1px solid var(--border);
        border-radius: 24px;
        padding: 18px 20px;
        overflow: hidden;
        max-height: 240px;
    }

    .missing-grid {
        max-height: 160px;
    }

    .right-column {
        grid-column: 2;
        grid-row: 2;
        display: flex;
        flex-direction: column;
        gap: 16px;
        height: 100%;
        min-height: 0;
        overflow: hidden;
    }

    .questions-panel {
        flex: 0 0 auto;
        border-radius: 24px;
        border: 1px solid var(--border);
        max-height: 45%;
        overflow-y: auto;
    }

    .results-panel {
        flex: 1 1 auto;
        max-height: none;
        min-height: 0;
        border-radius: 24px;
        border: 1px solid var(--border);
        overflow: hidden;
    }

    .results-list {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
    }
}

/* Larger iPad / desktop — give the header a bit more breathing room */
@media (min-width: 1024px) {
    .app-container {
        gap: 24px;
        padding: 24px;
    }

    header {
        padding: 16px 24px;
    }
}

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

.panel-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.clear-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.clear-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.results-list {
    list-style: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 5px;
    min-height: 150px;
}

.results-list::-webkit-scrollbar {
    width: 6px;
}

.results-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.results-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 12px 16px;
    border-radius: 12px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-item .student-id {
    font-weight: 800;
    color: var(--text-main);
}

.result-item .student-answer {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--primary);
}

/* Teacher Controls */
.teacher-controls {
    background: rgba(255, 255, 255, 0.03);
    padding: 12px;
    border-radius: 16px;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.answer-buttons {
    display: flex;
    gap: 5px;
    width: 100%;
}

.ans-btn {
    flex: 1;
    min-width: 40px;
    height: 48px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-weight: 800;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ans-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(79, 70, 229, 0.4);
}

.ans-btn.reset {
    flex: 0 0 44px;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.ans-btn.reset.active {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

.result-item.correct {
    border-left: 4px solid #10b981;
}

.result-item.correct .student-answer {
    color: #10b981;
}

.result-item.incorrect {
    border-left: 4px solid #ef4444;
}

.result-item.incorrect .student-answer {
    color: #ef4444;
}

.answer-hidden {
    filter: blur(8px);
    opacity: 0.3;
}

.lang-selector-inline {
    pointer-events: auto;
}

.lang-selector-inline .class-select {
    font-size: 0.9rem;
    padding: 6px 12px;
}


/* Language Overlay */
.lang-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-dark);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6vh 20px calc(6vh + env(safe-area-inset-bottom));
    text-align: center;
    overflow-y: auto;
    /* scroll on small screens with many languages */
    -webkit-overflow-scrolling: touch;
}

.lang-overlay h2 {
    font-size: 1.8rem;
    margin-bottom: 24px;
    background: -webkit-linear-gradient(45deg, #4f46e5, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.lang-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    max-width: 460px;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 14px 12px;
    border-radius: 14px;
    color: white;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 3px;
    line-height: 1.2;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    border-color: var(--primary);
}

.lang-btn span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* RTL Support */
/* CSS Grid reverses column order automatically in RTL — no overrides needed */

[dir="rtl"] .panel-header {
    flex-direction: row-reverse;
}

/* Questions panel header keeps normal RTL flow (right→left)
   so chevron stays far-right, title beside it, manage btn far-left */
[dir="rtl"] .questions-panel-header {
    flex-direction: row;
}

[dir="rtl"] .questions-header-left {
    flex-direction: row;
}

[dir="rtl"] .result-item {
    flex-direction: row-reverse;
}

[dir="rtl"] .nav-back {
    direction: rtl;
}

[dir="rtl"] .class-selector-container {
    flex-direction: row-reverse;
}

[dir="rtl"] .teacher-controls {
    align-items: flex-end;
}

[dir="rtl"] .teacher-controls span {
    text-align: right;
}

[dir="rtl"] .answer-buttons {
    flex-direction: row-reverse;
}

[dir="rtl"] .class-item {
    flex-direction: row-reverse;
}

[dir="rtl"] .btn-secondary {
    direction: rtl;
}


/* Zoom Controls */
.zoom-controls-wrapper {
    position: absolute;
    bottom: 24px;
    left: 24px;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 12px;
    z-index: 100;
    pointer-events: auto;
}

.zoom-toggle-btn {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.zoom-toggle-btn:active {
    transform: scale(0.92);
}

.zoom-toggle-btn.active {
    background: var(--primary);
    border-color: rgba(255, 255, 255, 0.3);
}

.zoom-slider-container {
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 16px 8px;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: opacity 0.2s, transform 0.2s;
    transform-origin: bottom;
}

.zoom-slider-container.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scaleY(0.8) translateY(10px);
}

.zoom-slider-vertical {
    -webkit-appearance: none;
    width: 4px;
    height: 140px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    outline: none;
    writing-mode: bt-lr;
    /* IE/Edge */
    appearance: slider-vertical;
    /* Webkit */
}

.zoom-slider-vertical::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.5);
    border: 2px solid var(--primary);
}

.zoom-slider-vertical::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.5);
    border: 2px solid var(--primary);
}

/* Hardware-accelerated CSS Blur for Privacy */
.camera-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}

.blurred-video {
    filter: blur(10px);
    /* Scale slightly to hide blurred transparent edges */
    transform: scale(1.1);
}

/* ─────────────── Export feature ─────────────── */

.export-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.export-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.5);
}

.export-btn:active {
    transform: translateY(0);
}

.export-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.export-modal:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.export-modal-content {
    background: #1e293b;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.92);
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.export-modal:not(.hidden) .export-modal-content {
    transform: scale(1);
}

.export-modal-content h3 {
    font-size: 1.4rem;
    margin-bottom: 18px;
    text-align: center;
    background: -webkit-linear-gradient(45deg, #4f46e5, #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.export-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.export-input {
    width: 100%;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: white;
    font-size: 1rem;
    font-family: inherit;
    margin-bottom: 20px;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.export-input:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
}

.export-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 14px;
}

.export-option-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 18px 12px;
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, filter 0.2s;
}

.export-option-btn.pdf {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.export-option-btn.excel {
    background: linear-gradient(135deg, #059669, #047857);
}

.export-option-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.export-option-btn:disabled {
    opacity: 0.6;
    cursor: wait;
    transform: none;
}

.export-cancel-btn {
    width: 100%;
    padding: 11px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.export-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.export-modal.hidden {
    display: flex;
}