/* ─────────────────────────────────────────────────────────────────────────
 * Quiz Challenge — Duolingo-inspired design system
 *
 * Design tokens are vendored verbatim from open-design in assets/tokens.css
 * (design-systems/duolingo). This file only @imports them and declares the
 * few extension tokens the package omits — never a raw hex at a use site.
 * ───────────────────────────────────────────────────────────────────────── */

@import url("assets/tokens.css");

/* ─── Extension tokens (absent from the duolingo package) ───────────────
 * --info and --elev-raised-active are not in the package; --ease-spring is
 * the app's historical alias for the package's --ease-standard. Declared once
 * here so every component can reference them by name.
 * ─────────────────────────────────────────────────────────────────────── */
:root {
  --info: #1cb0f6;
  --elev-raised-active: 0 0 0 #d7d7d7;
  --ease-spring: var(--ease-standard);
}

* { box-sizing: border-box; }
html {
    height: 100%;
}
body {
    margin: 0;
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-body);
    background: var(--bg);
    color: var(--fg);
    -webkit-font-smoothing: antialiased;
}

.wrap {
    max-width: 1080px;
    margin: 0 auto;
    padding: var(--space-8) var(--space-6) var(--space-12);
}

/* ─── Typography ─────────────────────────────────────────────────────── */

h1 {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 800;
    line-height: var(--leading-tight);
    margin: 0 0 var(--space-2);
}

h2 {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 800;
    line-height: var(--leading-tight);
    margin: 0 0 var(--space-4);
}

.subtitle {
    color: var(--muted);
    font-size: var(--text-lg);
    margin: 0 0 var(--space-6);
}

/* ─── Cards ──────────────────────────────────────────────────────────── */

.card {
    background: var(--bg);
    border: 2px solid var(--border);
    border-bottom: 4px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-5);
    transition: transform var(--motion-fast) var(--ease-spring),
                box-shadow var(--motion-fast) var(--ease-spring);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--elev-raised);
}

.card .bottom-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    margin-top: var(--space-5);
}

.action-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-5);
}

.side-actions {
    display: flex;
    gap: var(--space-3);
    align-items: center;
}

/* ─── Buttons ───────────────────────────────────────────────────────── */

.btn {
    appearance: none;
    font-family: var(--font-display);
    font-size: var(--text-base);
    font-weight: 800;
    letter-spacing: 0.02em;
    padding: 14px 24px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border);
    border-bottom: 4px solid var(--border);
    background: var(--bg);
    color: var(--muted);
    cursor: pointer;
    transition: transform var(--motion-fast) var(--ease-spring),
                box-shadow var(--motion-fast) var(--ease-spring),
                background var(--motion-fast),
                border-color var(--motion-fast);
}

.btn:hover {
    color: var(--fg);
    border-color: var(--meta);
}

.btn:active {
    transform: translateY(4px);
    box-shadow: var(--elev-raised-active);
}

.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    border-bottom-color: var(--accent-active);
    color: var(--accent-on);
}

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

.btn.primary:active {
    background: var(--accent-active);
}

.btn.small {
    padding: 8px 16px;
    font-size: var(--text-sm);
}

.btn.ghost {
    background: transparent;
    border-color: transparent;
    border-bottom-color: transparent;
    color: var(--info);
}

.btn.ghost:hover {
    background: rgba(28, 176, 246, 0.08);
}

.link a {
    color: var(--info);
    text-decoration: none;
    font-weight: 600;
}

.link a:hover {
    text-decoration: underline;
}

/* ─── Question UI ───────────────────────────────────────────────────── */

.progress {
    color: var(--muted);
    font-size: var(--text-sm);
    font-weight: 600;
    margin: 0 0 var(--space-3);
}

.qprompt {
    font-size: var(--text-lg);
    line-height: 1.4;
    margin: 0 0 var(--space-5);
}

.options {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.opt {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    border: 2px solid var(--border);
    border-bottom: 4px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    transition: transform var(--motion-fast) var(--ease-spring),
                box-shadow var(--motion-fast) var(--ease-spring),
                border-color var(--motion-fast);
}

.opt:hover {
    border-color: var(--info);
    transform: translateY(-2px);
    box-shadow: 0 4px 0 rgba(28, 176, 246, 0.25);
}

.opt input { margin: 0; }

/* ─── Inputs ────────────────────────────────────────────────────────── */

.text-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--text-base);
    font-family: inherit;
    margin-bottom: var(--space-4);
    background: var(--bg);
    transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}

.text-input:focus {
    outline: none;
    border-color: var(--info);
    box-shadow: var(--focus-ring);
}

textarea.text-input {
    resize: vertical;
    min-height: 100px;
}

.text-input:read-only,
.text-input[readonly] {
    background: var(--surface);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.7;
}

/* ─── Password visibility toggle ──────────────────────────────────────────
   quiz.js wraps each input[type=password] in a .pw-wrap and appends a
   .pw-toggle eye button. The wrapper is a positioned block so the eye sits
   inside the field's right edge. */
