/* ══════════════════════════════════════
   ATP TOEIC — Design System
   Modern, premium exam interface
   ══════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* Brand — shared Navy Monochromatic system */
    --brand-primary: #042077;
    --brand-dark: #071A4F;
    --brand-light: #E8EEFF;
    --brand-accent: #0A2F9C;

    /* Semantic — never decorative */
    --correct: #047857;
    --correct-bg: #ECFDF5;
    --wrong: #B42318;
    --wrong-bg: #FEF2F2;
    --warning: #92400E;
    --warning-bg: #FFFBEB;

    /* Neutrals */
    --bg: #F6F8FC;
    --bg-card: #FFFFFF;
    --bg-sidebar: #071A4F;
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --border: #DBE2EA;
    --border-hover: #C4CEDA;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(7, 26, 79, .05);
    --shadow-md: 0 4px 12px rgba(7, 26, 79, .08);
    --shadow-lg: 0 8px 30px rgba(7, 26, 79, .12);
    --shadow-glow: 0 0 20px rgba(4, 32, 119, .15);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transitions */
    --ease: cubic-bezier(.4, 0, .2, 1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ─── Layout (IDP: content left, navigator right) ─── */
.exam-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    grid-template-rows: auto 1fr;
    grid-template-areas:
        "topbar topbar"
        "content navigator";
    min-height: 100vh;
    height: 100vh;
}

.exam-header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 60px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    z-index: 100;
}

.exam-header__logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 18px;
    color: var(--brand-dark);
}

.exam-header__logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-dark));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: 700;
}

.exam-header__timer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--brand-light);
    border-radius: var(--radius-lg);
    font-variant-numeric: tabular-nums;
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    font-weight: 600;
    color: var(--brand-dark);
}

.exam-header__timer.warning {
    background: var(--warning-bg);
    color: #92400E;
}

.exam-header__timer.danger {
    background: var(--wrong-bg);
    color: var(--wrong);
    animation: pulse 1s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .6;
    }
}

.exam-header__actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ══════════════════════════════════════
   IDP EXAM SHELL — topbar / content / navigator
   ══════════════════════════════════════ */

/* Top Bar */
.exam-topbar {
    grid-area: topbar;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 0 24px;
    height: 64px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    z-index: 100;
}

.exam-topbar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.exam-topbar__logo {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-dark));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 16px;
}

