/*
 * Alice's Simple Quiz Maker - fun quizzes for curious minds
 * Copyright (C) 2026 Miss Alice & Saidone
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

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

:root {
    --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --green: #1D9E75;
    --green-dark: #0F6E56;
    --green-light: #E1F5EE;
    --green-text: #085041;
    --blue: #378ADD;
    --blue-dark: #185FA5;
    --blue-light: #E6F1FB;
    --blue-text: #0C447C;
    --red: #E24B4A;
    --red-light: #FCEBEB;
    --red-text: #501313;
    --amber: #BA7517;
    --amber-light: #FAEEDA;
    --amber-text: #633806;
    --gray-bg: #F7F6F2;
    --gray-border: #D3D1C7;
    --gray-muted: #888780;
    --text: #2C2C2A;
    --text-light: #5F5E5A;
    --text-on-accent: #FFFFFF;
    --white: #ffffff;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 4px 24px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
    --surface-soft: #F1F1EF;
    --focus-ring: rgba(29, 158, 117, 0.18);
    --editor-ai-border: var(--green-light);
    --editor-ai-bg: var(--white);
    --editor-manual-border: var(--blue-light);
    --editor-manual-bg: var(--white);
    --red-light-hover: var(--red-light);
    --green-shadow: rgba(29,158,117,0.3);
    --green-shadow-soft: rgba(29,158,117,0.25);
    --green-shadow-hover: rgba(29,158,117,0.4);
    --locked-bg: var(--surface-soft);
    --locked-border: var(--gray-border);
    --locked-text: var(--text-light);
    --locked-opacity: 0.78;
    --alert-border: var(--gray-border);
    --alert-bg: var(--amber-light);
    --progress-bg: rgba(255,255,255,0.5);
    --blue-light-hover: var(--blue-light);
    --danger-bg: var(--red-light);
    --danger-border: var(--red);
    --danger-text: var(--red-text);
    --danger-bg-hover: var(--red-light);
    --share-bg: var(--blue-light);
    --share-text: var(--blue-text);
    --share-bg-hover: var(--blue-light);
    --archive-bg: var(--amber-light);
    --archive-text: var(--amber-text);
    --archive-bg-hover: var(--amber-light);
    --restore-bg: var(--green-light);
    --restore-bg-hover: var(--green-light);
    --restore-text: #0F6E56;
    --publish-bg-hover: #BFE7DA;
    --publish-checkbox-accent: var(--green);
    --publish-checkbox-bg: var(--white);
    --overlay-bg: rgba(0,0,0,0.4);
    --loading-overlay-bg: rgba(255,255,255,0.85);
    --toast-shadow: rgba(0,0,0,0.2);
    --toast-bg-dark: #1D8A6B;
    --toast-text-dark: #F3FFFB;
    --disabled-bg: #ECECEC;
    --disabled-text: #838383;
    --log-console-bg: #121212;
    --log-console-text: #EDEDED;
    --log-console-border: #2A2A2A;
    --icon-btn-overlay-bg: rgba(0, 0, 0, 0.72);
    --icon-btn-overlay-bg-hover: rgba(0, 0, 0, 0.86);
    --student-exit-btn-bg: var(--blue-dark);
    --student-exit-btn-fg: var(--text-on-accent);
    --student-cancel-btn-bg: var(--blue-light);
    --student-cancel-btn-fg: var(--blue-text);
}

body {
    font-family: var(--font-sans, sans-serif);
    background: var(--gray-bg);
    min-height: 100vh;
    color: var(--text);
    transition: background-color 0.2s ease, color 0.2s ease;
}

button,
a,
input,
textarea,
select,
summary {
    transition: outline-color 0.15s ease, box-shadow 0.15s ease;
}

:where(button, a, input, textarea, select, summary):focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
}

:root[data-theme="dark"],
body[data-theme="dark"] {
    --surface-soft: #2E3A3A;
    --white: #263030;
    --gray-bg: #2F3939;
    --gray-border: #465656;
    --gray-muted: #B1BCBC;
    --text: #E2E9E9;
    --text-light: #C8D2D2;
    --text-on-accent: #DEE7E7;
    --green-light: #1D3A33;
    --green-dark: #7AE3C2;
    --green-text: #8CE5C7;
    --blue-light: #1C344C;
    --blue-dark: #9FCFFF;
    --blue-text: #9FCFFF;
    --red-light: #4D2A2A;
    --red-text: #FFB7B7;
    --amber-light: #4A3B24;
    --amber-text: #FFDCA5;
    --editor-ai-bg: var(--white);
    --editor-manual-bg: var(--white);
    --locked-bg: #343C3C;
    --locked-border: #505757;
    --locked-text: var(--gray-muted);
    --locked-opacity: 0.9;
    --alert-bg: var(--amber-light);
    --alert-border: var(--gray-border);
    --share-bg: var(--blue-light);
    --share-text: #D7C4FF;
    --share-bg-hover: var(--share-bg);
    --archive-bg: var(--alert-bg);
    --archive-bg-hover: var(--archive-bg);
    --restore-bg: var(--green-light);
    --restore-bg-hover: var(--restore-bg);
    --restore-text: #8CE5C7;
    --blue-light-hover: var(--blue-light);
    --loading-overlay-bg: rgba(30, 40, 40, 0.78);
    --shadow: 0 8px 24px rgba(0,0,0,0.35);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.45);
    --student-cancel-btn-bg: var(--blue-light);
    --student-cancel-btn-fg: var(--blue-text);
}

:root[data-theme="zenburn"],
body[data-theme="zenburn"] {
    --green: #8FB28F;
    --green-dark: #7F9F7F;
    --green-light: #2E3A2E;
    --green-text: #D0E0B0;
    --blue: #6CA0A3;
    --blue-dark: #8CD0D3;
    --blue-light: #2A3436;
    --blue-text: #BFDCDC;
    --red: #CC9393;
    --red-light: #463F34;
    --red-text: #F0D0D0;
    --amber: #D0BF8F;
    --amber-light: var(--red-light);
    --amber-text: #F2DFAF;
    --gray-bg: #2D2D2D;
    --gray-border: #5F5F5F;
    --gray-muted: #9A9A9A;
    --text: #DCDCCC;
    --text-light: #A9A98D;
    --text-on-accent: #1F1F1F;
    --white: #3A3A3A;
    --surface-soft: var(--gray-bg);
    --editor-ai-bg: var(--white);
    --editor-manual-bg: var(--white);
    --locked-bg: var(--white);
    --locked-border: var(--gray-border);
    --locked-text: var(--text-light);
    --alert-bg: var(--amber-light);
    --alert-border: var(--gray-border);
    --share-bg: var(--blue-light);
    --share-text: #D7C4FF;
    --share-bg-hover: var(--share-bg);
    --archive-bg: var(--alert-bg);
    --archive-bg-hover: var(--archive-bg);
    --restore-bg: var(--green-light);
    --restore-bg-hover: var(--restore-bg);
    --restore-text: #C8E3C8;
    --blue-light-hover: var(--blue-light);
    --loading-overlay-bg: rgba(35, 35, 35, 0.80);
    --log-console-bg: #1C1C1C;
    --log-console-text: #DCDCCC;
    --log-console-border: #404040;
    --shadow: 0 8px 24px rgba(0,0,0,0.35);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.45);
    --student-cancel-btn-bg: var(--blue-light);
    --student-cancel-btn-fg: var(--blue-text);
}

:root[data-theme="true-summer"],
body[data-theme="true-summer"] {
    --green: #4A9FB0;
    --green-dark: #2C7F8D;
    --green-light: #DFF2F6;
    --green-text: #1F5D67;
    --blue: #5E93C9;
    --blue-dark: #3D74AB;
    --blue-light: #E4EEF8;
    --blue-text: #2F5F8E;
    --red: #D47F90;
    --red-light: #F8E6EB;
    --red-text: #8F3E4F;
    --amber: #C8A87A;
    --amber-light: #F9F1E4;
    --amber-text: #7B5D36;
    --gray-bg: #EAF4FB;
    --gray-border: #C8D9E6;
    --gray-muted: #6C7F91;
    --text: #2A3E4F;
    --text-light: #4C6173;
    --text-on-accent: #FFFFFF;
    --white: #F7FBFF;
    --surface-soft: #F0F7FD;
    --editor-ai-bg: var(--white);
    --editor-manual-bg: var(--white);
    --locked-bg: #ECF2F8;
    --locked-border: #CFDBE6;
    --locked-text: #5E7283;
    --alert-bg: #F7F2E6;
    --alert-border: var(--gray-border);
    --share-bg: var(--blue-light);
    --share-text: var(--blue-text);
    --share-bg-hover: var(--share-bg);
    --archive-bg: var(--alert-bg);
    --archive-bg-hover: var(--archive-bg);
    --publish-checkbox-accent: #7CBAC7;
    --publish-checkbox-bg: #F4FAFD;
    --blue-light-hover: var(--blue-light);
    --loading-overlay-bg: rgba(234, 244, 251, 0.86);
    --shadow: 0 8px 24px rgba(70, 112, 145, 0.16);
    --shadow-lg: 0 10px 40px rgba(70, 112, 145, 0.2);
    --student-cancel-btn-bg: var(--blue-light);
    --student-cancel-btn-fg: var(--blue-text);
}

/* ===== SCREENS ===== */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ===== TOPBAR ===== */
.topbar {
    background: var(--white);
    border-bottom: 1.5px solid var(--gray-border);
    padding: 10px 12px;
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 100;
}
.topbar-back {
    background: var(--gray-bg); border: 1.5px solid var(--gray-border);
    border-radius: 8px; padding: 6px 12px;
    font-size: 14px; font-weight: 700; cursor: pointer;
    font-family: var(--font-sans, sans-serif); color: var(--text);
    transition: background 0.1s; text-decoration: none; display: inline-block;
}
.topbar-back:hover { background: var(--gray-border); }
.topbar-title { font-size: 18px; font-weight: 900; color: var(--green-dark); flex: 1; }
.topbar-badge {
    font-size: 12px; font-weight: 700; padding: 4px 10px;
    border-radius: 99px; background: var(--green-light); color: var(--green-text);
    border: none; cursor: default; font-family: var(--font-sans, sans-serif);
}
.topbar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 0;
}
@media (min-width: 768px) {
    .topbar { padding: 12px 20px; }
}