.pw-wrap {
    position: relative;
    display: block;
}
.pw-wrap .text-input {
    padding-right: 48px; /* room for the eye button */
}
.pw-toggle {
    position: absolute;
    top: 50%;
    right: var(--space-3);
    transform: translateY(calc(-50% - 2px)); /* optically centred vs the 4px border */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--meta);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color var(--motion-fast), background var(--motion-fast);
}
.pw-toggle:hover {
    color: var(--fg);
    background: var(--surface);
}
.pw-toggle:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    color: var(--fg);
}
.pw-toggle[aria-pressed="true"] {
    color: var(--info);
}

/* ─── Code-Mode Toggle ──────────────────────────────────────────────── */

.code-mode-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin-left: var(--space-2);
    margin-bottom: var(--space-4);
    color: var(--muted);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.code-mode-toggle input { margin: 0; }

.text-input.code-mode {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    line-height: var(--leading-body);
    tab-size: 2;
    white-space: pre;
    background: var(--surface);
    padding-left: 50px; /* room for the line-number gutter */
}

/* ─── Code Editor (line-number gutter) ──────────────────────────────── */

.code-editor {
    position: relative;
}

.code-editor .line-numbers {
    display: none;
}

.code-editor.code-mode .line-numbers {
    display: block;
    position: absolute;
    top: 14px;              /* textarea border (2px) + padding (12px) */
    bottom: 14px;
    left: 2px;              /* inside the textarea's 2px border */
    width: 42px;
    overflow: hidden;
    padding-right: 6px;
    text-align: right;
    color: var(--meta);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    line-height: var(--leading-body);
    white-space: pre;
    border-right: 1px solid var(--border);
    pointer-events: none;
    user-select: none;
}

/* ─── Number Input ──────────────────────────────────────────────────── */

input[type="number"] {
    appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ─── Timer ─────────────────────────────────────────────────────────── */

.pause-row {
    margin: var(--space-2) 0 0;
}
.pause-row .btn {
    padding: 4px 14px;
    font-size: var(--text-sm);
}

.timer-bar-track {
    width: 100%;
    height: 16px;
    background: var(--border);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.timer-bar {
    height: 100%;
    width: 100%;
    background: var(--success);
    border-radius: var(--radius-pill);
    transition: width 1s linear, background-color var(--motion-fast);
}

.timer-label {
    font-size: var(--text-xs);
    color: var(--muted);
    font-weight: 600;
    margin: var(--space-2) 0 var(--space-4);
}

/* ─── Results Table ─────────────────────────────────────────────────── */

.score-box {
    display: flex;
    align-items: baseline;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.score {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 800;
    color: var(--accent);
}

.pct {
    font-size: var(--text-lg);
    color: var(--muted);
}

table.results {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--space-5);
    table-layout: auto;
}

table.results th,
table.results td {
    text-align: left;
    padding: var(--space-3) var(--space-3);
    border-bottom: 2px solid var(--border);
    vertical-align: top;
    font-size: var(--text-sm);
    max-width: 520px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

table.results th {
    background: var(--surface);
    font-weight: 700;
}

table.results tr.ok td:first-child {
    border-left: 4px solid var(--success);
}

table.results tr.bad td:first-child {
    border-left: 4px solid var(--danger);
}

table.results small {
    color: var(--muted);
}

/* Wrap the results table so wide rows scroll inside the card instead of
   overflowing past its border. */
.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ─── Code Blocks ──────────────────────────────────────────────────── */

.code-block {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    margin: var(--space-2) 0;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    overflow-x: auto;
    white-space: pre;
}

.code-block code { background: transparent; }

/* ─── Reported Badge ──────────────────────────────────────────────── */

.reported-badge {
    display: inline-block;
    background: rgba(255, 150, 0, 0.15);
    color: #cc7a00;
    border: 1px solid rgba(255, 150, 0, 0.4);
    border-radius: var(--radius-pill);
    padding: 2px var(--space-2);
    font-size: var(--text-xs);
    font-weight: 700;
    margin-left: var(--space-2);
}

/* ─── Admin Cards ─────────────────────────────────────────────────── */

#timer-card,
#generate-card {
    display: none;
}

.admin-visible #timer-card,
.admin-visible #generate-card {
    display: block;
}

/* ─── Settings ────────────────────────────────────────────────────── */

label {
    display: block;
    margin-bottom: var(--space-1);
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--fg);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"] {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--text-base);
}

