.rpw-popup {
    --rpw-duration: 300ms;
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 0;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    overscroll-behavior: none;
    transition: opacity var(--rpw-duration) ease, visibility 0s linear var(--rpw-duration);
}

.rpw-popup *,
.rpw-popup *::before,
.rpw-popup *::after {
    box-sizing: border-box;
}

.rpw-popup.is-open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transition-delay: 0s;
}

.rpw-popup__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    opacity: 0;
    transition: opacity var(--rpw-duration) ease;
}

.rpw-popup.is-open .rpw-popup__backdrop {
    opacity: 1;
}

/*
 * Two explicit rows are important here. The header owns only the space it needs;
 * the screenshot viewport gets every remaining pixel and becomes the one and only
 * vertical scroller in the modal.
 */
.rpw-popup__dialog {
    position: relative;
    z-index: 1;
    width: 95vw;
    max-width: 1440px;
    height: 92vh;
    max-height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    background: #fff;
    border-radius: 0;
    outline: none;
    transform-origin: center;
    transition: opacity var(--rpw-duration) ease, transform var(--rpw-duration) ease;
}

.rpw-popup__header {
    position: relative;
    z-index: 3;
    width: 100%;
    max-width: none;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 18px;
    background: #020718;
    overflow: hidden;
}

.rpw-popup__header-label {
    min-width: 0;
    color: #e6edf3;
    font-size: 18px;
    line-height: 1.3;
}

.rpw-popup__close {
    flex: 0 0 auto;
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    margin: 0;
    padding: 10px 24px;
    border-radius: 999px;
    background: #dff1f7;
    color: #07111b;
    font: inherit;
    line-height: 1.2;
    cursor: pointer;
    touch-action: manipulation;
}

.rpw-popup__close:focus-visible,
.rpw-popup__scroll:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -3px;
}

/* The ONLY scroll container in the popup. */
.rpw-popup__scroll {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    max-width: none;
    height: 100%;
    min-width: 0;
    min-height: 0;
    max-height: 100%;
    overflow-x: hidden;
    overflow-y: scroll;
    overscroll-behavior-x: none;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    scrollbar-gutter: stable;
    background: #fff;
}

/* Keep the full screenshot at its natural aspect ratio. Theme/Elementor image
 * rules must not cap it to the viewport height. */
.rpw-popup .rpw-popup__scroll > .rpw-popup__screenshot {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    object-fit: initial;
    object-position: top center;
    margin: 0 auto;
    padding: 0;
    border: 0;
    vertical-align: top;
    user-select: none;
    -webkit-user-drag: none;
}

.rpw-editor-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    padding: 32px;
    text-align: center;
    color: #666;
    background: #f4f4f4;
    font-size: 14px;
}

html.rpw-scroll-locked,
body.rpw-scroll-locked {
    overscroll-behavior: none !important;
}

.rpw-animation-fade .rpw-popup__dialog { opacity: 0; }
.rpw-animation-fade.is-open .rpw-popup__dialog { opacity: 1; }

.rpw-animation-fade-scale .rpw-popup__dialog {
    opacity: 0;
    transform: scale(0.975);
}
.rpw-animation-fade-scale.is-open .rpw-popup__dialog {
    opacity: 1;
    transform: scale(1);
}

.rpw-animation-slide-up .rpw-popup__dialog {
    opacity: 0;
    transform: translateY(24px);
}
.rpw-animation-slide-up.is-open .rpw-popup__dialog {
    opacity: 1;
    transform: translateY(0);
}

.rpw-animation-slide-down .rpw-popup__dialog {
    opacity: 0;
    transform: translateY(-24px);
}
.rpw-animation-slide-down.is-open .rpw-popup__dialog {
    opacity: 1;
    transform: translateY(0);
}

.rpw-animation-none .rpw-popup__dialog,
.rpw-animation-none .rpw-popup__backdrop,
.rpw-animation-none {
    transition: none;
}

@media (max-width: 767px) {
    .rpw-popup__dialog {
        width: 100%;
        max-width: 100%;
        max-height: 100%;
    }

    .rpw-popup__header { gap: 12px; }
    .rpw-popup__header-label { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
    .rpw-popup,
    .rpw-popup__backdrop,
    .rpw-popup__dialog {
        transition-duration: 0.01ms !important;
    }
}