/* ===== TEACHER / EDITOR BODY ===== */
.teacher-body { padding: 1rem 0.75rem 1.5rem; max-width: 700px; margin: 0 auto; width: 100%; }
@media (min-width: 768px) {
    .teacher-body { padding: 1.5rem 1rem; }
}

.section-label {
    font-size: 11px; font-weight: 800; letter-spacing: 1px;
    text-transform: uppercase; color: var(--gray-muted);
    margin-bottom: 8px;
}

.input-field {
    width: 100%; padding: 12px 14px;
    border: 1.5px solid var(--gray-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans, sans-serif);
    font-size: 15px; font-weight: 600;
    background: var(--white); color: var(--text);
    transition: border-color 0.15s; outline: none;
}
.input-field:focus { border-color: var(--green); }

.otp-group {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.otp-input {
    width: 56px;
    height: 58px;
    border: 1.5px solid var(--gray-border);
    border-radius: 12px;
    background: var(--white);
    text-align: center;
    font-family: var(--font-sans, sans-serif);
    font-size: 1.5rem;
    font-weight: 900;
    text-transform: uppercase;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.otp-input:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px var(--focus-ring);
}


.ai-generator-card,
.editor-mode-card {
    background: var(--white);
    border: 1.5px solid var(--gray-border);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
}
.ai-generator-card { margin-bottom: 1rem; }
.ai-grid { display: grid; gap: 10px; }
.ai-textarea { min-height: 100px; resize: vertical; }

:is(.result-group-card, .about-card) {
    background: var(--white);
    border: 1.5px solid var(--gray-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.editor-mode-card + .editor-mode-card { margin-top: 1rem; }
.editor-mode-card-ai { margin-bottom: 0.75rem; border-color: var(--editor-ai-border); background: var(--editor-ai-bg); }
.editor-mode-card-manual { border-color: var(--editor-manual-border); background: var(--editor-manual-bg); }
.editor-mode-header { margin-bottom: 10px; }
.editor-mode-subtitle { font-size: 13px; color: var(--text-light); font-weight: 600; line-height: 1.4; }
.editor-mode-divider {
    position: relative;
    text-align: center;
    margin: 0.25rem 0 0.9rem;
}
.editor-mode-divider::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    border-top: 1.5px dashed var(--gray-border);
    transform: translateY(-50%);
}
.editor-mode-divider span {
    position: relative;
    display: inline-block;
    padding: 0 10px;
    border-radius: 99px;
    background: var(--gray-bg);
    color: var(--gray-muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

input[type="file"].input-field {
    padding: 8px;
}
input[type="file"].input-field::file-selector-button,
input[type="file"].input-field::-webkit-file-upload-button {
    border: 1.5px solid var(--gray-border);
    background: var(--gray-bg);
    color: var(--text);
    border-radius: 9px;
    padding: 8px 12px;
    margin-right: 10px;
    font-family: var(--font-sans, sans-serif);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s;
}
input[type="file"].input-field::file-selector-button:hover,
input[type="file"].input-field::-webkit-file-upload-button:hover {
    background: var(--green-light);
    border-color: var(--green);
    color: var(--green-text);
}

/* ===== QUESTION CARDS ===== */
.questions-list { display: grid; gap: 10px; margin-bottom: 1rem; }

.q-card {
    background: var(--white);
    border: 1.5px solid var(--gray-border);
    border-radius: var(--radius);
    overflow: hidden; transition: box-shadow 0.15s;
}
.q-card:hover { box-shadow: var(--shadow); }
.q-card-header {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; cursor: pointer; user-select: none;
}
.q-num {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--green-light); color: var(--green-text);
    font-size: 13px; font-weight: 800;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.q-preview { flex: 1; font-size: 14px; font-weight: 700; color: var(--text); }
.q-preview.empty { color: var(--gray-muted); font-style: italic; }
.q-toggle { font-size: 12px; color: var(--gray-muted); transition: transform 0.2s; }
.q-toggle.open { transform: rotate(180deg); }
.q-delete {
    background: var(--red-light); border: none; border-radius: 6px;
    width: 28px; height: 28px; cursor: pointer; font-size: 14px; color: var(--red);
    display: flex; align-items: center; justify-content: center; transition: background 0.1s;
}
.q-delete:hover { background: var(--red-light-hover); }
.q-card-body { padding: 0 14px 14px; display: none; }
.q-card-body.open { display: block; }
.q-row { margin-bottom: 10px; }
.q-row-label { font-size: 12px; font-weight: 700; color: var(--gray-muted); margin-bottom: 4px; }
.options-editor { display: grid; gap: 6px; }
.option-row { display: flex; align-items: center; gap: 8px; }
.option-letter {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--gray-bg); border: 1.5px solid var(--gray-border);
    font-size: 13px; font-weight: 800; color: var(--text-light);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; cursor: pointer; transition: all 0.15s;
}
.option-letter.correct { background: var(--green); border-color: var(--green); color: var(--text-on-accent); }
.correct-hint { font-size: 12px; color: var(--gray-muted); margin-top: 6px; }
.correct-hint span { color: var(--green); font-weight: 700; }

.btn-add-question {
    width: 100%; padding: 14px;
    border: 2px dashed var(--gray-border); border-radius: var(--radius);
    background: transparent; font-family: var(--font-sans, sans-serif);
    font-size: 15px; font-weight: 800; color: var(--gray-muted); cursor: pointer;
    transition: all 0.15s;
}
.btn-add-question:hover { border-color: var(--green); color: var(--green); background: var(--green-light); }

.btn-start-quiz {
    width: 100%; padding: 16px;
    background: var(--green);
    border: none; border-radius: var(--radius);
    font-family: var(--font-sans, sans-serif); font-size: 18px; font-weight: 900;
    color: var(--text-on-accent); cursor: pointer;
    box-shadow: 0 4px 20px var(--green-shadow);
    transition: transform 0.15s, box-shadow 0.15s; margin-top: 1rem;
}
.btn-start-quiz:hover { transform: translateY(-2px); box-shadow: 0 6px 24px var(--green-shadow-hover); }
.btn-start-quiz:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.validation-msg { font-size: 13px; color: var(--red); font-weight: 700; margin-top: 8px; text-align: center; display: none; }

/* ===== STUDENT ===== */
#screen-student {
    align-items: center; justify-content: center;
    padding: 2rem 1rem;
    background: var(--gray-bg);
}
.student-inner { width: 100%; max-width: 480px; text-align: center; }
.student-inner h2 { font-size: 28px; font-weight: 900; color: var(--blue-dark); margin-bottom: 8px; }
.student-inner p { font-size: 15px; color: var(--text-light); margin-bottom: 1.5rem; }
.quiz-picker { display: grid; gap: 10px; margin-bottom: 1.5rem; }
.quiz-pick-item {
    display: flex; align-items: center; gap: 14px;
    background: var(--white); border: 2px solid var(--gray-border);
    border-radius: var(--radius); padding: 14px 16px;
    cursor: pointer; transition: all 0.15s; text-align: left;
}
.quiz-pick-item:hover { border-color: var(--blue); background: var(--blue-light); transform: translateX(4px); }
.quiz-pick-item.is-locked {
    background: var(--locked-bg);
    border-color: var(--locked-border);
    opacity: var(--locked-opacity);
    cursor: default;
}
.quiz-pick-item.is-locked,
.quiz-pick-item.is-locked * {
    cursor: default;
}
.quiz-pick-item.is-locked:hover {
    transform: none;
    border-color: var(--locked-border);
    background: var(--locked-bg);
}
.quiz-pick-icon { font-size: 28px; flex-shrink: 0; }
.quiz-pick-item.is-locked .quiz-pick-icon { filter: grayscale(1); }
.quiz-pick-name { font-size: 16px; font-weight: 800; color: var(--text); display: block; }
.quiz-pick-item.is-locked .quiz-pick-name { color: var(--locked-text); }
.quiz-pick-count { font-size: 13px; color: var(--gray-muted); font-weight: 600; display: block; }
.student-alert {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 120;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    max-width: 360px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1.5px solid var(--alert-border);
    background: var(--alert-bg);
    box-shadow: var(--shadow-lg);
    color: var(--amber-text);
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.student-alert.show { opacity: 1; transform: translateY(0); }
.student-alert-title { font-size: 14px; font-weight: 900; line-height: 1.2; margin-bottom: 2px; }
.student-alert-text { font-size: 13px; font-weight: 700; line-height: 1.35; }
.no-quizzes { font-size: 15px; color: var(--gray-muted); padding: 2rem; }

/* ===== QUIZ PLAY ===== */
#screen-quiz,
#screen-result {
    background: var(--gray-bg);
    align-items: center; justify-content: center; padding: 2rem 1rem;
}
.quiz-container { width: 100%; max-width: 580px; }
.quiz-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.quiz-title-small { font-size: 16px; font-weight: 800; color: var(--green-dark); }
.quiz-score-badge {
    font-size: 13px; font-weight: 800; padding: 4px 12px;
    border-radius: 99px; background: var(--white); color: var(--text); box-shadow: var(--shadow);
}
.quiz-progress { margin-bottom: 1.25rem; }
.quiz-progress-label { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; color: var(--text-light); margin-bottom: 6px; }
.quiz-progress-bg { background: var(--progress-bg); border-radius: 99px; height: 10px; }
.quiz-progress-fill { height: 10px; border-radius: 99px; background: var(--green); transition: width 0.5s cubic-bezier(0.4,0,0.2,1); }
.quiz-card {
    background: var(--white); border-radius: 24px; padding: 1.75rem 1.5rem;
    box-shadow: var(--shadow-lg); animation: slideUp 0.3s cubic-bezier(0.4,0,0.2,1);
}
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.quiz-emoji { font-size: 44px; display: block; margin-bottom: 12px; }
.quiz-question { font-size: 19px; font-weight: 800; color: var(--text); margin-bottom: 1.25rem; line-height: 1.4; }
.quiz-media-box {
    width: 100%;
    max-height: min(60vh, 520px);
    border-radius: 14px;
    border: 2px solid var(--gray-border);
    overflow: hidden;
    background: var(--gray-bg);
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.quiz-media-img {
    width: 100%;
    height: auto;
    max-height: min(60vh, 520px);
    object-fit: contain;
    border-radius: inherit;
    display: block;
}
.quiz-media-box-editor {
    position: relative;
}
.qimage-remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 999px;
    background: var(--icon-btn-overlay-bg);
    color: var(--text-on-accent);
    font-size: 16px;
    line-height: 1;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.qimage-remove-btn:hover {
    background: var(--icon-btn-overlay-bg-hover);
}
.quiz-options { display: grid; gap: 10px; }
.quiz-opt {
    display: flex; align-items: center; gap: 12px; padding: 13px 16px;
    background: var(--gray-bg); border: 2px solid var(--gray-border); border-radius: 14px;
    font-family: var(--font-sans, sans-serif); font-size: 16px; font-weight: 700;
    color: var(--text); cursor: pointer; transition: all 0.15s; text-align: left; width: 100%;
}
.quiz-opt:hover:not(:disabled) { background: var(--green-light); border-color: var(--green); color: var(--green-text); transform: translateX(4px); }
.quiz-opt .ql {
    width: 30px; height: 30px; border-radius: 50%; background: var(--gray-border);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 800; flex-shrink: 0; transition: all 0.15s;
}
.quiz-opt:hover:not(:disabled) .ql { background: var(--green); color: var(--text-on-accent); }
.quiz-opt.correct { background: var(--green-light); border-color: var(--green); color: var(--green-text); }
.quiz-opt.correct .ql { background: var(--green); color: var(--text-on-accent); }
.quiz-opt.wrong { background: var(--red-light); border-color: var(--red); color: var(--red-text); }
.quiz-opt.wrong .ql { background: var(--red); color: var(--text-on-accent); }
.quiz-opt:disabled { cursor: default; transform: none; }
.quiz-feedback {
    margin-top: 14px; padding: 12px 16px; border-radius: 12px;
    font-size: 14px; font-weight: 700; line-height: 1.5; animation: slideUp 0.2s ease;
}
.quiz-feedback.correct { background: var(--green-light); color: var(--green-text); border-left: 4px solid var(--green); }
.quiz-feedback.wrong { background: var(--red-light); color: var(--red-text); border-left: 4px solid var(--red); }
.quiz-next {
    width: 100%; margin-top: 1rem; padding: 14px;
    background: var(--green);
    border: none; border-radius: 14px; font-family: var(--font-sans, sans-serif);
    font-size: 17px; font-weight: 900; color: var(--text-on-accent); cursor: pointer;
    box-shadow: 0 4px 16px var(--green-shadow); transition: transform 0.15s;
}
.quiz-next:hover { transform: translateY(-2px); }

/* ===== RESULT ===== */
.result-card {
    width: 100%; max-width: 480px; background: var(--white);
    border-radius: 28px; padding: 2.5rem 2rem; box-shadow: var(--shadow-lg);
    text-align: center; animation: slideUp 0.4s cubic-bezier(0.4,0,0.2,1);
}
.result-emoji { font-size: 72px; display: block; margin-bottom: 12px; animation: pop 0.5s cubic-bezier(0.175,0.885,0.32,1.275); }
@keyframes pop { from { transform: scale(0) rotate(-10deg); } to { transform: scale(1) rotate(0); } }
.result-title { font-size: 26px; font-weight: 900; color: var(--green-dark); margin-bottom: 6px; }
.result-subtitle { font-size: 15px; color: var(--text-light); margin-bottom: 1.25rem; }
.result-score { font-size: 56px; font-weight: 900; color: var(--green); line-height: 1; margin-bottom: 4px; }
.result-score span { font-size: 28px; color: var(--gray-muted); }
.result-stars { font-size: 30px; letter-spacing: 6px; margin: 10px 0 1.5rem; display: block; }
.result-pills { display: flex; justify-content: center; gap: 10px; margin-bottom: 1.75rem; flex-wrap: wrap; }
.rpill { padding: 6px 16px; border-radius: 99px; font-size: 14px; font-weight: 800; }
.rpill-ok { background: var(--green-light); color: var(--green-text); }
.rpill-bad { background: var(--red-light); color: var(--red-text); }
.result-btns { display: grid; gap: 10px; }
.btn-retry {
    padding: 14px; border: none; border-radius: var(--radius);
    font-family: var(--font-sans, sans-serif); font-size: 16px; font-weight: 800;
    cursor: pointer; transition: transform 0.15s;
}
.btn-retry:hover { transform: translateY(-2px); }
.btn-retry-play { background: var(--green); color: var(--text-on-accent); box-shadow: 0 4px 16px var(--green-shadow); }
.btn-retry-home { background: var(--gray-bg); color: var(--text); border: 1.5px solid var(--gray-border); }

/* ===== MANAGE (admin dashboard) ===== */
.manage-list { display: grid; gap: 12px; }
.manage-card {
    background: var(--white); border: 1.5px solid var(--gray-border);
    border-radius: var(--radius); padding: 1rem 1.25rem;
    display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow);
}
.manage-card-icon { font-size: 32px; flex-shrink: 0; }
.manage-card-info { flex: 1; min-width: 0; }
.manage-card-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 8px;
}
.manage-card-meta { font-size: 13px; color: var(--gray-muted); font-weight: 600; margin-top: 2px; }
.manage-card-actions { display: flex; gap: 8px; flex-shrink: 0; }
.teacher-enabled-toggle-form {
    margin: 0;
    display: inline-flex;
    align-items: center;
}
.teacher-enabled-toggle-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1.5px solid var(--gray-border);
    background: var(--gray-bg);
    cursor: pointer;
}
.teacher-enabled-toggle-label input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--green);
    cursor: pointer;
}
.teacher-manage-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
}
.teacher-ai-toggle-form {
    margin: 0;
    display: flex;
    align-items: center;
}
.teacher-ai-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1.5px solid var(--gray-border);
    background: var(--gray-bg);
    font-size: 13px;
    font-weight: 800;
    color: var(--text);
    cursor: pointer;
    margin-bottom: 6px;
}
.ai-image-toggle-label {
    display: flex;
    width: 100%;
    height: auto;
    min-height: 42px;
    padding: 10px 12px;
    line-height: 1.35;
}
.teacher-ai-toggle-label input[type="checkbox"],
.btn-publish-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    appearance: none;
    -webkit-appearance: none;
    background: var(--publish-checkbox-bg);
    border: 2px solid var(--publish-checkbox-accent);
    border-radius: 4px;
    display: inline-grid;
    place-content: center;
    cursor: pointer;
}
:is(.teacher-ai-toggle-label, .btn-publish-toggle) input[type="checkbox"]::before {
    content: "";
    width: 4px;
    height: 8px;
    border-right: 2px solid var(--text-on-accent);
    border-bottom: 2px solid var(--text-on-accent);
    transform: rotate(45deg) scale(0);
    transform-origin: center;
    transition: transform 0.08s ease-in-out;
}
:is(.teacher-ai-toggle-label, .btn-publish-toggle) input[type="checkbox"]:checked {
    background: var(--publish-checkbox-accent);
}
:is(.teacher-ai-toggle-label, .btn-publish-toggle) input[type="checkbox"]:checked::before {
    transform: rotate(45deg) scale(1);
}
:is(.teacher-ai-toggle-label, .btn-publish-toggle) input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--publish-checkbox-accent);
    outline-offset: 1px;
}
.btn-teacher-action {
    height: 36px;
    border-radius: 8px;
    border: 1.5px solid var(--blue-light-hover);
    background: var(--blue-light);
    padding: 0 12px;
    font-family: var(--font-sans, sans-serif);
    font-size: 13px;
    font-weight: 800;
    color: var(--blue-dark);
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn-teacher-action:hover {
    background: var(--blue-light-hover);
}
.btn-teacher-action:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.btn-teacher-action-danger {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger-text);
}
.btn-teacher-action-danger:hover {
    background: var(--danger-bg-hover);
}
.btn-icon-action {
    width: 36px; height: 36px; border-radius: 8px; border: none;
    font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.15s; font-family: var(--font-sans, sans-serif); text-decoration: none;
}
.btn-edit-quiz { background: var(--blue-light); color: var(--blue-dark); }
.btn-edit-quiz:hover { background: var(--blue-light-hover); }
.btn-share-quiz { background: var(--share-bg); color: var(--share-text); }
.btn-share-quiz:hover { background: var(--share-bg-hover); }
.btn-delete-quiz { background: var(--red-light); color: var(--red); }
.btn-delete-quiz:hover { background: var(--red-light-hover); }
.btn-archive-quiz { background: var(--archive-bg); color: var(--archive-text); }
.btn-archive-quiz:hover { background: var(--archive-bg-hover); }
.btn-restore-quiz { background: var(--restore-bg); color: var(--restore-text); }
.btn-restore-quiz:hover { background: var(--restore-bg-hover); }
body[data-theme="dark"] .btn-archive-quiz { background: var(--alert-bg); color: var(--amber-text); }
body[data-theme="dark"] .btn-archive-quiz:hover { background: var(--archive-bg-hover); }
.student-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-regenerate-password {
    height: 36px;
    border-radius: 8px;
    border: none;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-sans, sans-serif);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    background: var(--blue-light);
    color: var(--blue-dark);
    transition: background-color 0.15s, color 0.15s, opacity 0.15s;
}
.btn-regenerate-password:hover { background: var(--blue-light-hover); }
.btn-regenerate-icon-mobile {
    display: none;
}
.students-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 480px;
}
.students-print-card {
    overflow: auto;
    background: var(--white);
    border-radius: 14px;
    border: 1px solid var(--gray-border);
}
.students-table thead tr {
    background: var(--surface-soft);
}
.students-table td,
.students-table th {
    border-color: var(--gray-border) !important;
    color: var(--text);
}
.btn-publish-toggle {
    background: var(--green-light);
    color: var(--green-text);
    position: relative;
    overflow: hidden;
}
.btn-publish-toggle:hover { background: var(--publish-bg-hover); }
.btn-publish-toggle input[type="checkbox"]:disabled { cursor: not-allowed; }
.manage-empty { text-align: center; padding: 3rem 1rem; color: var(--gray-muted); font-size: 15px; font-weight: 600; }
.manage-empty span { font-size: 48px; display: block; margin-bottom: 12px; }