.checks {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

/* Settings numeric fields sit side-by-side on desktop, stack on mobile. */
.row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

@media (max-width: 640px) {
    .row { grid-template-columns: 1fr; }
}

.checks label {
    font-weight: 600;
}

.presets {
    margin: var(--space-4) 0;
}

.presets button {
    margin-right: var(--space-2);
}

.test-output {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    margin-top: var(--space-4);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}

/* ─── Modal ──────────────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(60, 60, 60, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-box {
    background: var(--bg);
    border: 2px solid var(--border);
    border-bottom: 4px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    max-width: 420px;
    width: calc(100% - var(--space-8));
    box-shadow: 0 4px 0 #d7d7d7, 0 12px 32px rgba(60, 60, 60, 0.18);
}

.modal-message {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 800;
    line-height: var(--leading-tight);
    margin: 0 0 var(--space-4);
}

.modal-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
}

/* Error variant for the notice dialog */
.modal-box.notice-error {
    border-color: var(--danger);
    border-bottom-color: var(--danger);
}
.modal-box.notice-error .modal-message { color: var(--danger); }

/* ─── Notice / Debug Output ────────────────────────────────────────── */

.notice {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    margin: var(--space-3) 0;
    font-size: var(--text-sm);
    color: var(--fg);
}

.notice.ok {
    background: rgba(88, 204, 2, 0.12);
    border-color: var(--success);
    color: #3b7a00;
    font-weight: 600;
}

.notice.bad {
    background: rgba(255, 75, 75, 0.10);
    border-color: var(--danger);
    color: #b11f1f;
    font-weight: 600;
}

/* ─── Site nav ──────────────────────────────────────────────────────── */

.site-nav {
    background: var(--bg);
    border-bottom: 2px solid var(--border);
}

.site-nav-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: var(--space-3) var(--space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}

.site-brand {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: var(--text-lg);
    color: var(--accent);
    text-decoration: none;
    letter-spacing: 0.01em;
}

.site-brand:hover {
    color: var(--accent-hover);
}

.site-links {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.site-links a {
    color: var(--muted);
    font-weight: 700;
    font-size: var(--text-sm);
    text-decoration: none;
}

.site-links a:hover {
    color: var(--fg);
}

.site-links a.btn {
    color: var(--accent-on);
}

.site-links a.btn:hover {
    color: var(--accent-on);
    background: var(--accent-hover);
}

.site-nav-logout {
    display: inline;
    margin: 0;
}

/* Impersonation banner — shown between nav and content when an admin is
   logged in as a student. */
.impersonation-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--accent);
    color: var(--accent-on);
    font-size: var(--text-sm);
    flex-wrap: wrap;
    text-align: center;
}
.impersonation-banner strong {
    color: inherit;
}
.impersonation-return {
    display: inline;
    margin: 0;
}
.impersonation-return .btn {
    background: var(--bg);
    color: var(--accent);
    border-color: var(--bg);
}

@media (max-width: 640px) {
    .site-nav-inner {
        padding: var(--space-3) var(--space-4);
        gap: var(--space-2);
    }
    .site-links { gap: var(--space-3); }
}

/* ─── Form fields (auth/account pages) ──────────────────────────────── */

.field {
    display: block;
    margin-bottom: var(--space-4);
}

.field > span {
    display: block;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--fg);
    margin-bottom: var(--space-2);
}

.field .text-input {
    margin-bottom: 0;   /* the .field wrapper owns the rhythm */
}

.field .error,
span.error {
    display: block;
    color: var(--danger);
    font-size: var(--text-sm);
    font-weight: 600;
    margin-top: var(--space-2);
}

.text-input[aria-invalid="true"] {
    border-color: var(--danger);
}

/* ─── Account facts (definition list on /account) ───────────────────── */

.account-facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--space-2) var(--space-4);
    margin: var(--space-4) 0;
    padding: 0;
}

.account-facts dt {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--text-sm);
    color: var(--muted);
}

.account-facts dd {
    margin: 0;
    font-size: var(--text-base);
    color: var(--fg);
}

/* ─── Results table (My Results on /quizzes) ────────────────────────── */

.results-table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-3) 0 var(--space-4);
    font-size: var(--text-sm);
}

.results-table th {
    font-family: var(--font-display);
    font-weight: 800;
    text-align: left;
    color: var(--muted);
    padding: var(--space-2) var(--space-3);
    border-bottom: 2px solid var(--border);
}

.results-table td {
    padding: var(--space-2) var(--space-3);
    border-bottom: 2px solid var(--surface);
    color: var(--fg);
}

.results-table tbody tr:hover {
    background: var(--surface);
}

.results-table a {
    color: var(--info);
    font-weight: 600;
    text-decoration: none;
}

.results-table a:hover {
    text-decoration: underline;
}

.debug {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    white-space: pre-wrap;
    overflow-x: auto;
    margin: var(--space-3) 0;
}

.options-cell {
    vertical-align: top;
}

.options-list {
    margin: 0;
    padding-left: var(--space-5);
    font-size: var(--text-sm);
    line-height: 1.5;
    color: var(--fg);
}

.options-list li {
    margin-bottom: var(--space-1);
}

/* ─── Responsive ─────────────────────────────────────────────────── */

