/* Module: Practice Arena — one-question-at-a-time practice shell.
   Owns the sticky top HUD (clock + live stats + circle palette), the fixed
   bottom Prev/Next bar, and the correct/wrong feedback effects.
   Loaded AFTER premium-ui.css / mobile-premium.css / design-system.css so its
   practice-mode overrides win without needing !important everywhere. */

:root {
    --pa-top: 64px;
    /* main-header height */
    --pa-rail-w: 320px;
    --pa-nav-h: 68px;
    --pa-correct: #34d399;
    --pa-wrong: #f87171;
    --pa-review: #a78bfa;
    --pa-gold: #ffd54f;
}

/* =========================================================
   1. ONE QUESTION AT A TIME
   ========================================================= */
body.pa-active #quiz-view .test-question-card,
body.pa-active #quiz-view .pa-passage {
    display: none;
}

body.pa-active #quiz-view .test-question-card.pa-visible,
body.pa-active #quiz-view .pa-passage.pa-visible {
    display: block;
}

/* The entrance animation is its own short-lived class, NOT part of .pa-visible.
   Tied to .pa-visible it re-ran every time a feedback class (pa-shake /
   pa-correct-flash) was removed from the card, which read as a blink a beat
   after answering. */
body.pa-active #quiz-view .test-question-card.pa-enter,
body.pa-active #quiz-view .pa-passage.pa-enter {
    animation: paCardIn .28s cubic-bezier(.22, .9, .3, 1) both;
}

body.pa-active #quiz-view .test-question-card {
    position: relative;
    overflow: hidden;
    contain: layout paint;
}

/* ---- Compact practice card: question + options without scrolling ----
   Sizes inside the card are in em so the zoom buttons (--pa-zoom) scale the
   question, the options and the solution together. */
body.pa-active #quiz-view .test-question-card {
    padding: 14px 16px !important;
    margin-bottom: 0;
    border-radius: 16px;
    font-size: calc(1rem * var(--pa-zoom, 1));
}

body.pa-active #quiz-view .question-text {
    margin: 0 0 10px 0 !important;
    line-height: 1.45;
    font-size: 1.04em;
}

body.pa-active #quiz-view .test-option {
    margin: 5px 0;
    padding: 0.7em 0.9em;
    font-size: .95em;
}

body.pa-active #quiz-view .explanation-container,
body.pa-active #quiz-view .hint-box {
    font-size: .95em;
}

body.pa-active #quiz-view .hint-level-row {
    margin-top: 6px !important;
}

body.pa-active #quiz-view .weakness-badges,
body.pa-active #quiz-view .pa-card-head {
    margin-bottom: 6px !important;
}

@keyframes paCardIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(.995);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

body.pa-active #quiz-view .test-question-card.pa-enter.pa-enter-back {
    animation-name: paCardInBack;
}

@keyframes paCardInBack {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(.995);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* Room for the fixed bottom bar, and as little dead space above the card as
   the layout allows — the question should land inside the first screen. */
body.pa-active .scroll-content {
    padding-top: 12px !important;
    padding-bottom: calc(var(--pa-nav-h) + 22px) !important;
}

/* HUD replaces the side palette + header stopwatch entirely */
body.pa-active .question-grid-panel,
body.pa-active .grid-overlay-back,
body.pa-active #grid-toggle-btn,
body.pa-active #header-timer-container {
    display: none !important;
}

/* =========================================================
   1b. TABLET / DESKTOP SPLIT: question column + analytics rail
   The stats block is moved into .pa-rail by JS (placeStats), so the sticky
   top strip is left holding nothing but the circle line and the question
   gets the full column — no scrolling to read the numbers.
   ========================================================= */
.pa-rail {
    display: none;
}