.exam-topbar__titles {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.exam-topbar__title {
    font-weight: 700;
    font-size: 15px;
    color: var(--brand-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 42vw;
}

.exam-topbar__sub {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.exam-topbar__timer {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    background: var(--brand-light);
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    font-weight: 700;
    color: var(--brand-dark);
    letter-spacing: .5px;
}

.exam-topbar__timer.warning {
    background: var(--warning-bg);
    color: #92400E;
}

.exam-topbar__timer.danger {
    background: var(--wrong-bg);
    color: var(--wrong);
    animation: pulse 1s infinite;
}

.exam-topbar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.exam-topbar__navtoggle {
    display: none;
}

/* Content (LEFT) */
.exam-content {
    grid-area: content;
    padding: 28px 36px;
    overflow-y: auto;
    height: calc(100vh - 64px);
}

.exam-content__inner {
    max-width: 820px;
    margin: 0 auto;
}

.exam-nav__count {
    font-size: 13px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Navigator (RIGHT) */
.exam-navigator {
    grid-area: navigator;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    padding: 24px 20px;
    overflow-y: auto;
    height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.navigator__section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.navigator__label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
}

.navigator__progress {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.navigator__progress-head {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.navigator__progress-pct {
    font-variant-numeric: tabular-nums;
    color: var(--brand-primary);
}

.navigator__progress-bar {
    height: 8px;
    background: var(--bg);
    border-radius: 999px;
    overflow: hidden;
}

.navigator__progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--brand-primary), var(--brand-dark));
    border-radius: 999px;
    transition: width .3s var(--ease);
}

.btn--block {
    width: 100%;
    justify-content: center;
}

/* Navigator part-nav (light theme override) */
.exam-navigator .part-nav__item {
    color: var(--text-secondary);
}

.exam-navigator .part-nav__item:hover {
    background: var(--brand-light);
    color: var(--brand-dark);
}

.exam-navigator .part-nav__item.active {
    background: var(--brand-light);
    color: var(--brand-dark);
    border-left: 3px solid var(--brand-primary);
}

.exam-navigator .part-nav__item.completed {
    color: var(--correct);
}

.exam-navigator .part-nav__icon {
    background: var(--bg);
}

.exam-navigator .part-nav__item.active .part-nav__icon {
    background: var(--brand-primary);
    color: #fff;
}

.exam-navigator .part-nav__badge {
    background: var(--bg);
    color: var(--text-secondary);
}

.exam-navigator .part-nav__item.active .part-nav__badge {
    background: var(--brand-primary);
    color: #fff;
}

.part-nav__name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Navigator question map (light theme override) */
.exam-navigator .question-map__dot {
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.exam-navigator .question-map__dot:hover {
    background: var(--brand-light);
    color: var(--brand-dark);
    border-color: var(--brand-primary);
}

.exam-navigator .question-map__dot.answered {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}

.exam-navigator .question-map__grid {
    grid-template-columns: repeat(6, 1fr);
}

/* ─── Sidebar (Part Navigator) ─── */
.exam-sidebar {
    background: var(--bg-sidebar);
    padding: 20px 16px;
    overflow-y: auto;
    color: white;
}

.exam-sidebar__title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #64748B;
    margin-bottom: 12px;
    padding: 0 8px;
}

.part-nav {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.part-nav__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all .2s var(--ease);
    font-size: 13px;
    font-weight: 500;
    color: #CBD5E1;
}

.part-nav__item:hover {
    background: rgba(255, 255, 255, .06);
    color: white;
}

.part-nav__item.active {
    background: rgba(10, 114, 225, .2);
    color: white;
    border-left: 3px solid var(--brand-primary);
}

.part-nav__item.completed {
    color: var(--correct);
}

.part-nav__badge {
    margin-left: auto;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .1);
    font-variant-numeric: tabular-nums;
}

.part-nav__item.active .part-nav__badge {
    background: var(--brand-primary);
    color: white;
}

.part-nav__icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    background: rgba(255, 255, 255, .06);
    flex-shrink: 0;
}

.part-nav__item.active .part-nav__icon {
    background: var(--brand-primary);
    color: white;
}

/* Question map */
.question-map {
    margin-top: 16px;
    padding: 16px 8px;
    border-top: 1px solid rgba(255, 255, 255, .06);
}

.question-map__label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #64748B;
    margin-bottom: 8px;
}

.question-map__grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}

.question-map__dot {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s var(--ease);
    background: rgba(255, 255, 255, .06);
    color: #64748B;
}

.question-map__dot:hover {
    background: rgba(255, 255, 255, .12);
    color: white;
}

.question-map__dot.answered {
    background: var(--brand-primary);
    color: white;
}

.question-map__dot.current {
    outline: 2px solid var(--brand-primary);
    outline-offset: 1px;
    color: white;
}

.question-map__dot.flagged {
    background: var(--warning);
    color: white;
}

/* ─── Main Content ─── */
.exam-main {
    padding: 24px 32px;
    overflow-y: auto;
    max-height: calc(100vh - 60px);
}

.exam-main__inner {
    max-width: 860px;
    margin: 0 auto;
}

/* Part Header */
.part-header {
    margin-bottom: 24px;
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand-primary) 100%);
    border-radius: var(--radius-lg);
    color: white;
}

.part-header__label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: .7;
}

.part-header__title {
    font-size: 22px;
    font-weight: 700;
    margin-top: 4px;
}

.part-header__desc {
    font-size: 14px;
    opacity: .85;
    margin-top: 8px;
    line-height: 1.5;
}