.archived-quizzes-accordion {
    margin-top: 1.5rem;
    border-top: 1px dashed var(--gray-border);
    padding-top: 12px;
}
.archived-quizzes-accordion summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-size: 15px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 10px;
}
.archived-quizzes-accordion summary::-webkit-details-marker {
    display: none;
}
.archived-accordion-icon {
    font-size: 14px;
    color: var(--gray-muted);
    transition: transform 0.2s;
}
.archived-quizzes-accordion[open] .archived-accordion-icon {
    transform: rotate(180deg);
}

/* ===== HOME ADMIN ===== */
.home-buttons { display: grid; gap: 12px; }
.btn-hero {
    display: flex; align-items: center; gap: 14px;
    padding: 18px 24px; border: none; border-radius: var(--radius);
    font-family: var(--font-sans, sans-serif); font-size: 17px; font-weight: 800;
    cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; text-align: left;
}
.btn-hero:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.btn-hero .btn-icon { font-size: 30px; flex-shrink: 0; }
.btn-hero .btn-label { font-size: 18px; font-weight: 900; display: block; }
.btn-hero .btn-desc { font-size: 13px; font-weight: 600; opacity: 0.8; display: block; }
.btn-teacher { background: var(--green); color: var(--text-on-accent); }
.btn-student { background: var(--blue); color: var(--text-on-accent); }

