#IFM_photo_viewer {
    position: fixed;
    inset: 0;
    z-index: 12000;
}

#IFM_photo_viewer[hidden] {
    display: none !important;
}

.IFM_photo_viewer-backdrop {
    position: absolute;
    inset: 0;
    background: #0f0f0fb3;
    backdrop-filter: blur(4px);
}

.IFM_photo_viewer-panel {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    padding: 0;
    box-sizing: border-box;
    pointer-events: none;
}

.IFM_photo_viewer-panel > * {
    pointer-events: auto;
}

.IFM_photo_viewer-stage {
    position: absolute;
    left: 15px;
    right: 15px;
    top: 70px;
    bottom: 112px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    box-sizing: border-box;
    overflow: hidden;
}

.IFM_photo_viewer-stage > * {
    pointer-events: auto;
}

#IFM_photo_viewer[data-zoomable="1"] .IFM_photo_viewer-stage {
    touch-action: none;
}

#IFM_photo_viewer[data-zoom-mode="original"] .IFM_photo_viewer-panel {
    pointer-events: auto;
    cursor: crosshair;
}

#IFM_photo_viewer[data-zoom-mode="original"] .IFM_photo_viewer-stage {
    pointer-events: auto;
    cursor: crosshair;
}

.IFM_photo_viewer-pan {
    flex: 0 0 auto;
    max-width: none;
    max-height: none;
    will-change: transform;
    border-radius: 8px;
}

.IFM_photo_viewer-img.IFM_photo_viewer-img--natural {
    max-width: none;
    max-height: none;
}

.IFM_photo_viewer-panel:not([data-has-thumbs="1"]) .IFM_photo_viewer-stage {
    bottom: 56px;
}

.IFM_photo_viewer-img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    user-select: none;
}

.IFM_photo_viewer-thumbs {
    position: absolute;
    left: 15px;
    right: 15px;
    bottom: 12px;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    max-width: none;
    padding: 4px 0;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: hidden;
}

.IFM_photo_viewer-thumbs[hidden] {
    display: none !important;
}

.IFM_photo_viewer-thumb {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: rgb(133 133 133 / 30%);
    box-sizing: border-box;
    transition: transform 0.12s ease, border-color 0.12s ease;
}

.IFM_photo_viewer-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.IFM_photo_viewer-thumb:hover {
    border-color: rgba(255, 255, 255, 0.35);
}

.IFM_photo_viewer-thumb.is-active {
    width: 68px;
    height: 68px;
    border-color: var(--color-lpd-active-border, #5d5cb5);
    transform: scale(1.04);
}

.IFM_photo_viewer-caption {
    position: absolute;
    left: 15px;
    right: 15px;
    bottom: 88px;
    max-width: none;
    text-align: center;
    font-size: 90%;
    opacity: 0.85;
    word-break: break-word;
    pointer-events: none;
}

.IFM_photo_viewer-panel:not([data-has-thumbs="1"]) .IFM_photo_viewer-caption {
    bottom: 16px;
}

.IFM_photo_viewer-toolbar {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    max-width: calc(100% - 24px);
    box-sizing: border-box;
    pointer-events: auto;
}

.IFM_photo_viewer-toolbar .IFM_photo_viewer-close,
.IFM_photo_viewer-toolbar .IFM_photo_viewer-download,
.IFM_photo_viewer-toolbar .IFM_photo_viewer-download_album,
.IFM_photo_viewer-toolbar .IFM_photo_viewer-zoom_toggle {
    position: static;
    flex: 0 0 auto;
    border: 0;
    border-radius: 8px;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.08);
    background-repeat: no-repeat;
    background-position: center;
    background-size: 60%;
}

.IFM_photo_viewer-close {
    background-image: url('../../../ico/bt/close.svg');
}

.IFM_photo_viewer-download_album {
    background-image: url('../../../ico/bt/folder-zip.svg');
}

.IFM_photo_viewer-download {
    background-image: url('../../../ico/bt/download.svg');
}

.IFM_photo_viewer-zoom_toggle {
    background-image: url('../../../ico/bt/fullscreen.svg');
}

.IFM_photo_viewer-nav {
    position: absolute;
    border: 0;
    border-radius: 8px;
    width: 44px;
    height: 44px;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.08);
    background-repeat: no-repeat;
    background-position: center;
    background-size: 60%;
    z-index: 2;
}