@media (min-width: 768px) {
    body.pa-active .pa-rail {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: var(--pa-top);
        right: 0;
        width: var(--pa-rail-w);
        height: calc(100vh - var(--pa-top));
        height: calc(100dvh - var(--pa-top));
        z-index: 95;
        border-left: 1px solid var(--line);
        background: var(--surface-solid);
        box-shadow: -8px 0 30px rgba(0, 0, 0, .26);
    }

    .pa-rail-head {
        flex-shrink: 0;
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 11px 14px;
        border-bottom: 1px solid var(--line);
        font-weight: 800;
        font-size: .9rem;
        color: var(--text-main);
    }

    .pa-rail-head i {
        color: var(--brand-2);
    }

    .pa-rail-body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        padding: 12px 12px 8px;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    /* Question column keeps everything left of the rail */
    body.pa-active.pa-rail-on .scroll-content {
        margin-right: var(--pa-rail-w) !important;
        width: calc(100% - var(--pa-rail-w)) !important;
        max-width: none !important;
    }

    body.pa-active.pa-rail-on .pa-navbar {
        right: var(--pa-rail-w);
    }

    /* Top strip = circle line only */
    body.pa-rail-on .pa-hud {
        padding: 8px 12px;
    }

    body.pa-rail-on .pa-palette-wrap {
        margin-top: 0;
        padding-top: 0;
        border-top: none;
    }

    body.pa-rail-on .pa-palette {
        padding-bottom: 4px;
    }

    /* ---- Stats block inside the rail ----
       Row 1: clock + the two toggles. Row 2: progress. Everything below is
       the stat grid, sized so the whole rail fits a laptop screen without
       its own scrollbar. */
    .pa-rail .pa-hud-row {
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
    }

    .pa-rail .pa-clock {
        flex: 1 1 auto;
        gap: 8px;
        padding: 6px 12px 6px 6px;
        border-radius: 999px;
        background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 14%, transparent), transparent 72%);
    }

    .pa-rail .pa-dial {
        width: 54px;
        height: 54px;
    }

    .pa-rail .pa-clock-main {
        font-size: 1.25rem;
    }

    .pa-rail .pa-clock-sub {
        font-size: .7rem;
    }

    .pa-rail .pa-tools {
        order: 1;
        margin-left: 0;
    }

    .pa-rail .pa-progress {
        order: 2;
        flex: 1 1 100%;
        min-width: 0;
    }

    .pa-rail .pa-btn-analyze {
        display: none;
    }

    /* The analysis grid below carries every one of these numbers with a
       clearer label — showing both just pushed the grid off-screen. */
    .pa-rail .pa-chips {
        display: none;
    }

    .pa-rail .pa-analysis {
        padding: 0;
        border: none;
        background: none;
        animation: none;
    }

    /* Breathing room under the progress line — the first cell row was sitting
       right on top of it. */
    .pa-rail .pa-analysis {
        margin-top: 12px;
    }

    .pa-rail .pa-an-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }

    .pa-rail .pa-an-cell {
        padding: 8px 6px;
        border-radius: 11px;
        text-align: center;
    }

    .pa-rail .pa-an-cell span {
        font-size: .58rem;
        letter-spacing: .2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: 1px;
    }

    .pa-rail .pa-an-cell b {
        font-size: 1.05rem;
    }

    .pa-rail .pa-an-actions {
        margin-top: 8px;
        gap: 6px;
    }

    /* Two jump buttons per row so a full set (wrong / review / pending /
       retry) costs two rows instead of four in a 320px rail. */
    .pa-rail .pa-an-btn {
        padding: 8px 10px;
        font-size: .78rem;
        min-width: 0;
        flex: 1 1 calc(50% - 3px);
    }
}

/* Tablet portrait: a 320px rail would squeeze the question column under
   450px and wrap the bottom bar onto three rows. Narrow the rail and trim
   the bar's labels instead — the icons keep their tooltips. */
@media (min-width: 768px) and (max-width: 1023.98px) {
    :root {
        --pa-rail-w: 268px;
    }

    body.pa-rail-on .pa-nav-hint,
    body.pa-rail-on .pa-nav-btn.review .pa-lbl {
        display: none;
    }

    body.pa-rail-on .pa-nav-btn {
        padding: 10px 16px;
    }

    .pa-rail .pa-an-cell b {
        font-size: .92rem;
    }
}

/* =========================================================
   2. STICKY HUD
   ========================================================= */
.pa-hud {
    position: sticky;
    top: var(--pa-top);
    z-index: 90;
    margin: -4px 0 10px;
    padding: 10px 14px 8px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface-solid);
    box-shadow: var(--shadow-sm);
}

.pa-hud-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* ---- Clock (analog + digital) ---- */
.pa-clock {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 12%, transparent), transparent 70%);
    flex-shrink: 0;
}

.pa-dial {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .35));
}

.pa-dial .pa-face {
    fill: color-mix(in srgb, var(--surface-raised) 90%, transparent);
    stroke: var(--line);
    stroke-width: 2;
}

.pa-dial .pa-tick {
    stroke: var(--text-muted);
    stroke-width: 1.6;
    stroke-linecap: round;
    opacity: .55;
}

.pa-dial .pa-tick-major {
    stroke: var(--text-main);
    opacity: .8;
    stroke-width: 2.4;
}

.pa-dial .pa-hand-min {
    stroke: var(--text-main);
    stroke-width: 3.4;
    stroke-linecap: round;
    transform-origin: 50px 50px;
    transition: transform .35s cubic-bezier(.3, 1.6, .5, 1);
}

.pa-dial .pa-hand-sec {
    stroke: var(--brand-2);
    stroke-width: 2;
    stroke-linecap: round;
    transform-origin: 50px 50px;
    transition: transform .18s cubic-bezier(.3, 1.9, .5, 1);
}

.pa-dial .pa-pin {
    fill: var(--brand-2);
}

