.main-popup-overlay {
    position: fixed;
    z-index: 10000;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.55);
    box-sizing: border-box;
}

.main-popup-overlay.is-visible { display: flex; }

.main-popup-overlay.is-closing {
    background: rgba(0, 0, 0, 0);
    transition: background 0.48s ease;
    pointer-events: none;
}

.main-popup {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background: #fff;
    box-shadow: 0 8px 35px rgba(0, 0, 0, 0.35);
    transform-origin: center center;
}

.main-popup-overlay.is-closing .main-popup {
    opacity: 0;
    transform: translate(var(--popup-move-x), var(--popup-move-y)) scale(0.06);
    transition: transform 0.48s cubic-bezier(0.72, 0, 0.88, 0.42), opacity 0.4s ease 0.08s;
}

.main-popup__image {
    display: block;
    width: auto;
    height: auto;
    max-width: 90vw;
    max-height: calc(90vh - 52px);
}

.main-popup__close-icon {
    position: absolute;
    z-index: 1;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font-size: 25px;
    line-height: 34px;
    cursor: pointer;
}

.main-popup__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 52px;
    padding: 8px 12px;
    box-sizing: border-box;
    color: #333;
    font-size: 14px;
}

.main-popup__footer label { margin: 0; cursor: pointer; }
.main-popup__footer input { margin: 0 6px 0 0; vertical-align: middle; }

.main-popup__close-button {
    padding: 7px 14px;
    border: 0;
    background: #333;
    color: #fff;
    cursor: pointer;
}

.main-popup-open {
    position: fixed;
    z-index: 9999;
    left: 20px;
    bottom: 20px;
    display: none;
    padding: 9px 14px;
    border: 0;
    border-radius: 20px;
    background: #333;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.28);
    color: #fff;
    font-size: 13px;
    cursor: pointer;
}

.main-popup-open.is-visible { display: block; }

.main-popup-open.is-receiving {
    opacity: 0.4;
    transform: scale(0.82);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.main-popup-open.is-arrived {
    animation: main-popup-arrived 0.36s ease;
}

@keyframes main-popup-arrived {
    0% { transform: scale(0.82); }
    55% { transform: scale(1.14); }
    100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .main-popup-overlay.is-closing,
    .main-popup-overlay.is-closing .main-popup,
    .main-popup-open.is-receiving {
        transition-duration: 0.01ms;
    }

    .main-popup-open.is-arrived { animation: none; }
}

/* Desktop: place the popup toward the left side of the viewport. */
@media (min-width: 768px) {
    .main-popup-overlay {
        justify-content: flex-start;
        padding-left: 6vw;
    }
}

/* Mobile: retain the original centered placement. */
@media (max-width: 767px) {
    .main-popup-overlay { padding: 12px; }
    .main-popup,
    .main-popup__image { max-width: calc(100vw - 24px); }
    .main-popup__image { max-height: calc(100vh - 76px); }
    .main-popup-open { left: 12px; bottom: 12px; }
}
