/* Base Styles with CSS Variables for Theme Switching */
:root {
    /* Light Mode Colors - Modern Youth Aesthetic */
    --bg-primary: #f5f5ff;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eef1ff;
    --text-primary: #1a1a2e;
    --text-secondary: #2a2a4a;
    --text-muted: #6e6e9f;
    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-gradient: linear-gradient(135deg, #6366f1, #a855f7);
    --card-bg: rgba(255, 255, 255, 0.9);
    --card-border: rgba(99, 102, 241, 0.1);
    --card-shadow: rgba(99, 102, 241, 0.15);
    --sidebar-bg: linear-gradient(180deg, #ffffff 0%, #f5f5ff 100%);
    --icon-bg: rgba(99, 102, 241, 0.1);
    --icon-color: #6366f1;
    --search-bg: rgba(99, 102, 241, 0.05);
    --search-border: rgba(99, 102, 241, 0.2);
    --badge-gradient: linear-gradient(90deg, #6366f1, #a855f7);
    --glow-color: rgba(99, 102, 241, 0.3);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px rgba(99, 102, 241, 0.15);
    --hot-badge: linear-gradient(90deg, #f43f5e, #ec4899);
    --new-badge: linear-gradient(90deg, #6366f1, #8b5cf6);
    --scroll-thumb: rgba(99, 102, 241, 0.5);
    --scroll-track: rgba(99, 102, 241, 0.1);
    --sidebar-width-collapsed: 80px;
    --sidebar-width-expanded: 180px;
}

/* Dark Mode Colors - Modern Youth Aesthetic */
.dark {
    --bg-primary: #0f0f1a;
    --bg-secondary: #16161f;
    --bg-tertiary: #1e1e2d;
    --text-primary: #f1f1ff;
    --text-secondary: #d1d1f0;
    --text-muted: #9494c0;
    --accent-primary: #818cf8;
    --accent-secondary: #a5b4fc;
    --accent-gradient: linear-gradient(135deg, #818cf8, #c084fc);
    --card-bg: rgba(30, 30, 45, 0.8);
    --card-border: rgba(129, 140, 248, 0.15);
    --card-shadow: rgba(0, 0, 0, 0.3);
    --sidebar-bg: linear-gradient(180deg, #16161f 0%, #0f0f1a 100%);
    --icon-bg: rgba(129, 140, 248, 0.15);
    --icon-color: #818cf8;
    --search-bg: rgba(129, 140, 248, 0.1);
    --search-border: rgba(129, 140, 248, 0.2);
    --badge-gradient: linear-gradient(90deg, #818cf8, #c084fc);
    --glow-color: rgba(129, 140, 248, 0.3);
    --glass-bg: rgba(30, 30, 45, 0.7);
    --glass-border: rgba(129, 140, 248, 0.1);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --hot-badge: linear-gradient(90deg, #f43f5e, #ec4899);
    --new-badge: linear-gradient(90deg, #818cf8, #c084fc);
    --scroll-thumb: rgba(129, 140, 248, 0.5);
    --scroll-track: rgba(30, 30, 45, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
    sans-serif;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
    position: relative;
    min-height: 100vh;
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, var(--bg-primary), var(--bg-secondary));
    opacity: 0.8;
    z-index: -1;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--scroll-track);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Particles */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background-color: var(--accent-primary);
    opacity: 0.3;
    border-radius: 50%;
}

/* Sidebar - 默认展开状态 */
.sidebar {
    width: var(--sidebar-width-expanded); /* 默认展开 */
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: fixed; /* 改为固定位置 */
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    z-index: 10;
    box-shadow: 1px 0 10px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-right: 1px solid var(--card-border);
    overflow-y: auto;
}

.logo {
    font-size: 24px;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 40px;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.logo::after {
    content: "";
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px; /* 默认展开状态 */
    height: 2px;
    background: var(--accent-gradient);
    transition: width 0.3s ease;
}

.nav-items {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: 12px;
    margin: 0 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    text-align: left;
}

.nav-item:hover {
    background: var(--icon-bg);
    transform: translateX(5px);
}

.nav-item.active {
    background: var(--icon-bg);
}

.nav-item.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: var(--accent-gradient);
    border-radius: 0 4px 4px 0;
}

.nav-icon {
    min-width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
    color: var(--accent-primary);
    transform: scale(1.1);
}

.nav-label {
    margin-left: 12px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 1; /* 默认展开状态 */
    transition: all 0.3s ease;
    color: var(--text-secondary);
    transform: translateX(0); /* 默认展开状态 */
}

.notification-dot {
    position: absolute;
    top: 8px;
    right: 16px;
    width: 6px;
    height: 6px;
    background: var(--accent-primary);
    border-radius: 50%;
    box-shadow: 0 0 5px var(--accent-primary);
    animation: pulse 2s infinite;
}

.sidebar-footer {
    margin-top: auto;
    width: 100%;
    padding-top: 20px;
    border-top: 1px solid var(--card-border);
}

.sidebar-footer .nav-item {
    font-size: 12px;
}

.sidebar-footer .nav-label a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: all 0.3s ease;
}

.sidebar-footer .nav-label a:hover {
    text-decoration: underline;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.5);
        opacity: 0.7;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Main Content */
.main-content {
    flex: 1;
    background: var(--bg-secondary);
    padding: 40px 24px; /* 增加上下内边距 */
    margin-left: var(--sidebar-width-expanded); /* 默认展开状态 */
    overflow-y: auto;
    position: relative;
    transition: background-color 0.3s ease, margin-left 0.3s ease;
}

/* Header */
.header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--card-border);
    position: relative;
}

/* Mobile menu toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    margin-right: 16px;
    transition: transform 0.3s ease;
}

.mobile-menu-toggle:hover {
    transform: scale(1.1);
}

/* Tool Sections */
.section {
    margin-bottom: 60px; /* 增加底部间距 */
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-header {
    display: flex;
    align-items: center;
    margin-bottom: 32px; /* 增加底部间距 */
    position: relative;
}

.section-title {
    font-size: 24px;
    font-weight: 600;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-right: 16px;
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: "";
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 40px;
    height: 2px;
    background: var(--accent-gradient);
    transition: width 0.3s ease;
}

.section-header:hover .section-title::after {
    width: 100%;
}

.section-subtitle {
    color: var(--text-muted);
    font-size: 14px;
}

/* 修改工具网格布局为每行7个，并增加间距 */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 24px; /* 增加间距从16px到24px */
    margin: 0 20px; /* 添加左右外边距，使内容不紧贴屏幕边缘 */
}

/* Horizontal Scrolling Categories */
.horizontal-category {
    margin-bottom: 70px; /* 增加底部间距 */
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.horizontal-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px; /* 增加底部间距 */
    padding-top: 20px; /* 增加顶部间距 */
}

.horizontal-category-title {
    font-size: 20px;
    font-weight: 600;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    position: relative;
    display: inline-block;
}

.horizontal-category-title::after {
    content: "";
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 30px;
    height: 2px;
    background: var(--accent-gradient);
    transition: width 0.3s ease;
}

.horizontal-category-header:hover .horizontal-category-title::after {
    width: 100%;
}

.view-all {
    color: var(--accent-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.view-all:hover {
    transform: translateX(5px);
}

/* 修改分类网格布局为每行7个，并增加间距 */
.category-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 24px; /* 增加间距从16px到24px */
    padding: 12px 0; /* 增加上下内边距 */
    margin: 0 20px; /* 添加左右外边距，使内容不紧贴屏幕边缘 */
}

/* 确保所有卡片布局一致，并增加内部间距 */
.category-grid .tool-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    height: 80px;
    padding: 18px; /* 增加内部间距 */
    position: relative;
    overflow: hidden;
}

/* 修复可能的嵌套问题导致的样式异常 */
.category-grid .tool-card > .tool-card {
    display: none; /* 隐藏错误嵌套的卡片 */
}

/* 确保图标和名称正确显示 */
.category-grid .tool-card .tool-icon {
    flex-shrink: 0;
    margin-right: 12px;
}

.category-grid .tool-card .tool-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 确保卡片在悬停时正确显示 */
.category-grid .tool-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 10px 25px var(--card-shadow);
    border-color: var(--accent-primary);
    z-index: 1;
}

/* 备案信息样式 */
.beian-info {
    width: 100%;
    text-align: center;
    font-size: 10px;
    color: var(--text-muted);
    padding: 8px 0;
    margin-top: 8px;
}

.beian-info a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.3s ease;
}

.beian-info a:hover {
    color: var(--accent-primary);
}

.horizontal-tool-card,
.tool-card {
    background: var(--glass-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: row;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    height: 80px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--glass-shadow);
}

.horizontal-tool-card::before,
.tool-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, transparent, var(--card-border));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.horizontal-tool-card::after,
.tool-card::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, var(--glow-color) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.5s ease;
    transform: scale(0.5);
    z-index: -1;
}

.horizontal-tool-card:hover,
.tool-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 10px 25px var(--card-shadow);
    border-color: var(--accent-primary);
    z-index: 1;
}

.horizontal-tool-card:hover::before,
.tool-card:hover::before {
    opacity: 0.1;
}

.horizontal-tool-card:hover::after,
.tool-card:hover::after {
    opacity: 0.2;
    transform: scale(1);
}

.tool-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--icon-bg);
    border-radius: 10px;
    margin-right: 12px;
    color: var(--icon-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.tool-icon::before {
    content: "";
    position: absolute;
    top: -100%;
    left: -100%;
    width: 300%;
    height: 300%;
    background: conic-gradient(transparent, var(--accent-primary), transparent 30%);
    opacity: 0;
    transition: opacity 0.3s ease;
    animation: rotate 4s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.tool-card:hover .tool-icon::before,
.horizontal-tool-card:hover .tool-icon::before {
    opacity: 0.2;
}

.tool-card:hover .tool-icon,
.horizontal-tool-card:hover .tool-icon {
    background: var(--accent-gradient);
    color: white;
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 0 15px var(--glow-color);
}

.tool-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    transition: transform 0.3s ease;
}

.tool-card:hover .tool-name,
.horizontal-tool-card:hover .tool-name {
    transform: scale(1.05);
}

.badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 3px 6px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    box-shadow: 0 0 10px var(--glow-color);
    color: white;
    transition: all 0.3s ease;
}