.pa-clock-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.pa-clock-main {
    font-family: 'Courier New', ui-monospace, monospace;
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: .5px;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

.pa-clock-sub {
    font-size: .68rem;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: .4px;
    text-transform: uppercase;
}

.pa-clock-sub b {
    color: var(--warning);
    font-variant-numeric: tabular-nums;
}

/* ---- Progress ---- */
.pa-progress {
    flex: 1;
    min-width: 150px;
}

.pa-progress-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: .78rem;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 5px;
}

.pa-progress-top b {
    color: var(--text-main);
    font-size: .95rem;
}

.pa-bar {
    height: 7px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text-main) 10%, transparent);
    overflow: hidden;
}

.pa-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--brand-2), var(--brand));
    box-shadow: 0 0 12px color-mix(in srgb, var(--brand-2) 60%, transparent);
    transition: width .35s ease;
}

.pa-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

/* ---- Live stat chips ---- */
.pa-chips {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.pa-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-raised);
    font-size: .78rem;
    font-weight: 800;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    transition: transform .18s ease, box-shadow .18s ease;
}

.pa-chip i {
    font-size: .8rem;
}

.pa-chip.pop-a,
.pa-chip.pop-b {
    animation: paChipPop .45s cubic-bezier(.2, 1.6, .4, 1);
}

@keyframes paChipPop {
    0% {
        transform: scale(1);
    }

    45% {
        transform: scale(1.22);
    }

    100% {
        transform: scale(1);
    }
}

.pa-chip.c-ok {
    color: var(--pa-correct);
    border-color: color-mix(in srgb, var(--pa-correct) 45%, transparent);
    background: color-mix(in srgb, var(--pa-correct) 12%, var(--surface-raised));
}

.pa-chip.c-bad {
    color: var(--pa-wrong);
    border-color: color-mix(in srgb, var(--pa-wrong) 45%, transparent);
    background: color-mix(in srgb, var(--pa-wrong) 12%, var(--surface-raised));
}

.pa-chip.c-rev {
    color: var(--pa-review);
    border-color: color-mix(in srgb, var(--pa-review) 45%, transparent);
    background: color-mix(in srgb, var(--pa-review) 12%, var(--surface-raised));
}

.pa-chip.c-gold {
    color: var(--pa-gold);
    border-color: color-mix(in srgb, var(--pa-gold) 45%, transparent);
    background: color-mix(in srgb, var(--pa-gold) 12%, var(--surface-raised));
}

.pa-chip.c-fire {
    color: #ff9f43;
    border-color: rgba(255, 159, 67, .45);
    background: color-mix(in srgb, #ff9f43 12%, var(--surface-raised));
}

.pa-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    min-width: 34px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-raised);
    color: var(--text-main);
    font-size: .8rem;
    font-weight: 800;
    cursor: pointer;
    transition: .18s ease;
}

.pa-icon-btn:hover {
    border-color: var(--brand);
    color: var(--brand);
    transform: translateY(-1px);
}

.pa-icon-btn.on {
    background: color-mix(in srgb, var(--brand-2) 18%, var(--surface-raised));
    border-color: var(--brand-2);
    color: var(--brand-2);
}

/* ---- Circle palette (the line of dots) ---- */
.pa-palette-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 9px;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
}

.pa-hud-lead:empty {
    display: none;
}

.pa-hud-lead {
    flex-shrink: 0;
}

.pa-parts-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-raised);
    color: var(--text-main);
    font-weight: 800;
    font-size: .78rem;
    cursor: pointer;
    transition: .18s ease;
}

.pa-parts-btn:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.pa-palette {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 3px 2px 7px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
}

/* Review-only mode: everything that is not marked drops out of the line. */
.pa-dot.is-hidden {
    display: none;
}

.pa-palette::-webkit-scrollbar {
    height: 5px;
}

.pa-palette::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 999px;
}

.pa-dot {
    position: relative;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--surface-raised);
    color: var(--text-muted);
    font-weight: 800;
    font-size: .8rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-variant-numeric: tabular-nums;
    transition: transform .18s cubic-bezier(.2, 1.5, .4, 1), background .2s, color .2s, box-shadow .2s;
}

.pa-dot:hover {
    transform: translateY(-2px) scale(1.06);
    color: var(--text-main);
}

.pa-dot.is-correct {
    background: var(--pa-correct);
    border-color: var(--pa-correct);
    color: #06251a;
    box-shadow: 0 0 12px color-mix(in srgb, var(--pa-correct) 55%, transparent);
}

.pa-dot.is-wrong {
    background: var(--pa-wrong);
    border-color: var(--pa-wrong);
    color: #2c0606;
    box-shadow: 0 0 12px color-mix(in srgb, var(--pa-wrong) 55%, transparent);
}

.pa-dot.is-review {
    border-color: var(--pa-review);
    color: var(--pa-review);
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--pa-review) 45%, transparent);
}

.pa-dot.is-review.is-correct,
.pa-dot.is-review.is-wrong {
    box-shadow: inset 0 0 0 2px var(--pa-review), 0 0 10px color-mix(in srgb, var(--pa-review) 45%, transparent);
}

