:root {
    --primary: #2563eb;
    --primary-light: #60a5fa;
    --secondary: #64748b;
    --background: #f8fafc;
    --surface: rgba(255, 255, 255, 0.9);
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

header {
    background: var(--surface);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    box-shadow: var(--shadow);
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.panel {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    padding-bottom: 5rem;
}

.passage-panel {
    border-right: 1px solid var(--border);
    background: #fff;
}

.question-panel {
    background: var(--background);
}

.card {
    background: var(--surface);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    margin-bottom: 2rem;
}

h1, h2, h3 {
    margin-bottom: 1rem;
    font-weight: 600;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 1rem;
}

.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-green  { background: #dcfce7; color: #166534; }
.badge-red    { background: #fee2e2; color: #991b1b; }

.passage-text {
    font-size: 1.1rem;
    white-space: pre-wrap;
    color: #334155;
}

.highlight {
    background-color: #fde68a;
    border-bottom: 2px solid #f59e0b;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.option-btn {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    font-size: 1rem;
    width: 100%;
}

.option-btn:hover {
    border-color: var(--primary-light);
    background-color: #eff6ff;
}

.option-btn.selected {
    border-color: var(--primary);
    background-color: #dbeafe;
    box-shadow: 0 0 0 2px var(--primary-light);
}

.option-btn.correct {
    border-color: var(--success);
    background-color: #dcfce7;
}

.option-btn.incorrect {
    border-color: var(--error);
    background-color: #fee2e2;
}

.reveal-btn {
    background: var(--primary);
    color: white;
    padding: 1rem 2rem;
    border: none;
    border-radius: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
    margin-top: 1rem;
}

.reveal-btn:hover {
    background: #1d4ed8;
}

.reveal-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.feedback-section {
    margin-top: 2rem;
    padding: 1.5rem;
    border-radius: 0.75rem;
    display: none;
}

.feedback-section.visible {
    display: block;
}

.feedback-success { background: #f0fdf4; border: 1px solid #bbf7d0; }
.feedback-error { background: #fef2f2; border: 1px solid #fecaca; }

.strategy-box {
    margin-top: 1rem;
    padding: 1rem;
    background: #fffbeb;
    border: 1px solid #fef3c7;
    border-radius: 0.5rem;
    font-size: 0.9rem;
}

.timer {
    font-family: monospace;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--secondary);
}

.question-counter {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Modal / Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.hidden { display: none; }

.btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    background: #fff;
    cursor: pointer;
    font-weight: 600;
}

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

/* ── Session Setup Screen ───────────────────────────────────────── */

#setupScreen {
    position: fixed;
    inset: 0;
    background: var(--background);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    overflow-y: auto;
    padding: 2rem 1rem;
}

.setup-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: 2rem 2.25rem 2.25rem;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
}

.setup-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1.75rem;
}

.setup-section {
    margin-bottom: 1.4rem;
}

.setup-section h3 {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
}

.setup-section label {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.6rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.15s;
    user-select: none;
}

.setup-section label:hover { background: #f1f5f9; }

.setup-section input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.q-count {
    margin-left: auto;
    font-size: 0.78rem;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 0.15rem 0.55rem;
    border-radius: 9999px;
    white-space: nowrap;
}

/* Difficulty colour dots */
.diff-dot {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    flex-shrink: 0;
}
.diff-easy   { background: #22c55e; }
.diff-medium { background: #f59e0b; }
.diff-hard   { background: #ef4444; }

.setup-section select {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    cursor: pointer;
}

/* Preset grid */
.preset-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.preset-btn {
    padding: 0.5rem 0.6rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    text-align: center;
}

.preset-btn:hover {
    background: #eff6ff;
    border-color: var(--primary-light);
    color: var(--primary);
}

/* Session summary bar */
.session-summary {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 0.5rem;
    padding: 0.65rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    min-height: 2.5rem;
    display: flex;
    align-items: center;
}

.session-summary.session-summary-empty {
    background: #fef2f2;
    border-color: #fecaca;
    color: var(--error);
}

.session-summary.session-summary-mastered {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #15803d;
}

.setup-start-btn {
    width: 100%;
    padding: 0.85rem;
    font-size: 1rem;
    border-radius: 0.75rem;
}

.setup-start-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ── Rhetorical Synthesis — notes list ─────────────────────────── */
.rs-intro {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-style: italic;
}

.rs-notes {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rs-notes li {
    padding: 0.55rem 0.75rem 0.55rem 1rem;
    background: #f8fafc;
    border-left: 3px solid var(--primary-light);
    border-radius: 0 0.4rem 0.4rem 0;
    font-size: 1rem;
    line-height: 1.5;
}

/* ── RS writing goal highlight (question text) ──────────────────── */
.rs-goal {
    background: #fef9c3;
    border-bottom: 2px solid #eab308;
    font-weight: 700;
    padding: 0 0.15rem;
    border-radius: 2px;
}

/* ── Transitions blank highlight ────────────────────────────────── */
.trans-blank {
    background: #dbeafe;
    border-bottom: 2px solid var(--primary);
    font-weight: 700;
    padding: 0 0.15rem;
    border-radius: 2px;
    letter-spacing: 0.05em;
}

/* ── Session history ────────────────────────────────────────────── */
.history-section {
    margin-top: 1.25rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.history-header {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0;
}

.history-header:hover { color: var(--primary); }

#historyList {
    margin-top: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.history-empty {
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 0.25rem 0;
}

.hist-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    padding: 0.4rem 0.6rem;
    border-radius: 0.4rem;
    background: #f8fafc;
    border: 1px solid var(--border);
}

.hist-date {
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 90px;
}

.hist-skills {
    flex: 1;
    color: var(--text);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hist-score {
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.78rem;
}

.hist-pass { background: #dcfce7; color: #166534; }
.hist-warn { background: #ffedd5; color: #9a3412; }
.hist-fail { background: #fee2e2; color: #991b1b; }

/* ── Resize handle ──────────────────────────────────────────────── */
.resize-handle {
    width: 6px;
    background: var(--border);
    cursor: col-resize;
    flex-shrink: 0;
    transition: background 0.15s;
    position: relative;
    z-index: 5;
}

.resize-handle:hover,
.resize-handle:active {
    background: var(--primary-light);
}

.resize-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    height: 2rem;
    width: 2px;
    border-left: 2px dotted var(--secondary);
    opacity: 0.4;
}

/* ── Resume banner ──────────────────────────────────────────────── */
.resume-banner {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.resume-info {
    font-size: 0.87rem;
    font-weight: 600;
    color: var(--primary);
    flex: 1;
}

.resume-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ── Completion screen ──────────────────────────────────────────── */
.completion-screen {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 150;
    overflow-y: auto;
    padding: 2rem 1rem;
}

.completion-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: 2rem 2.25rem;
    width: 100%;
    max-width: 560px;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}

.completion-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.completion-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.completion-score-row {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.75rem;
}

.completion-big-score {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text);
    font-family: monospace;
}

.completion-pct {
    font-size: 1.4rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 0.4rem;
}

.pct-pass { background: #dcfce7; color: #166534; }
.pct-warn { background: #ffedd5; color: #9a3412; }
.pct-fail { background: #fee2e2; color: #991b1b; }

/* ── Per-skill breakdown ────────────────────────────────────────── */
.skill-breakdown {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.breakdown-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
}

.breakdown-skill {
    font-weight: 700;
    width: 3.5rem;
    flex-shrink: 0;
    color: var(--text-muted);
}

.breakdown-bar {
    font-family: monospace;
    font-size: 0.75rem;
    letter-spacing: -0.02em;
    color: var(--primary-light);
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
}

.breakdown-score {
    font-weight: 700;
    font-size: 0.78rem;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    white-space: nowrap;
    flex-shrink: 0;
}

.bd-pass { background: #dcfce7; color: #166534; }
.bd-warn { background: #ffedd5; color: #9a3412; }
.bd-fail { background: #fee2e2; color: #991b1b; }

/* ── Missed questions ───────────────────────────────────────────── */
.missed-heading {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
}

.missed-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    max-height: 240px;
    overflow-y: auto;
}

.missed-item {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 0.5rem;
    padding: 0.65rem 0.75rem;
}

.missed-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}

.missed-skill {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
}

.missed-q {
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 0.35rem;
    line-height: 1.4;
}

.missed-answers {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.8rem;
}

.missed-wrong {
    color: #dc2626;
    font-weight: 600;
}

.missed-right {
    color: #16a34a;
    font-weight: 600;
}

/* ── Completion action buttons ──────────────────────────────────── */
.completion-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.completion-action-btn {
    padding: 0.7rem 1.5rem;
    font-size: 0.95rem;
    border-radius: 0.65rem;
}

/* ── Score display in header ────────────────────────────────────── */
.score-display {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* ══════════════════════════════════════════════════════════════════
   TABLET  (701 px – 1024 px)
   ══════════════════════════════════════════════════════════════════ */
@media (min-width: 701px) and (max-width: 1024px) {

    body {
        height: auto;
        overflow: auto;
        overflow-x: hidden;
    }

    #app {
        height: auto;
        min-height: 100svh;
    }

    header {
        padding: 0.75rem 1.5rem;
    }

    .controls {
        gap: 0.6rem;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    /* Stack panels vertically — no split pane on tablet */
    .main-content {
        flex-direction: column;
        overflow: visible;
    }

    .panel {
        flex: none;
        width: 100%;
        overflow-y: visible;
        padding: 1.5rem;
        padding-bottom: 2rem;
    }

    .passage-panel {
        border-right: none;
        border-bottom: 2px solid var(--border);
    }

    /* Passage scrolls freely — no height cap on tablet */
    .passage-text {
        font-size: 1rem;
    }

    .resize-handle {
        display: none;
    }

    /* Setup card — a bit wider */
    .setup-card {
        max-width: 600px;
    }

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

    /* Completion — centred floating card, not bottom sheet */
    .completion-screen {
        align-items: center;
        padding: 2rem;
    }

    .completion-card {
        max-width: 580px;
        border-radius: 1.25rem;
        max-height: 88vh;
    }
}

/* ══════════════════════════════════════════════════════════════════
   MOBILE  (≤ 700 px)
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {

    /* Body / app shell — allow normal page scroll */
    body {
        height: auto;
        overflow: auto;
        overflow-x: hidden;
    }

    #app {
        height: auto;
        min-height: 100svh;
    }

    /* ── Header ─────────────────────────────────────────────────── */
    header {
        padding: 0.6rem 1rem;
        flex-wrap: wrap;
        gap: 0.4rem;
        align-items: center;
    }

    .logo {
        font-size: 1rem;
    }

    .logo svg {
        display: none;   /* hide icon on small screens */
    }

    .controls {
        flex-wrap: wrap;
        gap: 0.4rem;
        justify-content: flex-end;
    }

    .controls .btn,
    .controls select {
        font-size: 0.8rem;
        padding: 0.3rem 0.6rem;
    }

    .timer {
        font-size: 1rem;
    }

    .question-counter {
        font-size: 0.8rem;
    }

    /* ── Main content — stack panels vertically ─────────────────── */
    .main-content {
        flex-direction: column;
        overflow: visible;
    }

    .panel {
        flex: none;
        width: 100%;
        overflow-y: visible;
        padding: 1rem;
        padding-bottom: 1.5rem;
    }

    /* Passage panel — max height so it doesn't bury the question */
    .passage-panel {
        border-right: none;
        border-bottom: 2px solid var(--border);
        max-height: 38vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .passage-text {
        font-size: 0.95rem;
    }

    /* Hide resize handle — useless on touch */
    .resize-handle {
        display: none;
    }

    /* ── Question card ───────────────────────────────────────────── */
    .card {
        border-radius: 0.75rem;
        padding: 1.1rem;
        margin-bottom: 1rem;
    }

    #questionText {
        font-size: 1rem !important;
        margin-bottom: 1rem !important;
    }

    /* ── Option buttons — larger tap targets ─────────────────────── */
    .option-btn {
        padding: 0.85rem 1rem;
        font-size: 0.95rem;
    }

    /* ── Feedback ────────────────────────────────────────────────── */
    .feedback-section {
        margin-top: 1rem;
        padding: 1rem;
    }

    /* ── Setup screen ────────────────────────────────────────────── */
    #setupScreen {
        padding: 1rem 0.5rem;
        align-items: flex-start;
    }

    .setup-card {
        padding: 1.25rem 1.1rem 1.5rem;
        border-radius: 1rem;
    }

    /* Preset grid — single column on very small phones */
    .preset-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.4rem;
    }

    .preset-btn {
        font-size: 0.75rem;
        padding: 0.45rem 0.4rem;
    }

    /* ── Completion screen ───────────────────────────────────────── */
    .completion-screen {
        padding: 0;
        align-items: flex-end;   /* sheet slides up from bottom */
    }

    .completion-card {
        border-radius: 1.25rem 1.25rem 0 0;
        max-width: 100%;
        max-height: 92svh;
        padding: 1.5rem 1.25rem;
    }

    .completion-big-score {
        font-size: 2rem;
    }

    .completion-pct {
        font-size: 1.1rem;
    }

    /* Missed list — remove the fixed max-height, let card scroll instead */
    .missed-list {
        max-height: none;
        overflow-y: visible;
    }

    /* ── History rows ────────────────────────────────────────────── */
    .hist-row {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .hist-skills {
        width: 100%;
        white-space: normal;
    }

    /* ── Resume banner ───────────────────────────────────────────── */
    .resume-banner {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

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

/* ══════════════════════════════════════════════════════════════════
   PASSAGE ENHANCEMENTS
   ══════════════════════════════════════════════════════════════════ */

/* Skill + domain badges above the passage */
.passage-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.passage-meta .badge {
    margin-bottom: 0;
}

/* Grey domain badge */
.badge-grey { background: #f1f5f9; color: #475569; }

/* WIC — target word highlight */
.wic-highlight {
    background: #fde68a;
    border-bottom: 2px solid #f59e0b;
    border-radius: 2px;
    padding: 0 0.1rem;
}

/* Boundaries / FSS fill-in-the-blank */
.q-blank {
    background: #e0f2fe;
    border-bottom: 2px solid #38bdf8;
    font-weight: 700;
    padding: 0 0.15rem;
    border-radius: 2px;
    letter-spacing: 0.05em;
}

/* Cross-Text Connections labels */
.cross-text-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary);
    background: #dbeafe;
    padding: 0.2rem 0.6rem;
    border-radius: 0.3rem;
    display: inline-block;
    margin-bottom: 0.4rem;
    margin-top: 0.1rem;
}

.cross-text-label-2 {
    margin-top: 1rem;
}

.cross-text-body {
    font-size: 1rem;
    line-height: 1.65;
    color: #334155;
    margin-bottom: 0.25rem;
}

/* CoE-Q data block */
.data-block {
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
}

.data-block-label {
    background: #f1f5f9;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.data-pre {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.88rem;
    white-space: pre;
    overflow-x: auto;
    padding: 0.75rem;
    margin: 0;
    line-height: 1.5;
    color: #334155;
    background: #fff;
}

.data-table-html {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table-html th {
    background: #f8fafc;
    font-weight: 700;
    padding: 0.45rem 0.75rem;
    text-align: left;
    border-bottom: 2px solid var(--border);
    color: var(--text);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-table-html td {
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--border);
    color: #334155;
}

.data-table-html tr:last-child td {
    border-bottom: none;
}

.data-table-html tr:nth-child(even) td {
    background: #f8fafc;
}

/* Note shown when there is no separate passage */
.no-passage-note {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ══════════════════════════════════════════════════════════════════
   PREDICTION HINT BOX
   ══════════════════════════════════════════════════════════════════ */

.prediction-hint {
    background: #fffbeb;
    border: 1px solid #fef3c7;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.88rem;
    line-height: 1.6;
    color: #78350f;
    margin-bottom: 1rem;
}

/* ══════════════════════════════════════════════════════════════════
   OPTION LETTER SPAN
   ══════════════════════════════════════════════════════════════════ */

.opt-letter {
    font-weight: 700;
    color: var(--primary);
    min-width: 1.4rem;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════════
   EXAM COUNTDOWN (setup logo)
   ══════════════════════════════════════════════════════════════════ */

.exam-countdown {
    margin-left: auto;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--primary);
    background: #dbeafe;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════════
   COMPLETION TIME
   ══════════════════════════════════════════════════════════════════ */

.completion-time {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

/* ══════════════════════════════════════════════════════════════════
   LIFETIME SKILL STATS
   ══════════════════════════════════════════════════════════════════ */

#lifetimeStats {
    margin-top: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.lifetime-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.82rem;
    padding: 0.35rem 0.5rem;
    border-radius: 0.4rem;
    background: #f8fafc;
    border: 1px solid var(--border);
}

.lifetime-skill {
    font-weight: 700;
    width: 3.5rem;
    flex-shrink: 0;
    color: var(--text-muted);
}

.lifetime-bar {
    font-family: monospace;
    font-size: 0.75rem;
    letter-spacing: -0.02em;
    color: var(--primary-light);
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
}

.lifetime-score {
    font-weight: 700;
    font-size: 0.78rem;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    white-space: nowrap;
    flex-shrink: 0;
}

.lt-pass { background: #dcfce7; color: #166534; }
.lt-warn { background: #ffedd5; color: #9a3412; }
.lt-fail { background: #fee2e2; color: #991b1b; }

/* ══════════════════════════════════════════════════════════════════
   HISTORY — per-question timing
   ══════════════════════════════════════════════════════════════════ */

.hist-time {
    font-weight: 400;
    opacity: 0.75;
    font-size: 0.75rem;
}

/* ══════════════════════════════════════════════════════════════════
   EXPORT / IMPORT
   ══════════════════════════════════════════════════════════════════ */

.export-import-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.25rem;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.export-btn {
    flex: 1;
    font-size: 0.82rem;
    padding: 0.45rem 0.75rem;
    color: var(--text-muted);
    background: #f8fafc;
}

.export-btn:hover {
    background: #eff6ff;
    border-color: var(--primary-light);
    color: var(--primary);
}

/* Export/Import modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: 1.5rem;
}

.modal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.75rem 2rem;
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow-lg);
}

.modal-card h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.modal-desc {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.modal-textarea {
    width: 100%;
    height: 220px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.82rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    resize: vertical;
    background: #f8fafc;
    color: var(--text);
    margin-bottom: 1rem;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* ══════════════════════════════════════════════════════════════════
   PRESET BUTTON VARIANTS
   ══════════════════════════════════════════════════════════════════ */

.preset-priority {
    border-color: #fca5a5;
    background: #fff5f5;
    color: #991b1b;
}

.preset-priority:hover {
    background: #fee2e2;
    border-color: #ef4444;
    color: #7f1d1d;
}

.preset-exam {
    border-color: #93c5fd;
    background: #eff6ff;
    color: #1e40af;
}

.preset-exam:hover {
    background: #dbeafe;
    border-color: var(--primary);
    color: #1e3a8a;
}

/* ══════════════════════════════════════════════════════════════════
   PRESET TOOLTIPS
   ══════════════════════════════════════════════════════════════════ */

[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #f8fafc;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.4;
    white-space: normal;
    max-width: 220px;
    min-width: 140px;
    text-align: center;
    padding: 0.45rem 0.65rem;
    border-radius: 0.4rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s;
    z-index: 400;
}

[data-tooltip]:hover::after {
    opacity: 1;
}
