/* ================= MODALS ================= */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 17, 10, 0.6);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg);
    border-radius: 4px;
    max-width: 560px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    border: 1.5px solid var(--text);
}

.modal.modal-exam {
    max-width: 680px;
}

.modal.modal-examsetup {
    max-width: 520px;
}

.modal.modal-leave {
    max-width: 520px;
}

.setup-brief {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 20px;
}

.setup-brief span {
    font-family: 'IBM Plex Mono', monospace;
    font-size: .68rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 5px 9px;
}

.setup-opt {
    display: flex;
    gap: 11px;
    align-items: flex-start;
    padding: 13px 14px;
    border: 1.5px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
}

.setup-opt+.setup-opt {
    margin-top: 10px;
}

.setup-opt:hover {
    border-color: var(--border-strong);
}

.setup-opt input {
    flex: none;
    margin-top: 3px;
}

.setup-opt b {
    display: block;
    font-size: .92rem;
    margin-bottom: 3px;
}

.setup-opt span {
    display: block;
    font-size: .8rem;
    line-height: 1.45;
    color: var(--text-muted);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.modal-head h3 {
    font-size: 1.2rem;
    margin: 0;
    font-family: 'Big Shoulders Display', sans-serif;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    display: flex;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 24px 22px;
}

.modal-foot {
    padding: 16px 22px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.q-text {
    font-size: 1.02rem;
    font-weight: 600;
    margin-bottom: 16px;
    font-family: 'Public Sans', sans-serif;
}

.option-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option {
    display: flex;
    align-items: center;
    gap: 11px;
    border: 1.5px solid var(--border);
    border-radius: 2px;
    padding: 11px 14px;
    cursor: pointer;
    font-size: .9rem;
}

.option:hover {
    border-color: var(--accent);
}

.option input {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    flex: none;
}

.option.correct {
    border-color: var(--success);
    background: var(--success-soft);
}

.option.incorrect {
    border-color: var(--danger);
    background: var(--danger-soft);
}

.option.disabled {
    cursor: default;
}

.feedback-box {
    margin-top: 16px;
    padding: 13px 15px;
    border-radius: 2px;
    font-size: .88rem;
    display: flex;
    gap: 9px;
    align-items: flex-start;
}

.feedback-box.success {
    background: var(--success-soft);
    color: var(--success);
}

.feedback-box.error {
    background: var(--danger-soft);
    color: var(--danger);
}

.feedback-box.hint {
    background: var(--gold-soft);
    color: var(--gold);
    margin-top: 10px;
}

.feedback-box a,
.feedback-box button.link {
    color: inherit;
    font-weight: 700;
    text-decoration: underline;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
}

.field-group {
    margin-bottom: 14px;
}

.field-label {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.field-input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--border-strong);
    background: var(--bg);
    color: var(--text);
    font-family: 'Public Sans', sans-serif;
    font-size: .92rem;
    border-radius: 2px;
}

.field-input:focus {
    outline: none;
    border-color: var(--accent);
}

.exam-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 22px;
    border-bottom: 1px solid var(--border);
    gap: 16px;
}

.exam-dots {
    display: flex;
    gap: 6px;
}

.exam-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bg-sunken);
    border: 1px solid var(--border-strong);
}

.exam-dot.answered {
    background: var(--accent);
    border-color: var(--accent);
}

.exam-dot.on {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* a quiz dot also carries how the question went, so the rail doubles as a scorecard */
.exam-dot.right {
    background: var(--success);
    border-color: var(--success);
}

.exam-dot.wrong {
    background: var(--danger);
    border-color: var(--danger);
}

.quiz-step {
    font-family: 'IBM Plex Mono', monospace;
    font-size: .72rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.quiz-eyebrow {
    font-family: 'IBM Plex Mono', monospace;
    font-size: .7rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 8px;
}

.quiz-eyebrow:empty {
    display: none;
}

.quiz-result-note {
    margin: 18px 0 8px;
    font-size: .88rem;
    color: var(--text-muted);
}

.quiz-missed {
    list-style: none;
    margin: 0;
    padding: 0;
    text-align: left;
    display: grid;
    gap: 6px;
}

.quiz-missed li {
    font-size: .88rem;
    border-left: 2px solid var(--danger);
    padding-left: 10px;
}

/* the reasoning held back during the attempt, returned once the score is settled */
.quiz-missed-why {
    margin: 4px 0 0;
    font-size: .82rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.quiz-missed .link {
    font: inherit;
    color: var(--accent);
    font-weight: 600;
    text-decoration: underline;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-align: left;
}

.exam-result {
    text-align: center;
    padding: 12px 0;
}

.exam-result .score {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 2.8rem;
    color: var(--text);
}

.exam-result-grid {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 20px 0;
}

.exam-result-grid .qmark {
    width: 32px;
    height: 32px;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'IBM Plex Mono', monospace;
    font-size: .82rem;
    font-weight: 600;
    border: 1.5px solid;
}

.exam-result-grid .qmark.right {
    background: var(--success-soft);
    color: var(--success);
    border-color: var(--success);
}

.exam-result-grid .qmark.wrong {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: var(--danger);
}

/* ---------- phone: dialogs become bottom sheets ----------
   Anchored to the thumb, full width, and the action row stays in reach
   however long the body runs. */
@media (max-width: 720px) {
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal,
    .modal.modal-exam,
    .modal.modal-examsetup,
    .modal.modal-leave {
        max-width: none;
        max-height: 92vh;
        max-height: 92dvh;
        border-width: 1.5px 0 0;
        border-radius: 12px 12px 0 0;
        animation: sheet-up .24s cubic-bezier(.2, .8, .2, 1);
    }

    .modal-head {
        padding: 16px 18px;
    }

    .modal-body {
        padding: 20px 18px;
    }

    .modal-foot {
        position: sticky;
        bottom: 0;
        z-index: 1;
        padding: 12px 18px calc(12px + var(--safe-b));
        background: var(--bg);
    }

    .modal-foot .btn {
        min-height: 44px;
    }

    .modal-close {
        padding: 10px;
        margin: -8px -8px -8px 0;
    }
}

@keyframes sheet-up {
    from {
        transform: translateY(40px);
        opacity: .4;
    }

    to {
        transform: none;
        opacity: 1;
    }
}
