:root {
    --lazy-svg: url('loading.svg');
    --bg: #f5f5f5;
}

body {
    background: #ebf0f6 !important;
}

.gallery-container {
    max-width: 1200px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.gallery-header {
    text-align: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.077);
    margin: 2rem;
    padding-bottom: 2rem;
}

.gallery-header h1 {
    font-size: 28px;
    color: #333;
    margin: 0 0 10px;
}

.gallery-desc {
    color: #666;
    font-size: 16px;
    margin: 0;
}

.gallery-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 2rem;
    justify-content: center;
}

.filter-btn {
    padding: 8px 16px;
    background: #fff;
    color: #333;
    border-radius: 20px;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
}

.filter-btn.active {
    background: linear-gradient(to right, #6f88ff 0, #657be5 100%);
    color: #fff;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #fff;
}

.gallery-link {
    display: block;
    text-decoration: none;
}

.gallery-img-wrap, .gallery-file {
    position: relative;
    padding-bottom: 100%;
    overflow: hidden;
    background-color: var(--bg);
    background-image: var(--lazy-svg);
    background-position: center;
    background-repeat: no-repeat;
    background-size: clamp(24px, 14%, 48px) auto;
}

.gallery-file .gallery-overlay {
    opacity: inherit;
}

.gallery-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 懒加载：与 Alpha 模板一致 */
img.lazy {
    opacity: 0;
    transition: opacity .35s ease;
    background-color: var(--bg);
    background-image: var(--lazy-svg);
    background-position: center;
    background-repeat: no-repeat;
    background-size: clamp(24px, 14%, 48px) auto;
}

img.lazy.lazy-loaded {
    opacity: 1;
}

.gallery-item:hover .gallery-overlay {
    opacity: 1;
    pointer-events: auto;
}

.video-item {
    background: #000;
}

.gallery-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background-image: url('video.svg');
    background-size: contain;
    background-repeat: no-repeat;
    transition: transform 0.3s, opacity 0.3s;
}

.video-item:hover .video-play-icon {
    transform: translate(-50%, -50%) scale(1.15);
    opacity: 1;
    pointer-events: auto;
}

.video-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 30px 10px 10px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    opacity: 0;
    transition: opacity 0.3s;
}

.video-item:hover .video-overlay {
    opacity: 1;
    pointer-events: auto;
}

.video-name {
    color: #fff;
    font-size: 14px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('unknown.svg');
    background-size: 48px 48px;
    background-position: center;
    background-repeat: no-repeat;
}

.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: .5rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    opacity: 0;
    transition: opacity 0.3s;
}

.gallery-item:hover .gallery-overlay {
    opacity: 1;
    pointer-events: auto;
}

.gallery-name {
    color: #fff;
    font-size: 14px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 16px;
}

.gallery-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin: 2rem;
}

.page-btn {
    height: 35px;
    line-height: 35px;
    text-align: center;
    padding: 0 16px;
    background: #fff;
    color: #333;
    border-radius: 10px;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
}

.page-btn.active {
    background: linear-gradient(to right, #6f88ff 0, #657be5 100%);
    color: #fff;
}

.page-ellipsis {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    color: #999;
}

@media (max-width: 768px) {
    .gallery-header h1 {
        font-size: 22px;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }

    .filter-btn {
        padding: 6px 12px;
        font-size: 14px;
    }

    .gallery-header, .gallery-filter, .gallery-pagination {
        margin: 1.5rem;
    }

    .gallery-header {
        padding-bottom: 1.5rem;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}