.badge-hot {
    background: var(--hot-badge);
}

.badge-new {
    background: var(--new-badge);
}

.tool-card:hover .badge,
.horizontal-tool-card:hover .badge {
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--glow-color);
}

/* Help Button */
.help-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 5px 20px var(--glow-color);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    overflow: hidden;
}

.help-button::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, var(--glow-color) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.help-button:hover::before {
    opacity: 1;
}

.help-button:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 8px 30px var(--glow-color);
}

/* Animations */
.tools-grid .tool-card,
.category-grid .horizontal-tool-card {
    opacity: 0;
    animation: fadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tools-grid .tool-card:nth-child(n),
.category-grid .horizontal-tool-card:nth-child(n) {
    animation-delay: calc(0.05s * var(--i, 0));
}

/* 更新响应式布局 */
@media (max-width: 1400px) {
    .tools-grid,
    .category-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 20px; /* 稍微减少间距但仍保持宽松 */
        margin: 0 16px; /* 稍微减少边距 */
    }
}

@media (max-width: 1200px) {
    .tools-grid,
    .category-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
        margin: 0 14px;
    }
}

@media (max-width: 992px) {
    .tools-grid,
    .category-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 18px;
        margin: 0 12px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: calc(-1 * var(--sidebar-width-expanded)); /* 移动端默认隐藏 */
        width: var(--sidebar-width-expanded); /* 移动端展开宽度 */
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar.active {
        left: 0;
    }

    .main-content {
        margin-left: 0; /* 在移动设备上不需要左边距 */
        padding-top: 30px; /* 减少移动端上边距 */
    }

    .mobile-menu-toggle {
        display: block;
        position: relative; /* 确保定位正确 */
        z-index: 1001; /* 确保在最上层 */
    }

    .tools-grid,
    .category-grid {
        grid-template-columns: repeat(2, 1fr); /* 确保移动端每行2个 */
        gap: 16px; /* 移动端稍微减少间距 */
        margin: 0 10px; /* 移动端减少边距但保留一些空间 */
    }

    .tool-card,
    .horizontal-tool-card {
        height: 70px;
        padding: 12px;
    }

    .tool-icon {
        width: 32px;
        height: 32px;
    }

    .tool-name {
        font-size: 12px;
    }

    .horizontal-category-header {
        margin-bottom: 24px; /* 移动端减少间距 */
        padding-top: 15px; /* 移动端减少间距 */
    }
}

