:root {
    --color-primary: #ef4444;
    --color-bg: #f7f8fa;
    --color-text: #222;
    --color-text-secondary: #666;
    --color-text-muted: #999;
    --color-white: #fff;
    --color-card-bg: #e5e7eb;
    --color-footer-bg: #1a1a1a;
    --color-border: #333;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --border-radius-sm: 8px;
    --border-radius-md: 14px;
    --border-radius-lg: 16px;
    --spacing-xs: 6px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 14px;
    --spacing-xl: 20px;
    --spacing-2xl: 24px;
    --transition-fast: 0.2s;
    --transition-normal: 0.3s;
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.04);
    --breakpoint-mobile: 920px;
    --sidebar-width: 220px;
    --max-content-width: 1300px;
    --max-single-width: 900px;
    --grid-min-width: 260px;
}

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

body {
    background: var(--color-bg);
    font-family: var(--font-family);
    color: var(--color-text);
}

.desktop-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    gap: var(--spacing-2xl);
    max-width: var(--max-content-width);
    margin: 0 auto;
    padding: var(--spacing-xl);
}

/* 主内容区 */
.main-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar {
    position: sticky;
    top: var(--spacing-xl);
    height: calc(100vh - 40px);
    overflow-y: auto;
    background: var(--color-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--spacing-xl) var(--spacing-md);
}

.sidebar-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 14px;
    text-align: center;
}

.cat-item {
    width: 100%;
    padding: 10px var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    margin-bottom: var(--spacing-xs);
    cursor: pointer;
    font-size: 14px;
    text-align: center;
    background: var(--color-card-bg);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 8px;
}

.cat-item.active {
    background: var(--color-primary);
    color: var(--color-white);
}

.cat-item.active .cat-icon {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* 分类图标通用样式 */
.cat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    font-size: 16px;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.cat-name {
    flex: 1;
}

.mobile-cats {
    display: none;
    padding: 0 var(--spacing-md) var(--spacing-md);
}

.mobile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-sm);
}

.mobile-cat {
    padding: 10px 8px;
    border-radius: var(--border-radius-sm);
    background: var(--color-white);
    text-align: center;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    transition: all var(--transition-fast);
}

.mobile-cat .cat-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fff5f5 0%, #ffe4e4 100%);
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.15);
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.mobile-cat:hover .cat-icon {
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.25);
}

.mobile-cat.active {
    background: var(--color-primary);
    color: var(--color-white);
}

.mobile-cat.active .cat-icon {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.wall-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--grid-min-width), 1fr));
    gap: var(--spacing-xl);
}

.wall-grid.single {
    grid-template-columns: 1fr !important;
    max-width: var(--max-single-width);
    margin: 0 auto;
}

.wall-card {
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    background: var(--color-card-bg);
    transition: all var(--transition-fast);
}

.wall-card img {
    width: 100%;
    height: auto;
    display: block;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.wall-card img.loaded {
    opacity: 1;
}

.card-bottom {
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--color-white);
}

.tag {
    font-size: 12px;
    color: var(--color-text-secondary);
}

.down-btn {
    font-size: 13px;
    color: var(--color-primary);
    font-weight: 500;
    cursor: pointer;
}

.fav-btn {
    font-size: 13px;
    color: #ef4444;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.fav-btn:hover {
    transform: scale(1.1);
}

.fav-btn.active {
    color: #dc2626;
    font-weight: 700;
}

.fav-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fav-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}

.fav-panel {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 320px;
    max-height: 400px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    z-index: 99;
    display: none;
    overflow: hidden;
}

.fav-panel.show {
    display: block;
}

.fav-panel-header {
    padding: 16px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fav-panel-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.fav-panel-clear {
    font-size: 12px;
    color: #64748b;
    cursor: pointer;
}

.fav-panel-clear:hover {
    color: #dc2626;
}

.fav-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
}

.fav-item {
    display: flex;
    gap: 12px;
    padding: 8px;
    border-radius: 8px;
    margin-bottom: 8px;
    background: #f8fafc;
    cursor: pointer;
}

.fav-item:hover {
    background: #f1f5f9;
}

.fav-item img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
}

.fav-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.fav-item-name {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
}

.fav-item-remove {
    font-size: 12px;
    color: #dc2626;
    cursor: pointer;
}

/* 工具栏基础样式 */
.top-toolbar {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 12px;
    padding: 14px 20px;
    background: var(--color-white);
    border-bottom: 1px solid #e5e7eb;
    align-items: center;
}

/* 工具栏在主内容区应该没有白色背景 */
.main-content .top-toolbar {
    padding: 16px 0;
    background: transparent;
    border-bottom: none;
}

.search-box {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-box input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    background: #f9fafb;
}

.search-box input:focus {
    border-color: var(--color-primary);
    background: white;
}