/* Directions là HTML người soạn nhập: wpautop sinh <p>, và đề cũ còn dùng
   <div style="text-align: justify"> lồng nhau. Gỡ margin mặc định để khối
   không bị giãn thêm, và ép text-align inline về left cho dễ đọc. */
.part-header__desc > *:first-child {
    margin-top: 0;
}

.part-header__desc > *:last-child {
    margin-bottom: 0;
}

.part-header__desc p,
.part-header__desc div {
    margin: 0 0 8px;
    text-align: left;
}

.part-header__desc strong,
.part-header__desc b {
    font-weight: 700;
    opacity: 1;
}

/* ── Audio Player ──
   Thanh tiến độ là <input type="range">. Phần đã phát tô bằng gradient theo
   biến --ap-pct do JS đặt, nên không cần thẻ fill riêng nằm đè lên. */
.audio-player {
    margin-bottom: 24px;
    padding: 14px 18px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
}

.audio-player__btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s var(--ease), transform .2s var(--ease);
    flex-shrink: 0;
}

.audio-player__btn:hover {
    background: var(--brand-dark);
    transform: scale(1.05);
}

.audio-player__btn:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 3px;
}

/* Mặc định hiện play; khi đang phát thì đổi sang pause. */
.audio-player__icon--pause,
.audio-player.is-playing .audio-player__icon--play {
    display: none;
}

.audio-player.is-playing .audio-player__icon--pause {
    display: block;
}

.audio-player__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.audio-player__meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.audio-player__time,
.audio-player__remain {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Range: bỏ giao diện mặc định của từng engine rồi tự vẽ track + thumb. */
.audio-player__range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 18px;
    margin: 0;
    background: transparent;
    cursor: pointer;
}

.audio-player__range:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

.audio-player__range::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background:
        linear-gradient(var(--brand-primary), var(--brand-primary)) 0 / var(--ap-pct, 0%) 100% no-repeat,
        var(--border);
}

.audio-player__range::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background:
        linear-gradient(var(--brand-primary), var(--brand-primary)) 0 / var(--ap-pct, 0%) 100% no-repeat,
        var(--border);
}

.audio-player__range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    margin-top: -4px;
    border-radius: 50%;
    background: var(--brand-primary);
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(4, 32, 119, .35);
}

.audio-player__range::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--brand-primary);
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(4, 32, 119, .35);
}

/* Player của directions nằm trong khối navy: nền card sáng sẽ thành một hộp
   trắng lệch tông, nên dùng nền trong suốt và viền sáng. */
.audio-player--directions {
    margin: 14px 0 0;
    padding: 12px 16px;
    background: rgba(255, 255, 255, .12);
    border-color: rgba(255, 255, 255, .28);
}

.audio-player--directions .audio-player__btn {
    width: 40px;
    height: 40px;
    background: #fff;
    color: var(--brand-dark);
}

.audio-player--directions .audio-player__btn:hover {
    background: rgba(255, 255, 255, .88);
}

.audio-player--directions .audio-player__time,
.audio-player--directions .audio-player__remain {
    color: rgba(255, 255, 255, .92);
}

.audio-player--directions .audio-player__range::-webkit-slider-runnable-track {
    background:
        linear-gradient(#fff, #fff) 0 / var(--ap-pct, 0%) 100% no-repeat,
        rgba(255, 255, 255, .26);
}

.audio-player--directions .audio-player__range::-moz-range-track {
    background:
        linear-gradient(#fff, #fff) 0 / var(--ap-pct, 0%) 100% no-repeat,
        rgba(255, 255, 255, .26);
}

.audio-player--directions .audio-player__range::-webkit-slider-thumb {
    background: #fff;
    border-color: var(--brand-dark);
}

.audio-player--directions .audio-player__range::-moz-range-thumb {
    background: #fff;
    border-color: var(--brand-dark);
}

/* Question Card */
.question-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 24px;
    margin-bottom: 16px;
    transition: all .2s var(--ease);
}

.question-card:hover {
    box-shadow: var(--shadow-md);
}

.question-card__number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--brand-light);
    color: var(--brand-primary);
    border-radius: 50%;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 12px;
}