@media (max-width: 800px) {
    .wrap {
        padding: var(--space-6) var(--space-4) var(--space-8);
    }

    h1 { font-size: var(--text-xl); }
    h2 { font-size: var(--text-lg); }

    table.results th,
    table.results td {
        font-size: var(--text-xs);
        padding: var(--space-2) var(--space-2);
    }

    .btn {
        padding: 10px 16px;
        font-size: var(--text-sm);
    }
}

/* ═══════════════════════════════════════════════════════════════════
 * Redesign layer — path progress, streak/gem pills, tactile options,
 * timer colour shift, question transitions, results cards, reveals.
 * ═══════════════════════════════════════════════════════════════════ */

/* ─── Path progress nodes ─────────────────────────────────────────── */

.qpath {
    display: flex;
    align-items: center;
    gap: 6px;
    /* nowrap + horizontal scroll (instead of wrap) so long sets stay on one
       row. overflow-y is explicit so the active node's scale + shadow ring is
       not clipped — with overflow-x:auto alone, CSS forces overflow-y:auto and
       the circles would be cropped. The vertical padding gives them room. */
    flex-wrap: nowrap;
    margin: var(--space-2) 0 var(--space-4);
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 2px;
    /* Hide scrollbar by default but keep functionality */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    scroll-behavior: smooth;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.qpath::-webkit-scrollbar {
    display: none;
}

.qpath .node {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 13px;
    border: 2px solid var(--border);
    border-bottom: 4px solid var(--border);
    background: var(--bg);
    color: var(--muted);
    transition: all var(--motion-base) var(--ease-spring);
}

.qpath .node.done {
    background: var(--accent);
    border-color: var(--accent);
    border-bottom-color: var(--accent-active);
    color: var(--accent-on);
}

.qpath .node.active {
    background: var(--bg);
    border-color: var(--accent);
    color: var(--accent);
    transform: scale(1.06);
    box-shadow: 0 0 0 3px rgba(88, 204, 2, 0.18);
    animation: node-pulse 1.6s var(--ease-spring) infinite;
}

.qpath .node.locked {
    background: var(--surface);
    color: var(--meta);
}

.qpath .path-line {
    width: 16px;
    height: 4px;
    flex: 0 0 auto;
    background: var(--border);
    border-radius: 999px;
}

.qpath .path-line.done { background: var(--accent); }

@keyframes node-pulse {
    0%, 100% { transform: scale(1.06); }
    50%      { transform: scale(1.12); }
}

/* ─── Streak / gem pills ──────────────────────────────────────────── */

.gami {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin: 0 0 var(--space-4);
}

.gami-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    font-family: var(--font-display);
    font-weight: 800;
    font-size: var(--text-sm);
    border: 2px solid transparent;
    line-height: 1;
}

.gami-pill .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.gami-streak {
    background: rgba(255, 200, 0, 0.16);
    border-color: rgba(255, 200, 0, 0.35);
    color: #7a5900;
}

.gami-gems {
    background: rgba(206, 130, 255, 0.14);
    border-color: rgba(206, 130, 255, 0.30);
    color: #6b2fb8;
}

.gami-pill.bump { animation: gami-bump 420ms var(--ease-spring); }

.gami-streak.broke { animation: gami-break 420ms var(--ease-spring); }

@keyframes gami-bump {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.18); }
    100% { transform: scale(1); }
}

@keyframes gami-break {
    0%   { transform: scale(1); }
    35%  { transform: scale(0.9); filter: grayscale(0.6); }
    100% { transform: scale(1); }
}

/* ─── Home card ───────────────────────────────────────────────────── */

.home-card .home-card-head {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.home-owl {
    width: 48px;
    height: 48px;
    flex: 0 0 auto;
    border-radius: 14px;
    background: var(--accent);
    border-bottom: 4px solid var(--accent-active);
    display: grid;
    place-items: center;
    font-size: 24px;
    color: #fff;
}

.home-title-text {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: var(--text-lg);
    line-height: 1.2;
}

/* ─── Tactile options ─────────────────────────────────────────────── */

.opt {
    -webkit-tap-highlight-color: transparent;
    min-height: 52px;
}

.opt.selected {
    border-color: var(--info);
    border-bottom-color: var(--info);
    background: rgba(28, 176, 246, 0.10);
    box-shadow: 0 4px 0 rgba(28, 176, 246, 0.22);
    color: var(--fg);
}

.opt.selected span { font-weight: 700; }

@keyframes opt-pop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.018); }
    100% { transform: scale(1); }
}

.opt.selected { animation: opt-pop 220ms var(--ease-spring); }

.opt input { accent-color: var(--info); width: 18px; height: 18px; }

/* Staggered entrance — gated behind html.js (set by an inline head script)
   so a JS-less or JS-failed page can never strand content at opacity:0.
   NOTE: the .in rule must repeat the html.js prefix — html.js .opt.enter
   (element + 2 classes) would otherwise out-specificity .opt.enter.in
   (3 classes, no element) and the hidden state would win forever. */