/* ===== LOGIN ===== */
.login-screen {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 2rem 1rem;
    background: var(--gray-bg);
}
.login-card {
    background: var(--white); border-radius: 24px; padding: 2.5rem 2rem;
    width: 100%; max-width: 400px; box-shadow: var(--shadow-lg);
}
.login-title { font-size: 28px; font-weight: 900; color: var(--green-dark); text-align: center; margin-bottom: 4px; }
.login-sub { font-size: 15px; color: var(--text-light); text-align: center; margin-bottom: 1.5rem; }
.form-group { margin-bottom: 1rem; }
.form-label { font-size: 13px; font-weight: 700; color: var(--text-light); display: block; margin-bottom: 6px; }
.form-group .cf-turnstile {
    width: 100%;
}
.form-group .cf-turnstile iframe {
    width: 100% !important;
}

/* ===== PROFILE PAGE ===== */
.screen-admin {
    background: var(--gray-bg);
    min-height: 100vh;
}
.topbar-inline-form { margin: 0; }
.topbar-back-link { text-decoration: none; }
.teacher-body-narrow { max-width: 520px; }
.editor-mode-card-spaced { margin-bottom: 1rem; }
.profile-heading {
    font-size: 24px;
    font-weight: 900;
    color: var(--green-dark);
    margin-bottom: 6px;
}
.profile-heading-lg {
    font-size: 26px;
}
.profile-subtitle {
    color: var(--text-light);
    font-weight: 600;
    margin-bottom: 1rem;
}
.profile-password-submit { margin-top: 1.25rem; }
.alert {
    padding: 10px 14px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 700; margin-bottom: 1rem;
}
.alert-error { background: var(--red-light); color: var(--red-text); }
.alert-success { background: var(--green-light); color: var(--green-text); }

