/* ==================== 响应式整体缩放 ==================== */
/* 线性缩放：1920px = 12px，2560px = 18px */
/* 公式：slope = (18-12)/(2560-1920) = 0.009375，intercept = 12 - 0.009375*1920 = -6 */
html {
    font-size: clamp(12px, calc(-6px + 0.9375vw), 18px);
}

/* ==================== Variables ==================== */
:root {
    --radius: 0.75rem;
    --spacing: 1rem;
    --max-width: 100rem;
    --content-padding: 3rem;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* ==================== Reset ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/*  :  */
.theme-transition, .theme-transition * {
    transition: background-color 200ms ease, color 200ms ease,
                border-color 200ms ease, box-shadow 200ms ease,
                fill 200ms ease, stroke 200ms ease !important;
}
@media (prefers-reduced-motion: reduce) {
    .theme-transition, .theme-transition * { transition: none !important; }
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    position: relative;
    overflow: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* 背景装饰 */
body::before,
body::after {
    content: '';
    position: fixed;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    opacity: 0.025;
    pointer-events: none;
    z-index: 0;
}

body::before {
    top: -250px;
    left: -250px;
    background: radial-gradient(circle, var(--color-text) 0%, transparent 70%);
}

body::after {
    bottom: -250px;
    right: -250px;
    background: radial-gradient(circle, var(--color-text) 0%, transparent 70%);
}

/* ==================== Fixed Sidebars ==================== */
.fixed-sidebar {
    display: none;
}

.fixed-sidebar-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.sidebar-section-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-bottom: 0.5rem;
}

.sidebar-section-title svg {
    opacity: 0.6;
}

/* Category Navigation */
.category-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.category-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    border-radius: 6px;
    text-decoration: none;
    color: var(--color-text-muted);
    font-size: 0.8125rem;
    transition: all 0.2s;
    cursor: pointer;
}

.category-link:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.category-link.active {
    background: var(--color-text);
    color: var(--color-card);
}

.category-icon {
    font-size: 0.5625rem;
    font-weight: 700;
    flex-shrink: 0;
    padding: 0.1875rem 0.3125rem;
    background: var(--color-bg);
    border-radius: 3px;
    letter-spacing: 0.3px;
    opacity: 0.8;
}

.category-link.active .category-icon {
    background: var(--category-active-text, var(--color-card));
    opacity: 1;
}

.category-count {
    margin-left: auto;
    font-size: 0.6875rem;
    padding: 0.0625rem 0.375rem;
    background: var(--color-bg);
    border-radius: 0.625rem;
    font-weight: 600;
    min-width: 1.25rem;
    text-align: center;
}

.category-link.active .category-count {
    background: var(--category-active-text, var(--color-card));
    color: var(--category-active, var(--color-primary));
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.8125rem;
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.2s;
}

.quick-action-btn:hover {
    background: var(--color-text);
    color: var(--color-card);
    border-color: var(--color-text);
}

.quick-action-btn svg {
    flex-shrink: 0;
    width: 0.875rem;
    height: 0.875rem;
}

/* Trending & Ranking Lists */
.trending-list,
.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.trending-item,
.ranking-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.trending-item:hover,
.ranking-item:hover {
    background: var(--color-bg);
}

.ranking-item {
    position: relative;
    padding-left: 1.75rem;
}

.ranking-number {
    position: absolute;
    left: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.125rem;
    height: 1.125rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--color-text-muted);
}

.ranking-item:nth-child(1) .ranking-number {
    color: #FFD700;
}

.ranking-item:nth-child(2) .ranking-number {
    color: #C0C0C0;
}

.ranking-item:nth-child(3) .ranking-number {
    color: #CD7F32;
}