.question-card__text {
    font-size: 15px;
    color: var(--text-primary);
    margin-bottom: 16px;
    line-height: 1.7;
}

.question-card__image {
    max-width: 100%;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    border: 1px solid var(--border);
}

/* ──── Open-ended questions (Speaking / Writing) ──── */

/* Visually hidden but still read out — used for the textarea label. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.question-card--open {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
}

.question-card--open>* {
    margin-bottom: 0;
}

.question-card__scenario {
    align-self: stretch;
    padding: 10px 14px;
    border-left: 3px solid var(--brand-primary);
    background: var(--brand-light);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.question-card__prompt {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.6;
    color: var(--text-primary);
}

.question-card__keywords {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.keyword-chip {
    padding: 4px 12px;
    border: 1px dashed var(--brand-primary);
    border-radius: 999px;
    background: var(--brand-light);
    color: var(--brand-primary);
    font-size: 13px;
    font-weight: 600;
}

.question-card__timing,
.question-card__note {
    font-size: 13px;
    color: var(--text-muted);
}

.question-card__note {
    font-style: italic;
}

/* Writing answer box */
.open-answer {
    align-self: stretch;
    width: 100%;
    box-sizing: border-box;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font: inherit;
    font-size: 15px;
    line-height: 1.7;
    resize: vertical;
    transition: border-color .15s var(--ease);
}

.open-answer:focus-visible {
    outline: none;
    border-color: var(--brand-primary);
}

.open-answer__meta {
    font-size: 13px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Speaking recorder */
.recorder {
    align-self: stretch;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.recorder__btn.recording {
    background: var(--incorrect, #dc2626);
    border-color: var(--incorrect, #dc2626);
    animation: recPulse 1.2s ease-in-out infinite;
}

@keyframes recPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .6;
    }
}

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

.recorder__status {
    font-size: 13px;
    color: var(--text-muted);
}

.recorder__audio {
    flex: 1 1 220px;
    min-width: 200px;
    height: 36px;
}

/* Mic check — gate shown before speaking exams */
.miccheck {
    max-width: 640px;
    margin: 0 auto;
    padding: 40px 24px 64px;
}

.miccheck__title {
    font-size: clamp(24px, 4vw, 32px);
    font-weight: 800;
    letter-spacing: -.02em;
    margin: 0 0 12px;
}

.miccheck__lead {
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0 0 24px;
}

.miccheck__steps {
    margin: 0 0 24px;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    line-height: 1.6;
}

.miccheck__meter {
    height: 12px;
    border-radius: 999px;
    background: var(--surface-2, #eef1f6);
    overflow: hidden;
}

.miccheck__meter-fill {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #16a34a, #4ade80);
    /* Fast enough to read as live sound, slow enough not to strobe. */
    transition: width 80ms linear;
}

.miccheck__status {
    font-size: 14px;
    color: var(--text-muted);
    margin: 12px 0 0;
}

.miccheck__status--bad {
    color: var(--incorrect, #dc2626);
    font-weight: 600;
}

.miccheck__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 20px 0;
}

.miccheck__footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.miccheck__note {
    font-size: 13px;
    color: var(--text-muted);
    margin: 12px 0 0;
}

/* Answer Options */
.answer-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.answer-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all .15s var(--ease);
    font-size: 14px;
}

.answer-option:hover {
    border-color: var(--brand-primary);
    background: var(--brand-light);
}

.answer-option.selected {
    border-color: var(--brand-primary);
    background: var(--brand-light);
}

.answer-option.correct {
    border-color: var(--correct);
    background: var(--correct-bg);
}

.answer-option.wrong {
    border-color: var(--wrong);
    background: var(--wrong-bg);
}

.answer-option__radio {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all .15s var(--ease);
}

.answer-option.selected .answer-option__radio {
    border-color: var(--brand-primary);
    background: var(--brand-primary);
}

.answer-option.selected .answer-option__radio::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
}

.answer-option__label {
    font-weight: 600;
    color: var(--brand-primary);
    min-width: 28px;
}

.answer-option__text {
    flex: 1;
}

/* ─── Navigation Footer ─── */
.exam-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all .2s var(--ease);
    font-family: inherit;
}

