* {
    box-sizing: border-box;
}

:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #6b7280;
    --line: #dfe5ee;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #15803d;
    --danger: #dc2626;
    --warning: #b45309;
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
    --radius: 18px;
}

html, body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

body {
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1, h2, p {
    margin-top: 0;
}

button, input, textarea {
    font: inherit;
}

input, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 13px 14px;
    outline: none;
    background: #fff;
    color: var(--text);
}

input:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

label {
    display: block;
    margin-bottom: 7px;
    font-size: 14px;
    font-weight: 700;
}

form > input,
form > textarea {
    margin-bottom: 16px;
}

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.16), transparent 34%),
        var(--bg);
}

.login-card {
    width: min(100%, 430px);
    padding: 34px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.admin-login {
    margin: 70px auto 0;
}

.brand-badge {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    margin-bottom: 18px;
    border-radius: 16px;
    background: var(--primary);
    color: white;
    font-weight: 800;
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 12px;
    padding: 12px 18px;
    cursor: pointer;
    font-weight: 800;
    text-decoration: none;
}

.btn:hover {
    text-decoration: none;
}

.btn.primary {
    background: var(--primary);
    color: #fff;
}

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

.btn.secondary {
    background: #e9eef7;
    color: var(--text);
}

.full {
    width: 100%;
}

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

.muted-light {
    margin-left: 10px;
    color: #cbd5e1;
    font-size: 14px;
}

.small {
    font-size: 13px;
}

.eyebrow {
    margin-bottom: 8px;
    color: var(--primary);
    font-size: 12px;
    letter-spacing: .12em;
    font-weight: 900;
    text-transform: uppercase;
}

.topbar {
    min-height: 66px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0 5vw;
    background: #111827;
    color: white;
}

.topbar nav {
    display: flex;
    gap: 18px;
}

.topbar nav a {
    color: #e5e7eb;
}

.container {
    width: min(1120px, calc(100% - 32px));
    margin: 38px auto;
}

.container.narrow {
    width: min(760px, calc(100% - 32px));
}

.hero {
    display: grid;
    gap: 22px;
    margin-bottom: 28px;
}

.exam-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 25px;
    background: linear-gradient(135deg, #eef4ff, #ffffff);
    border: 1px solid #cfe0ff;
    border-radius: var(--radius);
}

.panel {
    padding: 26px;
    margin-bottom: 24px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.alert {
    margin-bottom: 18px;
    padding: 13px 15px;
    border-radius: 12px;
    font-weight: 700;
}

.alert.error {
    background: #fff1f2;
    color: #be123c;
    border: 1px solid #fecdd3;
}

.alert.success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.exam-shell {
    width: min(1080px, calc(100% - 32px));
    margin: 26px auto 50px;
}

.stats-grid,
.result-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}

.stat,
.result-box {
    padding: 20px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 16px;
    text-align: center;
}

.stat span,
.result-box span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.stat strong,
.result-box strong {
    font-size: 30px;
}

.typing-card,
.result-card {
    padding: 28px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
}

.typing-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
}

.status-pill,
.badge {
    display: inline-flex;
    align-items: center;
    padding: 7px 10px;
    border-radius: 999px;
    background: #e5e7eb;
    color: #374151;
    font-size: 12px;
    font-weight: 800;
}

.status-pill.running {
    background: #fef3c7;
    color: #92400e;
}

.status-pill.done {
    background: #dcfce7;
    color: #166534;
}

.passage {
    min-height: 155px;
    margin: 20px 0;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #f8fafc;
    font-family: "Courier New", monospace;
    font-size: 24px;
    line-height: 1.65;
    letter-spacing: .015em;
}

.passage .correct {
    color: var(--success);
    background: #dcfce7;
}

.passage .incorrect {
    color: white;
    background: var(--danger);
}

.passage .current {
    border-bottom: 3px solid var(--primary);
}

.typing-input {
    min-height: 150px;
    resize: vertical;
    font-family: "Courier New", monospace;
    font-size: 22px;
    line-height: 1.5;
}

.result-card {
    margin-top: 70px;
    text-align: center;
}

.result-card .actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
}

.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.stack .btn {
    margin-top: 5px;
}

.hidden {
    display: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

code {
    background: #eef2f7;
    padding: 2px 6px;
    border-radius: 6px;
}

@media (max-width: 760px) {
    .topbar {
        padding: 14px 18px;
        align-items: flex-start;
        flex-direction: column;
    }

    .muted-light {
        display: block;
        margin: 4px 0 0;
    }

    .stats-grid,
    .result-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }

    .exam-card,
    .typing-head {
        align-items: stretch;
        flex-direction: column;
    }

    .passage {
        font-size: 19px;
    }
}


.security-code {
    display: inline-block;
    min-width: 110px;
    padding: 6px 10px;
    border: 1px dashed #94a3b8;
    border-radius: 8px;
    background: #f8fafc;
    color: #0f172a;
    font-family: "Courier New", monospace;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: .08em;
    text-align: center;
}

.student-code-table td:nth-child(3) {
    min-width: 230px;
}

@media print {
    .topbar,
    .admin-grid,
    .alert,
    .panel:not(:has(.student-code-table)) {
        display: none !important;
    }

    body {
        background: #fff;
    }

    .container {
        width: 100%;
        margin: 0;
    }

    .panel {
        border: 0;
        box-shadow: none;
    }

    .student-code-table th,
    .student-code-table td {
        padding: 8px;
        font-size: 11px;
    }
}

/* Updated admin dashboard */
.admin-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    padding: 22px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.summary-card span,
.summary-card small {
    display: block;
    color: var(--muted);
}

.summary-card strong {
    display: block;
    margin: 5px 0;
    font-size: 34px;
}

.roster-head {
    align-items: flex-start;
}

.roster-actions,
.roster-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.roster-toolbar {
    justify-content: space-between;
    margin: 18px 0;
}

.roster-toolbar input {
    max-width: 520px;
    margin: 0;
}

.copy-code-btn {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 10px;
    background: #fff;
    color: var(--primary);
    cursor: pointer;
    font-size: 12px;
    font-weight: 800;
}

.copy-code-btn:hover {
    background: #eff6ff;
}

button:disabled {
    opacity: .55;
    cursor: not-allowed;
}

@media (max-width: 760px) {
    .admin-summary-grid {
        grid-template-columns: 1fr;
    }

    .roster-head,
    .roster-toolbar,
    .roster-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .roster-toolbar input {
        max-width: none;
    }
}

@media print {
    .topbar,
    .admin-summary-grid,
    .admin-tools,
    .exam-list-panel,
    .roster-actions,
    .roster-toolbar,
    .alert,
    .no-print {
        display: none !important;
    }

    .student-roster-panel {
        display: block !important;
        margin: 0;
        padding: 0;
        border: 0;
        box-shadow: none;
    }

    .student-code-table {
        width: 100%;
    }

    .student-code-table th,
    .student-code-table td {
        white-space: normal;
        font-size: 11px;
    }
}




/* v9 advanced fixed five-line exam interface */
.exam-v9 {
    --exam-bg: #eef3f9;
    --exam-card: #ffffff;
    --exam-ink: #10213a;
    --exam-muted: #68758a;
    --exam-border: #d8e1ed;
    --exam-primary: #315eea;
    --exam-primary-soft: #e9efff;
    --exam-success: #15803d;
    --exam-success-soft: #dcfce7;
    --exam-danger: #dc2626;
    --exam-danger-soft: #fee2e2;

    height: 100vh;
    height: 100dvh;
    min-height: 560px;
    overflow: hidden;
    background: var(--exam-bg);
    color: var(--exam-ink);
    overscroll-behavior: none;
}

.exam-v9 .exam-header {
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 22px;
    border-bottom: 1px solid var(--exam-border);
    background: #ffffff;
}

.exam-v9 .exam-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 11px;
}

.exam-v9 .exam-brand-mark {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--exam-primary);
    color: #ffffff;
    font-size: 17px;
    font-weight: 900;
}

.exam-v9 .exam-brand-text {
    min-width: 0;
}

.exam-v9 .exam-brand-text strong,
.exam-v9 .exam-brand-text small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.exam-v9 .exam-brand-text strong {
    max-width: 55vw;
    font-size: 16px;
}

.exam-v9 .exam-brand-text small {
    margin-top: 2px;
    max-width: 55vw;
    color: var(--exam-muted);
    font-size: 11px;
}

.exam-v9 .exam-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.exam-v9 .exam-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 82px;
    justify-content: center;
    padding: 7px 11px;
    border-radius: 999px;
    background: #eef2f7;
    color: #4b5563;
    font-size: 12px;
    font-weight: 800;
}

.exam-v9 .status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.exam-v9 .exam-status.running {
    background: #fff7d6;
    color: #a16207;
}

.exam-v9 .exam-status.saving {
    background: var(--exam-success-soft);
    color: var(--exam-success);
}

.exam-v9 .exam-exit {
    padding: 7px 10px;
    border-radius: 8px;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
}

.exam-v9 .exam-exit:hover {
    background: #f1f5f9;
    text-decoration: none;
}

.exam-v9 .exam-workspace {
    width: min(1180px, calc(100% - 28px));
    height: calc(100dvh - 70px);
    margin: 10px auto 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
}

.exam-v9 .exam-metrics {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 1.45fr 1fr 1fr 1fr;
    gap: 8px;
}

.exam-v9 .metric {
    min-height: 66px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 9px 15px;
    border: 1px solid var(--exam-border);
    border-radius: 13px;
    background: var(--exam-card);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.035);
}

.exam-v9 .metric-time {
    border-color: #c8d6ff;
    background: #f7f9ff;
}

.exam-v9 .metric-label {
    margin-bottom: 2px;
    color: var(--exam-muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.exam-v9 .metric strong {
    font-size: 24px;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

.exam-v9 .metric-time strong {
    color: var(--exam-primary);
    font-size: 27px;
}

.exam-v9 .exam-main-card {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 13px 15px 10px;
    border: 1px solid var(--exam-border);
    border-radius: 16px;
    background: var(--exam-card);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.055);
    overflow: hidden;
}

.exam-v9 .guide-toolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.exam-v9 .guide-toolbar > div:first-child {
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.exam-v9 .guide-kicker {
    color: var(--exam-ink);
    font-size: 14px;
    font-weight: 900;
}

.exam-v9 .guide-subtitle {
    color: var(--exam-muted);
    font-size: 11px;
}

.exam-v9 .guide-toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.exam-v9 .guide-chip {
    padding: 4px 8px;
    border: 1px solid var(--exam-border);
    border-radius: 999px;
    background: #f8fafc;
    color: #64748b;
    font-size: 10px;
    font-weight: 800;
}

.exam-v9 .exam-progress-row {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
}

.exam-v9 .exam-progress-track {
    flex: 1 1 auto;
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: #e7edf5;
}

.exam-v9 .exam-progress-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--exam-primary);
    transition: width 120ms linear;
}

.exam-v9 .exam-progress-text {
    flex: 0 0 34px;
    color: var(--exam-muted);
    font-size: 11px;
    text-align: right;
}

/*
 * Browser-safe 5-line viewport.
 * No CSS multiplication inside calc(), and no scrollbar.
 * 5 lines x 30px line-height = 150px content + 24px vertical padding + 2px border = 176px.
 */
.exam-v9 .typing-guide-viewport {
    position: relative;
    flex: 0 0 176px;
    height: 176px;
    min-height: 176px;
    max-height: 176px;
    padding: 12px 16px;
    overflow: hidden !important;
    border: 1px solid #cfd9e7;
    border-radius: 13px;
    background:
        linear-gradient(to bottom, rgba(49, 94, 234, .035), rgba(49, 94, 234, 0)),
        #fbfcfe;
    overscroll-behavior: none;
    scrollbar-width: none;
    contain: layout paint;
}

.exam-v9 .typing-guide-viewport::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
    display: none !important;
}

