:root {
    --paper: #f8f3e7;
    --paper-strong: #efe5ce;
    --ink: #1c2a3a;
    --ink-soft: #415064;
    --accent: #9b2c2c;
    --accent-soft: #c84a4a;
    --line: #b7ab90;
    --ok: #17513a;
    --warn: #7d5b00;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    background: radial-gradient(circle at top right, #fdf9ee 0%, var(--paper) 50%, #efe4c8 100%);
    min-height: 100vh;
}

.page-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: linear-gradient(rgba(28, 42, 58, 0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(28, 42, 58, 0.035) 1px, transparent 1px);
    background-size: 24px 24px;
    z-index: -1;
}

.site-header {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1rem 1rem;
}

.kicker {
    margin: 0;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-soft);
}

h1 {
    margin: 0.2rem 0 0.2rem;
    font-family: "Source Serif 4", Georgia, serif;
    font-size: clamp(2rem, 4.2vw, 3.3rem);
}

.subtitle {
    margin: 0;
    color: var(--ink-soft);
}

.layout {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem;
    display: grid;
    gap: 1rem;
    grid-template-columns: 1.2fr 0.9fr;
}

.question-panel,
.answer-sheet {
    border: 2px solid var(--line);
    border-radius: 14px;
    background: linear-gradient(180deg, #fffdfa 0%, var(--paper) 100%);
    box-shadow: 0 10px 24px rgba(28, 42, 58, 0.08);
}

.question-panel {
    padding: 1rem;
}

.exam-controls {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    margin-bottom: 0.9rem;
    flex-wrap: wrap;
}

.exam-controls label {
    font-size: 0.92rem;
    color: var(--ink-soft);
}

.exam-select {
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 0.45rem 0.6rem;
    background: #fff;
    color: var(--ink);
    font: inherit;
    min-width: 250px;
}
.exam-count {
    margin: 0;
    color: var(--ink-soft);
    font-size: 0.9rem;
}
.question-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.subject-pill {
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.25rem 0.6rem;
    background: var(--paper-strong);
    color: var(--ink-soft);
    font-size: 0.85rem;
}

.question-id {
    margin: 0.45rem 0 0;
    color: var(--ink-soft);
    font-size: 0.84rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.seed-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    align-items: center;
    margin: 0.25rem 0 0.7rem;
}

.seed-controls label {
    font-size: 0.9rem;
    color: var(--ink-soft);
}

.seed-input {
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 0.45rem 0.6rem;
    background: #fff;
    color: var(--ink);
    font: inherit;
    min-width: 220px;
}

.question-source-row {
    margin: 0.3rem 0 0;
    color: var(--ink-soft);
    font-size: 0.86rem;
}

.question-source-row a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dotted currentColor;
}

.question-source-row a:hover {
    color: var(--accent-soft);
}
.question-preamble-card {
    margin: 0.9rem 0 0.45rem;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: 10px;
    background: linear-gradient(180deg, #fffdf6 0%, #f9f0db 100%);
}

.question-preamble-kicker {
    margin: 0;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-soft);
    font-weight: 700;
}

.question-preamble {
    margin: 0.45rem 0 0;
    color: var(--ink-soft);
    font-size: 0.95rem;
    line-height: 1.45;
    white-space: pre-line;
    }
    
    #questionStem {
        margin: 0.75rem 0;
        font-size: clamp(1.1rem, 2vw, 1.4rem);
        line-height: 1.35;
        font-family: "Courier New", Courier, monospace;
        white-space: pre-line;
}
.question-image-wrap {
    border: 1px dashed var(--line);
    border-radius: 10px;
    background: #fff;
    margin: 0 0 1rem;
    padding: 0.75rem;
}

.question-image-wrap img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

.hidden {
    display: none;
}

.options-wrap {
    display: flex;
        flex-wrap: wrap;
        gap: 0.55rem 1rem;
}

.question-choice {
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 0.35rem 0.55rem;
        font-size: 0.92rem;
}

.panel-actions,
.result-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
    margin-top: 1rem;
}

        .result-actions {
            display: flex;
            flex-wrap: wrap;
            gap: 0.6rem;
            margin-top: 0.7rem;
        }
    
        .results-panel,
        .review-panel {
            margin-top: 0.9rem;
            border: 1px solid var(--line);
            border-radius: 10px;
            background: #fffdf7;
            padding: 0.75rem;
        }
    
        .results-panel h3,
        .review-panel h3 {
            margin: 0 0 0.4rem;
            font-family: "Source Serif 4", Georgia, serif;
        }
    
        .results-summary-text,
        .review-summary-text {
            margin: 0;
            color: var(--ink-soft);
        }
    
        .review-list {
            margin-top: 0.7rem;
            display: grid;
            gap: 0.55rem;
        }
    
        .review-card {
            border: 1px solid var(--line);
            border-radius: 8px;
            background: #fff;
            padding: 0.65rem;
        }
    
        .review-card h4 {
            margin: 0 0 0.45rem;
            font-size: 1rem;
        }
    
        .review-stem {
            margin: 0 0 0.35rem;
            white-space: pre-line;
        }
    
        .review-answer {
            margin: 0.2rem 0;
        }
    
        .review-answer-wrong {
            color: #7a1f1f;
        }
    
        .review-answer-correct {
            color: var(--ok);
        }
    
        .review-explanation {
            margin: 0.35rem 0 0.45rem;
            color: var(--ink-soft);
        }
    
        .review-empty {
            margin: 0;
            color: var(--ok);
            font-weight: 600;
        }
    
        .review-jump {
            padding: 0.45rem 0.75rem;
        }