@media (max-width: 480px) {
    .tools-grid,
    .category-grid {
        grid-template-columns: repeat(2, 1fr); /* 确保在最小屏幕上仍然保持每行2个 */
        gap: 12px; /* 进一步减少间距 */
        margin: 0 8px; /* 减少边距但仍保留一些空间 */
    }

    .main-content {
        padding: 24px 8px; /* 减少主内容区域的内边距 */
    }

    .tool-card,
    .horizontal-tool-card {
        height: 65px; /* 在最小屏幕上稍微减小卡片高度 */
        padding: 10px; /* 减少内边距 */
    }

    .tool-icon {
        width: 28px; /* 减小图标尺寸 */
        height: 28px;
    }

    .horizontal-category-header {
        margin-bottom: 20px; /* 移动端进一步减少间距 */
        padding-top: 10px; /* 移动端进一步减少间距 */
    }
}

/* Accessibility focus styles */
a:focus,
button:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Skip to content link for accessibility */
.skip-to-content {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.skip-to-content:focus {
    position: fixed;
    top: 0;
    left: 0;
    width: auto;
    height: auto;
    padding: 10px;
    background: var(--accent-primary);
    color: white;
    z-index: 9999;
}

/* 当侧边栏悬停展开时，调整主内容区域 */
.sidebar:hover + .main-content {
    margin-left: var(--sidebar-width-expanded);
}

/* 移动端侧边栏收缩状态 */
@media (max-width: 768px) {
    .sidebar {
        width: var(--sidebar-width-expanded);
    }

    .sidebar:hover + .main-content {
        margin-left: 0; /* 移动端不调整主内容区域 */
    }
}

.friendlinks ul{list-style:none;padding:0;margin:0}
.friendlinks ul li {display:inline;margin-right:10px}
.friendlinks ul li a {color: #cccccc;}