.trending-icon,
.ranking-icon {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.375rem;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.trending-info,
.ranking-info {
    flex: 1;
    min-width: 0;
}

.trending-name,
.ranking-name {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.0625rem;
}

.trending-meta,
.ranking-meta {
    font-size: 0.625rem;
    color: var(--color-text-muted);
}

/* Hide sidebars on smaller screens */
@media (max-width: 1600px) {
    .fixed-sidebar {
        transform: translateX(0);
    }

    .fixed-sidebar-left {
        transform: translateX(-100%);
    }

    .fixed-sidebar-right {
        transform: translateX(100%);
    }
}


/* ==================== Container ==================== */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--content-padding);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

@media (max-width: 1400px) {
    :root {
        --content-padding: 2rem;
    }
}

@media (max-width: 768px) {
    :root {
        --content-padding: 1rem;
    }
}

/* ==================== Header ==================== */
.header {
    padding: 3rem 0 2rem;
    text-align: center;
}

.header-content {
    max-width: 600px;
    margin: 0 auto;
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--color-text);
    margin-bottom: 0.75rem;
}

.subtitle {
    font-size: 1rem;
    color: var(--color-text-muted);
    font-weight: 400;
    line-height: 1.6;
}

@media (max-width: 640px) {
    .header {
        padding: 3rem 0 2rem;
    }

    .title {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 0.9375rem;
    }
}

/* ==================== Main ==================== */
.main {
    flex: 1;
    padding: 2rem 0;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 200px);
}

/* ==================== Toolbar ==================== */
.toolbar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 240px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    transition: border-color 0.2s;
}

.search-box:focus-within {
    border-color: var(--color-text);
}

.search-box svg {
    color: var(--color-text-muted);
    flex-shrink: 0;
    width: 1.25rem !important;
    height: 1.25rem !important;
    min-width: 1.25rem;
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.9375rem;
    color: var(--color-text);
}

.search-box input::placeholder {
    color: var(--color-text-muted);
}

.filter-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-tag {
    padding: 0.625rem 1rem;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.filter-tag:hover {
    border-color: var(--color-text);
    color: var(--color-text);
}

.filter-tag.active {
    background: var(--color-text);
    color: var(--color-card);
    border-color: var(--color-text);
}

/* ==================== Content Layout ==================== */
.content-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2.5rem;
    flex: 1;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));  /* 响应式自适应 */
    gap: 1.25rem;
    align-items: start;
    margin-bottom: 0;  /* 移除底部边距，让分页更靠近 */
}

/* 中等屏幕优化 */
/* 移除强制列数设置，使用 auto-fit 自适应 */

/* ==================== Sidebar ==================== */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: sticky;
    top: 2rem;
    align-self: flex-start;
}

.sidebar-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.sidebar-card:hover {
    box-shadow: var(--shadow-md);
}

.sidebar-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: var(--color-bg);
    border-radius: 8px;
    transition: transform 0.2s;
}