/* ===== ERROR PAGE ===== */
.error-card {
    max-width: 560px;
}
.error-emoji {
    font-size: 52px;
    text-align: center;
    margin-bottom: 8px;
}
.error-status {
    display: flex;
    justify-content: center;
    gap: 8px;
    align-items: baseline;
}
.error-main-message {
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 1rem;
}
.error-details-accordion {
    border: 1.5px solid var(--gray-border);
    border-radius: var(--radius-sm);
    background: var(--gray-bg);
    overflow: hidden;
    margin-bottom: 1.25rem;
}
.error-details-accordion summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    list-style: none;
    padding: 12px 14px;
    font-size: 13px;
    font-weight: 800;
    color: var(--text);
}
.error-details-accordion summary::-webkit-details-marker {
    display: none;
}
.error-details-accordion .archived-accordion-icon {
    font-size: 12px;
}
.error-details-body {
    border-top: 1px solid var(--gray-border);
    padding: 10px 14px;
    color: var(--text-light);
    font-size: 13px;
    line-height: 1.45;
    word-break: break-word;
    white-space: pre-wrap;
}
.error-details-body p + p {
    margin-top: 8px;
}
.error-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed; inset: 0; background: var(--overlay-bg);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999; padding: 1rem;
}
.modal-box {
    background: var(--white); border-radius: var(--radius); padding: 1.75rem;
    max-width: 360px; width: 100%; text-align: center; box-shadow: var(--shadow-lg);
    animation: slideUp 0.2s ease;
}
.modal-emoji { font-size: 48px; display: block; margin-bottom: 12px; }
.modal-title { font-size: 20px; font-weight: 900; color: var(--text); margin-bottom: 8px; }
.modal-sub { font-size: 14px; color: var(--text-light); margin-bottom: 1.5rem; line-height: 1.5; }
.modal-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-modal {
    padding: 12px; border: none; border-radius: var(--radius-sm);
    font-family: var(--font-sans, sans-serif); font-size: 15px; font-weight: 800;
    cursor: pointer; transition: transform 0.1s;
}
.btn-modal:hover { transform: translateY(-1px); }
.btn-modal-cancel { background: var(--gray-bg); color: var(--text); border: 1.5px solid var(--gray-border); }
.btn-modal-confirm { background: var(--red); color: var(--text-on-accent); }
.btn-modal-share { background: var(--green); color: var(--text-on-accent); }
.modal-box-share { max-width: 460px; }
.student-exit-modal-box {
    max-width: 620px;
    text-align: left;
}
.student-exit-modal-btns {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}
.btn-modal-student-exit {
    background: var(--student-exit-btn-bg);
    color: var(--student-exit-btn-fg);
    border: 2px solid var(--student-exit-btn-fg);
    box-shadow: inset 0 0 0 2px var(--student-exit-btn-bg);
    min-width: 110px;
}
.btn-modal-student-cancel {
    background: var(--student-cancel-btn-bg);
    color: var(--student-cancel-btn-fg);
    border: none;
    min-width: 110px;
}
.share-grid {
    text-align: left;
    margin-bottom: 1.25rem;
}
.share-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
}
.share-option:hover { background: var(--gray-bg); }
.share-option input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--green);
}
.share-option-all {
    border: 1.5px dashed var(--gray-border);
    margin-bottom: 8px;
    font-weight: 800;
    color: var(--text);
}
.share-list {
    max-height: 230px;
    overflow: auto;
    border: 1.5px solid var(--gray-border);
    border-radius: 10px;
    background: var(--white);
    padding: 4px;
}