.btn {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 10px;
    padding: 0.55rem 0.9rem;
    font: inherit;
    cursor: pointer;
}

.btn:hover {
    border-color: var(--ink-soft);
}

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

#scoreText {
    margin: 0;
    color: var(--ink-soft);
}

.answer-sheet {
    padding: 0.9rem;
}

.answer-sheet-head h3 {
    margin: 0;
    font-family: "Source Serif 4", Georgia, serif;
}

.answer-sheet-head p {
    margin: 0.3rem 0 0.8rem;
    color: var(--ink-soft);
    font-size: 0.9rem;
}

.answer-sheet-grid-wrap {
    overflow: auto;
    max-height: 62vh;
    border: 1px solid var(--line);
    border-radius: 12px;
        background: linear-gradient(180deg, #fffdf7 0%, #f5ecd7 100%);
        padding: 0.55rem;
}

.answer-sheet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.55rem;
}

.sheet-question-box {
    border: 1px solid #b64242;
    border-radius: 8px;
    background: #fff8f8;
    padding: 0.45rem;
}

.sheet-question-box.is-current {
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px rgba(155, 44, 44, 0.25);
}

.sheet-question-box.is-incorrect {
    border-color: #8f2222;
    background: #fff1f1;
}

.sheet-question-box.is-correct {
    border-color: #1d5f43;
    background: #f2fbf6;
}

.sheet-question-jump {
    background: rgba(182, 66, 66, 0.13);
    border: 1px solid rgba(182, 66, 66, 0.35);
        border-radius: 3px;
    font: inherit;
    color: inherit;
    font-weight: 700;
    cursor: pointer;
    padding: 0.08rem 0;
    width: 3ch;
        min-width: 0;
        min-height: 22px;
        text-align: center;
        justify-self: start;
    }
    
    .sheet-options-list {
        display: grid;
    grid-template-columns: 1fr 38px;
    gap: 0.4rem;
        align-items: stretch;
    }

.sheet-option-labels {
    display: grid;
    gap: 0.15rem;
    justify-items: start;
    }
    
    .sheet-option-label {
    min-height: 24px;
    display: flex;
        align-items: center;
    font-size: 0.76rem;
    font-weight: 600;
        line-height: 1.2;
}

.sheet-answer-column {
    display: grid;
    gap: 0.15rem;
    border: 1px solid rgba(182, 66, 66, 0.35);
    border-radius: 4px;
    background: rgba(182, 66, 66, 0.13);
    padding: 1px 2px;
}

.sheet-answer-spacer {
    min-height: 22px;
    display: block;
}

.sheet-answer-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 22px;
}

.sheet-answer-rect {
    width: 30px;
    height: 18px;
    border: 1.5px solid var(--line);
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
    position: relative;
}

.sheet-answer-rect::after {
    content: "";
    position: absolute;
    left: 2px;
    right: 2px;
    top: 50%;
    height: 2px;
    background: #101010;
    transform: translateY(-50%) scaleX(0);
    transform-origin: center;
    transition: transform 110ms ease;
}

.sheet-question-jump.is-incorrect {
    background: rgba(159, 33, 33, 0.2);
    border-color: rgba(159, 33, 33, 0.5);
    }

.sheet-answer-rect.is-correct-answer {
    border-color: #1d5f43;
}

.sheet-answer-rect.is-wrong-selected {
    border-color: #8f2222;
    background: #fee6e6;
}

.print-area {
    display: none;
}

.print-inner {
    color: #111;
    font-family: "Source Serif 4", Georgia, serif;
}

.print-area .answer-sheet {
    box-shadow: none;
}

.print-area .answer-sheet-grid-wrap {
    max-height: none;
    overflow: visible;
}

.print-area .sheet-answer-rect.is-selected,
.print-area .sheet-answer-rect.is-wrong-selected,
.print-area .sheet-answer-rect.is-correct-answer,
.print-area .sheet-question-box.is-current,
.print-area .sheet-question-box.is-incorrect,
.print-area .sheet-question-box.is-correct,
.print-area .sheet-question-jump.is-incorrect {
    background: inherit;
    border-color: inherit;
    box-shadow: none;
}

.print-question {
    border-bottom: 1px solid #bbb;
    padding: 0.45rem 0;
}

.print-question p {
    white-space: pre-line;
}

.print-question h3 {
    margin: 0;
}

.print-subject {
    margin: 0.25rem 0;
    color: #444;
}

.print-table {
    width: 100%;
    border-collapse: collapse;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.print-table th,
.print-table td {
    border: 1px solid #666;
    padding: 0.35rem;
    text-align: left;
    vertical-align: top;
}

.print-table tbody tr:nth-child(even) {
    background: #f3ede0;
}

@media print {

    .site-header,
    .layout {
        display: none !important;
    }

    .print-area {
        display: block !important;
        padding: 0.5in;
    }
}

.sheet-answer-rect.is-selected {
    border-color: #101010;
    background: #fff;
}

.sheet-answer-rect.is-selected::after {
    transform: translateY(-50%) scaleX(1);
}

.sheet-answer-rect:disabled {
    cursor: not-allowed;
}

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

        .answer-sheet-grid-wrap {
        max-height: none;
    }
}