html.js .opt.enter { opacity: 0; transform: translateY(8px); }
html.js .opt.enter.in {
    opacity: 1;
    transform: none;
    transition: opacity 320ms cubic-bezier(0.22, 1, 0.36, 1),
                transform 380ms var(--ease-spring);
}

/* ─── Timer colour shift ──────────────────────────────────────────── */

.timer-bar {
    transition: width 1s linear, background-color 180ms;
}

.timer-bar.warn   { background: var(--warn) !important; }
.timer-bar.danger { background: var(--danger) !important; }

/* ─── Results cards ───────────────────────────────────────────────── */

/* ─── Results page layout ────────────────────────────────────────────── */
/* Lock the viewport and give the remaining height under the nav to .wrap.
   Inside the card, only the questions list scrolls. */
body:has(.results-page) {
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
}
body:has(.results-page) > :not(.wrap) {
    flex: 0 0 auto;
}
body:has(.results-page) .wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-top: var(--space-4);
    padding-bottom: var(--space-4);
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    flex-shrink: 0;
    margin-bottom: var(--space-4);
}
.results-header h1 { margin: 0; }

.card.results-page {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 0;
}

.card.results-page .score-hero,
.card.results-page .gami,
.card.results-page .results-actions {
    flex-shrink: 0;
}

.card.results-page .results-cards {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    margin-bottom: 0;
    padding-right: 4px;
}

/* Thin scrollbar for the internal cards list */
.results-cards::-webkit-scrollbar { width: 6px; }
.results-cards::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.results-cards::-webkit-scrollbar-track { background: transparent; }

.results-cards {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

/* ─── Result card options list ───────────────────────────────────────── */
.rc-options {
    list-style: none;
    margin: var(--space-3) 0 var(--space-2);
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.rc-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    background: var(--surface);
    font-size: var(--text-sm);
}
.rc-opt-marker {
    flex-shrink: 0;
    width: 18px;
    text-align: center;
    font-weight: 700;
}
.rc-opt-text { flex: 1; word-break: break-word; }
.rc-opt-text.opt-code {
    font-family: var(--font-mono, 'Courier New', monospace);
    white-space: pre-wrap;
}
.rc-opt-pill {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--accent-on);
}
.rc-opt-pill.ok  { background: var(--accent); }
.rc-opt-pill.bad { background: var(--danger); }
.rc-opt-correct {
    border-color: var(--success);
    background: color-mix(in srgb, var(--success) 12%, var(--surface));
}
.rc-opt-correct .rc-opt-marker { color: var(--success); }
.rc-opt-wrong {
    border-color: var(--danger);
    background: color-mix(in srgb, var(--danger) 12%, var(--surface));
}
.rc-opt-wrong .rc-opt-marker { color: var(--danger); }

.result-card {
    background: var(--bg);
    border: 2px solid var(--border);
    border-left: 4px solid var(--border);
    border-bottom: 4px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
}

.result-card.ok  { border-left-color: var(--success); }
.result-card.bad { border-left-color: var(--danger); }

.result-card .rc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.result-card .rc-title { font-weight: 800; font-family: var(--font-display); }

.result-card .rc-body {
    margin-top: var(--space-2);
    font-size: var(--text-sm);
    color: var(--fg);
}

.result-card .rc-body .muted { color: var(--muted); }

.tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: var(--surface);
    color: var(--muted);
    border: 2px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 700;
}

.tag.ok   { color: #2e7d00; border-color: rgba(88, 204, 2, 0.4); background: rgba(88,204,2,0.08); }
.tag.bad  { color: var(--danger); border-color: rgba(255, 75, 75, 0.4); background: rgba(255,75,75,0.08); }
.tag.warn { color: #7a5900; border-color: rgba(255, 200, 0, 0.4); background: rgba(255,200,0,0.12); }

/* ─── Score header ────────────────────────────────────────────────── */

.score-hero {
    display: flex;
    align-items: baseline;
    gap: var(--space-4);
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
}

.score-hero .big {
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: -0.03em;
    color: var(--accent);
}

.score-hero .big.ok  { color: var(--accent); }
.score-hero .big.mid { color: var(--warn); }
.score-hero .big.low { color: var(--danger); }

/* ─── Skip button (ghost) ─────────────────────────────────────────── */

.btn.skip {
    color: var(--muted);
}

/* ─── Skip link (accessibility) ───────────────────────────────────── */

a.skip {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--fg);
    color: var(--bg);
    padding: 10px 14px;
    border-radius: 0 0 var(--radius-sm) 0;
    z-index: 10000;
    font-weight: 700;
    font-size: var(--text-sm);
}

a.skip:focus { left: 0; box-shadow: var(--focus-ring); }

/* ─── Reveal animations ───────────────────────────────────────────── */

/* Hidden start state only when JS is active (html.js); without JS the
   content renders visible immediately. visibility:hidden (paired with
   opacity) makes the pre-reveal state inert to hit-testing — a below-the-
   fold element whose IntersectionObserver never fires can no longer
   swallow clicks meant for other content. The .in rule repeats the html.js
   prefix so it out-specificities the hidden state (element + 2 classes
   beats 2 classes alone — the original bug). */
html.js .reveal { opacity: 0; visibility: hidden; transform: translateY(14px); }
html.js .reveal.in {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity 520ms cubic-bezier(0.22, 1, 0.36, 1),
                transform 560ms var(--ease-spring),
                visibility 0s;
    will-change: transform, opacity;
}

/* ─── Reduced motion ──────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
    .qpath .node.active { animation: none; transform: none; }
    /* !important overrides the html.js hidden start states above. */
    .reveal, .opt.enter { opacity: 1 !important; visibility: visible !important; transform: none !important; }
    .quiz-swap { transition: none !important; }
    .quiz-swap.fade-in { opacity: 1 !important; transform: none !important; }
}