.exam-v9 .typing-guide-track {
    position: relative;
    width: 100%;
    margin: 0;
    padding: 0;
    transform: translate3d(0, 0, 0);
    will-change: transform;
    color: #1e293b;
    font-family: Consolas, "Courier New", ui-monospace, monospace;
    font-size: 20px;
    font-weight: 500;
    line-height: 30px;
    letter-spacing: .012em;
    white-space: pre-wrap;
    overflow-wrap: normal;
    word-break: normal;
}

.exam-v9 .guide-char {
    border-radius: 3px;
    transition: color 60ms linear, background-color 60ms linear;
}

.exam-v9 .guide-char.is-correct {
    color: #166534;
    background: rgba(220, 252, 231, .7);
}

.exam-v9 .guide-char.is-wrong {
    color: #ffffff;
    background: var(--exam-danger);
}

.exam-v9 .guide-char.is-current {
    color: #0f172a;
    background: #bfdbfe;
    box-shadow: inset 0 -3px 0 var(--exam-primary);
    animation: exam-current-pulse 1.05s ease-in-out infinite;
}

@keyframes exam-current-pulse {
    0%, 100% { background: #bfdbfe; }
    50% { background: #dbeafe; }
}

.exam-v9 .guide-legend {
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin: 5px 2px 4px;
    color: var(--exam-muted);
    font-size: 10px;
    font-weight: 700;
}

.exam-v9 .guide-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.exam-v9 .guide-legend i {
    width: 9px;
    height: 9px;
    display: inline-block;
    border-radius: 3px;
}

.exam-v9 .legend-current {
    background: #bfdbfe;
    box-shadow: inset 0 -2px 0 var(--exam-primary);
}

.exam-v9 .legend-correct {
    background: var(--exam-success-soft);
}

.exam-v9 .legend-wrong {
    background: var(--exam-danger);
}

.exam-v9 .typing-zone {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-top: 1px;
}

.exam-v9 .typing-zone-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
}

.exam-v9 .typing-zone-head label {
    margin: 0;
    color: var(--exam-ink);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.exam-v9 .typing-zone-info {
    display: flex;
    gap: 12px;
    color: var(--exam-muted);
    font-size: 10px;
    font-weight: 700;
}

.exam-v9 .exam-typing-input {
    flex: 1 1 auto;
    width: 100%;
    min-height: 82px;
    max-height: 128px;
    margin: 0;
    resize: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 2px solid #b9c7db;
    border-radius: 12px;
    padding: 11px 13px;
    background: #ffffff;
    color: #172033;
    font-family: Consolas, "Courier New", ui-monospace, monospace;
    font-size: 17px;
    line-height: 1.45;
    caret-color: var(--exam-primary);
    outline: none;
}

.exam-v9 .exam-typing-input:focus {
    border-color: var(--exam-primary);
    box-shadow: 0 0 0 4px rgba(49, 94, 234, .12);
}

.exam-v9 .exam-typing-input::placeholder {
    color: #8b97aa;
}

.exam-v9 .exam-hint-row {
    flex: 0 0 auto;
    min-height: 21px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 6px;
    color: var(--exam-muted);
    font-size: 10px;
}

.exam-v9 .exam-hint-row p {
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.exam-v9 .focus-hint {
    flex: 0 0 auto;
    font-weight: 800;
}

@media (max-height: 720px) {
    .exam-v9 .exam-header {
        height: 50px;
        padding: 0 16px;
    }

    .exam-v9 .exam-brand-mark {
        width: 30px;
        height: 30px;
        flex-basis: 30px;
        border-radius: 8px;
    }

    .exam-v9 .exam-brand-text small {
        display: none;
    }

    .exam-v9 .exam-workspace {
        height: calc(100dvh - 57px);
        margin-top: 5px;
        gap: 5px;
    }

    .exam-v9 .metric {
        min-height: 52px;
        padding: 5px 11px;
    }

    .exam-v9 .metric strong {
        font-size: 19px;
    }

    .exam-v9 .metric-time strong {
        font-size: 22px;
    }

    .exam-v9 .exam-main-card {
        padding: 8px 11px 7px;
    }

    .exam-v9 .guide-subtitle,
    .exam-v9 .guide-legend {
        display: none;
    }

    .exam-v9 .exam-progress-row {
        margin: 5px 0;
    }

    /*
     * Smaller but still exactly five visible lines:
     * 5 x 25px = 125px + 18px padding + 2px border = 145px.
     */
    .exam-v9 .typing-guide-viewport {
        flex-basis: 145px;
        height: 145px;
        min-height: 145px;
        max-height: 145px;
        padding: 9px 12px;
    }

    .exam-v9 .typing-guide-track {
        font-size: 16px;
        line-height: 25px;
    }

    .exam-v9 .exam-typing-input {
        min-height: 65px;
        max-height: 92px;
        padding: 8px 10px;
        font-size: 15px;
    }

    .exam-v9 .exam-hint-row {
        min-height: 16px;
        margin-top: 3px;
    }
}

@media (max-width: 760px) {
    .exam-v9 {
        min-height: 520px;
    }

    .exam-v9 .exam-header {
        height: 50px;
        padding: 0 10px;
    }

    .exam-v9 .exam-brand-text strong {
        max-width: 52vw;
        font-size: 14px;
    }

    .exam-v9 .exam-brand-text small {
        display: none;
    }

    .exam-v9 .exam-header-actions {
        gap: 5px;
    }

    .exam-v9 .exam-status {
        min-width: auto;
        padding: 6px 8px;
        font-size: 10px;
    }

    .exam-v9 .exam-workspace {
        width: calc(100% - 10px);
        height: calc(100dvh - 56px);
        margin-top: 4px;
        gap: 5px;
    }

    .exam-v9 .exam-metrics {
        grid-template-columns: 1.3fr 1fr 1fr 1fr;
        gap: 4px;
    }

    .exam-v9 .metric {
        min-height: 50px;
        padding: 5px 6px;
        border-radius: 9px;
    }

    .exam-v9 .metric-label {
        font-size: 7px;
        letter-spacing: .03em;
    }

    .exam-v9 .metric strong,
    .exam-v9 .metric-time strong {
        font-size: 16px;
    }

    .exam-v9 .exam-main-card {
        padding: 7px;
        border-radius: 11px;
    }

    .exam-v9 .guide-toolbar-right .guide-chip:last-child,
    .exam-v9 .guide-subtitle {
        display: none;
    }

    .exam-v9 .typing-guide-viewport {
        padding-left: 10px;
        padding-right: 10px;
    }

    .exam-v9 .typing-guide-track {
        font-size: 15px;
    }

    .exam-v9 .typing-zone-info {
        gap: 7px;
    }

    .exam-v9 .exam-hint-row p {
        display: none;
    }
}


/* v6 admin filters, editing, and best-result submission */
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

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

.admin-summary-grid {
    grid-template-columns: repeat(4, 1fr);
}

.inline-filter-form {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: min(100%, 420px);
}

.inline-filter-form select {
    min-width: 220px;
}

.compact-btn {
    padding: 8px 12px;
    white-space: nowrap;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0 16px;
    font-weight: 700;
}

.checkbox-row input {
    width: auto;
    margin: 0;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.best-result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    margin-top: 20px;
}

.best-result-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #f8fafc;
}

.best-result-card h2 {
    margin-bottom: 6px;
}

.submission-note {
    padding: 10px 12px;
    border-radius: 10px;
    background: #dcfce7;
    color: #166534;
    font-size: 13px;
}

.inline-form {
    display: inline;
}

.result-card .actions form {
    margin: 0;
}

@media (max-width: 900px) {
    .admin-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .filter-head {
        align-items: stretch;
        flex-direction: column;
    }

    .inline-filter-form {
        min-width: 0;
        width: 100%;
    }
}

@media (max-width: 600px) {
    .admin-summary-grid {
        grid-template-columns: 1fr 1fr;
    }

    .inline-filter-form {
        align-items: stretch;
        flex-direction: column;
    }

    .inline-filter-form select {
        min-width: 0;
    }
}


/* v10 scoring dashboard and selectable interface themes */
.theme-control {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    z-index: 50;
}

.theme-control-inline {
    margin-right: 2px;
}

.theme-control-floating {
    position: fixed;
    top: 14px;
    right: 14px;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.theme-control-icon {
    color: currentColor;
    font-size: 13px;
    opacity: .72;
}

.theme-select {
    width: auto;
    min-width: 90px;
    margin: 0;
    padding: 6px 27px 6px 9px;
    border: 1px solid rgba(148, 163, 184, .4);
    border-radius: 9px;
    background: rgba(255, 255, 255, .1);
    color: inherit;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: none;
}

.topbar .theme-select,
.exam-header .theme-select {
    border-color: rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .08);
    color: inherit;
}

.topbar .theme-select option,
.exam-header .theme-select option {
    color: #111827;
}

.student-dashboard {
    display: grid;
    gap: 22px;
}

.dashboard-welcome {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
}

.dashboard-welcome h1 {
    margin-bottom: 5px;
}

.dashboard-battle-rating {
    padding: 25px;
    border: 1px solid color-mix(in srgb, var(--primary) 22%, var(--line));
    border-radius: 22px;
    background: radial-gradient(circle at top right, color-mix(in srgb, var(--primary) 12%, transparent), transparent 42%), var(--panel);
    box-shadow: var(--shadow);
}

.rank-profile-card { display: flex; justify-content: space-between; gap: 24px; margin: 20px 0; padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); }
.rank-profile-card h2 { font-size: 22px; }
.rank-profile-progress { flex: 1; max-width: 420px; min-width: 220px; }
.rank-profile-progress > strong { font-size: 13px; }
.rank-profile-progress .small { line-height: 1.5; margin: 12px 0; }
.tier-badge { display: inline-flex; align-items: center; padding: 6px 12px; border: 1px solid currentColor; border-radius: 999px; font-size: 13px; font-weight: 850; background: var(--panel); color: var(--muted); }
.tier-bronze { color: #a56938; }
.tier-silver { color: #65758c; }
.tier-gold { color: #9c7417; }
.tier-platinum { color: #158776; }
.tier-diamond { color: #327ad3; }
.tier-master { color: #a253d6; }
html[data-theme-mode="dark"] .tier-bronze { color: #edb681; }
html[data-theme-mode="dark"] .tier-silver { color: #c4cede; }
html[data-theme-mode="dark"] .tier-gold { color: #f0cd68; }
html[data-theme-mode="dark"] .tier-platinum { color: #71d7c1; }
html[data-theme-mode="dark"] .tier-diamond { color: #91bbff; }
html[data-theme-mode="dark"] .tier-master { color: #d4a3ff; }
.tier-ladder { display: flex; flex-wrap: wrap; gap: 16px; margin: 20px 0; }
.tier-ladder > div { display: grid; gap: 7px; }
.tier-ladder small { color: var(--muted); }
@media (max-width: 760px) { .rank-profile-card { flex-direction: column; } .rank-profile-progress { max-width: none; min-width: 0; } }

.dashboard-battle-rating.is-pass { border-color: color-mix(in srgb, var(--success) 38%, var(--line)); }
.dashboard-battle-rating-head { display: flex; align-items: center; justify-content: space-between; gap: 22px; }
.dashboard-battle-rating-head h2 { margin-bottom: 4px; }
.dashboard-pass-mark { min-width: 150px; padding: 13px 18px; border: 2px solid var(--primary); border-radius: 17px; background: color-mix(in srgb, var(--primary) 9%, var(--panel)); text-align: center; }
.dashboard-battle-rating.is-pass .dashboard-pass-mark { border-color: var(--success); background: color-mix(in srgb, var(--success) 10%, var(--panel)); }
.dashboard-pass-mark strong, .dashboard-pass-mark span { display: block; }
.dashboard-pass-mark strong { color: var(--primary); font-size: 28px; letter-spacing: .04em; line-height: 1; }
.dashboard-battle-rating.is-pass .dashboard-pass-mark strong { color: var(--success); }
.dashboard-pass-mark span { margin-top: 5px; color: var(--muted); font-size: 13px; font-weight: 800; }
.dashboard-rating-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 22px; }
.dashboard-rating-stats > div { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb, var(--panel) 78%, var(--bg)); }
.dashboard-rating-stats span, .dashboard-rating-stats small { display: block; color: var(--muted); font-size: 11px; }
.dashboard-rating-stats strong { display: block; margin: 5px 0 3px; color: var(--text); font-size: 24px; font-variant-numeric: tabular-nums; }
.dashboard-rating-bars { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 20px; }
.rating-bar-label { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.rating-bar-label strong { color: var(--text); }
.rating-bar { height: 8px; margin-top: 7px; overflow: hidden; border-radius: 99px; background: var(--line); }
.rating-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #8b5cf6); }
.dashboard-battle-rating.is-pass .rating-bar i { background: linear-gradient(90deg, var(--success), #4ade80); }
.dashboard-rating-detail { margin: 18px 0 14px; color: var(--muted); line-height: 1.55; }

.dashboard-best {
    min-width: 210px;
    padding: 15px 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel);
    box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}

.dashboard-best span,
.dashboard-best small {
    display: block;
}

.dashboard-best span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.dashboard-best strong {
    display: inline-block;
    margin: 3px 0;
    color: var(--primary);
    font-size: 34px;
    line-height: 1;
}

.dashboard-best small {
    color: var(--muted);
    font-size: 11px;
}

.dashboard-exam-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 22px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, .12), transparent 38%),
        var(--panel);
    box-shadow: var(--shadow);
}

.dashboard-exam-main {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 16px;
}

.exam-icon-large {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    display: grid;
    place-items: center;
    border-radius: 15px;
    background: var(--primary);
    color: #fff;
    font-size: 22px;
    font-weight: 900;
}

.dashboard-exam-main h2 {
    margin-bottom: 5px;
}

.dashboard-exam-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(82px, 1fr));
    gap: 8px;
}

.dashboard-exam-stats > div {
    min-width: 82px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, .5);
    text-align: center;
}

.dashboard-exam-stats span,
.dashboard-exam-stats small {
    display: block;
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
}

.dashboard-exam-stats strong {
    display: block;
    margin: 3px 0;
    font-size: 20px;
}

.dashboard-start-btn {
    white-space: nowrap;
}

.exam-v10 .exam-metrics-v10 {
    grid-template-columns: 1.22fr repeat(5, 1fr);
}

.exam-v10 .metric small {
    display: block;
    margin-top: 3px;
    color: var(--exam-muted);
    font-size: 9px;
    font-weight: 700;
}

.exam-v10 .metric-gross strong {
    color: #0369a1;
}

.exam-v10 .metric-accuracy strong {
    color: #7c3aed;
}

.exam-v10 .metric-net {
    border-color: rgba(21, 128, 61, .3);
}

.exam-v10 .metric-net strong {
    color: var(--exam-success);
}

.exam-v10 .metric-errors strong {
    color: var(--exam-danger);
}

.exam-v10 .metric-best {
    border-color: rgba(49, 94, 234, .28);
    background: rgba(49, 94, 234, .045);
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.exam-v10 .metric-best strong {
    color: var(--exam-primary);
}

.exam-v10 .metric-best.is-new-best {
    transform: translateY(-2px);
    border-color: #22c55e;
    box-shadow: 0 8px 22px rgba(34, 197, 94, .16);
}

.exam-v10 .metric-best.is-new-best strong,
.exam-v10 .metric-best.is-new-best small {
    color: #15803d;
}

.result-grid-v10 {
    grid-template-columns: repeat(5, 1fr);
}

.result-grid-v10 .result-box small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
}

.result-grid-v10 .result-net {
    border-color: rgba(21, 128, 61, .28);
    background: rgba(22, 163, 74, .04);
}

.result-grid-v10 .result-net strong {
    color: var(--success);
}

.result-formula-note {
    margin: 18px auto 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg);
    color: var(--muted);
    font-size: 12px;
}

.best-gross-line {
    margin: -2px 0 8px;
    color: var(--muted);
    font-size: 12px;
}

/* Theme: Midnight */
html[data-theme-mode="dark"] {
    color-scheme: dark;
    --bg: #07111f;
    --panel: #0f1b2d;
    --text: #e8eef8;
    --muted: #9bacbf;
    --line: #253851;
    --primary: #70a5ff;
    --primary-dark: #4f8cff;
    --success: #4ade80;
    --danger: #fb7185;
    --shadow: 0 18px 50px rgba(0, 0, 0, .3);
}

html[data-theme-mode="dark"] body {
    background: var(--bg);
}

html[data-theme-mode="dark"] .topbar {
    background: #050c16;
}

html[data-theme-mode="dark"] input,
html[data-theme-mode="dark"] textarea,
html[data-theme-mode="dark"] select,
html[data-theme-mode="dark"] .dashboard-exam-stats > div {
    background: #0b1626;
    color: var(--text);
}

html[data-theme-mode="dark"] .exam-card {
    background: linear-gradient(135deg, #132846, #0f1b2d);
    border-color: #2a4366;
}

html[data-theme-mode="dark"] .passage,
html[data-theme-mode="dark"] .best-result-card,
html[data-theme-mode="dark"] .result-formula-note {
    background: #0b1626;
}

html[data-theme-mode="dark"] body.exam-v10 {
    --exam-bg: #07111f;
    --exam-card: #0f1b2d;
    --exam-ink: #edf4ff;
    --exam-muted: #9aacbf;
    --exam-border: #263a55;
    --exam-primary: #70a5ff;
    --exam-primary-soft: #142c4d;
    --exam-success: #4ade80;
    --exam-success-soft: #123522;
    --exam-danger: #fb7185;
    --exam-danger-soft: #411c28;
}

html[data-theme-mode="dark"] .exam-v10 .exam-header {
    background: #081321;
}

html[data-theme-mode="dark"] .exam-v10 .typing-guide-viewport,
html[data-theme-mode="dark"] .exam-v10 .exam-typing-input {
    background: #0a1728;
    color: #edf4ff;
}

html[data-theme-mode="dark"] .exam-v10 .typing-guide-track {
    color: #d9e6f5;
}

/* Theme: Ocean */
html[data-theme="ocean"] {
    --bg: #eef9fb;
    --panel: #ffffff;
    --text: #0b3340;
    --muted: #56727c;
    --line: #cde3e8;
    --primary: #0891b2;
    --primary-dark: #0e7490;
    --success: #15803d;
    --danger: #dc2626;
    --shadow: 0 18px 50px rgba(8, 145, 178, .10);
}

html[data-theme="ocean"] .topbar {
    background: #073b4c;
}

html[data-theme="ocean"] body.exam-v10 {
    --exam-bg: #eaf7fa;
    --exam-card: #ffffff;
    --exam-ink: #0b3340;
    --exam-muted: #5b7780;
    --exam-border: #c7e0e6;
    --exam-primary: #0891b2;
    --exam-primary-soft: #dff5f9;
}

/* Theme: Forest */
html[data-theme="forest"] {
    --bg: #f1f7f2;
    --panel: #ffffff;
    --text: #173222;
    --muted: #607467;
    --line: #d4e2d7;
    --primary: #2f855a;
    --primary-dark: #276749;
    --success: #15803d;
    --danger: #c2413b;
    --shadow: 0 18px 50px rgba(47, 133, 90, .10);
}

html[data-theme="forest"] .topbar {
    background: #173b2a;
}

html[data-theme="forest"] body.exam-v10 {
    --exam-bg: #edf6ef;
    --exam-card: #ffffff;
    --exam-ink: #173222;
    --exam-muted: #627568;
    --exam-border: #d0e1d4;
    --exam-primary: #2f855a;
    --exam-primary-soft: #e1f2e7;
}

@media (max-width: 980px) {
    .dashboard-exam-card {
        grid-template-columns: 1fr;
    }

    .dashboard-exam-stats {
        width: 100%;
    }

    .dashboard-start-btn {
        width: 100%;
    }

    .exam-v10 .exam-metrics-v10 {
        grid-template-columns: repeat(3, 1fr);
    }

    .result-grid-v10 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 700px) {
    .dashboard-welcome {
        align-items: stretch;
        flex-direction: column;
    }

    .dashboard-best {
        min-width: 0;
    }

    .dashboard-exam-main {
        align-items: flex-start;
    }

    .dashboard-exam-stats {
        grid-template-columns: repeat(3, 1fr);
    }

    .exam-v10 .exam-metrics-v10 {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }

    .exam-v10 .metric {
        min-height: 48px;
    }

    .exam-v10 .metric small {
        display: none;
    }

    .result-grid-v10 {
        grid-template-columns: repeat(2, 1fr);
    }

    .theme-control-icon {
        display: none;
    }

    .theme-select {
        min-width: 78px;
        padding-left: 6px;
        font-size: 10px;
    }
}

@media (max-height: 720px) and (min-width: 701px) {
    .exam-v10 .exam-metrics-v10 {
        grid-template-columns: 1.2fr repeat(5, 1fr);
    }

    .exam-v10 .metric {
        min-height: 48px;
    }

    .exam-v10 .metric small {
        display: none;
    }
}


/* v11 compatibility safeguard:
   the advanced exam structural system was introduced under exam-v9.
   exam.php now carries both classes, and this keeps basic page sizing safe. */
.exam-page.exam-v10 {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
}


/* v12 TypingMaster-style completed-word lock */
.exam-v10 .exam-typing-input.word-lock-rejected {
    animation: word-lock-reject 180ms ease-in-out 2;
}

@keyframes word-lock-reject {
    0%, 100% {
        border-color: var(--exam-primary);
        transform: translateX(0);
    }

    50% {
        border-color: var(--exam-danger);
        box-shadow: 0 0 0 4px rgba(220, 38, 38, .12);
        transform: translateX(2px);
    }
}

/* v11 focus-mode typing canvas: a calm, full-screen layout inspired by modern typing trainers. */
.exam-v11 {
    --exam-bg: #f4f6fb;
    --exam-card: rgba(255, 255, 255, .76);
    --exam-ink: #172033;
    --exam-muted: #718096;
    --exam-border: rgba(148, 163, 184, .26);
    --exam-primary: #4f46e5;
    --exam-success: #16a36a;
    --exam-danger: #e05252;
    background: radial-gradient(circle at 50% -20%, rgba(99, 102, 241, .12), transparent 44%), var(--exam-bg);
}

.exam-v11 .exam-header {
    width: min(1500px, calc(100% - 64px));
    height: 72px;
    margin: 0 auto;
    padding: 0;
    border-bottom: 1px solid var(--exam-border);
    background: transparent;
}

.exam-v11 .exam-workspace {
    width: min(1500px, calc(100% - 64px));
    height: calc(100dvh - 72px);
    margin: 0 auto;
    gap: 16px;
}

.exam-v11 .exam-metrics-v10 {
    grid-template-columns: 1.4fr repeat(5, 1fr);
    gap: 10px;
}

.exam-v11 .metric {
    min-height: 72px;
    padding: 12px 16px;
    border: 1px solid var(--exam-border);
    border-radius: 15px;
    background: var(--exam-card);
    box-shadow: 0 10px 30px rgba(51, 65, 85, .06);
    backdrop-filter: blur(12px);
}

.exam-v11 .metric strong { font-size: 27px; }
.exam-v11 .metric-time strong { color: var(--exam-primary); font-size: 31px; }
.exam-v11 .metric-net strong { color: var(--exam-success); }
.exam-v11 .metric-errors strong { color: var(--exam-danger); }

.exam-v11 .exam-main-card {
    min-height: 0;
    padding: 8px 0 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow: hidden;
}

.exam-v11 .guide-toolbar { padding: 0 4px; }
.exam-v11 .guide-kicker { font-size: 15px; letter-spacing: .01em; }
.exam-v11 .guide-subtitle { font-size: 12px; }
.exam-v11 .guide-chip { background: rgba(255, 255, 255, .42); }

.exam-v11 .exam-progress-row { margin: 12px 4px 8px; }
.exam-v11 .exam-progress-track { height: 5px; background: rgba(148, 163, 184, .22); }
.exam-v11 .exam-progress-bar { background: linear-gradient(90deg, #6366f1, #8b5cf6); }

.exam-v11 .typing-guide-viewport {
    flex: 1 1 42%;
    width: 100%;
    height: auto;
    min-height: 250px;
    max-height: none;
    padding: 25px clamp(12px, 4vw, 70px);
    border: 0;
    border-radius: 20px;
    background: rgba(255, 255, 255, .36);
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, .12);
}

.exam-v11 .typing-guide-track {
    color: #64748b;
    font-size: clamp(22px, 2.3vw, 32px);
    font-weight: 550;
    line-height: 1.72;
    letter-spacing: .018em;
}

.exam-v11 .guide-char.is-correct { color: #1f9d68; background: transparent; }
.exam-v11 .guide-char.is-wrong { color: #fff; background: #e05252; }
.exam-v11 .guide-char.is-current { color: var(--exam-ink); background: transparent; box-shadow: none; animation: none; }
.exam-v11 .guide-legend { margin: 8px 4px 6px; }

.exam-v11 .typing-zone {
    flex: 1 1 38%;
    min-height: 150px;
    padding: 0 clamp(12px, 4vw, 70px);
}

.exam-v11 .typing-zone-head { margin-bottom: 8px; }
.exam-v11 .typing-zone-head label { color: var(--exam-muted); font-size: 11px; }
.exam-v11 .typing-zone-info { font-size: 11px; }

.exam-v11 .exam-typing-input {
    min-height: 118px;
    max-height: none;
    padding: 18px 20px;
    border: 1px solid rgba(99, 102, 241, .26);
    border-radius: 16px;
    background: rgba(255, 255, 255, .78);
    color: var(--exam-ink);
    font-size: 20px;
    line-height: 1.55;
    box-shadow: 0 15px 35px rgba(51, 65, 85, .07);
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.exam-v11 .exam-typing-input:focus {
    border-color: var(--exam-primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, .12), 0 18px 40px rgba(51, 65, 85, .1);
    transform: translateY(-1px);
}

.exam-v11 .exam-hint-row { margin: 8px 4px 0; }
.exam-v11 .focus-hint { border-radius: 999px; padding: 5px 9px; background: rgba(255, 255, 255, .65); }

.exam-v11 .exam-fullscreen {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 10px;
    border: 1px solid var(--exam-border);
    border-radius: 9px;
    background: rgba(255, 255, 255, .46);
    color: var(--exam-muted);
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.exam-v11 .exam-fullscreen:hover,
.exam-v11 .exam-fullscreen[aria-pressed="true"] { border-color: var(--exam-primary); color: var(--exam-primary); }

html[data-theme-mode="dark"] .exam-v11 {
    --exam-bg: #0b1220;
    --exam-card: rgba(15, 27, 45, .78);
    --exam-ink: #edf4ff;
    --exam-muted: #9aacbf;
    --exam-border: rgba(86, 113, 148, .34);
    --exam-primary: #8aaeff;
    background: radial-gradient(circle at 50% -20%, rgba(79, 140, 255, .18), transparent 44%), var(--exam-bg);
}

html[data-theme-mode="dark"] .exam-v11 .typing-guide-viewport { background: rgba(15, 27, 45, .52); }
html[data-theme-mode="dark"] .exam-v11 .typing-guide-track { color: #91a3ba; }
html[data-theme-mode="dark"] .exam-v11 .guide-char.is-current { color: var(--exam-ink); }
html[data-theme-mode="dark"] .exam-v11 .exam-typing-input { background: rgba(10, 23, 40, .82); color: var(--exam-ink); }

@media (max-width: 980px) {
    .exam-v11 .exam-header, .exam-v11 .exam-workspace { width: min(100% - 28px, 760px); }
    .exam-v11 .exam-metrics-v10 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 700px) {
    .exam-v11 .exam-header { height: 64px; }
    .exam-v11 .exam-workspace { width: calc(100% - 20px); height: calc(100dvh - 64px); gap: 10px; }
    .exam-v11 .exam-brand-text small, .exam-v11 .exam-fullscreen span { display: none; }
    .exam-v11 .exam-header-actions { gap: 5px; }
    .exam-v11 .exam-metrics-v10 { grid-template-columns: repeat(3, 1fr); gap: 5px; }
    .exam-v11 .metric { min-height: 52px; padding: 7px 9px; }
    .exam-v11 .metric strong, .exam-v11 .metric-time strong { font-size: 20px; }
    .exam-v11 .typing-guide-viewport { min-height: 220px; padding: 18px 10px; }
    .exam-v11 .typing-guide-track { font-size: 21px; line-height: 1.65; }
    .exam-v11 .typing-zone { padding: 0 10px; }
    .exam-v11 .exam-typing-input { min-height: 105px; font-size: 17px; }
    .exam-v11 .guide-subtitle, .exam-v11 .guide-toolbar-right { display: none; }
    .exam-v11 .exam-hint-row p { display: none; }
}

html[data-theme-mode="dark"] .exam-v10 .exam-typing-input.word-lock-rejected {
    box-shadow: 0 0 0 4px rgba(251, 113, 133, .15);
}


/* v13 student submission dashboard and tabbed admin interface */
.dashboard-alert {
    margin-bottom: 0;
}

.dashboard-exam-card-v13 {
    grid-template-columns: minmax(0, 1fr) auto auto;
}

.dashboard-exam-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 180px;
}

.dashboard-submit-form {
    margin: 0;
}

.dashboard-submit-form .btn,
.dashboard-exam-actions .btn {
    width: 100%;
}

.success-btn {
    background: #15803d;
    color: #fff;
}

.success-btn:hover {
    background: #166534;
}

.submitted-result-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 17px;
    border: 1px solid #bbf7d0;
    border-radius: 15px;
    background: #f0fdf4;
}

.submitted-result-banner > div {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 11px;
}

.submitted-result-banner strong,
.submitted-result-banner small {
    display: block;
}

.submitted-result-banner small {
    margin-top: 2px;
    color: #4b6353;
}

.submitted-result-icon {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #15803d;
    color: #fff;
    font-weight: 900;
}

.attempt-status-saved {
    display: inline-flex;
    padding: 5px 8px;
    border-radius: 999px;
    background: #eef2f7;
    color: #64748b;
    font-size: 11px;
    font-weight: 800;
}

.admin-container-v13 {
    width: min(1380px, calc(100% - 30px));
}

.admin-page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 22px;
    margin-bottom: 18px;
}

.admin-page-heading h1 {
    margin-bottom: 6px;
}

.admin-heading-badge {
    min-width: 120px;
    padding: 11px 15px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    text-align: center;
}

.admin-heading-badge span,
.admin-heading-badge small {
    display: block;
}

.admin-heading-badge span {
    color: var(--primary);
    font-size: 25px;
    font-weight: 900;
}

.admin-heading-badge small {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.admin-tabs {
    position: sticky;
    top: 8px;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
    margin: 0 0 20px;
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
    backdrop-filter: blur(10px);
}

.admin-tabs a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 11px;
    color: var(--muted);
    text-decoration: none;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}

.admin-tabs a:hover {
    background: var(--bg);
    text-decoration: none;
}

.admin-tabs a.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 7px 18px rgba(37, 99, 235, .18);
}

.admin-tabs span,
.admin-tabs small {
    display: block;
}

.admin-tabs span {
    font-weight: 900;
}

.admin-tabs small {
    font-size: 9px;
    opacity: .78;
}

.admin-summary-grid-v13 {
    grid-template-columns: repeat(6, 1fr);
    margin-bottom: 22px;
}

.admin-overview-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(280px, .7fr);
    gap: 22px;
}

.overview-submission-list {
    display: grid;
    gap: 4px;
}

.overview-submission-list article {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.overview-submission-list article:last-child {
    border-bottom: 0;
}

.overview-student-avatar {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    background: var(--bg);
    color: var(--primary);
    font-weight: 900;
}

.overview-submission-info {
    min-width: 0;
}

.overview-submission-info strong,
.overview-submission-info span,
.overview-submission-info small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.overview-submission-info span,
.overview-submission-info small {
    color: var(--muted);
    font-size: 11px;
}

.overview-score {
    text-align: right;
}

.overview-score strong,
.overview-score span {
    display: block;
}

.overview-score strong {
    color: var(--primary);
    font-size: 20px;
}

.overview-score span {
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
}

.admin-quick-actions {
    align-self: start;
}

.admin-action-card {
    display: block;
    margin-top: 9px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg);
    color: var(--text);
    text-decoration: none;
}

.admin-action-card:hover {
    border-color: var(--primary);
    text-decoration: none;
}

.admin-action-card strong,
.admin-action-card span {
    display: block;
}

.admin-action-card span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
}

.admin-form-card {
    scroll-margin-top: 100px;
}

.admin-form-heading {
    margin-bottom: 16px;
}

.admin-inline-form-grid {
    display: grid;
    grid-template-columns: 1fr 1.35fr 1fr 1fr auto;
    align-items: end;
    gap: 12px;
}

.admin-inline-form-grid input {
    margin-bottom: 0;
}

.admin-inline-form-action {
    padding-bottom: 0;
}

.admin-exam-grid {
    display: grid;
    grid-template-columns: minmax(360px, .8fr) minmax(0, 1.35fr);
    gap: 22px;
}

.admin-exam-grid > .panel {
    align-self: start;
}

.admin-result-filter-panel {
    position: sticky;
    top: 94px;
    z-index: 10;
}

.admin-results-filter {
    display: grid;
    grid-template-columns: 1.2fr repeat(3, minmax(145px, .8fr)) auto;
    align-items: end;
    gap: 10px;
}

.admin-results-filter input,
.admin-results-filter select {
    margin: 0;
}

.admin-result-filter-actions {
    display: flex;
    gap: 7px;
}

.admin-results-table-wrap {
    max-height: 63vh;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.admin-results-table {
    min-width: 1500px;
}

.admin-results-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--panel);
}

.admin-results-table td small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 10px;
}

.admin-results-table .submitted-row {
    background: rgba(22, 163, 74, .045);
}

html[data-theme-mode="dark"] .submitted-result-banner {
    border-color: #22583b;
    background: #0e2b1d;
}

html[data-theme-mode="dark"] .submitted-result-banner small {
    color: #a9c8b4;
}

html[data-theme-mode="dark"] .admin-tabs {
    background: rgba(15, 27, 45, .94);
}

@media (max-width: 1150px) {
    .admin-summary-grid-v13 {
        grid-template-columns: repeat(3, 1fr);
    }

    .admin-inline-form-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .admin-inline-form-action {
        grid-column: 1 / -1;
    }

    .admin-results-filter {
        grid-template-columns: repeat(2, 1fr);
    }

    .admin-result-filter-actions {
        grid-column: 1 / -1;
    }
}

@media (max-width: 900px) {
    .dashboard-exam-card-v13 {
        grid-template-columns: 1fr;
    }

    .dashboard-exam-actions {
        width: 100%;
    }

    .admin-overview-grid,
    .admin-exam-grid {
        grid-template-columns: 1fr;
    }

    .admin-result-filter-panel {
        position: static;
    }
}

@media (max-width: 700px) {
    .admin-container-v13 {
        width: calc(100% - 16px);
    }

    .admin-page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .admin-heading-badge {
        width: 100%;
    }

    .admin-tabs {
        position: static;
        grid-template-columns: repeat(2, 1fr);
    }

    .admin-tabs a {
        align-items: flex-start;
        flex-direction: column;
        gap: 1px;
    }

    .admin-summary-grid-v13 {
        grid-template-columns: repeat(2, 1fr);
    }

    .admin-inline-form-grid,
    .admin-results-filter {
        grid-template-columns: 1fr;
    }

    .admin-result-filter-actions {
        grid-column: auto;
        flex-direction: column;
    }

    .admin-result-filter-actions .btn {
        width: 100%;
    }

    .submitted-result-banner {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media print {
    .admin-tabs,
    .admin-page-heading,
    .admin-result-filter-panel,
    .topbar,
    .theme-control,
    .no-print,
    .roster-actions,
    .admin-form-card,
    .admin-quick-actions {
        display: none !important;
    }

    .admin-container-v13 {
        width: 100%;
        margin: 0;
    }

    .admin-results-table-wrap {
        max-height: none;
        overflow: visible;
        border: 0;
    }

    .admin-results-table {
        min-width: 0;
        font-size: 9px;
    }
}


/* v14 compact result tables, student results page, and advanced admin filters */
.admin-results-table-wrap {
    max-height: 66vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.admin-results-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    font-size: 9.5px;
}

.admin-results-table th,
.admin-results-table td {
    padding: 7px 5px;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
    vertical-align: middle;
    line-height: 1.2;
}

.admin-results-table th {
    font-size: 8px;
    letter-spacing: .02em;
}

.admin-results-table td strong {
    font-size: 10px;
}

.admin-results-table td small {
    font-size: 8px;
}

.admin-results-table th:nth-child(1),
.admin-results-table td:nth-child(1) {
    width: 3%;
}

.admin-results-table th:nth-child(2),
.admin-results-table td:nth-child(2) {
    width: 11%;
}

.admin-results-table th:nth-child(3),
.admin-results-table td:nth-child(3) {
    width: 7%;
}

.admin-results-table th:nth-child(4),
.admin-results-table td:nth-child(4) {
    width: 9%;
}

.admin-results-table th:nth-child(5),
.admin-results-table td:nth-child(5),
.admin-results-table th:nth-child(6),
.admin-results-table td:nth-child(6),
.admin-results-table th:nth-child(7),
.admin-results-table td:nth-child(7) {
    width: 6%;
}

.admin-results-table th:nth-child(8),
.admin-results-table td:nth-child(8),
.admin-results-table th:nth-child(9),
.admin-results-table td:nth-child(9),
.admin-results-table th:nth-child(10),
.admin-results-table td:nth-child(10) {
    width: 5%;
}

.admin-results-table th:nth-child(11),
.admin-results-table td:nth-child(11) {
    width: 5%;
}

.admin-results-table th:nth-child(12),
.admin-results-table td:nth-child(12) {
    width: 8%;
}

.admin-results-table th:nth-child(13),
.admin-results-table td:nth-child(13),
.admin-results-table th:nth-child(14),
.admin-results-table td:nth-child(14) {
    width: 10%;
}

.admin-results-table .status-pill,
.admin-results-table .attempt-status-saved {
    padding: 4px 5px;
    font-size: 8px;
    white-space: normal;
    line-height: 1.05;
}

.admin-results-filter-v14 {
    grid-template-columns: repeat(5, minmax(120px, 1fr));
}

.admin-results-filter-v14 .filter-search {
    grid-column: span 2;
}

.admin-results-filter-v14 label {
    font-size: 10px;
}

.admin-results-filter-v14 input,
.admin-results-filter-v14 select {
    padding: 9px 10px;
    font-size: 11px;
}

.admin-results-filter-v14 .admin-result-filter-actions {
    align-self: end;
}

.student-results-page {
    display: grid;
    gap: 20px;
}

.results-page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
}

.results-page-heading h1 {
    margin-bottom: 6px;
}

.student-result-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(110px, 1fr));
    gap: 8px;
}

.student-result-summary > div {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--panel);
    text-align: center;
}

.student-result-summary span,
.student-result-summary small {
    display: block;
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
}

.student-result-summary strong {
    display: block;
    margin: 3px 0;
    color: var(--primary);
    font-size: 23px;
}

.student-best-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 14px;
}

.student-best-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 17px;
    background: var(--panel);
    box-shadow: 0 8px 24px rgba(15, 23, 42, .04);
}

.student-best-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.student-best-card-head h2 {
    margin-bottom: 0;
}

.student-best-metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
    margin: 16px 0;
}