.search-box button {
    padding: 8px 12px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.filter-box select {
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    background: #f9fafb;
}

.filter-box select:hover {
    background: white;
}

.batch-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.btn-small {
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}

.btn-small:hover {
    background: white;
}

.btn-small.btn-primary {
    background: var(--color-primary);
    color: white;
    border: none;
}

.btn-small:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 图片选择框 */
.wall-card {
    position: relative;
}

.select-checkbox {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #667eea;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    transition: all 0.2s;
}

.wall-card:hover .select-checkbox {
    opacity: 1;
}

.wall-card.selected .select-checkbox {
    opacity: 1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
}

.wall-card.selected .select-checkbox::after {
    content: '✓';
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.wall-card.selected {
    outline: 3px solid #667eea;
}

/* 历史记录面板 */
.history-panel {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 320px;
    max-height: 400px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    z-index: 99;
    display: none;
    overflow: hidden;
}

.history-panel.show {
    display: block;
}

.history-panel-header {
    padding: 16px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-panel-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.history-panel-clear {
    font-size: 12px;
    color: #64748b;
    cursor: pointer;
}

.history-panel-clear:hover {
    color: #dc2626;
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
}

.history-item {
    display: flex;
    gap: 12px;
    padding: 8px;
    border-radius: 8px;
    margin-bottom: 8px;
    background: #f8fafc;
    cursor: pointer;
}

.history-item:hover {
    background: #f1f5f9;
}

.history-item img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
}

.history-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.history-item-name {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
}

.history-item-time {
    font-size: 11px;
    color: #94a3b8;
}

.history-item-remove {
    font-size: 12px;
    color: #dc2626;
    cursor: pointer;
}

.loading {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--color-text-secondary);
    display: none;
}

.preview {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.97);
    display: none;
    place-items: center;
    z-index: 9999;
}

.preview img {
    max-width: 94%;
    max-height: 94vh;
    border-radius: var(--border-radius-md);
}

.close {
    position: absolute;
    top: 24px;
    right: 32px;
    color: var(--color-white);
    font-size: 32px;
    cursor: pointer;
}

.site-footer {
    background-color: var(--color-footer-bg);
    color: var(--color-text-muted);
    padding: var(--spacing-xl) 0;
    text-align: center;
    font-size: 14px;
    margin-top: 40px;
    border-top: 1px solid var(--color-border);
}

.site-footer .container {
    max-width: var(--max-content-width);
    margin: 0 auto;
    padding: 0 var(--spacing-xl);
}

.site-footer p {
    margin: 5px 0;
}

.site-footer a {
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color var(--transition-normal);
}

.site-footer a:hover {
    color: var(--color-white);
}

.cr-text {
    color: #ccc;
    font-weight: bold;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.hidden-copyright {
    position: absolute;
    left: -9999px;
    top: -9999px;
    opacity: 0;
    pointer-events: none;
}

.hidden-heading {
    display: none;
}

/* ============================================
   响应式设计
   ============================================ */

/* 手机端 (<= 920px) */
@media (max-width: 920px) {
    .desktop-layout {
        display: block;
        padding: 12px;
    }

    .sidebar {
        display: none;
    }

    .mobile-cats {
        display: block;
    }
    
    /* 工具栏在手机端 */
    .top-toolbar {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        gap: 10px;
        padding: 12px 16px;
        margin-bottom: 12px;
    }
    
    .search-box {
        grid-column: 1 / -1;
    }
    
    .filter-box select {
        font-size: 12px;
        padding: 8px 10px;
    }
    
    .btn-small {
        font-size: 12px;
        padding: 8px 10px;
    }

    .wall-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 10px;
    }

    .card-bottom {
        padding: 8px 10px;
    }

    .tag {
        font-size: 12px;
    }

    .down-btn, .fav-btn {
        font-size: 12px;
    }

    .fav-panel, .history-panel {
        width: 90%;
        right: 5%;
        bottom: 80px;
        max-height: 50vh;
    }
}

/* 小屏幕手机 (<= 480px) */
@media (max-width: 480px) {
    .wall-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .fav-panel, .history-panel {
        width: 95%;
        right: 2.5%;
    }
}

/* 平板/大屏手机 (481px - 920px) */
@media (min-width: 481px) and (max-width: 920px) {
    .wall-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
}

/* 桌面端 (>= 921px) */
@media (min-width: 921px) {
    /* 工具栏优化 */
    .top-toolbar {
        padding: 16px 0;
        border-bottom: none;
        background: transparent;
        gap: 16px;
    }
    
    .search-box {
        max-width: 400px;
    }
    
    .search-box input {
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .filter-box select {
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .btn-small {
        padding: 10px 16px;
        font-size: 14px;
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

@media (max-width: 920px) {
    .desktop-layout {
        grid-template-columns: 1fr;
        padding: var(--spacing-md);
    }
    
    .sidebar {
        display: none;
    }
    
    .mobile-cats {
        display: block;
    }
}