.btn--primary {
    background: var(--brand-primary);
    color: white;
}

.btn--primary:hover {
    background: var(--brand-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn--secondary {
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn--secondary:hover {
    background: var(--border);
    color: var(--text-primary);
}

.btn--danger {
    background: var(--wrong);
    color: white;
}

.btn--danger:hover {
    background: #DC2626;
}

.btn--success {
    background: var(--correct);
    color: white;
}

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

.btn--lg {
    padding: 14px 28px;
    font-size: 15px;
}

.btn--sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ─── Test List ─── */
.test-list-page {
    max-width: 960px;
    margin: 0 auto;
    padding: 40px 24px;
}

.test-list-page__title {
    font-size: 28px;
    font-weight: 800;
    color: var(--brand-dark);
    margin-bottom: 8px;
}

.test-list-page__subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.test-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.test-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 20px;
    cursor: pointer;
    transition: all .25s var(--ease);
    position: relative;
    overflow: hidden;
}

.test-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--brand-primary);
}

.test-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
    opacity: 0;
    transition: opacity .25s;
}

.test-card:hover::before {
    opacity: 1;
}

.test-card__year {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--brand-primary);
}

.test-card__title {
    font-size: 16px;
    font-weight: 700;
    margin-top: 4px;
    color: var(--text-primary);
}

.test-card__meta {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.test-card__meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.test-card__btn {
    margin-top: 16px;
    width: 100%;
}

/* ─── Result Page ─── */
.result-page {
    max-width: 700px;
    margin: 0 auto;
    padding: 40px 24px;
    text-align: center;
}

.result-score {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin: 32px 0;
}

.result-score__item {
    width: 140px;
    padding: 20px;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.result-score__label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.result-score__value {
    font-size: 36px;
    font-weight: 800;
    color: var(--brand-dark);
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

.result-score__item--total {
    background: linear-gradient(135deg, var(--brand-dark), var(--brand-primary));
    color: white;
    border: none;
}

.result-score__item--total .result-score__label {
    color: rgba(255, 255, 255, .7);
}

.result-score__item--total .result-score__value {
    color: white;
    font-size: 42px;
}

/* Parts breakdown */
.result-parts {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin: 24px 0;
}

.result-part {
    padding: 12px 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    text-align: center;
}

.result-part__label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

.result-part__score {
    font-size: 18px;
    font-weight: 700;
    color: var(--brand-dark);
    margin-top: 2px;
}

.result-part__total {
    font-size: 11px;
    color: var(--text-muted);
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .exam-layout {
        grid-template-columns: 1fr;
    }

    .exam-sidebar {
        display: none;
        position: fixed;
        inset: 60px 0 0 0;
        z-index: 50;
    }

    .exam-sidebar.open {
        display: block;
    }

    .exam-main {
        padding: 16px;
    }

    .result-score {
        flex-wrap: wrap;
    }

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

/* ══════════════════════════════════════
   APP TOP-NAV (shared shell nav)
   ══════════════════════════════════════ */
.app-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 24px;
    height: 60px;
    padding: 0 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.app-nav__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 18px;
    color: var(--brand-dark);
}

.app-nav__brand-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-dark));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.app-nav__links {
    display: flex;
    gap: 4px;
}

.app-nav__link {
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    transition: all .15s var(--ease);
}

.app-nav__link:hover {
    background: var(--bg);
    color: var(--text-primary);
}

.app-nav__link.active {
    background: var(--brand-light);
    color: var(--brand-primary);
}

.app-nav__user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.app-nav__avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

/* ══════════════════════════════════════
   RANKING / LEADERBOARD
   ══════════════════════════════════════ */
.rank-page {
    max-width: 1080px;
    margin: 0 auto;
    padding: 40px 24px 64px;
}

.rank-page__head {
    margin-bottom: 28px;
}

.rank-page__eyebrow {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--brand-primary);
}