/* ─── Layout utilities ─────────────────────────────────────────────
   Appended last so they win same-specificity ties against component
   :hover/:active states, preserving the old inline-style behaviour. */
.inline-form { display: inline; }
.btn.danger { background: #c62828; color: #fff; border-color: #c62828; }

/* ─── Spacing utilities (appended last; win same-specificity ties against
   earlier component rules, replicating the inline-style behaviour they
   replace — safe: no #id or !important margin rule exists on the converted
   elements, so a class at EOF reproduces the inline value exactly) ───── */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mr-2 { margin-right: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }

/* ─── Smooth question transitions ───────────────────────────────────── */

.quiz-swap {
    transition: opacity var(--motion-fast) ease-out, transform var(--motion-fast) ease-out;
}

.quiz-swap.fade-out {
    opacity: 0;
    transform: translateY(-10px);
}

.quiz-swap.fade-in {
    opacity: 0;
    transform: translateY(10px);
    animation: fadeIn var(--motion-base) var(--ease-spring) forwards;
}

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

/* ─── Question card skeleton (shown while the next question loads) ──── */

.card-skeleton:hover { transform: none; box-shadow: none; }

.sk-line {
    height: 16px;
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-3);
    background: linear-gradient(100deg,
        var(--surface) 40%,
        var(--border) 50%,
        var(--surface) 60%);
    background-size: 200% 100%;
    animation: skShimmer 1.2s linear infinite;
}

.sk-line.sk-title { height: 24px; width: 75%; }
.sk-line.short    { width: 50%; }
.sk-line:last-child { margin-bottom: 0; }

.sk-btn-row { display: flex; gap: var(--space-3); margin-top: var(--space-4); }
.sk-btn {
    height: 40px;
    width: 110px;
    border-radius: var(--radius-sm);
    background: var(--surface);
}

@keyframes skShimmer {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .sk-line { animation: none; }
}

/* ─── Admin accordion ─────────────────────────────────────────────────── */
.accordion {
    border: 2px solid var(--border);
    border-bottom-width: 4px;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    background: var(--bg);
    overflow: hidden;
}
.accordion > summary {
    list-style: none;
    cursor: pointer;
    padding: var(--space-4);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    font-size: var(--text-base);
}
.accordion > summary::-webkit-details-marker { display: none; }
.accordion > summary::after {
    content: "▾";
    transition: transform var(--motion-fast) var(--ease-spring);
    font-size: 1.2em;
    opacity: 0.6;
}
.accordion:not([open]) > summary::after {
    transform: rotate(-90deg);
}
.accordion[open] > summary {
    border-bottom: 2px solid var(--border);
}
.accordion-body {
    padding: var(--space-4);
}

/* Nested accordion (e.g. "Create a student" inside Manage Users) — lighter
   variant so nested panels don't read as top-level sections. */
.accordion-inner {
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    margin: var(--space-4) 0;
    background: var(--bg);
    overflow: hidden;
}
.accordion-inner > summary {
    list-style: none;
    cursor: pointer;
    padding: var(--space-3) var(--space-4);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}
.accordion-inner > summary::-webkit-details-marker { display: none; }
.accordion-inner > summary::after {
    content: "▾";
    transition: transform var(--motion-fast) var(--ease-spring);
    font-size: 1.1em;
    opacity: 0.6;
}
.accordion-inner:not([open]) > summary::after {
    transform: rotate(-90deg);
}
.accordion-inner[open] > summary {
    border-bottom: 2px solid var(--border);
}
.accordion-inner .accordion-body {
    padding: var(--space-3) var(--space-4);
}

/* Fold-up button row — sits at the bottom of an open accordion so a long
   panel can be collapsed without scrolling back to the summary. */
.accordion-fold {
    display: flex;
    justify-content: flex-end;
    margin-top: var(--space-4);
    padding-top: var(--space-3);
    border-top: 2px solid var(--border);
}

