.ui-photo-gallery {
    --ui-gallery-bg: var(--td-color-surface, #fff);
    --ui-gallery-border: var(--td-color-border, #d7e3e0);
    --ui-gallery-muted: var(--td-color-text-muted, #5b6b73);
    --ui-gallery-radius: var(--td-radius-lg, 1rem);
}

.ui-photo-gallery__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    gap: 0.85rem;
    padding: 0;
    margin: 0;
    list-style: none;
}

.ui-photo-gallery__card {
    min-width: 0;
    overflow: hidden;
    background: var(--ui-gallery-bg);
    border: 1px solid var(--ui-gallery-border);
    border-radius: var(--ui-gallery-radius);
}

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

.ui-photo-gallery__image,
.ui-photo-gallery__placeholder {
    display: grid;
    place-items: center;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: color-mix(in srgb, var(--ui-gallery-muted) 12%, transparent);
}

.ui-photo-gallery__placeholder {
    color: var(--ui-gallery-muted);
    font-size: 2rem;
}

.ui-photo-gallery__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.65rem 0.75rem;
}

.ui-photo-gallery__label {
    overflow: hidden;
    font-size: 0.8rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-photo-gallery__status {
    flex: 0 0 auto;
    padding: 0.2rem 0.5rem;
    color: var(--ui-gallery-muted);
    background: color-mix(in srgb, var(--ui-gallery-muted) 12%, transparent);
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: capitalize;
}

.ui-photo-gallery__status[data-status="ready"] {
    color: var(--td-color-success, #147d64);
    background: color-mix(in srgb, var(--td-color-success, #147d64) 12%, transparent);
}

.ui-photo-gallery__status[data-status="failed"] {
    color: var(--td-color-danger, #b42318);
    background: color-mix(in srgb, var(--td-color-danger, #b42318) 12%, transparent);
}

.ui-photo-gallery__empty {
    color: var(--ui-gallery-muted);
}

.ui-photo-gallery__dialog {
    width: min(92vw, 70rem);
    max-width: none;
    max-height: 92vh;
    padding: 0;
    overflow: hidden;
    background: transparent;
    border: 0;
}

.ui-photo-gallery__dialog::backdrop {
    background: rgb(0 0 0 / 82%);
}

.ui-photo-gallery__dialog-image {
    display: block;
    width: 100%;
    max-height: 88vh;
    object-fit: contain;
}

.ui-photo-gallery__close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    color: #fff;
    background: rgb(0 0 0 / 70%);
    border: 1px solid rgb(255 255 255 / 35%);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
}

@media (max-width: 36rem) {
    .ui-photo-gallery__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
