.gallery-viewer {
    --gallery-gap: 12px;
    --gallery-radius: 8px;
    position: relative;
}

.gallery-viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.gallery-view-switcher {
    display: inline-flex;
    gap: 6px;
    border-radius: 8px;
    padding: 4px;
    background: rgba(0, 0, 0, 0.04);
}

.gallery-view-btn {
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #666;
    cursor: pointer;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
    transition: all .2s ease;
}

.gallery-view-btn.active {
    color: #111;
    background: rgba(0, 0, 0, 0.08);
}

.gallery-image-count {
    color: #777;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.gallery-pictures-container {
    display: grid;
    gap: var(--gallery-gap);
    width: 100%;
}

.gallery-picture-item {
    position: relative;
    margin: 0;
    border-radius: var(--gallery-radius);
    overflow: hidden;
    background: rgba(0, 0, 0, 0.04);
    transition: opacity .28s ease, transform .28s ease;
    cursor: zoom-in;
}

.gallery-pictures-container.mode-switching .gallery-picture-item {
    opacity: .2;
    transform: translateY(8px) scale(.98);
}

.gallery-picture {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: transform .35s ease, opacity .35s ease;
}

.gallery-picture-item.is-image-loaded .gallery-picture {
    opacity: 1;
}

.gallery-picture-item:hover .gallery-picture {
    transform: scale(1.03);
}

.gallery-picture-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 8px 10px;
    font-size: 12px;
    color: #fff;
    background: linear-gradient(to top, rgba(0, 0, 0, .6), transparent);
    margin: 0;
    opacity: 0;
    transition: opacity .25s ease;
}

.gallery-picture-item:hover .gallery-picture-caption {
    opacity: 1;
}

.gallery-pictures-container.gallery-mode-0 {
    column-count: 4;
    column-gap: var(--gallery-gap);
    display: block;
}

.gallery-pictures-container.gallery-mode-0 .gallery-picture-item {
    display: inline-block;
    width: 100%;
    margin-bottom: var(--gallery-gap);
}

.gallery-pictures-container.gallery-mode-1 {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
}

.gallery-pictures-container.gallery-mode-1 .gallery-picture-item {
    aspect-ratio: auto;
}

.gallery-pictures-container.gallery-mode-2 {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.gallery-pictures-container.gallery-mode-2 .gallery-picture-item {
    aspect-ratio: 1 / 1;
}

.gallery-pictures-container.gallery-mode-3 {
    position: relative;
    min-height: 420px;
    display: block;
}

.gallery-pictures-container.gallery-mode-3 .gallery-picture-item {
    display: none;
    max-height: 520px;
    margin: 0 auto;
    width: fit-content;
}

.gallery-pictures-container.gallery-mode-3 .gallery-picture-item.carousel-active {
    display: block;
}

.gallery-pictures-container.gallery-mode-3 .gallery-picture {
    width: auto;
    max-width: 100%;
    max-height: 520px;
}

.gallery-carousel-controls,
.gallery-carousel-dots {
    display: none;
}

.gallery-viewer.carousel-mode .gallery-carousel-controls,
.gallery-viewer.carousel-mode .gallery-carousel-dots {
    display: flex;
}

.gallery-viewer.carousel-mode .gallery-carousel-dots.gallery-carousel-dots-hidden {
    display: none;
}

.gallery-carousel-controls {
    position: absolute;
    top: calc(50% + 15px);
    left: 0;
    right: 0;
    justify-content: space-between;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 5;
}

.gallery-carousel-btn {
    pointer-events: auto;
    border: 0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 21px;
    line-height: 1;
    cursor: pointer;
}

.gallery-carousel-dots {
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}

.gallery-carousel-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #bbb;
    border: 0;
    padding: 0;
}

.gallery-carousel-dot.active {
    background: #333;
    transform: scale(1.25);
}

.gallery-preview-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .92);
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s ease;
}

.gallery-preview-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.gallery-preview-content {
    position: relative;
    width: min(92vw, 1200px);
    max-height: 92vh;
    transform: scale(.97) translateY(10px);
    transition: transform .3s ease;
}

.gallery-preview-overlay.is-open .gallery-preview-content {
    transform: scale(1) translateY(0);
}

.gallery-preview-image-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}

.gallery-preview-image {
    max-width: 100%;
    max-height: 86vh;
    display: block;
    margin: 0 auto;
    border-radius: 6px;
    object-fit: contain;
    transition: opacity .2s ease;
}

.gallery-preview-overlay.is-loading .gallery-preview-image {
    opacity: 0;
}

.gallery-preview-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 48px;
    height: 48px;
    margin: -24px 0 0 -24px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, .25);
    border-top-color: #fff;
    opacity: 0;
    pointer-events: none;
    animation: gallery-preview-spin 0.9s linear infinite;
    transition: opacity .2s ease;
}

.gallery-preview-overlay.is-loading .gallery-preview-spinner {
    opacity: 1;
}

@keyframes gallery-preview-spin {
    to { transform: rotate(360deg); }
}

.gallery-preview-meta {
    text-align: center;
    margin-top: 10px;
    color: #fff;
}

.gallery-preview-caption {
    font-size: 30px;
    margin: 0;
    line-height: 1.2;
}

.gallery-preview-count {
    font-size: 12px;
    margin-top: 4px;
    color: rgba(255, 255, 255, .78);
    letter-spacing: .1em;
    text-transform: uppercase;
}

.gallery-preview-close,
.gallery-preview-nav {
    border: 1px solid rgba(255, 255, 255, .22);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: 36px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
}

.gallery-preview-close {
    position: fixed;
    top: 24px;
    right: 24px;
}

.gallery-preview-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
}

.gallery-preview-prev {
    left: 24px;
}

.gallery-preview-next {
    right: 24px;
}

body.gallery-preview-opened {
    overflow: hidden;
}

@media (max-width: 991.98px) {
    .gallery-pictures-container.gallery-mode-0 {
        column-count: 3;
    }
}

@media (max-width: 767.98px) {
    .gallery-pictures-container.gallery-mode-0 {
        column-count: 2;
    }

    .gallery-view-btn {
        padding: 8px 10px;
        font-size: 11px;
    }

    .gallery-pictures-container.gallery-mode-3 {
        min-height: 300px;
    }

    .gallery-pictures-container.gallery-mode-3 .gallery-picture,
    .gallery-pictures-container.gallery-mode-3 .gallery-picture-item {
        max-height: 360px;
    }

    .gallery-preview-caption {
        font-size: 22px;
    }

    .gallery-preview-nav,
    .gallery-preview-close {
        width: 46px;
        height: 46px;
        font-size: 28px;
    }

    .gallery-preview-prev {
        left: 10px;
    }

    .gallery-preview-next {
        right: 10px;
    }

    .gallery-preview-close {
        top: 10px;
        right: 10px;
    }
}