.rank-page__title {
    font-size: 30px;
    font-weight: 800;
    color: var(--brand-dark);
    margin-top: 4px;
    letter-spacing: -0.02em;
}

.rank-page__subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* ─── Podium (Top 3) ─── */
.podium {
    display: grid;
    grid-template-columns: 1fr 1.15fr 1fr;
    align-items: end;
    gap: 16px;
    margin-bottom: 36px;
}

.podium__slot {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 16px 20px;
    text-align: center;
    position: relative;
    transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}

.podium__slot:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.podium__slot--1 {
    border-color: #E9B949;
    box-shadow: 0 8px 30px rgba(233, 185, 73, .18);
    padding-top: 32px;
}

.podium__slot--1 .podium__avatar {
    width: 72px;
    height: 72px;
    font-size: 26px;
}

.podium__medal {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    color: #fff;
    border: 3px solid var(--bg-card);
}

.podium__slot--1 .podium__medal {
    background: #E9B949;
}

.podium__slot--2 .podium__medal {
    background: #9AA7B4;
}

.podium__slot--3 .podium__medal {
    background: #C08457;
}

.podium__avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    margin: 0 auto 12px;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    text-transform: uppercase;
}

.podium__name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.podium__score {
    font-size: 32px;
    font-weight: 800;
    color: var(--brand-dark);
    font-variant-numeric: tabular-nums;
    margin-top: 6px;
    line-height: 1;
}

.podium__score span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.podium__split {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.podium__bar {
    margin-top: 16px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: linear-gradient(180deg, var(--brand-light), transparent);
    font-weight: 800;
    color: var(--brand-primary);
    font-size: 22px;
}

.podium__slot--1 .podium__bar { height: 56px; line-height: 56px; }
.podium__slot--2 .podium__bar { height: 40px; line-height: 40px; }
.podium__slot--3 .podium__bar { height: 28px; line-height: 28px; }

/* ─── Personal rank strip ─── */
.myrank {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 18px 24px;
    margin-bottom: 24px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--brand-dark), var(--brand-primary));
    color: #fff;
}

.myrank__badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-right: 20px;
    border-right: 1px solid rgba(255, 255, 255, .2);
}

.myrank__badge-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    opacity: .7;
}

.myrank__badge-value {
    font-size: 34px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.myrank__meta {
    display: flex;
    gap: 32px;
    flex: 1;
}

.myrank__stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: .7;
}

.myrank__stat-value {
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
}

.myrank--unranked {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px dashed var(--border-hover);
    justify-content: center;
    text-align: center;
}

.ranking-privacy {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 0 0 20px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    cursor: pointer;
}

.ranking-privacy input {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--brand-primary);
}

.ranking-privacy span,
.ranking-privacy small {
    display: block;
}