.student-best-metrics > div {
    padding: 9px 8px;
    border-radius: 10px;
    background: var(--bg);
    text-align: center;
}

.student-best-metrics span,
.student-best-metrics small {
    display: block;
    color: var(--muted);
    font-size: 8px;
    font-weight: 800;
    text-transform: uppercase;
}

.student-best-metrics strong {
    display: block;
    margin: 2px 0;
    font-size: 18px;
}

.student-best-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

.student-best-footer > small {
    color: var(--muted);
    font-size: 10px;
}

.student-best-footer form {
    flex: 0 0 auto;
    margin: 0;
}

.student-results-table {
    width: 100%;
    font-size: 11px;
}

.student-results-table th,
.student-results-table td {
    padding: 9px 8px;
}

.student-results-table th {
    font-size: 9px;
}

.student-results-table .submitted-row {
    background: rgba(22, 163, 74, .045);
}

@media (max-width: 1150px) {
    .admin-results-filter-v14 {
        grid-template-columns: repeat(3, 1fr);
    }

    .admin-results-filter-v14 .filter-search {
        grid-column: span 1;
    }
}

@media (max-width: 850px) {
    .results-page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .student-result-summary {
        width: 100%;
    }

    .student-best-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .student-best-footer .btn {
        width: 100%;
    }

    .admin-results-filter-v14 {
        grid-template-columns: repeat(2, 1fr);
    }

    .admin-results-table {
        font-size: 8px;
    }

    .admin-results-table th,
    .admin-results-table td {
        padding: 5px 3px;
    }
}

