.fara-template-popup {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    overflow: hidden;
    transition: opacity .22s ease, visibility .22s ease;
}

.fara-template-popup.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.fara-template-popup__overlay {
    position: absolute;
    inset: 0;
    background: rgba(8, 19, 37, .72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.fara-template-popup__dialog {
    --fara-popup-width: 760px;
    --fara-popup-height: 85vh;
    --fara-popup-fit-scale: 1;
    position: relative;
    z-index: 1;
    width: min(100%, var(--fara-popup-width));
    max-height: calc(100dvh - 48px);
    overflow: auto;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .25);
    direction: rtl;
    transform-origin: center center;
    transform: translateY(16px) scale(calc(.985 * var(--fara-popup-fit-scale)));
    transition: transform .22s ease;
    scrollbar-width: thin;
}

.fara-template-popup.is-open .fara-template-popup__dialog {
    transform: translateY(0) scale(var(--fara-popup-fit-scale));
}

.fara-template-popup[data-current-height-mode="auto"] .fara-template-popup__dialog {
    height: auto;
    max-height: calc(100dvh - 48px);
    overflow: auto;
}

.fara-template-popup[data-current-height-mode="custom"] .fara-template-popup__dialog {
    height: min(var(--fara-popup-height), calc(100dvh - 48px));
    max-height: calc(100dvh - 48px);
    overflow: auto;
}

.fara-template-popup[data-current-height-mode="fit"] .fara-template-popup__dialog {
    height: auto;
    max-height: none;
    overflow: visible;
}

.fara-template-popup__content {
    position: relative;
    min-width: 0;
}

.fara-template-popup__close {
    position: sticky;
    top: 12px;
    float: left;
    z-index: 20;
    width: 38px;
    height: 38px;
    margin: 12px 12px -50px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(15, 32, 57, .08);
    color: #0f2039;
    font: 400 30px/36px Arial, sans-serif;
    cursor: pointer;
    transition: background .18s ease, transform .18s ease;
}

.fara-template-popup__close:hover,
.fara-template-popup__close:focus-visible {
    background: rgba(15, 32, 57, .15);
    transform: rotate(4deg);
    outline: none;
}

html.fara-popup-open,
body.fara-popup-open {
    overflow: hidden !important;
}

.fara-template-popup-editor-note {
    padding: 12px 14px;
    border: 1px dashed #9aa7b7;
    border-radius: 8px;
    background: #f6f8fb;
    color: #334155;
    font-size: 13px;
    line-height: 1.8;
    text-align: right;
}

@media (max-width: 767px) {
    .fara-template-popup {
        align-items: center;
        padding: 12px;
    }

    .fara-template-popup__dialog,
    .fara-template-popup[data-current-height-mode="auto"] .fara-template-popup__dialog,
    .fara-template-popup[data-current-height-mode="custom"] .fara-template-popup__dialog {
        max-height: calc(100dvh - 24px);
        border-radius: 16px;
    }

    .fara-template-popup[data-current-height-mode="custom"] .fara-template-popup__dialog {
        height: min(var(--fara-popup-height), calc(100dvh - 24px));
    }
}
