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

.emg-gallery__item {
    position: relative;
    margin: 0;
}

.emg-gallery__link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.emg-gallery__media {
    position: relative;
    display: block;
    overflow: hidden;
    min-height: 120px;
    border-radius: var(--emg-radius);
    background: #eceff3;
    box-shadow: 0 12px 28px rgba(20, 30, 45, 0.12);
}

.emg-gallery__media::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0) 45%, rgba(10, 16, 24, 0.28) 100%);
    opacity: 0;
    transition: opacity 180ms ease;
    pointer-events: none;
}

.emg-gallery__media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 220ms ease, filter 220ms ease;
}

.emg-gallery__link:hover .emg-gallery__media::after,
.emg-gallery__link:focus-visible .emg-gallery__media::after {
    opacity: 1;
}

.emg-gallery__link:hover img,
.emg-gallery__link:focus-visible img {
    transform: scale(1.045);
    filter: saturate(1.05) contrast(1.03);
}

.emg-gallery__link:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 4px;
    border-radius: var(--emg-radius);
}

.emg-gallery__caption {
    margin-top: 8px;
    color: #334155;
    font-size: 14px;
    line-height: 1.35;
}

.emg-empty {
    padding: 18px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    color: #475569;
    background: #f8fafc;
}

.emg-lightbox {
    position: fixed;
    z-index: 999999;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 28px;
    background: rgba(5, 8, 14, 0.88);
}

.emg-lightbox.is-open {
    display: flex;
}

.emg-lightbox__dialog {
    position: relative;
    width: min(1180px, 100%);
    max-height: calc(100vh - 56px);
}

.emg-lightbox__image {
    display: block;
    width: 100%;
    max-height: calc(100vh - 132px);
    object-fit: contain;
    border-radius: 8px;
    background: #111827;
}

.emg-lightbox__caption {
    min-height: 28px;
    margin-top: 12px;
    color: #f8fafc;
    font-size: 15px;
    line-height: 1.45;
    text-align: center;
}

.emg-lightbox__button {
    position: absolute;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    color: #0f172a;
    background: rgba(255, 255, 255, 0.92);
    cursor: pointer;
    transition: transform 150ms ease, background 150ms ease;
}

.emg-lightbox__button:hover,
.emg-lightbox__button:focus-visible {
    transform: scale(1.06);
    background: #ffffff;
}

.emg-lightbox__close {
    top: -18px;
    right: -18px;
}

.emg-lightbox__prev,
.emg-lightbox__next {
    top: 50%;
    transform: translateY(-50%);
}

.emg-lightbox__prev:hover,
.emg-lightbox__prev:focus-visible,
.emg-lightbox__next:hover,
.emg-lightbox__next:focus-visible {
    transform: translateY(-50%) scale(1.06);
}

.emg-lightbox__prev {
    left: -22px;
}

.emg-lightbox__next {
    right: -22px;
}

body.emg-lightbox-open {
    overflow: hidden;
}

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

    .emg-lightbox {
        padding: 14px;
    }

    .emg-lightbox__image {
        max-height: calc(100vh - 118px);
    }

    .emg-lightbox__close {
        top: 8px;
        right: 8px;
    }

    .emg-lightbox__prev {
        left: 8px;
    }

    .emg-lightbox__next {
        right: 8px;
    }
}
