:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    --accent-color: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: #eef2ff;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #64748b;
    --border-color: #334155;
    --border-hover: #475569;
    --accent-color: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-light: #312e81;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color var(--transition-normal), color var(--transition-normal);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.hidden {
    display: none !important;
}

.icon {
    width: 20px;
    height: 20px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.header {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    transition: all var(--transition-normal);
}

[data-theme="dark"] .header {
    background: rgba(15, 23, 42, 0.9);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 22px;
}

.logo-icon {
    font-size: 28px;
}

.logo-text {
    background: linear-gradient(135deg, var(--accent-color), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.main {
    padding: 40px 20px 60px;
}

.hero {
    text-align: center;
    margin-bottom: 48px;
}

.hero-title {
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.search-box {
    max-width: 640px;
    margin: 0 auto;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 18px;
    width: 20px;
    height: 20px;
    color: var(--text-tertiary);
    pointer-events: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#searchInput {
    width: 100%;
    padding: 16px 48px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    outline: none;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-md);
}

#searchInput::placeholder {
    color: var(--text-tertiary);
}

#searchInput:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px var(--accent-light), var(--shadow-md);
}

.clear-btn {
    position: absolute;
    right: 14px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.clear-btn:hover {
    background: var(--text-tertiary);
    color: var(--bg-primary);
}

.clear-btn svg {
    width: 16px;
    height: 16px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.categories {
    margin-bottom: 32px;
}

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

.section-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.result-count {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow-x: auto;
}

.category-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.category-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.category-tab.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

[data-theme="dark"] .category-tab.active {
    box-shadow: 0 2px 8px rgba(129, 140, 248, 0.4);
}

.category-count {
    font-size: 12px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.category-tab.active .category-count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.tools-section {
    margin-bottom: 48px;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-color), #8b5cf6);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition-slow);
}

.tool-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-color);
    box-shadow: var(--shadow-xl);
}

.tool-card:hover::before {
    transform: scaleX(1);
}

.tool-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.tool-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: var(--accent-light);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.tool-card:hover .tool-icon {
    transform: scale(1.1);
}

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

.tool-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.3;
}

.tool-url {
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.tool-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tool-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
    padding-top: 4px;
}

.tool-tag {
    display: inline-block;
    font-size: 12px;
    padding: 3px 10px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
    cursor: pointer;
    border: 1px solid transparent;
}

.tool-tag:hover {
    background: var(--accent-light);
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
}

.tags-section {
    margin-bottom: 48px;
}

.tags-section .section-title {
    margin-bottom: 16px;
}

.tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
}

.tag-cloud-item {
    display: inline-block;
    padding: 6px 14px;
    font-size: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tag-cloud-item:hover {
    background: var(--accent-light);
    color: var(--accent-color);
    border-color: var(--accent-color);
    transform: scale(1.05);
}

.tag-cloud-item.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 24px 0;
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.footer p {
    font-size: 14px;
    color: var(--text-secondary);
}

.footer-tip {
    font-size: 12px !important;
    color: var(--text-tertiary) !important;
}

.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: var(--radius-full);
    background: var(--accent-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-fast);
    z-index: 90;
}

.back-to-top:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.back-to-top svg {
    width: 24px;
    height: 24px;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }

    .header-inner {
        height: 56px;
    }

    .logo-text {
        font-size: 20px;
    }

    .logo-icon {
        font-size: 24px;
    }

    .main {
        padding: 24px 16px 48px;
    }

    .hero {
        margin-bottom: 32px;
    }

    .hero-title {
        font-size: 26px;
    }

    .hero-subtitle {
        font-size: 14px;
        margin-bottom: 24px;
    }

    #searchInput {
        padding: 14px 44px;
        font-size: 15px;
    }

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

    .category-tabs {
        flex-wrap: nowrap;
        padding: 10px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .category-tabs::-webkit-scrollbar {
        display: none;
    }

    .category-tab {
        padding: 8px 14px;
        font-size: 13px;
    }

    .tools-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .tool-card {
        padding: 16px;
    }

    .tool-icon {
        width: 42px;
        height: 42px;
        font-size: 24px;
    }

    .tool-name {
        font-size: 15px;
    }

    .tool-desc {
        font-size: 13px;
    }

    .section-title {
        font-size: 18px;
    }

    .tags-cloud {
        padding: 14px;
        gap: 8px;
    }

    .tag-cloud-item {
        padding: 5px 12px;
        font-size: 13px;
    }

    .footer-inner {
        flex-direction: column;
        text-align: center;
    }

    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 42px;
        height: 42px;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 22px;
    }

    .tool-header {
        gap: 10px;
    }

    .tool-icon {
        width: 38px;
        height: 38px;
        font-size: 22px;
    }
}
