/* ===== Modal ===== */
/* Lock background scrolling while a modal is open (H5 scrolls on html/body) */
html.modal-open,
html.modal-open body {
    overflow: hidden;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 100ms ease;
}

.modal {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 90%;
    max-width: 28.75rem;
    max-height: 90vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    animation: slideUp 150ms ease;
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
}

.modal__title {
    font-size: 1.05rem;
    font-weight: 600;
}

.modal__close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--color-text-secondary);
    padding: 0.25rem;
    line-height: 1;
}

.modal__body {
    padding: 1rem;
}

.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--color-border);
}

/* ===== H5: bottom sheet style modal ===== */
@media (max-width: 640px) {
    .modal-overlay {
        align-items: flex-end;
    }

    .modal {
        width: 100%;
        max-width: none;
        max-height: 88dvh;
        border-radius: 1rem 1rem 0 0;
        animation: slideUp 150ms ease;
    }

    .modal__body {
        padding: 0.875rem calc(1rem + env(safe-area-inset-right)) calc(1rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left));
    }

    .modal__footer {
        position: sticky;
        bottom: 0;
        background: var(--color-surface);
        padding: 0.75rem calc(1rem + env(safe-area-inset-right)) calc(0.75rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left));
    }

    .modal__footer .btn {
        flex: 1;
        justify-content: center;
        padding: 0.625rem 1rem;
    }
}
