/* CSS 变量定义 */
:root {
    --primary-color: #5b7fff;
    --primary-light: #7a95ff;
    --primary-dark: #4a66e5;
    --secondary-color: #22c55e;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --bg-gradient: linear-gradient(to bottom, #f9fafb 0%, #ffffff 100%);
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 8px 24px rgba(0, 0, 0, 0.15);
    --border-radius-sm: 4px;
    --border-radius-md: 6px;
    --border-radius-lg: 8px;
    --border-radius-xl: 12px;
    --border-radius-2xl: 16px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
}

/* 基础样式重置 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-overflow-scrolling: touch;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* iOS/macOS 触摸优化 - 所有可交互元素 */
button, a, input, select, textarea, [role="button"], [onclick] {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    touch-action: manipulation;
    cursor: pointer;
}

/* 优化触摸反馈 */
button:active, a:active, [role="button"]:active {
    opacity: 0.7;
    transform: scale(0.98);
    transition: all 0.1s ease;
}

/* 防止 iOS 双击缩放 */
input, textarea, select {
    touch-action: manipulation;
}

/* 硬件加速优化 */
.card-hover-effect, .modal-container, .modal-overlay, .btn-primary {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    will-change: transform;
}

/* 自定义滚动条 - 更简洁 */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 5px;
    border: 2px solid #f1f5f9;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 模态框背景和动画 - 更自然 */
