.smg-gallery {
    display: grid;
    grid-template-columns: repeat(var(--smg-columns), minmax(0, 1fr));
    gap: 16px;
}

.smg-gallery-item {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    cursor: zoom-in;
}

.smg-gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .25s ease;
}

.smg-gallery-item:hover .smg-gallery-image,
.smg-gallery-item:focus-visible .smg-gallery-image {
    transform: scale(1.035);
}

.smg-gallery-item:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 3px;
}

.smg-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.smg-modal.is-open {
    display: flex;
}

.smg-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .9);
}

.smg-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(1200px, 100%);
    height: min(88vh, 900px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.smg-modal-figure {
    width: 100%;
    height: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.smg-modal-image {
    display: block;
    max-width: 100%;
    max-height: calc(100% - 60px);
    width: auto;
    height: auto;
    object-fit: contain;
}

.smg-modal-caption {
    max-width: 800px;
    margin-top: 14px;
    color: #fff;
    text-align: center;
    font-size: 15px;
}

.smg-modal-close,
.smg-modal-prev,
.smg-modal-next {
    position: absolute;
    z-index: 2;
    border: 0;
    background: rgba(0, 0, 0, .45);
    color: #fff;
    cursor: pointer;
}

.smg-modal-close {
    top: 0;
    right: 0;
    width: 46px;
    height: 46px;
    font-size: 34px;
    line-height: 1;
}

.smg-modal-prev,
.smg-modal-next {
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 64px;
    font-size: 34px;
}

.smg-modal-prev {
    left: 0;
}

.smg-modal-next {
    right: 0;
}

.smg-modal-counter {
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
}

body.smg-modal-open {
    overflow: hidden;
}

@media (max-width: 900px) {
    .smg-gallery {
        grid-template-columns: repeat(min(var(--smg-columns), 3), minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .smg-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .smg-modal {
        padding: 12px;
    }

    .smg-modal-prev,
    .smg-modal-next {
        width: 42px;
        height: 54px;
        font-size: 28px;
    }
}