@media (max-width: 600px) {
    .student-result-summary,
    .student-best-metrics,
    .admin-results-filter-v14 {
        grid-template-columns: 1fr 1fr;
    }

    .student-best-grid {
        grid-template-columns: 1fr;
    }
}


/* v15 admin result delete action */
.admin-results-table th:nth-child(15),
.admin-results-table td:nth-child(15) {
    width: 6%;
    text-align: center;
}

.admin-results-table th:nth-child(2),
.admin-results-table td:nth-child(2) {
    width: 10%;
}

.admin-results-table th:nth-child(4),
.admin-results-table td:nth-child(4) {
    width: 8%;
}

.admin-results-table th:nth-child(13),
.admin-results-table td:nth-child(13),
.admin-results-table th:nth-child(14),
.admin-results-table td:nth-child(14) {
    width: 8%;
}

.delete-result-form {
    margin: 0;
}

.delete-result-btn {
    border: 1px solid #fecaca;
    border-radius: 7px;
    padding: 4px 6px;
    background: #fff1f2;
    color: #be123c;
    font-size: 8px;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
}

.delete-result-btn:hover {
    border-color: #fda4af;
    background: #ffe4e6;
}

html[data-theme-mode="dark"] .delete-result-btn {
    border-color: #65303c;
    background: #3b1822;
    color: #fda4af;
}

