* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: rgb(50, 50, 50);
    min-height: 100vh;
    padding-bottom: 40px;
}

header {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    padding: 20px 30px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

h1 {
    color: #333;
    margin: 0;
    font-size: 1.6em;
    font-weight: 700;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.slider-control {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
    color: #666;
}

.header-btn {
    padding: 8px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s ease;
}

.header-btn:hover {
    background: #764ba2;
    transform: translateY(-2px);
}

.header-desc {
    background: rgba(102, 126, 234, 0.1);
    padding: 12px 18px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.header-desc p {
    color: #555;
    font-size: 0.9em;
    line-height: 1.6;
    margin: 0;
}

/* 弹窗样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.3s ease;
}

.modal:not(.hidden) {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: zoomIn 0.3s ease;
}

.modal-content h2 {
    color: #667eea;
    margin-top: 0;
    margin-bottom: 20px;
}

.modal-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.modal-content ul li {
    padding: 8px 0;
    color: #444;
    font-size: 0.95em;
    border-bottom: 1px solid #eee;
}

.modal-content ul li:last-child {
    border-bottom: none;
}

.modal-content p {
    margin: 0;
    font-size: 1em;
}

.modal-content a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.modal-content a:hover {
    text-decoration: underline;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: #333;
}

.loading {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    padding: 15px 30px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 8px;
    color: white;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.loading.hidden {
    display: none;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#slider {
    width: 100px;
    height: 5px;
    cursor: pointer;
}

#slider-value {
    color: #667eea;
    font-weight: 600;
    font-size: 1em;
    min-width: 20px;
    text-align: center;
}

/* 主容器 - 左右布局 */
.main-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 0;
    padding: 0;
    max-width: 100%;
    align-items: start;
}

/* 标签面板 - top 和 maxHeight 由 JS 动态设置 */
.tag-panel {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 0;
    padding: 20px;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    overflow-x: hidden;
    position: sticky;
    top: 160px;
    max-height: calc(100vh - 160px);
}

.tag-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 2px solid rgba(102, 126, 234, 0.2);
}

.tag-panel h3 {
    color: #667eea;
    font-size: 1.1em;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.clear-btn {
    padding: 5px 12px;
    font-size: 0.8em;
    border: 1px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.clear-btn:hover {
    background: #667eea;
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.selected-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
    min-height: 20px;
}

.selected-tag {
    padding: 6px 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 6px;
    font-size: 0.82em;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.selected-tag .remove {
    cursor: pointer;
    font-weight: bold;
    opacity: 0.8;
}

.selected-tag .remove:hover {
    opacity: 1;
}

.count-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 3px 10px;
    border-radius: 15px;
    font-size: 0.85em;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-item {
    padding: 8px 12px;
    background: rgba(102, 126, 234, 0.08);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.88em;
    color: #333;
    display: inline-flex;
    gap: 6px;
    align-items: center;
    white-space: nowrap;
}

.tag-item:hover {
    background: rgba(102, 126, 234, 0.15);
    border-color: rgba(102, 126, 234, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.tag-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 3px 12px rgba(102, 126, 234, 0.4);
}

.tag-count {
    font-size: 0.85em;
    opacity: 0.7;
}

/* 回到顶部按钮 */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 55px;
    height: 55px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    z-index: 999;
}

.back-to-top:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.back-to-top.hidden {
    opacity: 0;
    pointer-events: none;
}

/* 瀑布流容器 - 改用相对定位 */
.waterfall-container {
    position: relative;
    flex: 1;
    padding: 25px 30px;
    margin: 0;
}

/* 瀑布流项目 - 改用绝对定位 */
.waterfall-item {
    position: absolute;
    border-radius: 5px;
    overflow: hidden;
    transition: transform 0.2s;
    cursor: pointer;
    animation: fadeIn 0.5s ease;
}

.waterfall-item:hover {
    transform: scale(1.02);
}

.waterfall-item img {
    width: 100%;
    height: auto;
    display: block;
}

.waterfall-item .image-info {
    padding: 12px;
    background: white;
}

.waterfall-item .image-name {
    font-size: 0.9em;
    color: #333;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.waterfall-item .image-size {
    font-size: 0.75em;
    color: #999;
    margin-top: 4px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .waterfall-container {
        padding: 15px;
    }
}

@media (max-width: 768px) {
    .main-container {
        display: flex;
        flex-direction: column;
        padding: 10px;
    }

    .tag-panel {
        width: 100%;
        position: static;
        max-height: 300px !important;
        min-height: auto;
    }

    .tag-panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .tag-list {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .waterfall-container {
        padding: 0;
    }

    .back-to-top {
        width: 45px;
        height: 45px;
        font-size: 20px;
        bottom: 20px;
        right: 20px;
    }

    header {
        padding: 10px 15px;
    }

    .header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    h1 {
        font-size: 1.2em;
    }

    .header-controls {
        width: 100%;
        flex-wrap: wrap;
        gap: 10px;
    }

    .slider-control {
        font-size: 0.85em;
    }

    #slider {
        width: 80px;
    }

    .header-btn {
        padding: 6px 12px;
        font-size: 0.85em;
    }

    .header-desc p {
        font-size: 0.8em;
    }
}

@media (max-width: 480px) {
    header {
        padding: 8px 10px;
    }

    h1 {
        font-size: 1em;
    }

    .header-btn {
        padding: 5px 10px;
        font-size: 0.8em;
    }

    .header-desc p {
        font-size: 0.75em;
    }
}

/* 灯箱效果 */
.lightbox {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    animation: fadeIn 0.3s ease;
}

.lightbox.hidden {
    display: none;
}

.lightbox:not(.hidden) {
    display: flex;
    justify-content: center;
    align-items: center;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    cursor: grab;
    transition: transform 0.1s ease-out;
    user-select: none;
    -webkit-user-drag: none;
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.close {
    position: absolute;
    top: 20px;
    right: 40px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
    z-index: 1001;
}

.close:hover {
    color: #bbb;
}

.lightbox-caption {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    text-align: center;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 20px;
    border-radius: 20px;
    max-width: 80%;
}

.lightbox-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 16px;
    border-radius: 15px;
    font-size: 0.85em;
    z-index: 1001;
}

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    font-size: 30px;
    padding: 15px 20px;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s ease;
    z-index: 1001;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

.nav-btn.prev {
    left: 20px;
}

.nav-btn.next {
    right: 20px;
}

/* 灯箱响应式 */
@media (max-width: 768px) {
    .lightbox-hint {
        font-size: 0.75em;
        padding: 5px 12px;
    }

    .lightbox-caption {
        font-size: 0.85em;
        padding: 8px 15px;
    }
}

@media (max-width: 480px) {
    .lightbox-hint {
        font-size: 0.7em;
        padding: 4px 10px;
        bottom: 10px;
    }

    .lightbox-caption {
        bottom: 40px;
        font-size: 0.8em;
        padding: 6px 12px;
    }

    .nav-btn {
        font-size: 24px;
        padding: 10px 15px;
    }
}


/* 空图库仍保留完整导航与标签栏。 */
.empty-state { width: 100%; text-align: center; padding: 96px 24px; color: #cbd5e1; }
.empty-state.hidden { display: none; }
.empty-state h2 { margin-bottom: 12px; color: #f8fafc; }
.main-container:has(.empty-state:not(.hidden)) .waterfall-container { display: none; }

.waterfall-container { min-width: 0; }
@media (max-width: 768px) { .waterfall-container { width: 100%; flex: none; } }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.admin-link { display: inline-block; text-decoration: none; white-space: nowrap; }
.search-control input { min-width: 180px; width: 210px; border: 1px solid #dde1ee; border-radius: 6px; padding: 9px 12px; color: #3b425c; background: #f6f7fc; font: inherit; font-size: 13px; }
.header-top { gap: 20px; }
.header-controls { flex-wrap: wrap; justify-content: flex-end; }
.gallery-stage { min-width: 0; }
.gallery-notice { color: #d3d5e3; font-size: 13px; padding: 18px 20px 0; line-height: 1.5; }
.gallery-notice.hidden { display: none; }
.empty-state { grid-column: 2; grid-row: 1; }
.empty-state .header-btn { margin-top: 20px; }
.main-container:has(.empty-state:not(.hidden)) .gallery-stage { display: none; }
.image-metrics { margin-top: 5px; font-size: 12px; line-height: 1.7; color: #c0c6ed; }
.image-metrics:empty { display: none; }
.image-unavailable { min-height: 110px; background: #444653; color: #c3c7dc; }
.image-unavailable img { min-height: 110px; padding: 10px; font-size: 12px; }
@media (max-width: 1250px) { .header-top { flex-wrap: wrap; } .header-controls { flex: 1; } }
@media (max-width: 768px) { .header-controls { justify-content: flex-start; } .search-control { width: 100%; } .search-control input { width: 100%; } .gallery-stage { width: 100%; } }

.selected-tags:empty { display: none; }
@media (max-width: 640px) {
    .main-container { gap: 12px; }
    .tag-panel { padding: 12px; }
    .tag-panel-header { margin-bottom: 10px; padding-bottom: 8px; flex-direction: row; align-items: center; }
    .tag-panel:has(.tag-list:empty) .tag-panel-header { margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
    .tag-list:empty { display: none; }
    .selected-tags { margin-bottom: 8px; }
}

.admin-link.hidden { display: none; }
