.photo-album-gallery,
.photo-albums-index,
.recent-photos {
    display: grid;
    gap: 15px;
    width: 100%;
}

.photo-album-gallery,
.photo-albums-index {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.recent-photos {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.photo-album-gallery__item,
.photo-albums-index__card,
.recent-photos__item {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: 8px;
    aspect-ratio: 1 / 1;
    background: #f3f4f6;
    text-decoration: none;
}

.photo-album-gallery__image,
.photo-albums-index__image,
.recent-photos__image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.25s ease;
}

.photo-album-gallery__item:hover .photo-album-gallery__image,
.photo-albums-index__card:hover .photo-albums-index__image,
.recent-photos__item:hover .recent-photos__image,
.photo-album-gallery__item:focus-visible .photo-album-gallery__image,
.photo-albums-index__card:focus-visible .photo-albums-index__image,
.recent-photos__item:focus-visible .recent-photos__image {
    transform: scale(1.04);
}

.photo-albums-index__placeholder {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #e5e7eb, #f9fafb);
}

.photo-albums-index__overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px;
    color: #fff;
    text-align: center;
    background: rgba(0, 0, 0, 0.45);
}

.photo-albums-index__title {
    display: block;
    font-size: clamp(18px, 2vw, 22px);
    font-weight: 700;
    line-height: 1.2;
}

.photo-albums-index__date {
    display: block;
    font-size: 14px;
    line-height: 1.3;
    opacity: 0.92;
}

.photo-album-gallery__item:focus-visible,
.photo-albums-index__card:focus-visible,
.recent-photos__item:focus-visible,
.photo-album-viewer button:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

body.photo-album-viewer-open {
    overflow: hidden;
    touch-action: none;
}

.photo-album-viewer {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: none;
    background: rgba(0, 0, 0, 0.94);
    color: #fff;
}

.photo-album-viewer.is-open {
    display: block;
}

.photo-album-viewer__stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 72px 72px 92px;
    box-sizing: border-box;
}

.photo-album-viewer__image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    opacity: 1;
    transition: opacity 0.16s ease;
}

.photo-album-viewer.is-loading .photo-album-viewer__image {
    opacity: 0.2;
}

.photo-album-viewer__loader {
    position: absolute;
    top: 50%;
    left: 50%;
    display: none;
    width: 42px;
    height: 42px;
    margin: -21px 0 0 -21px;
    border: 4px solid rgba(255, 255, 255, 0.32);
    border-top-color: #fff;
    border-radius: 999px;
    animation: photo-album-viewer-spin 0.8s linear infinite;
}

.photo-album-viewer.is-loading .photo-album-viewer__loader {
    display: block;
}

@keyframes photo-album-viewer-spin {
    to {
        transform: rotate(360deg);
    }
}

.photo-album-viewer__caption {
    position: fixed;
    right: 18px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
    left: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-height: 44px;
    padding: 0 220px;
    box-sizing: border-box;
    pointer-events: none;
    text-align: center;
}

.photo-album-viewer__title {
    display: block;
    max-width: 100%;
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.photo-album-viewer__count {
    display: block;
    font-size: 13px;
    line-height: 1.2;
    opacity: 0.8;
}

.photo-album-viewer__button {
    position: fixed;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 46px;
    min-height: 46px;
    border: 0;
    border-radius: 999px;
    color: #111;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    appearance: none;
}

.photo-album-viewer__button:active {
    transform: translateY(1px);
}

.photo-album-viewer__close {
    top: calc(env(safe-area-inset-top, 0px) + 16px);
    right: 16px;
    width: 50px;
    height: 50px;
    font-size: 34px;
    font-weight: 400;
}

.photo-album-viewer__prev,
.photo-album-viewer__next {
    top: 50%;
    width: 52px;
    height: 52px;
    transform: translateY(-50%);
    font-size: 32px;
    font-weight: 400;
}

.photo-album-viewer__prev:active,
.photo-album-viewer__next:active {
    transform: translateY(calc(-50% + 1px));
}

.photo-album-viewer__prev {
    left: 16px;
}

.photo-album-viewer__next {
    right: 16px;
}

.photo-album-viewer__bottom-controls {
    position: fixed;
    right: 12px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
    left: 12px;
    z-index: 3;
    display: none;
    gap: 8px;
}

.photo-album-viewer__bottom-controls .photo-album-viewer__button {
    position: static;
    flex: 1 1 0;
    width: auto;
    min-height: 46px;
    padding: 10px 12px;
    font-size: 15px;
}

@media (max-width: 782px) {
    .photo-album-gallery,
    .photo-albums-index {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .recent-photos {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .photo-album-viewer__stage {
        padding: 62px 10px 102px;
    }

    .photo-album-viewer__image {
        max-width: calc(100vw - 20px);
        max-height: calc(100dvh - 174px);
    }

    .photo-album-viewer__caption {
        bottom: calc(env(safe-area-inset-bottom, 0px) + 68px);
        padding: 0 10px;
        min-height: 24px;
    }

    .photo-album-viewer__title {
        display: none;
    }

    .photo-album-viewer__prev,
    .photo-album-viewer__next {
        display: none;
    }

    .photo-album-viewer__close {
        top: calc(env(safe-area-inset-top, 0px) + 10px);
        right: 10px;
        width: 46px;
        height: 46px;
    }

    .photo-album-viewer__bottom-controls {
        display: flex;
    }
}

@media (max-width: 420px) {
    .photo-album-gallery,
    .photo-albums-index,
    .recent-photos {
        grid-template-columns: 1fr 1fr;
    }

    .photo-albums-index__overlay {
        padding: 12px;
    }

    .photo-albums-index__title {
        font-size: 16px;
    }

    .photo-albums-index__date {
        font-size: 12px;
    }
}