.ranking-privacy small {
    margin-top: 4px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ─── Ranked table ─── */
.rank-table {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.rank-row {
    display: grid;
    grid-template-columns: 64px 1fr 120px 120px 96px;
    align-items: center;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    transition: background .15s var(--ease);
}

.rank-row:first-child {
    border-top: none;
}

.rank-row--head {
    background: var(--bg);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.rank-row--body:hover {
    background: var(--brand-light);
}

.rank-row--me {
    background: var(--brand-light);
    box-shadow: inset 3px 0 0 var(--brand-primary);
}

.rank-row__rank {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.rank-row__user {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.rank-row__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    flex-shrink: 0;
}

.rank-row__name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rank-row__sub {
    font-size: 12px;
    color: var(--text-muted);
}

.rank-row__cell {
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
}

.rank-row__score {
    font-size: 17px;
    font-weight: 800;
    color: var(--brand-dark);
    font-variant-numeric: tabular-nums;
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 800;
    color: #fff;
}

.rank-badge--1 { background: #E9B949; }
.rank-badge--2 { background: #9AA7B4; }
.rank-badge--3 { background: #C08457; }

/* ─── Empty / states ─── */
.rank-empty {
    text-align: center;
    padding: 64px 24px;
    color: var(--text-muted);
}

.rank-empty__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-top: 12px;
}

/* ─── Ranking responsive ─── */
@media (max-width: 768px) {
    .podium {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .podium__slot--1 { order: -1; }
    .podium__bar { display: none; }

    .myrank {
        flex-wrap: wrap;
        gap: 16px;
    }

    .myrank__meta {
        gap: 20px;
    }

    .rank-row {
        grid-template-columns: 44px 1fr 72px;
    }

    .rank-row__hide-sm {
        display: none;
    }
}

/* ─── Exam shell responsive ─── */
@media (max-width: 1024px) {
    .exam-layout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "topbar"
            "content";
    }

    .exam-topbar__navtoggle {
        display: inline-flex;
    }

    .exam-navigator {
        position: fixed;
        top: 64px;
        right: 0;
        width: 320px;
        max-width: 85vw;
        height: calc(100vh - 64px);
        transform: translateX(100%);
        transition: transform .28s var(--ease);
        box-shadow: var(--shadow-lg);
        z-index: 120;
    }

    .exam-navigator.open {
        transform: translateX(0);
    }
}

@media (max-width: 560px) {
    .exam-content {
        padding: 20px 16px;
    }

    .exam-topbar {
        gap: 12px;
        padding: 0 14px;
    }

    .exam-topbar__title {
        max-width: 38vw;
    }

    .exam-topbar__timer {
        font-size: 16px;
        padding: 8px 14px;
    }
}

/* ══════════════════════════════════════
   RESULT REVIEW — per-part grid + detail
   ══════════════════════════════════════ */
.review-section {
    text-align: left;
    margin-top: 8px;
}

.review-legend {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.review-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.review-swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    display: inline-block;
}

.review-swatch--correct { background: var(--correct); }
.review-swatch--wrong { background: var(--wrong); }
.review-swatch--blank {
    background: var(--bg);
    border: 1px solid var(--border-hover);
}

.review-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.review-part {
    margin-bottom: 18px;
}

.review-part__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.review-part__wrong {
    font-size: 12px;
    font-weight: 600;
    color: var(--wrong);
}

.review-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 8px;
}

.review-dot {
    aspect-ratio: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .12s var(--ease), box-shadow .12s var(--ease);
    color: #fff;
}

.review-dot:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.review-dot--correct { background: var(--correct); border-color: var(--correct); }
.review-dot--wrong { background: var(--wrong); border-color: var(--wrong); }
.review-dot--blank {
    background: var(--bg);
    border-color: var(--border-hover);
    color: var(--text-muted);
}

.review-detail {
    margin-top: 18px;
    padding: 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.review-detail__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 15px;
}

.review-status {
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
}

.review-status--correct { background: var(--correct-bg); color: var(--correct); }
.review-status--wrong { background: var(--wrong-bg); color: var(--wrong); }
.review-status--blank { background: var(--bg); color: var(--text-muted); }

.review-detail__q {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 12px;
    line-height: 1.5;
}

.review-opts {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.review-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.review-opt--correct {
    background: var(--correct-bg);
    border-color: var(--correct);
}

.review-opt--wrong {
    background: var(--wrong-bg);
    border-color: var(--wrong);
}

.review-opt__label {
    width: 26px;
    height: 26px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border-radius: 50%;
    background: var(--bg);
    color: var(--text-secondary);
}

.review-opt--correct .review-opt__label { background: var(--correct); color: #fff; }
.review-opt--wrong .review-opt__label { background: var(--wrong); color: #fff; }

.review-opt__text { flex: 1; }

.review-opt__tag {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    flex: none;
}

.review-opt__tag--correct { background: var(--correct); color: #fff; }
.review-opt__tag--wrong { background: var(--wrong); color: #fff; }

.review-detail__exp {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}