/* Purple text on a filled red/green dot is unreadable — the review ring alone
   carries the mark once the question has been attempted. */
.pa-dot.is-review.is-correct {
    color: #06251a;
}

.pa-dot.is-review.is-wrong {
    color: #2c0606;
}

.pa-dot.is-golden::after {
    content: '★';
    position: absolute;
    top: -5px;
    right: -3px;
    font-size: .62rem;
    color: var(--pa-gold);
    text-shadow: 0 0 6px rgba(255, 213, 79, .8);
}

.pa-dot.is-current {
    transform: scale(1.16);
    border-color: var(--brand);
    color: var(--brand);
    background: color-mix(in srgb, var(--brand) 16%, var(--surface-raised));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 28%, transparent);
}

.pa-dot.is-current.is-correct {
    color: #06251a;
    background: var(--pa-correct);
}

.pa-dot.is-current.is-wrong {
    color: #2c0606;
    background: var(--pa-wrong);
}

.pa-dot.mark-a,
.pa-dot.mark-b {
    animation: paDotPop .5s cubic-bezier(.2, 1.7, .4, 1);
}

@keyframes paDotPop {
    0% {
        transform: scale(1);
    }

    40% {
        transform: scale(1.45);
    }

    100% {
        transform: scale(1.16);
    }
}

/* =========================================================
   3. ANALYSIS PANEL
   ========================================================= */
.pa-analysis {
    display: none;
    margin-top: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-raised);
    animation: paCardIn .22s ease both;
}

.pa-analysis.open {
    display: block;
}

.pa-an-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
    gap: 8px;
}

.pa-an-cell {
    padding: 9px 10px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-solid) 80%, transparent);
}

.pa-an-cell span {
    display: block;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    font-weight: 800;
}

.pa-an-cell b {
    font-size: 1.15rem;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

.pa-an-cell.bump {
    animation: paCellBump .55s cubic-bezier(.2, 1.5, .4, 1);
}

@keyframes paCellBump {
    0% {
        transform: scale(1);
        border-color: var(--line);
    }

    40% {
        transform: scale(1.06);
        border-color: var(--brand-2);
        box-shadow: 0 0 16px color-mix(in srgb, var(--brand-2) 30%, transparent);
    }

    100% {
        transform: scale(1);
        border-color: var(--line);
    }
}

.pa-an-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.pa-an-btn {
    flex: 1;
    min-width: 140px;
    padding: 9px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface-solid);
    color: var(--text-main);
    font-weight: 800;
    font-size: .85rem;
    cursor: pointer;
    transition: .18s ease;
}

.pa-an-btn:hover {
    transform: translateY(-1px);
    border-color: var(--brand);
    color: var(--brand);
}

.pa-an-btn.danger {
    border-color: color-mix(in srgb, var(--pa-wrong) 55%, transparent);
    color: var(--pa-wrong);
}

.pa-an-btn.review-only {
    border-color: color-mix(in srgb, var(--pa-review) 50%, transparent);
    color: var(--pa-review);
}

.pa-an-btn.review-only.on {
    background: color-mix(in srgb, var(--pa-review) 20%, var(--surface-solid));
    border-color: var(--pa-review);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--pa-review) 25%, transparent);
}

.pa-an-btn.pending-only.on {
    background: color-mix(in srgb, var(--brand) 20%, var(--surface-solid));
    border-color: var(--brand);
    color: var(--brand);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 25%, transparent);
}

/* =========================================================
   4. BOTTOM NAV BAR
   ========================================================= */
.pa-navbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--line);
    background: var(--surface-solid);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, .28);
}

.pa-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--surface-raised);
    color: var(--text-main);
    font-weight: 800;
    font-size: .92rem;
    cursor: pointer;
    transition: .18s ease;
}

.pa-nav-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: var(--brand);
    color: var(--brand);
}

.pa-nav-btn:disabled {
    opacity: .38;
    cursor: not-allowed;
}

.pa-nav-btn.primary {
    background: linear-gradient(135deg, var(--brand-2), var(--brand));
    border-color: transparent;
    color: #06121b;
    box-shadow: 0 8px 22px color-mix(in srgb, var(--brand-2) 35%, transparent);
}

.pa-nav-btn.primary:hover:not(:disabled) {
    color: #06121b;
    filter: brightness(1.06);
}

.pa-nav-btn.review.on {
    border-color: var(--pa-review);
    color: var(--pa-review);
    background: color-mix(in srgb, var(--pa-review) 16%, var(--surface-raised));
}

.pa-zoom-group {
    display: flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-raised);
}

.pa-zoom-btn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-main);
    font-size: .9rem;
    cursor: pointer;
    transition: .16s ease;
}

.pa-zoom-btn:hover:not(:disabled) {
    background: var(--brand-soft);
    color: var(--brand);
}

.pa-zoom-btn:disabled {
    opacity: .32;
    cursor: not-allowed;
}