.stat-item:hover {
    transform: translateY(-2px);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.375rem;
    background: linear-gradient(135deg, var(--color-text) 0%, var(--color-text-muted) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

.popular-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.popular-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.popular-item:hover {
    background: var(--color-bg);
    border-color: var(--color-border);
    transform: translateX(4px);
}

.popular-icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.5rem;
    background: linear-gradient(135deg, var(--color-bg) 0%, var(--color-border) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9375rem;
    font-weight: 600;
    flex-shrink: 0;
    color: var(--color-text);
}

.popular-info {
    flex: 1;
    min-width: 0;
}

.popular-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popular-downloads {
    font-size: 0.6875rem;
    color: var(--color-text-muted);
}

/* ==================== Pagination ==================== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 0;
    margin-top: 0;
}

.pagination button {
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 0.75rem;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled):not(.active) {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-card-hover);
}

.pagination button.active {
    background: var(--color-primary);
    color: var(--color-card);
    border-color: var(--color-primary);
    font-weight: 600;
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

@media (max-width: 1024px) {
    .content-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }
}

@media (max-width: 640px) {
    .toolbar {
        flex-direction: column;
    }

    .pagination {
        flex-wrap: wrap;
    }
}

/* ==================== Tool Card ==================== */
.tool-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
    min-height: 12.5rem; /* 200px */
    max-height: 12.5rem;
}

.tool-card:hover {
    border-color: var(--color-text);
    box-shadow: var(--shadow-sm);
}

.tool-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.tool-icon {
    width: 2.25rem; /* 36px */
    height: 2.25rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* 6种柔和淡雅的图标背景色 */
.tool-icon.color-1 { background: #f0f9ff; } /* 极浅蓝 */
.tool-icon.color-2 { background: #fdf2f8; } /* 极浅粉 */
.tool-icon.color-3 { background: #ecfdf5; } /* 极浅绿 */
.tool-icon.color-4 { background: #fffbeb; } /* 极浅黄 */
.tool-icon.color-5 { background: #f5f3ff; } /* 极浅紫 */
.tool-icon.color-6 { background: #fff7ed; } /* 极浅橙 */

.tool-icon.color-1 svg { stroke: #60a5fa; } /* 淡蓝 */
.tool-icon.color-2 svg { stroke: #f472b6; } /* 淡粉 */
.tool-icon.color-3 svg { stroke: #4ade80; } /* 淡绿 */
.tool-icon.color-4 svg { stroke: #fbbf24; } /* 淡黄 */
.tool-icon.color-5 svg { stroke: #a78bfa; } /* 淡紫 */
.tool-icon.color-6 svg { stroke: #fb923c; } /* 淡橙 */

.tool-icon svg {
    width: 1.25rem;
    height: 1.25rem;
    stroke-width: 2;
}

.tool-info {
    flex: 1;
    min-width: 0;
}

.tool-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tool-version {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.tool-description {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    line-height: 1.6;  /* 增加行高，让文字更易读 */
    display: -webkit-box;
    -webkit-line-clamp: 2;  /* 最多显示2行 */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;  /* 超出显示省略号 */
    flex: 1;  /* 占据剩余空间 */
    min-height: calc(0.875rem * 1.6 * 2);  /* 精确匹配两行高度 */
    max-height: calc(0.875rem * 1.6 * 2);
}

.tool-tags {
    display: flex;
    flex-wrap: nowrap;  /* 不换行，保持单行 */
    gap: 0.5rem;
    overflow: hidden;  /* 超出部分隐藏 */
}

.tool-tag {
    padding: 0.25rem 0.625rem;
    background: var(--color-bg);
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-weight: 500;
    white-space: nowrap;   /* 标签文字不换行 */
    flex-shrink: 0;        /* 不被压缩 */
}

/* ==================== Footer ==================== */
.footer {
    padding: 2rem 0;
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.footer-links {
    display: flex;
    gap: 1rem;
}

.footer-links a {
    color: var(--color-text-muted);
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--color-text);
}

@media (max-width: 640px) {
    .footer {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* ==================== Modal ==================== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--spacing);
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--color-card);
    border-radius: var(--radius);
    max-width: 37.5rem; /* 600px */
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2rem; /* 32px */
    height: 2rem;
    border: none;
    background: var(--color-bg);
    border-radius: 0.375rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--color-border);
    color: var(--color-text);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.modal-subtitle {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
    word-break: break-all; /* 允许在任意字符处换行，充分利用空间 */
}

.download-section {
    margin-top: 2rem;
}

.download-section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.download-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.download-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--color-bg);
    border-radius: 8px;
    gap: 1rem;
}

.download-info {
    flex: 1;
    min-width: 0;
}

.download-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
}

.download-size {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.download-btn {
    padding: 0.5rem 1rem;
    background: var(--color-text);
    color: var(--color-card);
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.download-btn:hover {
    opacity: 0.9;
}

/* ==================== Download Toast ==================== */
.download-toast {
    position: fixed;
    top: 0.55rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-card);
    color: var(--color-text);
    padding: 0.5rem 1.25rem;
    border-radius: 3.125rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 10001;
    opacity: 0;
    transition: all 0.25s ease;
    border: 1px solid var(--color-border);
    animation: alert-slide-down 0.25s ease;
}

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

.download-toast svg {
    color: #10b981;
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}