.modal-overlay {
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.25s ease;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.modal-overlay.open {
    opacity: 1;
}

.modal-container {
    transform: translateY(30px);
    opacity: 0;
    transition: all 0.25s ease;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.modal-overlay.open .modal-container {
    transform: translateY(0);
    opacity: 1;
}

/* 加载动画 */
.loader {
    border: 5px solid var(--border-color);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

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

/* 按钮悬停效果 - 更微妙 */
.btn-primary {
    transition: all var(--transition-normal);
    position: relative;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    opacity: 0.9;
}

/* 卡片悬停效果 - 更自然 */
.card-hover-effect {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.card-hover-effect:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

/* 触摸设备的卡片反馈 */
@media (hover: none) and (pointer: coarse) {
    .card-hover-effect:active {
        transform: scale(0.97);
        box-shadow: var(--shadow-md);
    }
}

/* 移动端卡片图片优化 */
@media (max-width: 768px) {
    .card-hover-effect .aspect-square img {
        object-fit: cover;
        width: 100%;
        height: 100%;
    }
    
    /* 确保卡片标题不会太高 */
    .card-hover-effect .flex-col {
        min-height: auto;
    }
    
    /* 标题多行显示 */
    .card-hover-effect h3 {
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        white-space: normal;
    }
}

/* 卡片标题通用样式 - 支持多行 */
.card-title-multiline {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    line-height: 1.4;
}

/* 简约滑动开关样式 */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.toggle-input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    border-radius: 24px;
    transition: all 0.25s ease;
}

.toggle-slider:before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* 悬停效果 */
.toggle-switch:hover .toggle-slider {
    background-color: #94a3b8;
}

/* 选中状态 - 默认（收藏/蓝色） */
.toggle-input:checked + .toggle-slider {
    background-color: #5b7fff;
}

.toggle-input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* 选中状态悬停 */
.toggle-input:checked + .toggle-slider:hover {
    background-color: #4a66e5;
}

/* 精选资源开关（琥珀色） */
.toggle-switch-amber .toggle-input:checked + .toggle-slider {
    background-color: #f59e0b;
}

.toggle-switch-amber .toggle-input:checked + .toggle-slider:hover {
    background-color: #d97706;
}

/* 焦点状态（键盘导航） */
.toggle-input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(91, 127, 255, 0.2);
}

.toggle-switch-amber .toggle-input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

/* 禁用状态 */
.toggle-input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* iOS 优化 */
@supports (-webkit-touch-callout: none) {
    .toggle-slider {
        -webkit-tap-highlight-color: transparent;
    }
    
    .toggle-slider:before {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* iOS 风格优化 */
@supports (-webkit-touch-callout: none) {
    .toggle-slider {
        -webkit-tap-highlight-color: transparent;
    }
    
    .toggle-slider:before {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* 工具提示样式 - 更简洁 */
.tooltip-container {
    position: relative;
    display: inline-block;
}

.tooltip-text {
    visibility: hidden;
    width: auto;
    background-color: #334155;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 6px 10px;
    position: absolute;
    z-index: 100;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.2s ease;
    white-space: nowrap;
    font-size: 0.875rem;
}

.tooltip-container:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -4px;
    border-width: 4px;
    border-style: solid;
    border-color: #334155 transparent transparent transparent;
}

/* 代理模式提示 tooltip */
.proxy-toggle-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.proxy-info-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid #94a3b8;
    color: #94a3b8;
    cursor: help;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.proxy-info-icon:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(91, 127, 255, 0.08);
}

.proxy-info-icon svg {
    width: 12px;
    height: 12px;
}

.proxy-info-tooltip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #f1f5f9;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.75rem;
    line-height: 1.5;
    white-space: nowrap;
    text-align: center;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
    font-weight: 400;
}

.proxy-info-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1e293b;
}

.proxy-info-icon:hover .proxy-info-tooltip,
.proxy-info-icon:active .proxy-info-tooltip {
    visibility: visible;
    opacity: 1;
}

/* 移动端 tooltip 适配：空间不够时换到下方 */
@media (max-width: 768px) {
    .proxy-info-tooltip.proxy-tooltip-mobile {
        bottom: auto;
        top: calc(100% + 10px);
    }

    .proxy-info-tooltip.proxy-tooltip-mobile::after {
        top: auto;
        bottom: 100%;
        border-top-color: transparent;
        border-bottom-color: #1e293b;
    }
}

/* 移动端代理说明独立展开区域 */
.mobile-proxy-info-section {
    padding: 0 2px;
}

.mobile-proxy-info-trigger {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    padding: 6px 8px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    font-size: 0.75rem;
    cursor: pointer;
    transition: color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-proxy-info-trigger:hover,
.mobile-proxy-info-trigger:active {
    color: var(--primary-color);
}

.mobile-proxy-info-trigger svg {
    flex-shrink: 0;
}

.mobile-proxy-info-trigger .expand-arrow {
    margin-left: auto;
    transition: transform 0.2s ease;
}

.mobile-proxy-info-trigger.open .expand-arrow {
    transform: rotate(180deg);
}

.mobile-proxy-info-content {
    max-height: 0;
    overflow: hidden;
    padding: 0 8px;
    font-size: 0.7rem;
    color: #64748b;
    line-height: 1.5;
    transition: max-height 0.3s ease, padding 0.3s ease, margin 0.3s ease;
}

.mobile-proxy-info-content.open {
    max-height: 80px;
    padding: 4px 8px 6px;
}

/* 站点入口弹窗 */
.sites-popup {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 90;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px 8px 12px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-xl);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity 0.35s ease, transform 0.35s ease;
    pointer-events: none;
}

.sites-popup.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.sites-popup-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.sites-popup-links {
    display: flex;
    gap: 6px;
}

.sites-popup-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.2;
    color: var(--primary-color);
    background: rgba(91, 127, 255, 0.08);
    border-radius: 20px;
    text-decoration: none;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.sites-popup-links a:hover {
    background: var(--primary-color);
    color: #fff;
}

.sites-popup-close {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: #fff;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
    padding: 0;
}

.sites-popup-close:hover {
    color: var(--text-primary);
    border-color: #cbd5e1;
    box-shadow: var(--shadow-md);
}

/* 移动端适配 */
@media (max-width: 640px) {
    .sites-popup {
        top: auto;
        bottom: 124px;
        left: 10px;
        right: 10px;
        width: auto;
        max-width: calc(100vw - 20px);
        justify-content: center;
        padding: 7px 28px 7px 10px;
        gap: 6px;
        border-radius: var(--border-radius-lg);
        transform: translateY(12px);
    }

    .sites-popup.visible {
        transform: translateY(0);
    }

    .sites-popup-title {
        font-size: 0.68rem;
    }

    .sites-popup-links {
        flex-wrap: nowrap;
        gap: 5px;
    }

    .sites-popup-links a {
        font-size: 0.68rem;
        padding: 3px 9px;
    }

    .sites-popup-close {
        top: 4px;
        right: 6px;
        width: 24px;
        height: 24px;
        font-size: 14px;
        line-height: 24px;
        border: none;
        box-shadow: none;
        background: transparent;
        color: var(--text-secondary);
    }
}

/* 站点入口小球 */
.sites-ball {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 91;
    width: 40px;
    height: 40px;
    max-width: 40px;
    max-height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(91, 127, 255, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.sites-ball.visible {
    opacity: 1;
    pointer-events: auto;
    animation: sites-ball-pulse 2.2s ease-in-out infinite;
}

.sites-ball svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sites-ball:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 20px rgba(91, 127, 255, 0.5);
    animation: none;
}

.sites-ball:active {
    transform: scale(0.9);
}

@keyframes sites-ball-pulse {
    0%, 100% { box-shadow: 0 2px 12px rgba(91, 127, 255, 0.35); }
    50% { box-shadow: 0 2px 12px rgba(91, 127, 255, 0.35), 0 0 0 10px rgba(91, 127, 255, 0); }
}

@media (max-width: 640px) {
    .sites-ball {
        top: auto;
        bottom: 72px;
        right: 16px;
        left: auto;
        width: 44px;
        height: 44px;
        min-width: 44px;
        max-width: 44px;
        min-height: 44px;
        max-height: 44px;
    }

    .sites-ball svg {
        width: 22px;
        height: 22px;
    }
}

/* 超链接悬停效果 */
.link-hover {
    transition: all var(--transition-fast);
    position: relative;
    display: inline-block;
}

.link-hover:hover {
    color: var(--primary-color);
    transform: translateY(-1px);
}

/* 回到顶部按钮 - 更简洁 */
#back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 40;
    background-color: var(--primary-color);
    color: white;
    padding: 12px;
    border-radius: 50%;
    box-shadow: var(--shadow-md);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
}

#back-to-top.show {
    opacity: 0.9;
    visibility: visible;
}

#back-to-top:hover {
    opacity: 1;
    transform: translateY(-2px);
}