/* The login-as confirmation modal reuses the shared modal component defined
   earlier (`.modal-overlay` / `.modal-box` / `.modal-message` /
   `.modal-actions`), so no additional rules are needed here. */

/* ─── AI assistant chat (admin) ─────────────────────────────────────────── */
.ai-chat-thread {
    max-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-2);
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-3);
}
.ai-msg {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    line-height: var(--leading-body);
    max-width: 85%;
    white-space: pre-wrap;
    word-break: break-word;
}
.ai-msg-user {
    align-self: flex-end;
    background: var(--accent);
    color: var(--accent-on);
    font-weight: 600;
}
.ai-msg-assistant {
    align-self: flex-start;
    background: var(--bg);
    border: 2px solid var(--border);
    color: var(--fg);
}
.ai-chat-input {
    display: flex;
    gap: var(--space-2);
}
.ai-chat-input .text-input {
    margin-bottom: 0;
    flex: 1;
}

/* ─── Ask AI (results page) ───────────────────────────────────────────── */
.ask-fab {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--accent);
    color: var(--accent-on);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    z-index: 900;
    box-shadow: 0 4px 0 var(--accent-active);
    transition: transform 0.15s, box-shadow 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ask-fab:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--accent-active); }
.ask-panel {
    position: fixed;
    bottom: calc(var(--space-6) + 66px);
    right: var(--space-6);
    width: 340px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 120px);
    display: none;
    flex-direction: column;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    z-index: 899;
    overflow: hidden;
}
.ask-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-bottom: 2px solid var(--border);
    background: var(--surface);
}
.ask-title { font-family: var(--font-display); font-weight: 800; color: var(--fg); }
.ask-close { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--muted); padding: 2px; line-height: 1; }
.ask-question-picker { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); background: var(--surface); }
.ask-q-label { display: block; font-size: var(--text-xs); font-weight: 600; color: var(--muted); margin-bottom: var(--space-1); }
.ask-question-picker .text-input { margin-bottom: 0; font-size: var(--text-sm); }
.ask-thread {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--bg);
    min-height: 140px;
}
.ask-msg {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    line-height: var(--leading-body);
    max-width: 80%;
    white-space: pre-wrap;
    word-break: break-word;
}
.ask-msg-user { align-self: flex-end; background: var(--accent); color: var(--accent-on); font-weight: 600; }
.ask-msg-assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); color: var(--fg); }
.ask-input-row { display: flex; gap: var(--space-2); padding: var(--space-3); border-top: 2px solid var(--border); background: var(--surface); }
.ask-input-row .text-input { margin-bottom: 0; flex: 1; }
@media (max-width: 480px) {
    .ask-panel { width: calc(100vw - 16px); right: var(--space-2); }
    .ask-fab { right: var(--space-3); }
}

/* ─── Generate preview items ───────────────────────────────────────────── */
.gen-q-item {
    padding: var(--space-2);
    border-bottom: 1px solid var(--border);
    font-size: var(--text-sm);
}
.gen-q-item:last-child { border-bottom: none; }

/* ─── Quiz Editor ──────────────────────────────────────────────────────── */
.qe-q-title { font-weight: 600; font-size: var(--text-sm); }
.qe-q-actions { margin-left: auto; display: flex; gap: var(--space-1); align-items: center; }
.qe-q-actions form { margin: 0; }
.qe-q-actions .btn { padding: 2px 8px; font-size: var(--text-xs); }
.qe-type-fields { margin-top: var(--space-2); }
#set-selector { max-width: 400px; }

/* ─── Generate preview + spinner ─────────────────────────────────────── */
.gen-q-item { padding: var(--space-2); border-bottom: 1px solid var(--border); }
.gen-q-item:last-child { border-bottom: none; }
.gen-q-head { display: flex; align-items: center; gap: var(--space-1); flex-wrap: wrap; margin-bottom: 4px; font-size: var(--text-sm); }
.gen-q-topic { color: var(--muted); }
.gen-q-badge { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1px 6px; font-size: var(--text-xs); }
.gen-q-timer { color: #1cb0f6; font-size: var(--text-xs); }
.gen-q-pts { color: var(--accent-active); font-size: var(--text-xs); font-weight: 600; }
.gen-q-prompt { margin: 4px 0; }
.gen-q-code {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-2);
    margin: 4px 0;
    overflow-x: auto;
    font-family: var(--font-mono, 'Courier New', monospace);
    font-size: var(--text-sm, 13px);
    white-space: pre;
    line-height: 1.4;
}
.gen-q-code code { font-family: inherit; background: none; padding: 0; }
.gen-q-opts { list-style: none; padding: 0; margin: 4px 0; }
.gen-q-opts li { padding: 2px 0 2px 8px; border-left: 3px solid transparent; }
.gen-q-opts li.gen-q-correct { border-left-color: var(--accent); color: var(--accent-active); font-weight: 600; }
.gen-q-answer { font-size: var(--text-sm); margin: 4px 0; }
.gen-q-expl { font-size: var(--text-xs); color: var(--muted); margin-top: 4px; font-style: italic; }
.gen-spinner { position: absolute; inset: 0; background: rgba(255,255,255,0.85); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2); z-index: 10; border-radius: inherit; }
.gen-spinner-dot { width: 28px; height: 28px; border: 4px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: gen-spin 0.8s linear infinite; }
@keyframes gen-spin { to { transform: rotate(360deg); } }
#gen-status.gen-error {
    display: block;
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    border: 2px solid var(--danger);
    color: var(--danger);
    font-weight: 700;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    margin-top: var(--space-2);
}
.gen-refine-row { display: flex; gap: var(--space-2); margin: var(--space-2) 0; }
.gen-refine-row input { flex: 1; }

