body.ui-modal-open {
    overflow: hidden;
}

.ui-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;

    display: none;
    align-items: center;
    justify-content: center;

    padding: 30px;
}

.ui-modal.is-open {
    display: flex;
}

.ui-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .58);
}

.ui-modal__dialog {
    position: relative;
    z-index: 1;

    width: min(900px, 100%);
    max-height: calc(100dvh - 60px);

    display: flex;
    flex-direction: column;

    min-width: 0;
    overflow: hidden;

    border-radius: 14px;
    background: var(--surface, #fff);

    box-shadow: 0 30px 90px rgba(0, 0, 0, .22);
}

.ui-modal__header {
    flex: 0 0 auto;

    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;

    padding: 28px 30px 24px;
    border-bottom: 1px solid var(--border, #ddd);
}

.ui-modal__heading {
    min-width: 0;
}

.ui-modal__meta {
    margin-bottom: 8px;
    color: var(--muted, #777);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .14em;
}

.ui-modal__title {
    margin: 0;
    font-size: clamp(1.8rem, 2.4vw, 2.7rem);
    line-height: 1.1;
    letter-spacing: -.04em;
    overflow-wrap: anywhere;
}

.ui-modal__close {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    padding: 0;

    border: 1px solid var(--border, #ddd);
    border-radius: 8px;
    background: transparent;

    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
}

.ui-modal__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;

    padding: 6px 30px 30px;
}

.ui-modal__footer {
    flex: 0 0 auto;
    padding: 20px 30px;
    border-top: 1px solid var(--border, #ddd);
}

@media (max-width: 700px) {
    .ui-modal {
        padding: 10px;
    }

    .ui-modal__dialog {
        width: 100%;
        max-height: calc(100dvh - 20px);
    }

    .ui-modal__header {
        gap: 15px;
        padding: 18px 16px 16px;
    }

    .ui-modal__title {
        font-size: clamp(1.55rem, 7vw, 2.3rem);
    }

    .ui-modal__body {
        padding: 0 16px 20px;
    }

    .ui-modal__footer {
        padding: 14px 16px;
    }
}

@media (max-width: 420px) {
    .ui-modal {
        padding: 0;
    }

    .ui-modal__dialog {
        width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }
}