/* 搜索框焦点效果 - 更自然 */
#searchInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(91, 127, 255, 0.15);
    outline: none;
}

/* 筛选标签样式 - 更简单 */
.filter-tag {
    transition: all 0.15s ease;
}

.filter-tag:hover {
    opacity: 0.85;
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn var(--transition-normal) ease-out;
}

/* 骨架屏加载效果 */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

/* 移动端优化样式 - 扩大范围到 768px，增大字体 */
@media (max-width: 768px) {
    /* 强制两列布局 */
    #item-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.875rem !important;
    }

    /* 优化卡片样式 */
    .card-hover-effect {
        border-radius: 10px;
    }
    
    .card-hover-effect .p-5 {
        padding: 0.875rem !important;
    }
    
    /* 增大卡片标题字体 */
    .card-hover-effect h3 {
        font-size: 0.9375rem !important; /* 15px，从 14px 增大 */
        line-height: 1.35 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden !important;
        text-overflow: ellipsis;
        white-space: normal !important;
    }
    
    /* 增大年份字体 */
    .card-hover-effect p {
        font-size: 0.8125rem !important; /* 13px，从 12px 增大 */
        margin-top: 0.375rem !important;
    }
    
    /* 优化收藏按钮 */
    .favorite-btn {
        width: 34px !important;
        height: 34px !important;
        top: 8px !important;
        right: 8px !important;
    }
    
    .favorite-btn svg {
        width: 18px !important;
        height: 18px !important;
    }

    /* 优化标题大小 */
    h1 {
        font-size: 1.25rem !important;
        line-height: 1.4 !important;
    }

    /* 优化搜索框大小和位置 */
    #searchInput {
        font-size: 16px; /* iOS 防止自动缩放 */
        padding: 0.625rem 2.5rem 0.625rem 1rem !important;
    }
    
    #searchButton {
        right: 0.75rem !important;
    }

    /* 优化模态框在小屏幕上的显示 */
    .modal-container {
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
        -webkit-overflow-scrolling: touch;
    }

    /* 优化详情页布局 */
    #modal-content {
        padding: 1rem !important;
    }
    
    /* 优化模态框图片 */
    #modal-img {
        width: 120px !important;
        height: 120px !important;
    }
    
    /* 优化模态框标题 */
    #modal-title {
        font-size: 1.125rem !important;
    }

    /* 优化移动端的按钮和交互元素大小 */
    button, a {
        touch-action: manipulation;
        min-height: 44px; /* iOS 推荐的最小触摸目标 */
    }

    /* 回到顶部按钮在移动端上更小一些 */
    #back-to-top {
        bottom: 16px;
        right: 16px;
        padding: 10px;
    }
    
    /* iOS 优化：防止橡皮筋效果 */
    body {
        overscroll-behavior-y: none;
    }
    
    /* 优化侧边栏在移动端的显示 */
    aside .p-6 {
        padding: 1rem !important;
    }
    
    /* 优化筛选按钮 */
    #year-filter-list button,
    #subject-filter-tags button {
        font-size: 0.8125rem !important;
        padding: 0.375rem 0.75rem !important;
    }
    
    /* 优化容器内边距 */
    .container {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    /* 优化主内容区域 */
    #main-page {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }
}