/* ─── Quiz Editor option rows ─────────────────────────────────────────── */
.qe-option-row { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-1); }
.qe-option-label { min-width: 36px; font-weight: 600; font-size: var(--text-sm); color: var(--muted); text-align: right; }
.qe-option-row .text-input { flex: 1; }
.qe-option-correct { display: flex; align-items: center; gap: 4px; font-size: var(--text-xs); white-space: nowrap; }
.qe-option-del { flex-shrink: 0; }
.qe-code-toggle { display: flex; align-items: center; gap: var(--space-1); font-size: var(--text-sm); margin: var(--space-1) 0; }
.qe-options-container { margin-bottom: var(--space-2); }

/* ─── Per-option code block (monospace) ──────────────────────────────── */
.opt span.opt-code {
    font-family: var(--font-mono, 'Courier New', monospace);
    white-space: pre-wrap;
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 2px 6px;
}
/* ─── Quiz editor per-option code checkbox ───────────────────────────── */
.qe-option-code { display: flex; align-items: center; gap: 4px; font-size: var(--text-xs); white-space: nowrap; }
.qe-option-row .code-opt { font-family: var(--font-mono, 'Courier New', monospace); }

/* ─── AI quick action buttons ────────────────────────────────────────── */
.ai-quick-actions { display: flex; gap: var(--space-1); flex-wrap: wrap; margin: var(--space-2) 0; }
.ai-quick-actions .btn { font-size: var(--text-xs); }

/* ─── Stats page ─────────────────────────────────────────────────────── */
.stats-page { padding: var(--space-6); }
.stats-quiz-title { font-weight: 800; font-family: var(--font-display); font-size: var(--text-lg); }

.stats-summary {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}
.stat-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    border: 2px solid var(--border);
    background: var(--surface);
    min-width: 100px;
}
.stat-pill.ok  { border-color: var(--success); }
.stat-pill.mid { border-color: var(--warn); }
.stat-pill.low { border-color: var(--danger); }
.stat-label { font-size: var(--text-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
.stat-value { font-size: var(--text-xl); font-weight: 800; font-family: var(--font-display); color: var(--fg); }
.stat-sub { font-size: var(--text-sm); color: var(--muted); }
.stat-pill.ok .stat-value { color: var(--success); }
.stat-pill.mid .stat-value { color: var(--warn); }
.stat-pill.low .stat-value { color: var(--danger); }

.stats-section-title {
    font-size: var(--text-base);
    font-weight: 800;
    margin-bottom: var(--space-3);
    color: var(--fg);
}

.stats-questions {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}
.stats-q-card {
    padding: var(--space-3) var(--space-4);
    border-left: 4px solid var(--border);
}
.stats-q-card.ok  { border-left-color: var(--success); }
.stats-q-card.mid { border-left-color: var(--warn); }
.stats-q-card.low { border-left-color: var(--danger); }

.stats-q-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
}
.stats-q-title { font-weight: 700; font-family: var(--font-display); }
.stats-q-prompt {
    font-size: var(--text-sm);
    color: var(--muted);
    margin: var(--space-1) 0 var(--space-2);
}

.stats-q-metrics {
    display: flex;
    gap: var(--space-4);
    flex-wrap: wrap;
}
.metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 60px;
}
.metric-value { font-size: var(--text-lg); font-weight: 800; font-family: var(--font-display); }
.metric-value.ok  { color: var(--success); }
.metric-value.bad { color: var(--danger); }
.metric-label { font-size: var(--text-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }

/* Results Page - no page scroll, internal question scroll */
.results-page {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
}
.results-questions-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
}


/* ─── Quizzes page fixed shell ──────────────────────────────────────── */
body:has(.quiz-hub) {
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
}
body:has(.quiz-hub) > :not(.wrap) {
    flex: 0 0 auto;
}
body:has(.quiz-hub) .wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-top: var(--space-4);
    padding-bottom: var(--space-4);
}
.card.quiz-hub {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: 720px;
    margin: var(--space-4) auto 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.quiz-hub > *:not(.quiz-results-scroll) {
    flex-shrink: 0;
}
.quiz-results-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}
.quiz-results-scroll .results-table thead th {
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}