.pa-nav-mid {
    flex: 1;
    text-align: center;
    color: var(--text-muted);
    font-size: .8rem;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.15;
}

.pa-nav-mid b {
    color: var(--text-main);
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}

.pa-nav-hint {
    font-size: .68rem;
    opacity: .75;
}

/* =========================================================
   5. FEEDBACK EFFECTS
   ========================================================= */
.pa-fx {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: visible;
    z-index: 5;
}

.pa-spark {
    position: absolute;
    width: 9px;
    height: 9px;
    left: var(--x, 50%);
    top: var(--y, 50%);
    margin: -4px 0 0 -4px;
    border-radius: 2px;
    background: var(--c, #ffd54f);
    box-shadow: 0 0 10px var(--c, #ffd54f);
    animation: paSpark var(--dur, .9s) cubic-bezier(.15, .8, .3, 1) forwards;
}

@keyframes paSpark {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1) rotate(0deg);
    }

    70% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty)) scale(.2) rotate(var(--rot, 220deg));
    }
}

.pa-ring {
    position: absolute;
    left: var(--x, 50%);
    top: var(--y, 50%);
    width: 26px;
    height: 26px;
    margin: -13px 0 0 -13px;
    border-radius: 50%;
    border: 3px solid var(--pa-correct);
    animation: paRing .75s cubic-bezier(.2, .8, .3, 1) forwards;
}

@keyframes paRing {
    0% {
        opacity: .95;
        transform: scale(.3);
    }

    100% {
        opacity: 0;
        transform: scale(6);
    }
}

.pa-float {
    position: absolute;
    left: var(--x, 50%);
    top: var(--y, 50%);
    transform: translate(-50%, -50%);
    font-weight: 900;
    font-size: 1.05rem;
    color: var(--pa-correct);
    text-shadow: 0 2px 10px rgba(0, 0, 0, .5);
    animation: paFloat 1.1s cubic-bezier(.2, .8, .3, 1) forwards;
    white-space: nowrap;
}

.pa-float.bad {
    color: var(--pa-wrong);
}

@keyframes paFloat {
    0% {
        opacity: 0;
        transform: translate(-50%, -10%) scale(.7);
    }

    22% {
        opacity: 1;
        transform: translate(-50%, -60%) scale(1.12);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -190%) scale(1);
    }
}

.pa-glow {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0;
    animation: paGlowFade .9s ease forwards;
}

.pa-glow.ok {
    box-shadow: inset 0 0 0 2px var(--pa-correct), inset 0 0 42px color-mix(in srgb, var(--pa-correct) 30%, transparent);
}

.pa-glow.bad {
    box-shadow: inset 0 0 0 2px var(--pa-wrong), inset 0 0 42px color-mix(in srgb, var(--pa-wrong) 30%, transparent);
}

@keyframes paGlowFade {
    0% {
        opacity: 0;
    }

    25% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

body.pa-active #quiz-view .test-question-card.pa-shake {
    animation: paShake .5s cubic-bezier(.36, .07, .19, .97);
}

@keyframes paShake {

    10%,
    90% {
        transform: translateX(-3px);
    }

    20%,
    80% {
        transform: translateX(6px);
    }

    30%,
    50%,
    70% {
        transform: translateX(-10px);
    }

    40%,
    60% {
        transform: translateX(10px);
    }

    100% {
        transform: translateX(0);
    }
}

/* Full-session confetti.
   z-index sits ABOVE the summary overlay (100002): below it, the overlay's
   backdrop-filter counted the falling pieces as backdrop and blurred them the
   moment the overview opened. pointer-events:none keeps the card clickable. */
.pa-confetti {
    position: fixed;
    inset: 0;
    z-index: 100003;
    pointer-events: none;
    overflow: hidden;
}

.pa-conf-piece {
    position: absolute;
    top: -14px;
    width: 9px;
    height: 15px;
    background: var(--c, #ffd54f);
    border-radius: 2px;
    /* Promote each piece to its own layer so the rotation is rasterised at
       device resolution instead of being scaled from one flat snapshot. */
    will-change: transform, opacity;
    backface-visibility: hidden;
    animation: paFall var(--dur, 2.6s) linear var(--delay, 0s) forwards;
}

@keyframes paFall {
    0% {
        opacity: 1;
        transform: translateY(-10vh) rotate(0deg);
    }

    100% {
        opacity: .1;
        transform: translateY(105vh) rotate(760deg);
    }
}

/* =========================================================
   5b. VIEW SOLUTION GATE
   ========================================================= */
.pa-solution-row {
    display: none;
    margin-top: 10px;
}

.pa-solution-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: 12px;
    border: 1px solid color-mix(in srgb, var(--brand-2) 55%, transparent);
    background: color-mix(in srgb, var(--brand-2) 14%, var(--surface-raised));
    color: var(--brand-2);
    font-weight: 800;
    font-size: .88em;
    cursor: pointer;
    transition: .18s ease;
}