/* 平板设备优化 */
@media (min-width: 769px) and (max-width: 1024px) {
    /* 优化卡片网格在平板上的显示 */
    #item-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 1.5rem !important;
    }
}

/* 大屏设备优化 (桌面端) */
@media (min-width: 1025px) {
    /* 增大卡片标题字体 */
    .card-hover-effect h3 {
        font-size: 1.125rem !important; /* 18px，从默认的 1rem (16px) 增大 */
        line-height: 1.4 !important;
    }
    
    /* 增大年份字体 */
    .card-hover-effect p {
        font-size: 0.9375rem !important; /* 15px，从默认的 0.875rem (14px) 增大 */
    }
}

/* 极小屏幕优化 (iPhone SE, 小屏安卓) */
@media (max-width: 375px) {
    /* 保持两列，但进一步优化间距 */
    #item-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.625rem !important;
    }
    
    /* 进一步减小卡片内边距 */
    .card-hover-effect .p-5 {
        padding: 0.625rem !important;
    }
    
    /* 优化标题字体 - 稍微增大 */
    .card-hover-effect h3 {
        font-size: 0.875rem !important; /* 14px，从 13px 增大 */
        line-height: 1.3 !important;
    }
    
    /* 优化年份字体 - 稍微增大 */
    .card-hover-effect p {
        font-size: 0.75rem !important; /* 12px，从 11px 增大 */
    }
    
    /* 优化收藏按钮 */
    .favorite-btn {
        width: 30px !important;
        height: 30px !important;
        top: 6px !important;
        right: 6px !important;
    }
    
    .favorite-btn svg {
        width: 16px !important;
        height: 16px !important;
    }
    
    /* 优化容器内边距 */
    .container {
        padding-left: 0.625rem !important;
        padding-right: 0.625rem !important;
    }
    
    /* 优化主标题 */
    h1 {
        font-size: 1.125rem !important;
    }
    
    /* 优化侧边栏 */
    aside .p-6 {
        padding: 0.75rem !important;
    }
}

