.trmg-gallery {
    --trmg-gap: clamp(18px, 1.5vw, 24px);
    --trmg-surface: var(--wp--preset--color--base, var(--theme-palette-color-8, transparent));
    --trmg-surface-strong: var(--wp--preset--color--background, var(--theme-palette-color-7, transparent));
    --trmg-border: color-mix(in srgb, currentColor 14%, transparent);
    --trmg-muted: color-mix(in srgb, currentColor 65%, transparent);
    --trmg-radius: var(--wp--custom--border-radius, var(--theme-form-field-border-radius, var(--theme-button-border-radius, 0px)));
    color: inherit;
    font: inherit;
}

.trmg-gallery__header {
    margin: 0 0 var(--trmg-gap);
}

.trmg-gallery__name {
    margin: 0;
    font-size: clamp(1.5rem, 2vw, 2rem);
    line-height: 1.1;
    color: inherit;
    font: inherit;
    font-size: clamp(1.5rem, 2vw, 2rem);
}

.trmg-gallery__description {
    margin-top: calc(var(--trmg-gap) * 0.7);
    color: var(--trmg-muted);
}

.trmg-gallery__toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 calc(var(--trmg-gap) * 0.9);
    flex-wrap: wrap;
}

.trmg-gallery__toolbar-label {
    white-space: nowrap;
    color: inherit;
}

.trmg-gallery__select {
    min-width: 230px;
    max-width: 100%;
    font: inherit;
    color: inherit;
    background: inherit;
    border-radius: var(--trmg-radius);
    appearance: auto;
}

.trmg-gallery__category-title {
    margin: 0 0 calc(var(--trmg-gap) * 0.85);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
}

.trmg-gallery__category-title.is-hidden {
    display: none;
}

.trmg-gallery--masonry .trmg-gallery__grid {
    position: relative;
    min-height: 1px;
    margin-top: calc(var(--trmg-gap) * 0.25);
}

.trmg-gallery--masonry .trmg-gallery__item {
    position: absolute;
    top: 0;
    left: 0;
    transition: transform 220ms ease, opacity 180ms ease;
    will-change: transform;
}

.trmg-gallery--grid .trmg-gallery__grid {
    display: grid;
    grid-template-columns: repeat(var(--trmg-columns), minmax(0, 1fr));
    gap: var(--trmg-gap);
    margin-top: calc(var(--trmg-gap) * 0.25);
}

.trmg-gallery__item[hidden] {
    display: none !important;
}

.trmg-gallery__card {
    margin: 0;
    overflow: hidden;
    border-radius: var(--trmg-radius);
    border: 1px solid rgba(127, 127, 127, 0.18);
    border-color: var(--trmg-border);
    background: var(--trmg-surface-strong);
    box-shadow: none;
}

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

.trmg-gallery__media {
    display: block;
    overflow: hidden;
    background: var(--trmg-surface);
}

.trmg-gallery__media--landscape {
    aspect-ratio: 4 / 3;
}

.trmg-gallery__media--square {
    aspect-ratio: 1 / 1;
}

.trmg-gallery__media--portrait {
    aspect-ratio: 4 / 5;
}

.trmg-gallery__image {
    display: block;
    width: 100%;
    height: auto;
    transition: transform 220ms ease, filter 220ms ease;
}

.trmg-gallery__media--natural .trmg-gallery__image {
    height: auto;
}

.trmg-gallery__media--landscape .trmg-gallery__image,
.trmg-gallery__media--square .trmg-gallery__image,
.trmg-gallery__media--portrait .trmg-gallery__image {
    width: 100%;
    height: 100%;
}

.trmg-gallery__media--fit-cover .trmg-gallery__image {
    object-fit: cover;
}

.trmg-gallery__media--fit-contain .trmg-gallery__image {
    object-fit: contain;
}

.trmg-gallery__card:hover .trmg-gallery__image,
.trmg-gallery__link:focus-visible .trmg-gallery__image {
    transform: scale(1.015);
    filter: saturate(1.02);
}