#IFM_photo_viewer[data-zoom-mode="fit"] .IFM_photo_viewer-zoom_toggle {
    background-image: url('../../../ico/bt/fullscreen.svg');
}

#IFM_photo_viewer[data-zoom-mode="original"] .IFM_photo_viewer-zoom_toggle {
    background-image: url('../../../ico/bt/fullscreen-exit.svg');
}

.IFM_photo_viewer-zoom_toggle[hidden] {
    display: none !important;
}

.IFM_photo_viewer-next,
.IFM_photo_viewer-prev {
    width: 100px;
    height: calc(100vh - 200px);
    background-color: transparent !important;
    background-image: none !important;
    isolation: isolate;
    opacity: 0.8;
}

.IFM_photo_viewer-next::before,
.IFM_photo_viewer-prev::before,
.IFM_photo_viewer-next::after,
.IFM_photo_viewer-prev::after {
    content: '';
    position: absolute;
    inset: 0;
    background-repeat: no-repeat;
    background-size: 40%;
    pointer-events: none;
}

.IFM_photo_viewer-next::before,
.IFM_photo_viewer-prev::before {
    z-index: -1;
    filter: brightness(0) blur(1px);
    opacity: 1;
    transform: translate(0px, 0px);
}

.IFM_photo_viewer-next::after,
.IFM_photo_viewer-prev::after {
    z-index: 0;
    filter: brightness(2.5);
}

.IFM_photo_viewer-prev {
    left: 0px;
    top: 50%;
    transform: translateY(-50%);
}

.IFM_photo_viewer-prev::before,
.IFM_photo_viewer-prev::after {
    background-image: url('../../../ico/bt/skip-previous.svg');
    background-position: 30% 50%;
}

.IFM_photo_viewer-next {
    right: 0px;
    top: 50%;
    transform: translateY(-50%);
}

.IFM_photo_viewer-next::before,
.IFM_photo_viewer-next::after {
    background-image: url('../../../ico/bt/skip-next.svg');
    background-position: 70% 50%;
}

/* На тач-устройствах вся stage ловит свайп листания, не только область картинки (pan). */
html[data-mobile="1"] #IFM_photo_viewer .IFM_photo_viewer-stage {
    pointer-events: auto;
}

@media (max-width: 650px) {
    #IFM_photo_viewer .IFM_photo_viewer-stage {
        pointer-events: auto;
    }

    .IFM_photo_viewer-next,
    .IFM_photo_viewer-prev {
        width: 42px;
        height: calc(150px);
    }

    .IFM_photo_viewer-next::before,
    .IFM_photo_viewer-prev::before,
    .IFM_photo_viewer-next::after,
    .IFM_photo_viewer-prev::after {
        background-position: 50% 50%;
        background-size: 100%;
    }
}

.IFM_photo_viewer-close:hover,
.IFM_photo_viewer-download:hover,
.IFM_photo_viewer-download_album:hover,
.IFM_photo_viewer-nav:hover,
.IFM_photo_viewer-zoom_toggle:hover {
    background-color: rgba(255, 255, 255, 0.16);
}

.IFM_photo_viewer-nav[hidden],
.IFM_photo_viewer-download_album[hidden] {
    display: none !important;
}

.IFM_photo_viewer-confirm {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: rgb(20 20 20 / 55%);
    box-sizing: border-box;
}

.IFM_photo_viewer-confirm[hidden] {
    display: none !important;
}

.IFM_photo_viewer-confirm-dialog {
    width: min(380px, 100%);
    padding: 18px 18px 14px;
    border-radius: 12px;
    background: #2a2a32;
    color: #f2f2f5;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    box-sizing: border-box;
}

.IFM_photo_viewer-confirm-text {
    margin: 0 0 16px;
    line-height: 1.45;
    font-size: 95%;
}

.IFM_photo_viewer-confirm-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.IFM_photo_viewer-confirm-btn {
    min-width: 88px;
    height: 36px;
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    background: rgba(93, 92, 181, 0.55);
    color: #fff;
    font: inherit;
    cursor: pointer;
}

.IFM_photo_viewer-confirm-btn:hover {
    background: rgba(93, 92, 181, 0.75);
}

.IFM_photo_viewer-confirm-btn--ghost {
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
}

.IFM_photo_viewer-confirm-btn--ghost:hover {
    background: rgba(255, 255, 255, 0.08);
}