/* 大屏手机优化 (iPhone 14 Plus, iPhone 15 Plus 等) */
@media (min-width: 414px) and (max-width: 768px) {
    /* 确保使用两列布局 */
    #item-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }
    
    /* 稍微增大卡片内边距 */
    .card-hover-effect .p-5 {
        padding: 1rem !important;
    }
    
    /* 增大字体 */
    .card-hover-effect h3 {
        font-size: 1rem !important; /* 16px */
        line-height: 1.4 !important;
    }
    
    .card-hover-effect p {
        font-size: 0.875rem !important; /* 14px */
    }
    
    /* 稍大的收藏按钮 */
    .favorite-btn {
        width: 36px !important;
        height: 36px !important;
    }
    
    .favorite-btn svg {
        width: 20px !important;
        height: 20px !important;
    }
}

/* 滚动进度指示器 - 更简洁 */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: var(--primary-color);
    z-index: 1000;
    width: 0%;
    transition: width 0.1s ease-out;
}

/* 项目卡片悬停效果 - 更自然 */
.item-card {
    transition: all 0.2s ease;
    border-radius: 12px;
    overflow: hidden;
}

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

/* 移动端筛选标签 */
.filter-tag {
    transition: all 0.15s ease;
}

.filter-tag.active {
    background-color: var(--primary-color);
    color: white;
}

/* 模态框动画 - 更简单 */
.modal {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.2s ease;
}

.modal.active .modal-content {
    transform: translateY(0);
    opacity: 1;
}

/* 移动端模态框优化 */
@media (max-width: 768px) {
    .modal-content {
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
        border-radius: 16px;
    }

    /* 确保模态框内的图片适应屏幕宽度 */
    #modal-img {
        width: 100%;
        height: auto;
        object-fit: contain;
        max-height: 250px;
    }

    /* 优化下载项在移动端的显示 */
    .modal-download-item {
        padding: 3px 8px;
        margin: 2px;
        font-size: 0.85rem;
    }
}

/* 平滑滚动 */
html {
    scroll-behavior: smooth;
    /* iOS 滚动优化 */
    -webkit-overflow-scrolling: touch;
}

/* iOS/macOS 滚动容器优化 */
.overflow-y-auto, .overflow-auto {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* 增强加载动画 */
.loader {
    width: 48px;
    height: 48px;
    border: 3px solid var(--primary-color);
    border-bottom-color: transparent;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

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

/* 全局隐藏滚动条，但为模态框（详细页）保留滚动条 */
body::-webkit-scrollbar {
    width: 0;
    height: 0;
}

body::-webkit-scrollbar-track {
    background: transparent;
}

body::-webkit-scrollbar-thumb {
    background: transparent;
}

/* 为模态框（详细页）添加自定义滚动条 */
.modal-container::-webkit-scrollbar {
    width: 8px;
}

.modal-container::-webkit-scrollbar-track {
    background: var(--border-color);
    border-radius: 4px;
}

.modal-container::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 4px;
    transition: background-color var(--transition-fast);
}

.modal-container::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* iOS/macOS 性能优化 - 图片懒加载 */
img {
    content-visibility: auto;
    loading: lazy;
}

/* iOS/macOS 性能优化 - 减少重绘 */
#item-grid {
    contain: layout style paint;
}

/* iOS Safari 修复 - 防止输入框缩放 */
@supports (-webkit-touch-callout: none) {
    input, textarea, select {
        font-size: 16px !important;
    }
}

/* macOS Safari 优化 - 平滑滚动 */
@media (prefers-reduced-motion: no-preference) {
    * {
        scroll-behavior: smooth;
    }
}

/* iOS 优化 - 防止长按选择 */
img, svg {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* 触摸设备优化 - 增大点击区域 */
@media (hover: none) and (pointer: coarse) {
    button, a, [role="button"] {
        min-height: 44px;
        min-width: 44px;
        padding: 12px;
    }
    
    /* 移除悬停效果，使用点击效果 */
    .btn-primary:hover {
        transform: none;
    }
    
    .btn-primary:active {
        transform: scale(0.95);
    }
}