.pa-solution-btn:hover {
    background: color-mix(in srgb, var(--brand-2) 24%, var(--surface-raised));
    transform: translateY(-1px);
}

body.pa-active #quiz-view .explanation-container {
    animation: paCardIn .26s ease both;
}

/* =========================================================
   5c. SESSION SUMMARY OVERLAY
   ========================================================= */
.pa-summary {
    position: fixed;
    inset: 0;
    z-index: 100002;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(6, 9, 14, .62);
    backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity .22s ease;
}

.pa-summary.open {
    display: flex;
    opacity: 1;
}

.pa-sum-card {
    position: relative;
    width: min(760px, 100%);
    max-height: min(88vh, 780px);
    overflow-y: auto;
    padding: 22px;
    border-radius: 22px;
    border: 1px solid var(--line);
    background: var(--surface-solid);
    box-shadow: var(--shadow-md);
    transform: translateY(14px) scale(.985);
    transition: transform .24s cubic-bezier(.2, .9, .3, 1);
}

.pa-summary.open .pa-sum-card {
    transform: none;
}

.pa-sum-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--surface-raised);
    color: var(--text-muted);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    transition: .16s ease;
}

.pa-sum-close:hover {
    color: var(--text-main);
    border-color: var(--brand);
}

.pa-sum-head {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    padding-bottom: 16px;
    border-bottom: 1px dashed var(--line);
}

.pa-sum-ring {
    position: relative;
    width: 118px;
    height: 118px;
    flex-shrink: 0;
}

.pa-sum-ring svg {
    width: 100%;
    height: 100%;
}

.pa-sum-ring .ring-bg {
    fill: none;
    stroke: color-mix(in srgb, var(--text-main) 12%, transparent);
    stroke-width: 11;
}

.pa-sum-ring .ring-fg {
    fill: none;
    stroke: var(--brand-2);
    stroke-width: 11;
    stroke-linecap: round;
    filter: drop-shadow(0 0 8px color-mix(in srgb, var(--brand-2) 55%, transparent));
    animation: paRingDraw .9s cubic-bezier(.2, .8, .3, 1) both;
}

@keyframes paRingDraw {
    from {
        stroke-dashoffset: 340;
    }

    to {
        stroke-dashoffset: 0;
    }
}

.pa-sum-ring-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
}

.pa-sum-ring-text b {
    font-size: 1.7rem;
    font-weight: 900;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

.pa-sum-ring-text span {
    font-size: .62rem;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--text-muted);
    font-weight: 800;
}

.pa-sum-title {
    flex: 1;
    min-width: 220px;
}

.pa-sum-title h2 {
    margin: 0 0 4px;
    font-size: 1.42rem;
    font-weight: 900;
    color: var(--text-main);
}

.pa-sum-grade {
    margin: 0 0 10px;
    font-size: .92rem;
    font-weight: 700;
}

.pa-sum-grade.tone-gold {
    color: var(--pa-gold);
}

.pa-sum-grade.tone-good {
    color: var(--pa-correct);
}

.pa-sum-grade.tone-ok {
    color: var(--brand);
}

.pa-sum-grade.tone-warn {
    color: #ff9f43;
}

.pa-sum-grade.tone-bad {
    color: var(--pa-wrong);
}

.pa-sum-score {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text-main);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.pa-sum-score span {
    font-size: .95rem;
    font-weight: 700;
    color: var(--text-muted);
}

.pa-sum-time {
    margin-top: 8px;
    font-size: .84rem;
    font-weight: 700;
    color: var(--text-muted);
}

.pa-sum-time i {
    color: var(--warning);
    margin-right: 5px;
}

.pa-sum-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
    gap: 8px;
    margin: 16px 0;
}

.pa-sum-cell {
    padding: 9px 10px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface-raised);
    text-align: center;
}

.pa-sum-cell span {
    display: block;
    font-size: .6rem;
    text-transform: uppercase;
    letter-spacing: .4px;
    font-weight: 800;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pa-sum-cell b {
    font-size: 1.1rem;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

.pa-sum-strip-wrap {
    padding: 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-raised) 70%, transparent);
}

.pa-sum-strip-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 9px;
    font-size: .74rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .4px;
}

.pa-sum-legend {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 700;
}

.pa-sum-legend .dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: -1px;
}

.pa-sum-legend .dot.ok {
    background: var(--pa-correct);
}

.pa-sum-legend .dot.bad {
    background: var(--pa-wrong);
}

.pa-sum-legend .dot.rev {
    background: transparent;
    box-shadow: inset 0 0 0 2px var(--pa-review);
}

.pa-sum-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    max-height: 132px;
    overflow-y: auto;
}

.pa-sum-dot {
    width: 27px;
    height: 27px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface-raised);
    color: var(--text-muted);
    font-size: .7rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform .16s ease;
}