/* ===== LOADING OVERLAY ===== */
#loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--loading-overlay-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    font-family: var(--font-sans, sans-serif);
    gap: 12px;
}

#loading-overlay .loading-icon {
    font-size: 44px;
    transform-origin: center center; /* Centro perfetto per una rotazione fluida */
    animation: wonderland-ultra-smooth 2s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
    will-change: transform;
}

#loading-overlay p {
    font-size: 16px;
    font-weight: 700;
    color: var(--green-dark);
}

@keyframes wonderland-ultra-smooth {
    /* --- RESET & PICCOLO BALZO 1 --- */
    0%   { transform: translateY(0) rotate(0deg); }
    10%  { transform: translateY(-6px) rotate(0deg); }
    20%  { transform: translateY(0) rotate(0deg); }

    /* --- PICCOLO BALZO 2 --- */
    30%  { transform: translateY(-12px) rotate(0deg); }
    40%  { transform: translateY(0) rotate(0deg); }

    /* --- IL GRANDE BALZO --- */
    /* Inizio rotazione */
    45%  { transform: translateY(0) rotate(0deg) scale(1.10, 0.90); }
    60%  { transform: translateY(-90px) rotate(180deg) scale(1); } /* Apice */
    75%  { transform: translateY(0) rotate(360deg) scale(1.10, 0.90); } /* Atterraggio */

    /* --- STABILIZZAZIONE FINALE --- */
    90%  { transform: translateY(-5px) rotate(360deg); }
    100% { transform: translateY(0) rotate(360deg); }
}

