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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
    overflow-x: hidden;
}

/* ========== 顶部 ========== */
.header {
    background: #fff;
    padding: 14px 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 22px;
    font-weight: 700;
    color: #333;
}

/* ========== 主分类导航 ========== */
.top-nav {
    display: flex;
    gap: 0;
    padding: 0 24px;
    background: #fff;
    border-bottom: 1px solid #eee;
    overflow-x: auto;
    white-space: nowrap;
    position: sticky;
    top: 54px;
    z-index: 99;
}

.top-nav .nav-item {
    padding: 12px 20px;
    cursor: pointer;
    font-size: 15px;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    flex-shrink: 0;
}

.top-nav .nav-item:hover { color: #333; }

.top-nav .nav-item.active {
    color: #333;
    font-weight: 600;
    border-bottom-color: #333;
}

/* ========== 移动端侧边栏切换按钮 ========== */
.sidebar-toggle {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    margin: 10px 12px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    color: #555;
    cursor: pointer;
}

/* ========== 左右分栏主布局 ========== */
.main-layout {
    display: flex;
    min-height: calc(100vh - 110px);
}

/* ========== 左侧侧边栏 ========== */
.sidebar {
    width: 220px;
    min-width: 220px;
    background: #fff;
    border-right: 1px solid #eee;
    overflow-y: auto;
    height: calc(100vh - 110px);
    position: sticky;
    top: 110px;
}

.sidebar-header {
    padding: 16px 16px 8px;
    font-size: 13px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar .sub-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 8px 16px;
}

.sidebar .sub-nav .tag {
    padding: 9px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    background: transparent;
    color: #555;
    transition: all 0.15s;
    border: none;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar .sub-nav .tag:hover {
    background: #f5f5f5;
    color: #333;
}

.sidebar .sub-nav .tag.active {
    background: #333;
    color: #fff;
    font-weight: 500;
}

/* 遮罩层（移动端用） */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 199;
}

/* ========== 右侧内容区 ========== */
.content {
    flex: 1;
    min-width: 0;
    padding: 0;
}

/* ========== 瀑布流画廊 ========== */
.gallery {
    column-count: 5;
    column-gap: 10px;
    padding: 16px;
}

.gallery .card {
    break-inside: avoid;
    margin-bottom: 10px;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
}

.gallery .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.gallery .card img {
    width: 100%;
    display: block;
}

.gallery .card .card-info {
    padding: 8px 12px;
    font-size: 12px;
    color: #999;
}

.gallery .card .card-info .name {
    color: #555;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========== 流式加载状态 ========== */
.stream-status {
    text-align: center;
    padding: 24px 0 16px;
    font-size: 13px;
    color: #999;
}

.scroll-trigger {
    height: 1px;
}

/* ========== 图片懒加载淡入 ========== */
.card img {
    opacity: 0;
    transition: opacity 0.3s;
}

.card img.loaded {
    opacity: 1;
}

/* ========== 响应式 - 大屏6列 ========== */
@media (min-width: 1600px) {
    .gallery { column-count: 6; }
}

/* ========== 响应式 - 中屏4列 ========== */
@media (max-width: 1200px) {
    .gallery { column-count: 4; }
}

/* ========== 响应式 - 小屏3列 ========== */
@media (max-width: 1000px) {
    .gallery { column-count: 3; }
}

/* ========== 响应式 - 平板 ========== */
@media (max-width: 768px) {
    .top-nav {
        padding: 0 12px;
        top: 50px;
    }

    .sidebar-toggle {
        display: flex;
    }

    .main-layout {
        min-height: auto;
    }

    /* 侧边栏变为抽屉 */
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 260px;
        min-width: 260px;
        height: 100vh;
        z-index: 200;
        transition: left 0.3s ease;
        box-shadow: none;
    }

    .sidebar.open {
        left: 0;
        box-shadow: 4px 0 24px rgba(0,0,0,0.15);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .gallery {
        column-count: 2;
        padding: 10px;
        column-gap: 8px;
    }

    .gallery .card {
        margin-bottom: 8px;
    }
}

/* ========== 响应式 - 手机 ========== */
@media (max-width: 480px) {
    .header { padding: 12px 14px; }
    .logo { font-size: 18px; }

    .top-nav .nav-item {
        padding: 10px 14px;
        font-size: 14px;
    }

    .gallery {
        column-count: 2;
        padding: 6px;
        column-gap: 6px;
    }

    .gallery .card {
        margin-bottom: 6px;
        border-radius: 6px;
    }
}

/* ========== 图片弹窗 Lightbox ========== */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.85);
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.lightbox.open {
    display: flex;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lightbox-toolbar {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 6px;
}

.lightbox-close {
    background: rgba(0,0,0,0.5);
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
}

.lightbox-close:hover {
    opacity: 1;
    background: rgba(0,0,0,0.7);
}

.lightbox-img-wrap {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 200px;
    min-height: 150px;
}

.lightbox-img-wrap img {
    max-width: 85vw;
    max-height: calc(90vh - 100px);
    object-fit: contain;
    border-radius: 6px;
    opacity: 0;
    transition: opacity 0.3s;
}

.lightbox-img-wrap img.loaded {
    opacity: 1;
}

.lightbox-loading {
    position: absolute;
    color: #aaa;
    font-size: 14px;
}

.lightbox-loading.hidden {
    display: none;
}

.lightbox-actions {
    display: none;
}

.lb-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 12px;
    height: 36px;
    border: none;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
    white-space: nowrap;
    opacity: 0.9;
}

.lb-btn:hover {
    background: rgba(0,0,0,0.7);
    opacity: 1;
}

.lb-btn:disabled {
    opacity: 0.4;
    cursor: wait;
}

.lightbox-toast {
    position: absolute;
    bottom: -40px;
    padding: 6px 18px;
    background: rgba(0,0,0,0.8);
    color: #fff;
    border-radius: 6px;
    font-size: 13px;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.lightbox-toast.show {
    opacity: 1;
}

@media (max-width: 480px) {
    .lightbox { padding: 10px; }

    .lightbox-img-wrap img {
        max-width: 95vw;
        max-height: 65vh;
    }

    .lightbox-actions {
        gap: 8px;
        margin-top: 12px;
    }

    .lb-btn {
        padding: 7px 14px;
        font-size: 12px;
    }

    .lightbox-close {
        top: -34px;
        right: 0;
    }
}