.pa-sum-dot:hover {
    transform: translateY(-2px) scale(1.08);
}

.pa-sum-dot.ok {
    background: var(--pa-correct);
    border-color: var(--pa-correct);
    color: #06251a;
}

.pa-sum-dot.bad {
    background: var(--pa-wrong);
    border-color: var(--pa-wrong);
    color: #2c0606;
}

.pa-sum-dot.rev {
    box-shadow: inset 0 0 0 2px var(--pa-review);
}

.pa-sum-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.pa-sum-btn {
    flex: 1 1 160px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    border-radius: 13px;
    border: 1px solid var(--line);
    background: var(--surface-raised);
    color: var(--text-main);
    font-weight: 800;
    font-size: .86rem;
    cursor: pointer;
    transition: .18s ease;
}

.pa-sum-btn:hover {
    transform: translateY(-1px);
    border-color: var(--brand);
    color: var(--brand);
}

.pa-sum-btn.primary {
    background: linear-gradient(135deg, var(--brand-2), var(--brand));
    border-color: transparent;
    color: #06121b;
}

.pa-sum-btn.primary:hover {
    color: #06121b;
    filter: brightness(1.06);
}

.pa-sum-btn.danger {
    border-color: color-mix(in srgb, var(--pa-wrong) 55%, transparent);
    color: var(--pa-wrong);
}

.pa-sum-btn.ghost {
    color: var(--text-muted);
}

.pa-an-btn.summary {
    border-color: color-mix(in srgb, var(--brand-2) 55%, transparent);
    color: var(--brand-2);
}

@media (max-width: 767.98px) {
    .pa-sum-card {
        padding: 16px;
        border-radius: 18px;
        max-height: 92vh;
    }

    .pa-sum-head {
        gap: 14px;
    }

    .pa-sum-ring {
        width: 92px;
        height: 92px;
    }

    .pa-sum-title h2 {
        font-size: 1.2rem;
    }

    .pa-sum-score {
        font-size: 1.6rem;
    }

    .pa-sum-btn {
        flex: 1 1 100%;
    }
}

/* =========================================================
   5c-2. PAUSE — question hidden behind a blur, clock stopped
   ========================================================= */
body.pa-paused #quiz-view .test-question-card,
body.pa-paused #quiz-view .pa-passage {
    filter: blur(11px) saturate(.75);
    pointer-events: none;
    user-select: none;
}

body.pa-active #quiz-view .test-question-card,
body.pa-active #quiz-view .pa-passage {
    transition: filter .28s ease;
}

.pa-nav-btn.pause.on {
    border-color: var(--brand-2);
    color: var(--brand-2);
    background: color-mix(in srgb, var(--brand-2) 16%, var(--surface-raised));
}

.pa-pause-overlay {
    position: fixed;
    inset: 0;
    z-index: 100002;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    /* No backdrop-filter here: the question carries its own blur, and a second
       blur layer would soften the card's own text. */
    background: rgba(6, 9, 14, .48);
    opacity: 0;
    transition: opacity .2s ease;
}

.pa-pause-overlay.open {
    display: flex;
    opacity: 1;
}

.pa-pause-card {
    width: min(420px, 100%);
    padding: 26px 24px 22px;
    border-radius: 24px;
    text-align: center;
    border: 1px solid var(--line);
    background:
        radial-gradient(120% 80% at 50% -10%, color-mix(in srgb, var(--brand-2) 18%, transparent), transparent 60%),
        var(--surface-solid);
    box-shadow: var(--shadow-md);
    transform: translateY(12px) scale(.97);
    transition: transform .24s cubic-bezier(.2, .9, .3, 1);
}

.pa-pause-overlay.open .pa-pause-card {
    transform: none;
}

.pa-pause-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.7rem;
    color: var(--brand-2);
    background: color-mix(in srgb, var(--brand-2) 15%, transparent);
    border: 1px solid color-mix(in srgb, var(--brand-2) 45%, transparent);
    animation: paPausePulse 2.6s ease-in-out infinite;
}

@keyframes paPausePulse {

    0%,
    100% {
        box-shadow: 0 0 0 8px color-mix(in srgb, var(--brand-2) 9%, transparent);
    }

    50% {
        box-shadow: 0 0 0 17px color-mix(in srgb, var(--brand-2) 3%, transparent);
    }
}

.pa-pause-card h2 {
    margin: 0 0 6px;
    font-size: 1.34rem;
    font-weight: 900;
    color: var(--text-main);
}

.pa-pause-sub {
    margin: 0 0 18px;
    font-size: .84rem;
    font-weight: 600;
    color: var(--text-muted);
}

.pa-pause-clock {
    font-family: 'Courier New', ui-monospace, monospace;
    font-size: 2.4rem;
    font-weight: 900;
    letter-spacing: 2px;
    line-height: 1;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

.pa-pause-clock-label {
    display: block;
    margin-top: 5px;
    font-size: .62rem;
    text-transform: uppercase;
    letter-spacing: .7px;
    font-weight: 800;
    color: var(--text-muted);
}

.pa-pause-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    margin: 20px 0 18px;
}

