.gallery-page {
    max-width: 1280px;
    margin: 0 auto;
    padding: 120px 1rem 4rem;
    box-sizing: border-box;
}

.gallery-page #gallery-grid {
    padding: 0;
    margin: 0;
}

.gallery-header {
    text-align: center;
    margin-bottom: 3rem;
}

.gallery-header h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.gallery-header p {
    color: var(--gray);
}

.gallery-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
    justify-content: center;
}

.gallery-filter {
    padding: 0.5rem 1rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--gray);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.gallery-filter:hover,
.gallery-filter.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

/* 瀑布流容器 - 使用CSS Grid实现更可靠的布局 */
#gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    width: 100%;
}

@media (max-width: 1024px) {
    #gallery-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    #gallery-grid { grid-template-columns: 1fr; }
}

/* 每张图片 */
.gallery-item {
    margin: 0;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    position: relative;
    display: block;
}

.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 12px;
    vertical-align: top;
    min-height: 100px;
    background: #f0f0f0;
}

/* hover 遮罩 - 显示标题/作者 */
.gallery-item .gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 40% 0.75rem 0.75rem;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 0 0 12px 12px;
    pointer-events: none;
}

.gallery-item:hover .gallery-overlay {
    opacity: 1;
}

.gallery-overlay .overlay-title {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-overlay .overlay-author {
    color: rgba(255,255,255,0.8);
    font-size: 0.78rem;
}

/* 空状态 */
.gallery-empty {
    text-align: center;
    padding: 4rem;
    color: var(--gray);
    width: 100%;
    grid-column: 1 / -1;
}

/* Lightbox */
.gallery-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.gallery-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.gallery-lightbox img {
    max-width: min(90vw, 1200px);
    max-height: 88vh;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    display: block;
}

.lightbox-info {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.8);
    font-size: 0.875rem;
    white-space: nowrap;
}

.gallery-lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.12);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.gallery-lightbox-close:hover { background: rgba(255,255,255,0.25); }

.gallery-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.12);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.gallery-lightbox-nav:hover { background: rgba(255,255,255,0.25); }
.gallery-lightbox-prev { left: 1rem; }
.gallery-lightbox-next { right: 1rem; }

@media (max-width: 600px) {
    .gallery-lightbox-nav { width: 38px; height: 38px; }
    .gallery-lightbox-prev { left: 0.4rem; }
    .gallery-lightbox-next { right: 0.4rem; }
}
