.dg-gallery {
    margin: var(--dg-margin-y, 35px) auto;
    max-width: var(--dg-max-w, 1300px);
    padding: var(--dg-pad, 0);
    background: var(--dg-bg, transparent);
    border-radius: var(--dg-bg-radius, 0);
    box-sizing: border-box;
}

/* Grid layout */
.dg-gallery.dg-layout-grid {
    display: grid;
    gap: var(--dg-gap, 12px);
    justify-content: center;
    grid-template-columns: repeat(var(--dg-cols, 4), 1fr);
}

.dg-gallery.dg-layout-grid.dg-cols-1 { --dg-cols: 1; }
.dg-gallery.dg-layout-grid.dg-cols-2 { --dg-cols: 2; }
.dg-gallery.dg-layout-grid.dg-cols-3 { --dg-cols: 3; }
.dg-gallery.dg-layout-grid.dg-cols-4 { --dg-cols: 4; }
.dg-gallery.dg-layout-grid.dg-cols-5 { --dg-cols: 5; }
.dg-gallery.dg-layout-grid.dg-cols-6 { --dg-cols: 6; }

/* Masonry layout via CSS columns - no JS needed */
.dg-gallery.dg-layout-masonry {
    column-gap: var(--dg-gap, 12px);
    column-count: 4;
}

.dg-gallery.dg-layout-masonry.dg-cols-1 { column-count: 1; }
.dg-gallery.dg-layout-masonry.dg-cols-2 { column-count: 2; }
.dg-gallery.dg-layout-masonry.dg-cols-3 { column-count: 3; }
.dg-gallery.dg-layout-masonry.dg-cols-4 { column-count: 4; }
.dg-gallery.dg-layout-masonry.dg-cols-5 { column-count: 5; }
.dg-gallery.dg-layout-masonry.dg-cols-6 { column-count: 6; }

.dg-gallery.dg-layout-masonry .dg-gallery-item {
    break-inside: avoid;
    margin-bottom: var(--dg-gap, 12px);
}

.dg-gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--dg-radius, 14px);
    background: var(--dg-tile-bg, #f5f5f0);
    padding: var(--dg-tile-pad, 0);
    border: var(--dg-border-w, 0) solid var(--dg-border-c, #ddd);
    box-sizing: border-box;
    cursor: pointer;
    line-height: 0;
    box-shadow: var(--dg-shadow, 0 4px 14px rgba(0, 0, 0, .08));
}

.dg-gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: .2s ease;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
    border-radius: max(0px, calc(var(--dg-radius, 14px) - var(--dg-tile-pad, 0px)));
}

.dg-layout-grid .dg-gallery-item img {
    height: var(--dg-img-h, 100%);
    aspect-ratio: var(--dg-aspect, auto);
    object-fit: cover;
}

.dg-gallery-item:hover img {
    transform: var(--dg-hover-transform, scale(1.02));
    filter: var(--dg-hover-filter, none);
}

/* Lightbox */
.dg-lightbox {
    position: fixed;
    inset: 0;
    background: var(--dg-lb-bg, rgba(0, 0, 0, .96));
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    padding: 40px;
}

.dg-lightbox.active {
    display: flex;
}

.dg-lightbox-inner {
    width: 100%;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dg-lightbox img {
    display: block;
    max-width: 92vw;
    max-height: 78vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border: 2px solid var(--dg-accent, #6f3faf);
    background: #fff;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}

.dg-lightbox-caption {
    width: 100%;
    max-width: 1000px;
    margin-top: 18px;
    text-align: center;
    color: #fff;
    font-size: 18px;
    line-height: 1.5;
    font-weight: 500;
}

.dg-lightbox-close {
    position: absolute;
    top: 20px;
    right: 26px;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--dg-accent, #6f3faf);
    color: #fff;
    font-size: 30px;
    cursor: pointer;
    border: none;
}

.dg-lightbox-prev,
.dg-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 58px;
    height: 58px;
    border: none;
    border-radius: 50%;
    background: var(--dg-accent, #6f3faf);
    color: #fff;
    cursor: pointer;
    font-size: 22px;
}

.dg-lightbox-prev {
    left: 26px;
}

.dg-lightbox-next {
    right: 26px;
}

@media (max-width: 1024px) {
    .dg-gallery.dg-layout-grid.dg-cols-4,
    .dg-gallery.dg-layout-grid.dg-cols-5,
    .dg-gallery.dg-layout-grid.dg-cols-6 {
        --dg-cols: 3;
    }

    .dg-gallery.dg-layout-masonry.dg-cols-4,
    .dg-gallery.dg-layout-masonry.dg-cols-5,
    .dg-gallery.dg-layout-masonry.dg-cols-6 {
        column-count: 3;
    }
}

@media (max-width: 768px) {
    .dg-gallery.dg-layout-grid.dg-cols-3,
    .dg-gallery.dg-layout-grid.dg-cols-4,
    .dg-gallery.dg-layout-grid.dg-cols-5,
    .dg-gallery.dg-layout-grid.dg-cols-6 {
        --dg-cols: 2;
    }

    .dg-gallery.dg-layout-masonry.dg-cols-3,
    .dg-gallery.dg-layout-masonry.dg-cols-4,
    .dg-gallery.dg-layout-masonry.dg-cols-5,
    .dg-gallery.dg-layout-masonry.dg-cols-6 {
        column-count: 2;
    }

    .dg-lightbox {
        padding: 20px;
    }

    .dg-lightbox img {
        max-width: 96vw;
        max-height: 68vh;
    }

    .dg-lightbox-prev,
    .dg-lightbox-next {
        width: 48px;
        height: 48px;
    }

    .dg-lightbox-caption {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .dg-gallery.dg-layout-grid {
        --dg-cols: 1;
    }

    .dg-gallery.dg-layout-masonry {
        column-count: 1;
    }
}