.pa-pause-stats>div {
    padding: 8px 4px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-raised) 75%, transparent);
}

.pa-pause-stats span {
    display: block;
    font-size: .55rem;
    text-transform: uppercase;
    letter-spacing: .3px;
    font-weight: 800;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pa-pause-stats b {
    font-size: 1rem;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

.pa-pause-actions {
    display: flex;
    gap: 8px;
}

.pa-pause-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--surface-raised);
    color: var(--text-main);
    font-weight: 800;
    font-size: .88rem;
    cursor: pointer;
    transition: .18s ease;
}

.pa-pause-btn:hover {
    transform: translateY(-1px);
}

.pa-pause-btn.primary {
    background: linear-gradient(135deg, var(--brand-2), var(--brand));
    border-color: transparent;
    color: #06121b;
    box-shadow: 0 8px 22px color-mix(in srgb, var(--brand-2) 32%, transparent);
}

.pa-pause-btn.ghost {
    color: var(--text-muted);
    flex: 0 1 auto;
}

.pa-pause-hint {
    margin-top: 12px;
    font-size: .7rem;
    font-weight: 700;
    color: var(--text-muted);
}

@media (max-width: 767.98px) {
    .pa-pause-card {
        padding: 22px 16px 18px;
        border-radius: 20px;
    }

    .pa-pause-clock {
        font-size: 2rem;
    }

    .pa-pause-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .pa-pause-icon {
        animation: none;
    }
}

/* =========================================================
   5d. FIGURE FALLBACK
   ========================================================= */
.figure-img-missing {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px dashed color-mix(in srgb, var(--warning) 55%, transparent);
    background: color-mix(in srgb, var(--warning) 10%, transparent);
    color: var(--warning);
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer;
    transition: .18s ease;
}

.figure-img-missing:hover {
    background: color-mix(in srgb, var(--warning) 18%, transparent);
}

/* =========================================================
   5e. QUESTION HEAD: number + exam-source chip
   ========================================================= */
.pa-card-head {
    flex-wrap: wrap;
    gap: 8px;
}

.pa-head-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.pa-exam-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--warning) 45%, transparent);
    background: color-mix(in srgb, var(--warning) 12%, transparent);
    color: var(--warning);
    font-size: .7em;
    font-weight: 800;
    letter-spacing: .3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pa-exam-chip i {
    font-size: .9em;
    opacity: .85;
}

/* =========================================================
   6. IN-CARD REVIEW BUTTON
   ========================================================= */
.pa-review-btn {
    background: none;
    border: none;
    font-size: 1.05rem;
    cursor: pointer;
    color: #667;
    padding: 0;
    transition: .2s;
}

.pa-review-btn.active {
    color: var(--pa-review);
    text-shadow: 0 0 10px color-mix(in srgb, var(--pa-review) 60%, transparent);
}

/* =========================================================
   7. RESPONSIVE
   ========================================================= */
@media (max-width: 767.98px) {
    .pa-hud {
        padding: 8px 10px 6px;
        border-radius: 14px;
        margin: -2px 0 12px;
    }

    .pa-hud-row {
        gap: 8px;
    }

    .pa-dial {
        width: 34px;
        height: 34px;
    }

    .pa-clock {
        padding: 4px 10px 4px 4px;
        gap: 7px;
    }

    .pa-clock-main {
        font-size: .92rem;
    }

    /* Phone HUD must stay short — the question is the point, not the chrome.
       Row 1: clock + progress + toggles. Row 2: chips on one scrolling line.
       Row 3: the palette. */
    .pa-progress {
        flex: 1 1 60px;
        min-width: 60px;
    }

    /* The ✓/✗ chips right below already say how many are attempted. */
    #pa-done-label {
        display: none;
    }

    .pa-icon-btn {
        height: 30px;
        min-width: 30px;
        padding: 0 8px;
    }

    .pa-btn-analyze span {
        display: none;
    }

    .pa-chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        margin-top: 6px;
    }

    .pa-chips::-webkit-scrollbar {
        display: none;
    }

    .pa-chip {
        padding: 4px 8px;
        font-size: .72rem;
    }

    .pa-dot {
        width: 30px;
        height: 30px;
        font-size: .74rem;
    }

    .pa-navbar {
        gap: 6px;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    }

    .pa-nav-btn {
        padding: 10px 14px;
        font-size: .85rem;
    }

    .pa-nav-btn span.pa-lbl {
        display: none;
    }

    .pa-nav-hint {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {

    .pa-spark,
    .pa-ring,
    .pa-float,
    .pa-conf-piece,
    body.pa-active #quiz-view .test-question-card.pa-shake,
    body.pa-active #quiz-view .test-question-card.pa-visible {
        animation: none !important;
    }
}