@media (max-width: 900px) {
    .delete-result-btn {
        padding: 4px 5px;
        font-size: 7px;
    }
}

/* Top scores */
.top-scores-page { padding-bottom: 48px; }
.top-scores-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 30px 0 24px; }
.top-scores-heading h1 { margin-bottom: 8px; }
.my-rank-card { min-width: 150px; padding: 16px 20px; text-align: center; border: 1px solid color-mix(in srgb, var(--primary) 25%, var(--line)); border-radius: 16px; background: color-mix(in srgb, var(--primary) 6%, var(--panel)); }
.my-rank-card span, .my-rank-card small { display: block; color: var(--muted); font-size: 12px; }
.my-rank-card strong { display: block; margin: 3px 0; color: var(--primary); font-size: 30px; }
.top-scores-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.top-scores-toolbar h2 { margin-bottom: 0; }
.score-filter-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.score-filter-links .btn { padding: 9px 13px; font-size: 13px; }
.top-scores-panel { margin-top: 20px; }
.top-scores-table td:first-child, .top-scores-table th:first-child { width: 84px; }
.top-scores-table td:nth-last-child(1) { white-space: nowrap; }
.score-rank { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; padding: 5px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); font-weight: 800; }
.score-rank.gold { background: #fff3c4; color: #8a5c00; }
.score-rank.silver { background: #edf1f5; color: #5c6875; }
.score-rank.bronze { background: #f7e0d2; color: #8d4b2e; }
.score-student-no { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.score-wpm { color: var(--primary); font-variant-numeric: tabular-nums; }
.my-score-row { background: color-mix(in srgb, var(--primary) 6%, transparent); }
html[data-theme-mode="dark"] .score-rank.gold { background: #584511; color: #ffe18a; }
html[data-theme-mode="dark"] .score-rank.silver { background: #35404d; color: #d4dbe4; }
html[data-theme-mode="dark"] .score-rank.bronze { background: #553526; color: #f4b294; }
@media (max-width: 760px) {
    .top-scores-heading, .top-scores-toolbar { align-items: stretch; flex-direction: column; }
    .score-filter-links { justify-content: flex-start; }
    .top-scores-table { min-width: 720px; }
    .dashboard-battle-rating-head { align-items: stretch; flex-direction: column; }
    .dashboard-pass-mark { align-self: flex-start; }
    .dashboard-rating-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-rating-bars { grid-template-columns: 1fr; }
}

/* Shared badge artwork and smooth passage movement. */
.badge-icon { width: 19px; height: 19px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tier-badge, .badge-chip, .mode-title { display: inline-flex; align-items: center; gap: 6px; }
.badge-chip .badge-icon { width: 16px; height: 16px; }
.tier-badge .badge-icon { width: 21px; height: 21px; }
.smooth-guide-viewport { position: relative; }
.smooth-guide-track { position: relative; will-change: transform; transition: transform 180ms cubic-bezier(.25,.8,.25,1); }
.smooth-guide-track .guide-char { transition: color 100ms ease, background-color 100ms ease; }
.typing-guide-caret { position: absolute; top: 0; left: 0; width: 2px; border-radius: 2px; background: var(--exam-primary, var(--primary)); pointer-events: none; transition: transform 100ms cubic-bezier(.45,0,.55,1); will-change: transform; z-index: 1; }
.typing-guide-caret[hidden] { display: none; }
.typing-guide-caret.is-idle { animation:typing-caret-rest 1.2s ease-in-out infinite; }
@keyframes typing-caret-rest { 0%,100% { opacity:1; } 50% { opacity:.35; } }
.guide-reset { transition: none !important; }
@media (prefers-reduced-motion: reduce) {
    .smooth-guide-track, .smooth-guide-track .guide-char, .typing-guide-caret { transition: none !important; }
    .typing-guide-caret.is-idle { animation:none; }
}
/* Midnight contrast: keep component surfaces and their text in the same palette. */
html[data-theme-mode="dark"] :is(.stat, .result-box, .typing-card, .result-card, .summary-card, .copy-code-btn) {
    background: var(--panel);
    color: var(--text);
}
html[data-theme-mode="dark"] :is(code, .security-code, .btn.secondary) {
    background: #182b44;
    color: #edf4ff;
    border-color: #39516f;
}
html[data-theme-mode="dark"] .copy-code-btn:hover { background: #182b44; color: #a9caff; }
html[data-theme-mode="dark"] :is(.btn.primary, .brand-badge, .exam-brand-mark, .exam-icon-large) { color: #07111f; }
html[data-theme-mode="dark"] :is(input, textarea)::placeholder { color: #a8b8cc; opacity: 1; }
html[data-theme-mode="dark"] select option { background: #0b1626; color: #e8eef8; }
html[data-theme-mode="dark"] :is(.status-pill, .badge, .attempt-status-saved) { background: #24364f; color: #dce7f6; }
html[data-theme-mode="dark"] .status-pill.running { background: #453514; color: #ffe19a; }
html[data-theme-mode="dark"] :is(.status-pill.done, .alert.success) { background: #123522; color: #8aefad; border-color: #285a3c; }
html[data-theme-mode="dark"] .alert.error { background: #411c28; color: #ffb3bf; border-color: #743443; }
html[data-theme-mode="dark"] .passage .correct { background: #123522; color: #8aefad; }
html[data-theme-mode="dark"] .passage .incorrect { background: #91334a; color: #fff; }
html[data-theme-mode="dark"] .exam-v10 :is(.metric-gross strong, .metric-best strong) { color: #9ed8ff; }
html[data-theme-mode="dark"] .exam-v10 .metric-accuracy strong { color: #d4b5ff; }
html[data-theme-mode="dark"] .exam-v10 .guide-chip { background: #182b44; color: #bdcce0; }
html[data-theme-mode="dark"] .admin-tabs a.active { color: #07111f; }
html[data-theme-mode="dark"] .exam-v11 .guide-char.is-correct { color: #6ee7a2; }
html[data-theme-mode="dark"] .exam-v10 .guide-char.is-wrong { background: #91334a; color: #fff; }
/* High-contrast passage states for both exams and team battles. */
html[data-theme-mode="dark"] :is(.typing-guide-viewport,.fight-guide) { background:#101d30; color:#c3cfdf; }
html[data-theme-mode="dark"] :is(.typing-guide-track,.fight-guide-track,.smooth-guide-track) { color:#c3cfdf; }
html[data-theme-mode="dark"] :is(.exam-v11,.fight-guide) .guide-char.is-correct { color:#84edb1; background:transparent; }
html[data-theme-mode="dark"] :is(.exam-v11,.fight-guide) .guide-char.is-wrong { color:#fff0f3; background:#743044; text-decoration:underline; text-decoration-color:#ffb2c3; text-underline-offset:3px; }
html[data-theme-mode="dark"] :is(.exam-v11,.fight-guide) .guide-char.is-current { color:#ffffff; background:transparent; }
html[data-theme-mode="dark"] .smooth-guide-viewport .typing-guide-caret { background:#a8c7ff; opacity:1; }
html[data-theme-mode="dark"] :is(#fightInput,.exam-v11 .exam-typing-input) { background:#0c1829; color:#edf4ff; caret-color:#a8c7ff; }
html[data-theme-mode="dark"] :is(#fightInput,.exam-v11 .exam-typing-input)::placeholder { color:#b3c1d4; opacity:1; }

/* Shared student navigation: identical sizing and link order on every page. */
html { scrollbar-gutter: stable; }
html .topbar.site-header { min-height: 84px; display: grid; grid-template-columns: auto 132px minmax(0,1fr); align-items: center; gap: 24px; padding: 16px clamp(20px,3vw,56px); background: var(--panel); color: var(--text); border-bottom: 1px solid var(--line); }
html .topbar.site-header .site-brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; white-space: nowrap; }
html .topbar.site-header .site-brand-mark { display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px; background: #315eea; color: #fff; font-size: 13px; font-weight: 850; letter-spacing: -.3px; }
html .topbar.site-header .site-brand strong { display: block; font-size: 17px; line-height: 22px; letter-spacing: -.4px; }
html .topbar.site-header .site-brand small { display: block; font-size: 11px; line-height: 17px; font-weight: 500; color: var(--muted); }
html .topbar.site-header .site-theme-slot { width: 132px; min-height: 36px; }
html .topbar.site-header .theme-control { width: 132px; margin: 0; gap: 6px; }
html .topbar.site-header .theme-select { width: 112px; min-width: 112px; height: 36px; padding: 6px 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 12px; font-weight: 650; border-radius: 9px; }
html .topbar.site-header .theme-select option { color: var(--text); background: var(--panel); }
html .topbar.site-header .theme-control-icon { color: var(--muted); }
html .topbar.site-header nav { min-width: 0; display: flex; justify-content: flex-end; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: thin; }
html .topbar.site-header nav > a { display: block; flex-shrink: 0; padding: 9px 10px; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 650; line-height: 18px; white-space: nowrap; text-decoration: none; }
html .topbar.site-header nav > a:hover { color: var(--text); background: var(--bg); }
html .topbar.site-header nav > a[aria-current="page"] { color: var(--primary); background: color-mix(in srgb,var(--primary) 10%,var(--panel)); }
html .topbar.site-header a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (max-width: 1250px) {
    html .topbar.site-header { grid-template-columns: 1fr 132px; gap: 12px 20px; }
    html .topbar.site-header nav { grid-column: 1/-1; justify-content: flex-start; }
}
@media (max-width: 600px) {
    html .topbar.site-header { padding: 12px 16px; }
    html .topbar.site-header .site-brand { gap: 8px; }
    html .topbar.site-header .site-brand strong { font-size: 15px; }
    html .topbar.site-header .site-brand-mark { width: 32px; height: 32px; font-size: 11px; border-radius: 9px; }
    html .topbar.site-header .site-brand small { font-size: 10px; }
}
@media (max-width: 600px) {
    html .topbar.site-header { gap: 12px; }
    html .topbar.site-header .site-brand { min-width: 0; }
    html .topbar.site-header .site-brand > span:last-child { min-width: 0; }
    html .topbar.site-header .site-brand strong { overflow: hidden; text-overflow: ellipsis; }
    html .topbar.site-header .site-theme-slot, html .topbar.site-header .theme-control { width: 110px; }
    html .topbar.site-header .theme-select { width: 90px; min-width: 90px; }
    html .topbar.site-header { grid-template-columns: minmax(0,1fr) 110px; }
}

html[data-theme="lavender"] { color-scheme:light; --bg:#f5f3ff; --panel:#ffffff; --text:#2e1065; --muted:#5b4775; --line:#c4b5fd; --primary:#6d28d9; --primary-dark:#5b21b6; }
html[data-theme="lavender"] body.exam-v10 { --exam-bg:#f5f3ff; --exam-card:#ffffff; --exam-ink:#2e1065; --exam-muted:#5b4775; --exam-border:#c4b5fd; --exam-primary:#6d28d9; --exam-primary-soft:#ede9fe; }

html[data-theme="sand"] { color-scheme:light; --bg:#faf6ed; --panel:#fffdf8; --text:#382b19; --muted:#695638; --line:#d8c7a3; --primary:#80551c; --primary-dark:#684316; }
html[data-theme="sand"] body.exam-v10 { --exam-bg:#faf6ed; --exam-card:#fffdf8; --exam-ink:#382b19; --exam-muted:#695638; --exam-border:#d8c7a3; --exam-primary:#80551c; --exam-primary-soft:#f3e9d2; }

/* Pair foregrounds with their surfaces, including native form controls. */
html[data-theme="ocean"] { --primary:#0e7490; }
html[data-theme="forest"] { --muted:#4b6353; }
html[data-theme-mode="dark"] { --muted:#b6c5d8; }
html[data-theme] :is(input,textarea)::placeholder { color:var(--muted); opacity:1; }
html[data-theme] select option { color:var(--text); background:var(--panel); }
html[data-theme-mode="dark"] :is(.btn.primary:hover,.btn.primary:focus-visible) { background:#a9caff; color:#07111f; }
html[data-theme] :is(a,button,input,textarea,select):focus-visible { outline:3px solid var(--primary); outline-offset:3px; }

/* Executive Navy: neutral surfaces with a restrained accent. */
html[data-theme="navy"] { color-scheme:light; --bg:#f1f4f8; --panel:#ffffff; --text:#172b46; --muted:#485b73; --line:#c4cedc; --primary:#24476d; --primary-dark:#193653; --success:#15803d; --danger:#b91c1c; --shadow:0 12px 36px rgba(24,35,48,.08); }
html[data-theme="navy"] body.exam-v10 { --exam-bg:#f1f4f8; --exam-card:#ffffff; --exam-ink:#172b46; --exam-muted:#485b73; --exam-border:#c4cedc; --exam-primary:#24476d; --exam-primary-soft:#e4edf7; }

/* Studio Teal: neutral surfaces with a restrained accent. */
html[data-theme="teal"] { color-scheme:light; --bg:#f0f7f6; --panel:#ffffff; --text:#183d39; --muted:#456560; --line:#bdd5cf; --primary:#16675f; --primary-dark:#10524c; --success:#15803d; --danger:#b91c1c; --shadow:0 12px 36px rgba(24,35,48,.08); }
html[data-theme="teal"] body.exam-v10 { --exam-bg:#f0f7f6; --exam-card:#ffffff; --exam-ink:#183d39; --exam-muted:#456560; --exam-border:#bdd5cf; --exam-primary:#16675f; --exam-primary-soft:#dcefe9; }

/* Graphite: neutral surfaces with a restrained accent. */
html[data-theme="graphite"] { color-scheme:light; --bg:#f3f4f5; --panel:#ffffff; --text:#252b33; --muted:#525d69; --line:#c9cfd6; --primary:#424e5d; --primary-dark:#303b49; --success:#15803d; --danger:#b91c1c; --shadow:0 12px 36px rgba(24,35,48,.08); }
html[data-theme="graphite"] body.exam-v10 { --exam-bg:#f3f4f5; --exam-card:#ffffff; --exam-ink:#252b33; --exam-muted:#525d69; --exam-border:#c9cfd6; --exam-primary:#424e5d; --exam-primary-soft:#e5e9ef; }

/* Burgundy: neutral surfaces with a restrained accent. */
html[data-theme="burgundy"] { color-scheme:light; --bg:#faf4f5; --panel:#ffffff; --text:#431f2c; --muted:#75515e; --line:#dfc5ce; --primary:#8b304e; --primary-dark:#70223d; --success:#15803d; --danger:#b91c1c; --shadow:0 12px 36px rgba(24,35,48,.08); }
html[data-theme="burgundy"] body.exam-v10 { --exam-bg:#faf4f5; --exam-card:#ffffff; --exam-ink:#431f2c; --exam-muted:#75515e; --exam-border:#dfc5ce; --exam-primary:#8b304e; --exam-primary-soft:#f4e1e8; }

/* Cobalt Blue: coordinated interface and typing surfaces. */
html[data-theme="cobalt"] { color-scheme:light; --bg:#eff4fc; --panel:#ffffff; --text:#182e50; --muted:#4b607d; --line:#c5d2e6; --primary:#2457a6; --primary-dark:#194483; --success:#15803d; --danger:#b91c1c; --shadow:0 12px 36px rgba(24,35,48,.08); }
html[data-theme="cobalt"] :is(body.exam-v10,body.exam-v11) { --exam-bg:#eff4fc; --exam-card:#ffffff; --exam-ink:#182e50; --exam-muted:#4b607d; --exam-border:#c5d2e6; --exam-primary:#2457a6; --exam-primary-soft:#e2ebfa; --exam-success:#15803d; --exam-success-soft:#dcfce7; --exam-danger:#b91c1c; --exam-danger-soft:#fee2e2; }
html[data-theme="cobalt"] :is(.typing-guide-viewport,.exam-typing-input) { background:#ffffff; color:#182e50; }
html[data-theme="cobalt"] .typing-guide-track { color:#4b607d; }

/* Soft Sage: coordinated interface and typing surfaces. */
html[data-theme="sage"] { color-scheme:light; --bg:#f2f6f0; --panel:#ffffff; --text:#293c27; --muted:#53694e; --line:#cbd7c5; --primary:#416b39; --primary-dark:#31532b; --success:#15803d; --danger:#b91c1c; --shadow:0 12px 36px rgba(24,35,48,.08); }
html[data-theme="sage"] :is(body.exam-v10,body.exam-v11) { --exam-bg:#f2f6f0; --exam-card:#ffffff; --exam-ink:#293c27; --exam-muted:#53694e; --exam-border:#cbd7c5; --exam-primary:#416b39; --exam-primary-soft:#e5eedf; --exam-success:#15803d; --exam-success-soft:#dcfce7; --exam-danger:#b91c1c; --exam-danger-soft:#fee2e2; }
html[data-theme="sage"] :is(.typing-guide-viewport,.exam-typing-input) { background:#ffffff; color:#293c27; }
html[data-theme="sage"] .typing-guide-track { color:#53694e; }

/* Royal Plum: coordinated interface and typing surfaces. */
html[data-theme="plum"] { color-scheme:light; --bg:#f7f2f8; --panel:#ffffff; --text:#402344; --muted:#705375; --line:#dac8de; --primary:#773a83; --primary-dark:#5e2c68; --success:#15803d; --danger:#b91c1c; --shadow:0 12px 36px rgba(24,35,48,.08); }
html[data-theme="plum"] :is(body.exam-v10,body.exam-v11) { --exam-bg:#f7f2f8; --exam-card:#ffffff; --exam-ink:#402344; --exam-muted:#705375; --exam-border:#dac8de; --exam-primary:#773a83; --exam-primary-soft:#f0e2f3; --exam-success:#15803d; --exam-success-soft:#dcfce7; --exam-danger:#b91c1c; --exam-danger-soft:#fee2e2; }
html[data-theme="plum"] :is(.typing-guide-viewport,.exam-typing-input) { background:#ffffff; color:#402344; }
html[data-theme="plum"] .typing-guide-track { color:#705375; }

/* Warm Copper: coordinated interface and typing surfaces. */
html[data-theme="copper"] { color-scheme:light; --bg:#faf4ef; --panel:#fffdfb; --text:#462c20; --muted:#785843; --line:#e0cbbc; --primary:#92502c; --primary-dark:#753d20; --success:#15803d; --danger:#b91c1c; --shadow:0 12px 36px rgba(24,35,48,.08); }
html[data-theme="copper"] :is(body.exam-v10,body.exam-v11) { --exam-bg:#faf4ef; --exam-card:#fffdfb; --exam-ink:#462c20; --exam-muted:#785843; --exam-border:#e0cbbc; --exam-primary:#92502c; --exam-primary-soft:#f5e6da; --exam-success:#15803d; --exam-success-soft:#dcfce7; --exam-danger:#b91c1c; --exam-danger-soft:#fee2e2; }
html[data-theme="copper"] :is(.typing-guide-viewport,.exam-typing-input) { background:#fffdfb; color:#462c20; }
html[data-theme="copper"] .typing-guide-track { color:#785843; }

/* Arctic Blue: coordinated interface and typing surfaces. */
html[data-theme="arctic"] { color-scheme:light; --bg:#f0f8fa; --panel:#ffffff; --text:#173b47; --muted:#466873; --line:#bfd9df; --primary:#176b80; --primary-dark:#105568; --success:#15803d; --danger:#b91c1c; --shadow:0 12px 36px rgba(24,35,48,.08); }
html[data-theme="arctic"] :is(body.exam-v10,body.exam-v11) { --exam-bg:#f0f8fa; --exam-card:#ffffff; --exam-ink:#173b47; --exam-muted:#466873; --exam-border:#bfd9df; --exam-primary:#176b80; --exam-primary-soft:#def0f4; --exam-success:#15803d; --exam-success-soft:#dcfce7; --exam-danger:#b91c1c; --exam-danger-soft:#fee2e2; }
html[data-theme="arctic"] :is(.typing-guide-viewport,.exam-typing-input) { background:#ffffff; color:#173b47; }
html[data-theme="arctic"] .typing-guide-track { color:#466873; }

/* Olive Stone: coordinated interface and typing surfaces. */
html[data-theme="olive"] { color-scheme:light; --bg:#f6f6ef; --panel:#fffffc; --text:#353820; --muted:#636746; --line:#d4d6bb; --primary:#626b2f; --primary-dark:#4c5423; --success:#15803d; --danger:#b91c1c; --shadow:0 12px 36px rgba(24,35,48,.08); }
html[data-theme="olive"] :is(body.exam-v10,body.exam-v11) { --exam-bg:#f6f6ef; --exam-card:#fffffc; --exam-ink:#353820; --exam-muted:#636746; --exam-border:#d4d6bb; --exam-primary:#626b2f; --exam-primary-soft:#ebedd9; --exam-success:#15803d; --exam-success-soft:#dcfce7; --exam-danger:#b91c1c; --exam-danger-soft:#fee2e2; }
html[data-theme="olive"] :is(.typing-guide-viewport,.exam-typing-input) { background:#fffffc; color:#353820; }
html[data-theme="olive"] .typing-guide-track { color:#636746; }

/* Curated ten-theme collection. Dark themes share accessible component states. */
html[data-theme="midnight"][data-theme-mode="dark"] { color-scheme:dark; --bg:#081221; --panel:#101f33; --text:#edf5ff; --muted:#b6c8df; --line:#3d5878; --primary:#95beff; --primary-dark:#b5d2ff; --success:#95e8b5; --danger:#ffb6c1; --theme-soft:#192f49; --theme-on-accent:#081221; --shadow:0 16px 42px rgba(0,0,0,.24); }
html[data-theme="midnight"] :is(body.exam-v10,body.exam-v11) { --exam-bg:#081221; --exam-card:#101f33; --exam-ink:#edf5ff; --exam-muted:#b6c8df; --exam-border:#3d5878; --exam-primary:#95beff; --exam-primary-soft:#192f49; --exam-success:#95e8b5; --exam-success-soft:#153b29; --exam-danger:#ffb6c1; --exam-danger-soft:#542535; background:var(--exam-bg); }
html[data-theme="ocean"][data-theme-mode="dark"] { color-scheme:dark; --bg:#061c24; --panel:#0c2b36; --text:#e6fcff; --muted:#a7cfd6; --line:#366574; --primary:#6edce8; --primary-dark:#a0f0f7; --success:#95e8b5; --danger:#ffb6c1; --theme-soft:#123f4b; --theme-on-accent:#061c24; --shadow:0 16px 42px rgba(0,0,0,.24); }
html[data-theme="ocean"] :is(body.exam-v10,body.exam-v11) { --exam-bg:#061c24; --exam-card:#0c2b36; --exam-ink:#e6fcff; --exam-muted:#a7cfd6; --exam-border:#366574; --exam-primary:#6edce8; --exam-primary-soft:#123f4b; --exam-success:#95e8b5; --exam-success-soft:#153b29; --exam-danger:#ffb6c1; --exam-danger-soft:#542535; background:var(--exam-bg); }
html[data-theme="forest"][data-theme-mode="dark"] { color-scheme:dark; --bg:#0a1c16; --panel:#122d23; --text:#edfff4; --muted:#afcfbc; --line:#406c55; --primary:#86dfa7; --primary-dark:#b3f3cb; --success:#95e8b5; --danger:#ffb6c1; --theme-soft:#1b4232; --theme-on-accent:#0a1c16; --shadow:0 16px 42px rgba(0,0,0,.24); }
html[data-theme="forest"] :is(body.exam-v10,body.exam-v11) { --exam-bg:#0a1c16; --exam-card:#122d23; --exam-ink:#edfff4; --exam-muted:#afcfbc; --exam-border:#406c55; --exam-primary:#86dfa7; --exam-primary-soft:#1b4232; --exam-success:#95e8b5; --exam-success-soft:#153b29; --exam-danger:#ffb6c1; --exam-danger-soft:#542535; background:var(--exam-bg); }
html[data-theme="lavender"][data-theme-mode="dark"] { color-scheme:dark; --bg:#1a1028; --panel:#291b3b; --text:#f8edff; --muted:#d0b9e3; --line:#715584; --primary:#d5acff; --primary-dark:#e9ccff; --success:#95e8b5; --danger:#ffb6c1; --theme-soft:#3b2954; --theme-on-accent:#1a1028; --shadow:0 16px 42px rgba(0,0,0,.24); }
html[data-theme="lavender"] :is(body.exam-v10,body.exam-v11) { --exam-bg:#1a1028; --exam-card:#291b3b; --exam-ink:#f8edff; --exam-muted:#d0b9e3; --exam-border:#715584; --exam-primary:#d5acff; --exam-primary-soft:#3b2954; --exam-success:#95e8b5; --exam-success-soft:#153b29; --exam-danger:#ffb6c1; --exam-danger-soft:#542535; background:var(--exam-bg); }
html[data-theme="navy"][data-theme-mode="dark"] { color-scheme:dark; --bg:#11132b; --panel:#1d2143; --text:#f0f1ff; --muted:#bcc3e6; --line:#545f94; --primary:#adb7ff; --primary-dark:#cdd3ff; --success:#95e8b5; --danger:#ffb6c1; --theme-soft:#2c325b; --theme-on-accent:#11132b; --shadow:0 16px 42px rgba(0,0,0,.24); }
html[data-theme="navy"] :is(body.exam-v10,body.exam-v11) { --exam-bg:#11132b; --exam-card:#1d2143; --exam-ink:#f0f1ff; --exam-muted:#bcc3e6; --exam-border:#545f94; --exam-primary:#adb7ff; --exam-primary-soft:#2c325b; --exam-success:#95e8b5; --exam-success-soft:#153b29; --exam-danger:#ffb6c1; --exam-danger-soft:#542535; background:var(--exam-bg); }
html[data-theme="burgundy"][data-theme-mode="dark"] { color-scheme:dark; --bg:#241017; --panel:#381c28; --text:#ffedf3; --muted:#dfb9c9; --line:#855568; --primary:#ffaac8; --primary-dark:#ffcee0; --success:#95e8b5; --danger:#ffb6c1; --theme-soft:#502939; --theme-on-accent:#241017; --shadow:0 16px 42px rgba(0,0,0,.24); }
html[data-theme="burgundy"] :is(body.exam-v10,body.exam-v11) { --exam-bg:#241017; --exam-card:#381c28; --exam-ink:#ffedf3; --exam-muted:#dfb9c9; --exam-border:#855568; --exam-primary:#ffaac8; --exam-primary-soft:#502939; --exam-success:#95e8b5; --exam-success-soft:#153b29; --exam-danger:#ffb6c1; --exam-danger-soft:#542535; background:var(--exam-bg); }
html[data-theme="copper"][data-theme-mode="dark"] { color-scheme:dark; --bg:#21160f; --panel:#33251a; --text:#fff4e6; --muted:#d8c1a7; --line:#826347; --primary:#f3bd83; --primary-dark:#ffdbb5; --success:#95e8b5; --danger:#ffb6c1; --theme-soft:#493426; --theme-on-accent:#21160f; --shadow:0 16px 42px rgba(0,0,0,.24); }
html[data-theme="copper"] :is(body.exam-v10,body.exam-v11) { --exam-bg:#21160f; --exam-card:#33251a; --exam-ink:#fff4e6; --exam-muted:#d8c1a7; --exam-border:#826347; --exam-primary:#f3bd83; --exam-primary-soft:#493426; --exam-success:#95e8b5; --exam-success-soft:#153b29; --exam-danger:#ffb6c1; --exam-danger-soft:#542535; background:var(--exam-bg); }
html[data-theme="graphite"][data-theme-mode="dark"] { color-scheme:dark; --bg:#111315; --panel:#1d2125; --text:#f4f6f8; --muted:#bec6cf; --line:#5a6571; --primary:#c6d3df; --primary-dark:#e0e9f1; --success:#95e8b5; --danger:#ffb6c1; --theme-soft:#2c3238; --theme-on-accent:#111315; --shadow:0 16px 42px rgba(0,0,0,.24); }
html[data-theme="graphite"] :is(body.exam-v10,body.exam-v11) { --exam-bg:#111315; --exam-card:#1d2125; --exam-ink:#f4f6f8; --exam-muted:#bec6cf; --exam-border:#5a6571; --exam-primary:#c6d3df; --exam-primary-soft:#2c3238; --exam-success:#95e8b5; --exam-success-soft:#153b29; --exam-danger:#ffb6c1; --exam-danger-soft:#542535; background:var(--exam-bg); }
html[data-theme-mode="dark"] :is(.topbar,.exam-v10 .exam-header,.exam-v11 .exam-header) { background:var(--panel); color:var(--text); }
html[data-theme-mode="dark"] :is(input,textarea,select,.dashboard-exam-stats>div,.passage,.best-result-card,.result-formula-note,.stat,.result-box,.typing-card,.result-card,.summary-card,.copy-code-btn) { background:var(--panel); color:var(--text); border-color:var(--line); }
html[data-theme-mode="dark"] :is(code,.security-code,.btn.secondary,.guide-chip,.status-pill,.badge,.attempt-status-saved) { background:var(--theme-soft); color:var(--text); border-color:var(--line); }
html[data-theme-mode="dark"] :is(.exam-card) { background:linear-gradient(135deg,var(--theme-soft),var(--panel)); border-color:var(--line); }
html[data-theme-mode="dark"] :is(.btn.primary,.btn.primary:hover,.brand-badge,.exam-brand-mark,.exam-icon-large,.admin-tabs a.active) { background:var(--primary); color:var(--theme-on-accent); }
html[data-theme-mode="dark"] :is(.btn.primary:hover,.btn.primary:focus-visible) { background:var(--primary-dark); }
html[data-theme-mode="dark"] :is(.typing-guide-viewport,.fight-guide,.exam-v11 .typing-guide-viewport) { background:var(--panel); color:var(--muted); }
html[data-theme-mode="dark"] :is(.typing-guide-track,.fight-guide-track,.smooth-guide-track,.exam-v11 .typing-guide-track) { color:var(--muted); }
html[data-theme-mode="dark"] :is(#fightInput,.exam-v10 .exam-typing-input,.exam-v11 .exam-typing-input) { background:var(--panel); color:var(--text); caret-color:var(--primary); }
html[data-theme-mode="dark"] :is(input,textarea)::placeholder { color:var(--muted); opacity:1; }
html[data-theme-mode="dark"] select option { background:var(--panel); color:var(--text); }
html[data-theme-mode="dark"] :is(.exam-v11,.fight-guide) .guide-char.is-current { color:var(--text); }
html[data-theme-mode="dark"] .copy-code-btn:hover { color:var(--primary); background:var(--theme-soft); }
html[data-theme-mode="dark"] .smooth-guide-viewport .typing-guide-caret { background:var(--primary); }
html[data-theme-mode="dark"] :is(.metric-gross strong,.metric-best strong,.metric-accuracy strong) { color:var(--primary); }

/* Five light themes complement five distinct dark palettes. */
html[data-theme="classic"][data-theme-mode="light"] { color-scheme:light; --bg:#f5f5f2; --panel:#ffffff; --text:#242d32; --muted:#556268; --line:#c7ceca; --primary:#385d70; --primary-dark:#29495a; --success:#166534; --danger:#b91c1c; --theme-soft:#ebede8; --shadow:0 12px 36px rgba(24,35,48,.08); }
html[data-theme="classic"][data-theme-mode="light"] :is(body.exam-v10,body.exam-v11) { --exam-bg:#f5f5f2; --exam-card:#ffffff; --exam-ink:#242d32; --exam-muted:#556268; --exam-border:#c7ceca; --exam-primary:#385d70; --exam-primary-soft:#ebede8; --exam-success:#166534; --exam-success-soft:#dcfce7; --exam-danger:#b91c1c; --exam-danger-soft:#fee2e2; background:#f5f5f2; }
html[data-theme="sand"][data-theme-mode="light"] { color-scheme:light; --bg:#faf4e8; --panel:#fffdf8; --text:#3b2c1d; --muted:#715b40; --line:#d7c4a3; --primary:#80551c; --primary-dark:#684316; --success:#166534; --danger:#b91c1c; --theme-soft:#f0e4cd; --shadow:0 12px 36px rgba(24,35,48,.08); }
html[data-theme="sand"][data-theme-mode="light"] :is(body.exam-v10,body.exam-v11) { --exam-bg:#faf4e8; --exam-card:#fffdf8; --exam-ink:#3b2c1d; --exam-muted:#715b40; --exam-border:#d7c4a3; --exam-primary:#80551c; --exam-primary-soft:#f0e4cd; --exam-success:#166534; --exam-success-soft:#dcfce7; --exam-danger:#b91c1c; --exam-danger-soft:#fee2e2; background:#faf4e8; }
html[data-theme="arctic"][data-theme-mode="light"] { color-scheme:light; --bg:#edf7fc; --panel:#ffffff; --text:#173c52; --muted:#446579; --line:#b9d4e4; --primary:#1b638c; --primary-dark:#134d6e; --success:#166534; --danger:#b91c1c; --theme-soft:#dfeef7; --shadow:0 12px 36px rgba(24,35,48,.08); }
html[data-theme="arctic"][data-theme-mode="light"] :is(body.exam-v10,body.exam-v11) { --exam-bg:#edf7fc; --exam-card:#ffffff; --exam-ink:#173c52; --exam-muted:#446579; --exam-border:#b9d4e4; --exam-primary:#1b638c; --exam-primary-soft:#dfeef7; --exam-success:#166534; --exam-success-soft:#dcfce7; --exam-danger:#b91c1c; --exam-danger-soft:#fee2e2; background:#edf7fc; }
html[data-theme="sage"][data-theme-mode="light"] { color-scheme:light; --bg:#eff5ed; --panel:#fcfefb; --text:#293d29; --muted:#4f674c; --line:#bfceba; --primary:#3e6937; --primary-dark:#2f512a; --success:#166534; --danger:#b91c1c; --theme-soft:#e0ebda; --shadow:0 12px 36px rgba(24,35,48,.08); }
html[data-theme="sage"][data-theme-mode="light"] :is(body.exam-v10,body.exam-v11) { --exam-bg:#eff5ed; --exam-card:#fcfefb; --exam-ink:#293d29; --exam-muted:#4f674c; --exam-border:#bfceba; --exam-primary:#3e6937; --exam-primary-soft:#e0ebda; --exam-success:#166534; --exam-success-soft:#dcfce7; --exam-danger:#b91c1c; --exam-danger-soft:#fee2e2; background:#eff5ed; }
html[data-theme="rose"][data-theme-mode="light"] { color-scheme:light; --bg:#fcf0f3; --panel:#fffcfd; --text:#512938; --muted:#7a5262; --line:#e0bac9; --primary:#a13360; --primary-dark:#812347; --success:#166534; --danger:#b91c1c; --theme-soft:#f5e0e7; --shadow:0 12px 36px rgba(24,35,48,.08); }
html[data-theme="rose"][data-theme-mode="light"] :is(body.exam-v10,body.exam-v11) { --exam-bg:#fcf0f3; --exam-card:#fffcfd; --exam-ink:#512938; --exam-muted:#7a5262; --exam-border:#e0bac9; --exam-primary:#a13360; --exam-primary-soft:#f5e0e7; --exam-success:#166534; --exam-success-soft:#dcfce7; --exam-danger:#b91c1c; --exam-danger-soft:#fee2e2; background:#fcf0f3; }
html[data-theme-mode="light"] :is(.typing-guide-viewport,.fight-guide,.exam-v11 .typing-guide-viewport) { background:var(--panel); color:var(--muted); }
html[data-theme-mode="light"] :is(.typing-guide-track,.fight-guide-track,.smooth-guide-track,.exam-v11 .typing-guide-track) { color:var(--muted); }
html[data-theme-mode="light"] :is(#fightInput,.exam-v10 .exam-typing-input,.exam-v11 .exam-typing-input) { background:var(--panel); color:var(--text); caret-color:var(--primary); }
html[data-theme-mode="light"] :is(.topbar.site-header,.exam-v10 .exam-header) { background:var(--panel); color:var(--text); }
html[data-theme-mode="light"] :is(.btn.primary,.btn.primary:hover,.brand-badge,.exam-brand-mark,.exam-icon-large) { background:var(--primary); color:#fff; }
html[data-theme-mode="light"] .btn.primary:hover { background:var(--primary-dark); }
