.thm-gallery {
    width: 100%;
    margin: 1.5rem 0;
}

.thm-gallery__grid {
    display: grid;
    grid-template-columns: repeat(var(--thm-gallery-columns, 3), minmax(0, 1fr));
    gap: 14px;
}

.thm-gallery__item {
    min-width: 0;
    margin: 0;
}

.thm-gallery__open {
    display: block;
    width: 100%;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: #dfe5e6;
    cursor: zoom-in;
}

.thm-gallery__image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.thm-gallery__open:hover .thm-gallery__image,
.thm-gallery__open:focus-visible .thm-gallery__image {
    opacity: 0.88;
    transform: scale(1.025);
}

.thm-gallery--ratio-1-1 .thm-gallery__open,
.thm-gallery--ratio-1-1 .thm-gallery__image {
    aspect-ratio: 1 / 1;
}

.thm-gallery--ratio-4-3 .thm-gallery__open,
.thm-gallery--ratio-4-3 .thm-gallery__image {
    aspect-ratio: 4 / 3;
}

.thm-gallery--ratio-16-9 .thm-gallery__open,
.thm-gallery--ratio-16-9 .thm-gallery__image {
    aspect-ratio: 16 / 9;
}

.thm-gallery--ratio-auto .thm-gallery__image {
    height: auto;
    object-fit: contain;
}

.thm-gallery__caption {
    padding: 0.6rem 0.2rem 0;
    color: #4a5d66;
    font-size: 0.9rem;
    line-height: 1.35;
}

.thm-gallery__dialog {
    width: min(94vw, 1280px);
    max-width: none;
    height: min(92vh, 900px);
    max-height: none;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: transparent;
}

.thm-gallery__dialog::backdrop {
    background: rgba(24, 31, 36, 0.9);
}

.thm-gallery__dialog-content {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    position: relative;
    width: 100%;
    height: 100%;
    background: #1f292f;
}

.thm-gallery__dialog-image {
    align-self: center;
    justify-self: center;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.thm-gallery__dialog-caption {
    min-height: 2.8rem;
    padding: 0.8rem 4rem;
    background: #4a5d66;
    color: #fff;
    text-align: center;
}

.thm-gallery__close,
.thm-gallery__previous,
.thm-gallery__next {
    position: absolute;
    z-index: 2;
    border: 0;
    background: rgba(74, 93, 102, 0.9);
    color: #fff;
    cursor: pointer;
}

.thm-gallery__close {
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    font-size: 2rem;
    line-height: 1;
}

.thm-gallery__previous,
.thm-gallery__next {
    top: 50%;
    width: 48px;
    height: 64px;
    transform: translateY(-50%);
    font-size: 2.6rem;
    line-height: 1;
}

.thm-gallery__previous {
    left: 12px;
}

.thm-gallery__next {
    right: 12px;
}

.thm-gallery__close:hover,
.thm-gallery__close:focus-visible,
.thm-gallery__previous:hover,
.thm-gallery__previous:focus-visible,
.thm-gallery__next:hover,
.thm-gallery__next:focus-visible {
    background: #80ba24;
}

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

    .thm-gallery__dialog {
        width: 100vw;
        height: 100vh;
        margin: 0;
    }

    .thm-gallery__dialog-caption {
        padding-right: 1rem;
        padding-left: 1rem;
    }

    .thm-gallery__previous {
        left: 4px;
    }

    .thm-gallery__next {
        right: 4px;
    }
}

@media (max-width: 420px) {
    .thm-gallery__grid {
        grid-template-columns: 1fr;
    }
}