.trmg-gallery__content {
    padding: 1rem 1rem 1.1rem;
    background: inherit;
}

.trmg-gallery__eyebrow {
    margin: 0 0 0.45rem;
    color: var(--trmg-muted);
    font-size: 0.82rem;
    line-height: 1.3;
    text-transform: uppercase;
}

.trmg-gallery__title {
    margin: 0;
    font-size: 0.98rem;
    line-height: 1.3;
}

.trmg-gallery__caption {
    margin: 0.45rem 0 0;
    color: var(--trmg-muted);
    font-size: 0.92rem;
    line-height: 1.45;
}

.trmg-gallery__empty {
    padding: 1rem 1.15rem;
    border: 1px solid rgba(127, 127, 127, 0.18);
    border-color: var(--trmg-border);
    background: var(--trmg-surface);
    color: var(--trmg-muted);
}

.trmg-lightbox-open {
    overflow: hidden;
}

.trmg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    color: var(--trmg-theme-text, inherit);
    font-family: var(--trmg-theme-font, inherit);
}

.trmg-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(10px);
}

.trmg-lightbox[data-trmg-scheme="dark"] .trmg-lightbox__backdrop {
    background: rgba(15, 23, 42, 0.64);
}

.trmg-lightbox__dialog {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    width: min(1180px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    margin: 1rem auto;
    padding: 1rem;
    border-radius: var(--trmg-theme-radius, var(--trmg-radius));
    border: 1px solid rgba(127, 127, 127, 0.18);
    background: var(--trmg-theme-surface-strong, var(--trmg-surface-strong, #fff));
    color: var(--trmg-theme-text, inherit);
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.12);
}

.trmg-lightbox__stage {
    display: grid;
    gap: 1rem;
    justify-items: center;
    max-height: calc(100vh - 6rem);
}

.trmg-lightbox__image {
    display: block;
    max-width: 100%;
    max-height: min(74vh, 880px);
    border-radius: calc(var(--trmg-theme-radius, var(--trmg-radius)) * 0.85);
    object-fit: contain;
}

.trmg-lightbox__meta {
    width: min(760px, 100%);
}

.trmg-lightbox__title,
.trmg-lightbox__caption,
.trmg-lightbox__description {
    margin: 0;
}

.trmg-lightbox__title + .trmg-lightbox__caption,
.trmg-lightbox__caption + .trmg-lightbox__description,
.trmg-lightbox__title + .trmg-lightbox__description {
    margin-top: 0.65rem;
}

.trmg-lightbox__caption,
.trmg-lightbox__description {
    color: var(--trmg-theme-muted, var(--trmg-muted));
}

.trmg-lightbox__close,
.trmg-lightbox__nav {
    border: 1px solid rgba(127, 127, 127, 0.18);
    border-radius: 999px;
    width: 3rem;
    height: 3rem;
    cursor: pointer;
    color: inherit;
    background: var(--trmg-theme-surface, var(--trmg-surface, transparent));
    transition: transform 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.trmg-lightbox__close:hover,
.trmg-lightbox__close:focus-visible,
.trmg-lightbox__nav:hover,
.trmg-lightbox__nav:focus-visible {
    background: color-mix(in srgb, currentColor 8%, var(--trmg-theme-surface, transparent));
    border-color: color-mix(in srgb, currentColor 20%, transparent);
    transform: translateY(-1px);
    outline: none;
}

.trmg-lightbox__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

@media (max-width: 1024px) {
    .trmg-gallery--grid .trmg-gallery__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .trmg-gallery__toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .trmg-gallery--grid .trmg-gallery__grid {
        grid-template-columns: 1fr;
    }

    .trmg-lightbox__dialog {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 4rem 1rem 1rem;
    }

    .trmg-lightbox__stage {
        order: 2;
    }

    .trmg-lightbox__nav {
        position: absolute;
        top: 1.25rem;
    }

    .trmg-lightbox__nav--prev {
        left: 1rem;
    }

    .trmg-lightbox__nav--next {
        right: 4.5rem;
    }
}