/* ===== TOAST ===== */
#toast {
    position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%);
    background: var(--green-dark); color: var(--text-on-accent);
    padding: 12px 24px; border-radius: 99px;
    font-family: var(--font-sans, sans-serif); font-size: 15px; font-weight: 800;
    z-index: 9999; box-shadow: 0 4px 16px var(--toast-shadow);
    transition: opacity 0.3s; opacity: 0; pointer-events: none;
}
body[data-theme="dark"] #toast {
    background: var(--toast-bg-dark);
    color: var(--toast-text-dark);
}

@media (max-width: 768px) {
    .topbar {
        flex-wrap: wrap;
        padding: 10px 14px;
        gap: 10px;
    }

    .topbar-title {
        width: 100%;
        font-size: 17px;
    }

    .topbar-actions {
        width: 100%;
    }

    .teacher-body {
        padding: 1rem 0.75rem 1.25rem;
    }

    .manage-card {
        align-items: flex-start;
        flex-wrap: wrap;
        padding: 0.9rem 1rem;
    }

    .manage-card-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .quiz-card,
    .result-card,
    .login-card {
        padding: 1.5rem 1.1rem;
        border-radius: 20px;
    }
}

@media (max-width: 480px) {
    .quiz-question { font-size: 17px; }
    .result-score { font-size: 42px; }

    .topbar-back {
        padding: 6px 10px;
        font-size: 13px;
    }

    .topbar-badge {
        font-size: 11px;
        padding: 4px 8px;
    }

    .student-inner h2,
    .login-title {
        font-size: 24px;
    }

    .quiz-opt {
        font-size: 15px;
        padding: 12px;
        gap: 10px;
    }

    .quiz-opt .ql {
        width: 28px;
        height: 28px;
    }

    .manage-card {
        gap: 10px;
    }

    .manage-card-title {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .home-buttons .btn-hero {
        padding: 14px 16px;
    }

    .btn-hero .btn-label {
        font-size: 17px;
    }

    .results-table {
        min-width: 0;
    }

    .results-table th,
    .results-table td {
        padding: 9px 8px;
        font-size: 12px;
    }

    .btn-unlock-single {
        padding: 8px 10px;
        font-size: 12px;
    }

    .students-table {
        min-width: 0;
    }

    .students-table td,
    .students-table th {
        padding: 9px 8px !important;
    }

    .student-actions {
        justify-content: flex-end;
        flex-wrap: nowrap;
    }

    .btn-regenerate-password {
        width: 36px;
        padding: 0;
        justify-content: center;
    }

    .btn-regenerate-text {
        display: none;
    }

    .btn-regenerate-icon-mobile {
        display: inline;
        font-size: 16px;
        line-height: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== RESULTS PAGE ===== */
.results-groups {
    display: grid;
    gap: 14px;
}
.result-group-card {
    padding: 14px;
}
.result-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.result-group-header h2 {
    font-size: 18px;
    font-weight: 900;
    color: var(--green-dark);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-unlock-all,
.btn-unlock-single {
    border: none;
    border-radius: 10px;
    font-family: var(--font-sans, sans-serif);
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-unlock-all {
    background: var(--green);
    color: var(--text-on-accent);
    padding: 10px 14px;
    font-size: 14px;
    box-shadow: 0 4px 14px var(--green-shadow-soft);
}
.btn-unlock-all:hover { transform: translateY(-1px); }
.btn-unlock-single {
    background: var(--green-light);
    color: var(--green-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1;
}
.btn-unlock-single:hover {
    background: var(--green);
    color: var(--text-on-accent);
    transform: translateY(-1px);
}
.btn-unlock-single:disabled {
    background: var(--disabled-bg);
    color: var(--disabled-text);
    cursor: not-allowed;
}
.results-table-wrap {
    overflow: auto;
    border: 1px solid var(--gray-border);
    border-radius: 12px;
}
.results-table {
    width: 100%;
    border-collapse: collapse;
}
.results-table th {
    text-align: left;
    background: var(--surface-soft);
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text);
}
.results-table td {
    padding: 10px 12px;
    border-top: 1px solid var(--gray-border);
    font-size: 14px;
    color: var(--text);
}
.status-pill {
    font-size: 12px;
    font-weight: 800;
    border-radius: 999px;
    padding: 5px 9px;
    display: inline-block;
}
.status-pill-locked {
    background: var(--amber-light);
    color: var(--amber-text);
}
.status-pill-unlocked {
    background: var(--blue-light);
    color: var(--blue-dark);
}

.results-mobile-list {
    display: none;
}

.result-mobile-item {
    border: 1px solid var(--gray-border);
    border-radius: 12px;
    background: var(--white);
}

.result-mobile-item + .result-mobile-item {
    margin-top: 8px;
}

.result-mobile-item summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px 12px;
}


.result-mobile-item summary::after {
    content: '▾';
    color: var(--gray-muted);
    font-size: 13px;
    margin-left: 8px;
    display: inline-block;
    transition: transform 0.2s;
}

.result-mobile-item[open] summary::after {
    transform: rotate(180deg);
}
.result-mobile-item summary::-webkit-details-marker {
    display: none;
}

.result-mobile-student {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 800;
    color: var(--text);
}

.result-mobile-score {
    margin-left: auto;
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 800;
    color: var(--green-dark);
    background: var(--green-light);
    border-radius: 999px;
    padding: 4px 8px;
}

.result-mobile-content {
    border-top: 1px solid var(--gray-border);
    padding: 10px 12px;
    display: grid;
    gap: 10px;
}

.result-mobile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
}

.result-mobile-row span {
    color: var(--text-light);
    font-weight: 700;
}

.result-mobile-action {
    display: flex;
    justify-content: flex-end;
}

@media (max-width: 640px) {
    .results-table {
        display: none;
    }

    .results-table-wrap {
        border: none;
        overflow: visible;
    }

    .results-mobile-list {
        display: block;
    }
}

.results-analytics {
    margin-top: 12px;
    border-top: 1px dashed var(--gray-border);
    padding-top: 12px;
}
.results-analytics summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    font-size: 15px;
    color: var(--green-dark);
    font-weight: 800;
}
.results-analytics summary::-webkit-details-marker {
    display: none;
}
.results-analytics-content {
    margin-top: 10px;
}
.analytics-accordion-icon {
    font-size: 14px;
    color: var(--gray-muted);
    transition: transform 0.2s;
}
.results-analytics[open] .analytics-accordion-icon {
    transform: rotate(180deg);
}
.results-analytics-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 10px;
}
.analytics-metric {
    background: var(--surface-soft);
    border: 1px solid var(--gray-border);
    border-radius: 10px;
    padding: 10px;
}
.analytics-label {
    display: block;
    font-size: 12px;
    color: var(--text-light);
    font-weight: 700;
}
.analytics-metric strong {
    font-size: 20px;
    color: var(--text);
}
.analytics-difficult h4 {
    font-size: 13px;
    margin-bottom: 6px;
}
.analytics-difficult ul {
    list-style: none;
    display: grid;
    gap: 6px;
}
.analytics-difficult li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid var(--gray-border);
    border-radius: 8px;
    padding: 7px 9px;
    font-size: 13px;
}
.analytics-difficult p {
    font-size: 13px;
    color: var(--gray-muted);
}

.about-grid {
    display: grid;
    gap: 12px;
}

.about-card {
    padding: 14px;
}

.about-card h2 {
    margin-bottom: 10px;
    font-size: 17px;
    color: var(--green-dark);
}

.about-list {
    list-style: none;
    display: grid;
    gap: 6px;
    color: var(--text-light);
    font-weight: 600;
}

.admin-about-footer {
    margin-top: 18px;
    text-align: center;
}

.admin-about-link {
    font-size: 12px;
    color: var(--gray-muted);
    text-decoration: none;
    font-weight: 700;
}

.admin-about-link:hover {
    text-decoration: underline;
}

/* ===== ABOUT / LOGS ===== */
.about-footer-link {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
}

.log-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.log-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.log-status {
    font-size: 13px;
    color: var(--text-light);
    font-weight: 700;
}

.log-console {
    margin-top: 10px;
    background: var(--log-console-bg);
    color: var(--log-console-text);
    border-radius: 12px;
    padding: 12px;
    min-height: 420px;
    max-height: 70vh;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    border: 1px solid var(--log-console-border);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    line-height: 1.45;
}
