/* 主题颜色变量 */
:root {
    /* 深色主题（默认） */
    --bg-color: #1a1b1e;
    --sidebar-bg: #2d2e32;
    --card-bg-gradient-1: #2f3035;
    --card-bg-gradient-2: #2b2c30;
    --site-card-bg-gradient-1: #363940;
    --site-card-bg-gradient-2: #31343a;
    --site-card-hover-bg: linear-gradient(145deg, #3f434b, #353940);
    --text-color: #e4e6eb;
    --text-muted: #8b8c8f;
    --text-bright: #ffffff;
    --secondary-bg: #3a3b3f;
    --border-color: rgba(255, 255, 255, 0.05);
    --shadow-color: rgba(0, 0, 0, 0.15);
    --highlight-bg: rgba(74, 158, 255, 0.3);
    --scrollbar-color: rgba(255, 255, 255, 0.15);
    --scrollbar-hover-color: rgba(255, 255, 255, 0.25);
    --accent-color: #4a9eff;
    --accent-hover: #3a8eef;
    --nav-item-color: #a1a2a5;
    --success-color: #4caf50;
    --error-color: #f44336;
    --white-color: #ffffff;
    --gradient-color: linear-gradient(135deg, #4a9eff 0%, #a855f7 50%, #ff6b6b 100%);
    --gradient-color-simple: linear-gradient(135deg, #4a9eff 0%, #a855f7 100%);
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 60px;
}

/* 浅色主题：预加载阶段同样应用变量，避免读取默认暗色值 */
html.theme-preload,
body.light-theme {
    --bg-color: #e0e0d8;
    --sidebar-bg: #f0f0eb;
    --card-bg-gradient-1: #f0f0eb;
    --card-bg-gradient-2: #e9e9e4;
    --site-card-bg-gradient-1: #ffffff;
    --site-card-bg-gradient-2: #f4f5f0;
    --site-card-hover-bg: linear-gradient(145deg, #fafaf8, #eef0eb);
    --text-color: #333333;
    --text-muted: #666666;
    --text-bright: #000000;
    --secondary-bg: #d9d9d4;
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-color: rgba(0, 0, 0, 0.1);
    --highlight-bg: rgba(74, 158, 255, 0.15);
    --scrollbar-color: rgba(0, 0, 0, 0.1);
    --scrollbar-hover-color: rgba(0, 0, 0, 0.2);
    --accent-color: #4a9eff;
    --accent-hover: #3a8eef;
    --nav-item-color: #666666;
    --success-color: #4caf50;
    --error-color: #f44336;
    --white-color: #ffffff;
    --gradient-color: linear-gradient(135deg, #4a9eff 0%, #a855f7 50%, #ff6b6b 100%);
    --gradient-color-simple: linear-gradient(135deg, #4a9eff 0%, #a855f7 100%);
}

/* 预加载主题 - 在JS完全加载前显示正确的主题 */
html.theme-preload body {
    background-color: #e0e0d8; /* 明亮主题背景色 */
    color: #333333; /* 明亮主题文本色 */
}

/* 预加载侧边栏状态 - 在JS完全加载前显示正确的侧边栏宽度 */
html.sidebar-collapsed-preload .sidebar {
    width: var(--sidebar-collapsed-width);
}

html.sidebar-collapsed-preload .content {
    margin-left: var(--sidebar-collapsed-width);
}

/* 控制页面预加载状态 */
html.preload .layout {
    opacity: 0;
}

html.preload * {
    transition: none !important;
}

/* 主题切换按钮 */
.theme-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(145deg, var(--site-card-bg-gradient-1), var(--site-card-bg-gradient-2));
    color: var(--text-bright);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    box-shadow: 0 4px 16px var(--shadow-color);
    border: 1px solid var(--border-color);
}

.theme-toggle:hover {
    transform: translateY(-2px);
    background: linear-gradient(145deg, var(--secondary-bg), var(--site-card-bg-gradient-1));
    box-shadow: 0 6px 20px var(--shadow-color);
    color: var(--accent-color);
}

.theme-toggle:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px var(--shadow-color);
}

/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 通用滚动条样式 */
.custom-scrollbar {
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: var(--scrollbar-color) transparent; /* Firefox */
}

/* Webkit滚动条样式（Chrome, Safari, Edge等） */
.custom-scrollbar::-webkit-scrollbar {
    width: 7px; /* 统一滚动条宽度 */
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-color); /* 使用变量 */
    border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: var(--scrollbar-hover-color); /* 使用变量 */
}

/* 防止滚动条导致的布局偏移 */
html {
    overflow-y: hidden; /* 改为hidden，移除强制显示的滚动条 */
    scrollbar-width: thin; /* Firefox */
}

/* 搜索高亮样式 */
.highlight {
    background-color: var(--highlight-bg);
    border-radius: 2px;
    padding: 0 2px;
    font-weight: bold;
    color: var(--text-color);
}


body {
    font-family: var(--font-body);
    font-weight: var(--font-weight-body);
    line-height: 1.6;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    overflow: hidden; /* 防止body滚动 */
    padding-right: 0 !important; /* 防止滚动条导致的布局偏移 */
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* 布局 */
.layout {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
    overflow: hidden; /* 防止layout滚动 */
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* 确保加载后立即显示 */
body.loaded .layout {
    opacity: 1;
}

/* 移动端基础样式 */
.mobile-buttons {
    display: none;
    position: fixed;
    top: 1rem;
    left: 0;
    right: 0;
    width: 100%;
    padding: 0 1rem;
    justify-content: space-between;
    z-index: 900; /* 修改z-index，确保按钮层级高于基础内容但低于弹出面板 */
    pointer-events: none; /* 防止按钮区域阻挡其他内容 */
}

.menu-toggle,
.search-toggle {
    background: var(--sidebar-bg);
    border: none;
    color: var(--text-color);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px var(--shadow-color);
    pointer-events: auto; /* 恢复按钮的点击事件 */
}

.menu-toggle:hover,
.search-toggle:hover {
    background: var(--secondary-bg);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.menu-toggle:active,
.search-toggle:active {
    transform: translateY(0);
}

/* 遮罩层 */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 950; /* 调整遮罩层z-index，处于按钮与弹出面板之间 */
}

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

/* 侧边栏样式 */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    box-shadow: 2px 0 10px var(--shadow-color);
    z-index: 100;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
    height: 100vh; /* 确保高度固定 */
    /* 使用Grid布局分为三个部分 */
    display: grid;
    grid-template-rows: auto 1fr auto;
    grid-template-areas: 
        "header"
        "content"
        "footer";
    /* 应用自定义滚动条样式 */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: var(--scrollbar-color) transparent; /* Firefox */
    overflow-y: hidden; /* 防止整个侧边栏滚动 */
    transition: background-color 0.3s ease;
}

/* 侧边栏折叠状态 */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    overflow-x: hidden;
}

/* 优化侧边栏折叠时的Logo部分 */
.sidebar.collapsed .logo {
    padding: 1.2rem 0.5rem 0.6rem;
    justify-content: center;
    display: flex;
    align-items: center;
    height: 60px; /* 确保与展开状态高度一致 */
    margin-bottom: 0.8rem; /* 收起态同样拉开与按钮的间距 */
}

/* 折叠状态下的侧边栏内容区域调整 */
.sidebar.collapsed .sidebar-content {
    padding: 0;
    scrollbar-width: none; /* 隐藏滚动条 */
}

/* 调整折叠侧边栏的部分元素间距 */
.sidebar.collapsed .nav-section {
    gap: 2px;
}

/* 减小折叠状态下的版权区域高度 */
.sidebar.collapsed .copyright {
    padding: 0.4rem;
    height: 0;
    min-height: 0;
    border-top: none;
}

.sidebar.collapsed .sidebar-content::-webkit-scrollbar {
    display: none; /* 隐藏WebKit浏览器的滚动条 */
}

/* 侧边栏头部区域 */
.sidebar .logo {
    grid-area: header;
    padding: 1.2rem 1.2rem 0.6rem; /* 调整上下padding更紧凑 */
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: hidden; /* 防止内容溢出 */
    position: relative; /* 添加相对定位，作为按钮的参考 */
    height: 60px; /* 固定高度，确保两种状态下一致 */
    margin-bottom: 0.8rem; /* 与下方按钮区域拉开间距 */
}

.logo h1 {
    font-size: 1.4rem;
    color: var(--text-bright);
    margin-bottom: 0;
    padding-left: 0.5rem;
    letter-spacing: 0.5px;
    transition: opacity 0.3s ease, transform 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* 侧边栏折叠按钮 */
.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--accent-color);
    height: 28px;
    width: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: 8px;
    padding: 0;
    flex-shrink: 0; /* 防止按钮被压缩 */
    /* 在展开态使用flex对齐，保持与标题自然对齐 */
}

.sidebar-toggle .toggle-icon {
    font-size: 0.9rem;
    transition: transform 0.3s ease;
}

.sidebar-toggle:hover {
    background: var(--secondary-bg);
}

.sidebar-toggle:active {
}

.sidebar.collapsed .sidebar-toggle {
    position: absolute;
    right: 16px; /* 与展开态保持一致的右侧间距 */
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
    height: 28px; /* 与展开态一致 */
    width: 28px;  /* 与展开态一致 */
}

.sidebar.collapsed .sidebar-toggle:hover {
    transform: translateY(-50%);
}

.sidebar.collapsed .sidebar-toggle:active {
    transform: translateY(-50%);
}

/* 侧边栏折叠状态下的按钮图标旋转180度 */
.sidebar.collapsed .toggle-icon {
    transform: rotate(180deg);
}

/* 侧边栏内容区域 - 可滚动 */
.sidebar-content {
    grid-area: content;
    overflow-y: auto; /* 只有内容区域可滚动 */
    padding: 0 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem; /* 从1rem减小到0.6rem */
    /* 隐藏滚动条但保持滚动功能 */
    scrollbar-width: none; /* Firefox */
}

.sidebar-content::-webkit-scrollbar {
    display: none; /* Webkit browsers */
}

/* 折叠状态下的内容区域调整 */
.sidebar.collapsed .sidebar-content {
    padding: 0 0.5rem;
    scrollbar-width: none; /* 隐藏滚动条 */
}

.sidebar.collapsed .sidebar-content::-webkit-scrollbar {
    display: none; /* 隐藏WebKit浏览器的滚动条 */
}

/* 折叠状态下的Logo文本 */
.sidebar.collapsed .logo h1 {
    opacity: 0;
    transform: translateX(-20px);
    width: 0;
    visibility: hidden; /* 确保完全隐藏，防止干扰布局 */
}

/* 导航区域样式 */
.nav-section {
    display: flex;
    flex-direction: column;
    gap: 0.4rem; /* 增大按钮间距 */
}

.section-title {
    font-size: 1rem;
    color: var(--accent-color);
    padding: 0.4rem 0.5rem; /* 减小上下padding */
    margin-bottom: 0.2rem; /* 增大与下方按钮组的间距 */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.3s ease;
}

.section-title i {
    font-size: 1.2rem;
}

/* 调整侧边栏折叠状态下的章节标题 */
.sidebar.collapsed .section-title {
    justify-content: center;
    /* 统一与展开态的垂直间距 */
    padding: 0.4rem 0; 
    text-align: center;
    margin-bottom: 0.2rem; /* 与展开态保持一致且更大 */
}

.sidebar.collapsed .section-title i {
    margin: 0 auto;
    font-size: 1.2rem;
}

/* 折叠状态下的导航项布局优化 */
.sidebar.collapsed .nav-section {
    gap: 0.4rem;
    align-items: center;
}

.sidebar.collapsed .nav-item {
    padding: 0;
    justify-content: center;
    width: 44px; /* 增大按钮方块尺寸 */
    height: 44px; /* 增大按钮方块尺寸 */
    text-align: center;
    margin-left: auto;
    margin-right: auto;
    border-radius: 10px; /* 略增圆角 */
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

.sidebar.collapsed .nav-item i {
    font-size: 1.25rem;
    width: auto;
    margin: 0;
    padding: 0;
}

.sidebar.collapsed .nav-item .icon-container {
    margin: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 折叠状态下的导航项文本 */
.sidebar.collapsed .nav-item .nav-text,
.sidebar.collapsed .nav-item .external-icon {
    opacity: 0;
    transform: translateX(-10px);
    width: 0;
    display: none; /* 完全移除，防止干扰布局 */
    visibility: hidden;
}

.nav-item {
    display: flex;
    align-items: center;
    height: 44px; /* 增大按钮高度 */
    padding: 0 0.9rem; /* 略增左右内边距 */
    color: var(--nav-item-color);
    text-decoration: none;
    border-radius: 10px; /* 略增圆角，与增大高度协调 */
    /* 限定可过渡属性，避免折叠/展开时Y向抖动 */
    transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.nav-item .icon-container {
    width: 24px;
    height: 100%; /* 与按钮高度一致，垂直对齐更稳定 */
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 1rem;
    transition: margin 0.3s ease;
}

.nav-item .nav-text {
    flex: 1;
    transition: opacity 0.3s ease, transform 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item .external-icon {
    font-size: 0.9rem;
    opacity: 0.6;
    margin-left: 0.5rem;
    transition: all 0.3s ease;
}

.nav-item:hover {
    background-color: var(--secondary-bg);
    color: var(--text-bright);
}

.nav-item:hover .external-icon {
    opacity: 1;
    transform: translateX(2px);
}

.nav-item.active {
    background-color: var(--secondary-bg);
    color: var(--text-bright);
}

.nav-item i {
    width: 20px;
    text-align: center;
}

/* 折叠状态下的版权区域 */
.sidebar.collapsed .copyright {
    opacity: 0;
    visibility: hidden; /* 确保完全隐藏 */
}

/* 主内容区域 - 修复滚动条问题 */
.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem 1.5rem; 
    background-color: var(--bg-color);
    position: relative;
    height: 100vh; /* 固定高度 */
    overflow-y: auto; /* 使用auto替代scroll，只在需要时显示滚动条 */
    overflow-x: hidden;
    width: calc(100vw - var(--sidebar-width));
    display: flex;
    flex-direction: column;
    align-items: center;
    /* 隐藏滚动条但保持滚动功能 */
    scrollbar-width: none; /* Firefox */
}

.content::-webkit-scrollbar {
    display: none; /* Webkit browsers */
}

/* 优化内容区域在侧边栏折叠状态下的边距 */
body .content.expanded {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100vw - var(--sidebar-collapsed-width));
}

/* 仅在交互时启用布局相关过渡，避免首帧闪烁 */
.with-anim .sidebar {
    transition: width 0.3s ease, background-color 0.3s ease;
}

.with-anim .content {
    transition: background-color 0.3s ease, margin-left 0.3s ease, width 0.3s ease;
}

/* 搜索框容器 - 固定在顶部 */
.search-container {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 0 2rem;
    margin-bottom: 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* 搜索框 */
.search-box {
    position: relative;
    width: 100%;
    max-width: 600px;
    background-color: var(--sidebar-bg);
    border-radius: 12px;
    transition: background-color 0.3s ease;
}

.search-box::after {
    content: '';
    position: absolute;
    right: 4rem;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none; /* 不阻挡点击，避免遮住图标可点击区域 */
}

.search-box.has-results::after {
    background-color: var(--success-color);
    opacity: 1;
}

.search-box.no-results::after {
    background-color: var(--error-color);
    opacity: 1;
}

.search-box input {
    width: 100%;
    padding: 1rem 6rem 1rem 1.5rem; /* 扩大右侧内边距，给左移的点留空间 */
    border: none;
    border-radius: 12px;
    background-color: transparent;
    color: var(--text-color);
    font-size: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--shadow-color);
}

.search-box input:focus {
    outline: none;
    background-color: var(--secondary-bg);
    box-shadow: 0 4px 12px var(--shadow-color);
}

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

.search-box i {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.search-box.has-results i {
    color: var(--success-color);
}

.search-box.no-results i {
    color: var(--error-color);
}

/* 搜索图标和搜索引擎切换图标位置调整 */
.search-box .search-icon {
    right: 2.0rem;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 下拉指示图标交互与状态 */
.search-box .search-engine-toggle:hover { color: inherit; }

.search-box.dropdown-open .search-engine-toggle { transform: translateY(-50%) rotate(180deg); }

.search-box .search-engine-toggle {
    right: 0.8rem;
    cursor: pointer;
    font-size: 0.8rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 搜索引擎下拉菜单 */
.search-engine-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    right: 1rem;
    background-color: var(--sidebar-bg);
    border-radius: 10px;
    box-shadow: 0 4px 15px var(--shadow-color);
    display: none;
    z-index: 100;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
}

.search-engine-dropdown.active {
    display: flex;
    animation: fadeIn 0.2s ease-out forwards;
}

.search-engine-option {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin: 0.3rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: var(--card-bg-gradient-1);
}

.search-engine-option:hover {
    background-color: var(--card-bg-gradient-2);
    transform: translateY(-2px);
    box-shadow: 0 3px 8px var(--shadow-color);
}

.search-engine-option.active {
    background-color: var(--secondary-bg);
    color: white;
}

.search-engine-option i {
    position: static;
    transform: none;
    font-size: 1.2rem;
}

/* 页面容器 */
.page {
    position: relative;
    width: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    padding-top: 2rem;
    padding-left: 0.5rem; 
    padding-right: 0.5rem; 
}

.page.active {
    display: flex;
}

/* 欢迎区域 */
.welcome-section {
    width: 100%;
    max-width: 1300px;
    margin: 0 auto 3.5rem auto;
    padding: 0 6rem 0 2rem;
    text-align: left;
    position: relative;
    z-index: 5;
}

.welcome-section h2 {
    font-family: var(--font-title);
    font-weight: var(--font-weight-title);
    font-size: 2.4rem;
    color: var(--text-bright);
    margin-bottom: 0.5rem;
    letter-spacing: 0.5px;
    transition: color 0.3s ease;
}

.welcome-section h3 {
    font-family: var(--font-subtitle);
    font-weight: var(--font-weight-subtitle);
    font-size: 2rem;
    margin-bottom: 1rem;
    letter-spacing: 0.3px;
    background: var(--gradient-color);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    position: relative;
    display: inline-block;
    text-shadow: 0 0 20px rgba(74, 158, 255, 0.1);
    animation: glow 2s ease-in-out infinite alternate;
}

.welcome-section h3::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: inherit;
    filter: blur(20px);
    opacity: 0.3;
    z-index: -1;
}

.welcome-section .subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1.5;
    transition: color 0.3s ease;
}

@keyframes glow {
    from {
        filter: drop-shadow(0 0 2px rgba(74, 158, 255, 0.2))
               drop-shadow(0 0 4px rgba(168, 85, 247, 0.2));
    }
    to {
        filter: drop-shadow(0 0 4px rgba(74, 158, 255, 0.4))
               drop-shadow(0 0 8px rgba(168, 85, 247, 0.4));
    }
}

/* 分类样式 */
.category {
    background: linear-gradient(145deg, var(--card-bg-gradient-1), var(--card-bg-gradient-2));
    border-radius: 16px;
    padding: 2rem;
    margin: 0 1rem 2.5rem 2rem;
    width: calc(100% - 3rem);
    max-width: 1300px;
    position: relative;
    z-index: 1;
    opacity: 1; /* 移除进入时的浮动/淡入动画，避免切页时跳动 */
    box-shadow: 0 4px 20px var(--shadow-color);
    border: 1px solid var(--border-color);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.category h2 {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    color: var(--text-bright);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    letter-spacing: 0.3px;
    transition: color 0.3s ease;
}

.category h2 i {
    color: var(--accent-color);
    font-size: 1.3rem;
}

/* 多层级嵌套样式 */
/* 层级2: 子分类 */
.category-level-2 {
    margin: 1.5rem 0 1.5rem 2rem;
    padding: 1.5rem;
    background: linear-gradient(145deg,
        rgba(var(--card-bg-rgb), 0.8),
        rgba(var(--card-bg-rgb), 0.6));
    border-left: 3px solid var(--accent-color);
    border-radius: 12px;
    width: calc(100% - 3.5rem);
}

.category-level-2 .category-header h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-bright);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    letter-spacing: 0.2px;
}

.category-level-2 .category-header h3 i {
    color: var(--accent-color);
    font-size: 1.2rem;
}

/* 层级3: 分组 */
.group-level-3, .category-level-3 {
    margin: 1rem 0 1rem 1.5rem;
    padding: 1rem;
    background: rgba(var(--card-bg-rgb), 0.4);
    border-left: 2px solid var(--secondary-color);
    border-radius: 8px;
    width: calc(100% - 2.5rem);
}

.group-level-3 .group-header h4,
.category-level-3 .category-header h4 {
    font-size: 1rem;
    margin-bottom: 0.8rem;
    color: var(--text-bright);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: 0.2px;
}

.group-level-3 .group-header h4 i,
.category-level-3 .category-header h4 i {
    color: var(--secondary-color);
    font-size: 1.1rem;
}

/* 层级4: 更深层次的分组 */
.group-level-4, .category-level-4 {
    margin: 0.8rem 0 0.8rem 1rem;
    padding: 0.8rem;
    background: rgba(var(--card-bg-rgb), 0.2);
    border-left: 1px solid var(--tertiary-color);
    border-radius: 6px;
    width: calc(100% - 1.8rem);
}

.group-level-4 .group-header h5,
.category-level-4 .category-header h5 {
    font-size: 0.95rem;
    margin-bottom: 0.6rem;
    color: var(--text-bright);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    letter-spacing: 0.1px;
}

.group-level-4 .group-header h5 i,
.category-level-4 .category-header h5 i {
    color: var(--tertiary-color);
    font-size: 1rem;
}

/* 切换图标样式 */
.toggle-icon {
    display: inline-block;
    margin-left: auto;
    transition: transform 0.3s ease;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.category-header:hover .toggle-icon,
.group-header:hover .toggle-icon {
    color: var(--accent-color);
}

/* 展开/折叠动画 */
.category-content, .group-content {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    max-height: 9999px;
    opacity: 1;
}

.category.collapsed .category-content,
.group.collapsed .group-content {
    max-height: 0;
    opacity: 0;
}

.category.collapsed .toggle-icon i,
.group.collapsed .toggle-icon i {
    transform: rotate(-90deg);
}

/* 空内容提示 */
.empty-content {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 1rem;
    font-size: 0.9rem;
}

/* 子容器样式 */
.subcategories-container,
.groups-container {
    width: 100%;
}

/* 确保嵌套的网站网格正确显示 */
.category-level-2 .sites-grid,
.group-level-3 .sites-grid,
.category-level-3 .sites-grid,
.group-level-4 .sites-grid,
.category-level-4 .sites-grid {
    margin-top: 0.8rem;
    gap: 0.8rem;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

/* 响应式设计 - 嵌套结构 */
@media (max-width: 768px) {
    .category-level-2 {
        margin-left: 1rem;
        padding: 1rem;
        width: calc(100% - 2rem);
    }
    
    .group-level-3, .category-level-3 {
        margin-left: 0.5rem;
        padding: 0.8rem;
        width: calc(100% - 1.3rem);
    }
    
    .group-level-4, .category-level-4 {
        margin-left: 0.3rem;
        padding: 0.6rem;
        width: calc(100% - 0.9rem);
    }
    
    .category-level-2 .sites-grid,
    .group-level-3 .sites-grid,
    .category-level-3 .sites-grid,
    .group-level-4 .sites-grid,
    .category-level-4 .sites-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.6rem;
    }
}

@media (max-width: 480px) {
    .category {
        margin-left: 1rem;
        padding: 1.5rem;
    }
    
    .category-level-2, .group-level-3, .category-level-3 {
        margin-left: 0.5rem;
        padding: 0.8rem;
        width: calc(100% - 1rem);
    }
    
    .group-level-4, .category-level-4 {
        margin-left: 0.3rem;
        padding: 0.6rem;
        width: calc(100% - 0.6rem);
    }
    
    .category-level-2 .sites-grid,
    .group-level-3 .sites-grid,
    .category-level-3 .sites-grid,
    .group-level-4 .sites-grid,
    .category-level-4 .sites-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5rem;
    }
}

/* 网站卡片网格 */
.sites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
    gap: 1.2rem;
    position: relative;
    z-index: 1;
    width: 100%;
}

/* 网站卡片样式 */
.site-card {
    background: linear-gradient(145deg, var(--site-card-bg-gradient-1), var(--site-card-bg-gradient-2));
    border-radius: 12px;
    padding: 1.2rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease, background 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    backface-visibility: hidden;
    transform: translateZ(0);
    will-change: transform;
    max-width: 100%;
    position: relative;
    box-shadow: 0 4px 16px var(--shadow-color);
    border: 1px solid var(--border-color);
    z-index: 2;
}

.site-card:hover {
    transform: translateY(-4px);
    background: var(--site-card-hover-bg);
    border-color: var(--border-color);
}

.site-card i {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: var(--accent-color);
    transition: all 0.3s ease;
}

/* 网站卡片 favicon 图片样式，与图标尺寸保持一致 */
.site-card .favicon-icon {
    display: inline-block;
    width: 1.8rem;
    height: 1.8rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    object-fit: cover;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.site-card .icon-placeholder,
.site-card .icon-fallback {
    display: inline-block;
    width: 1.8rem;
    height: 1.8rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    flex-shrink: 0;
    vertical-align: middle;
    text-align: center;
    line-height: 1.8rem;
    font-size: 1.8rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* 确保图标容器在加载过程中保持固定尺寸 */
.site-card .icon-container {
    display: inline-block;
    width: 1.8rem;
    height: 1.8rem;
    margin-bottom: 1rem;
    position: relative;
    vertical-align: middle;
}

.site-card .icon-container .favicon-icon,
.site-card .icon-container .icon-placeholder,
.site-card .icon-container .icon-fallback {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin-bottom: 0;
}

/* 优化图标切换动画 */
.site-card .icon-container .favicon-icon {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.site-card .icon-container .favicon-icon.loaded {
    opacity: 1;
}

.site-card .icon-container .favicon-icon.error {
    display: none;
}

.site-card .icon-container .icon-placeholder {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.site-card .icon-container .icon-placeholder.hidden {
    opacity: 0;
    pointer-events: none;
}

.site-card .icon-container .icon-fallback {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.site-card .icon-container .icon-fallback.visible {
    opacity: 1;
}

.site-card:hover i {
    transform: scale(1.1);
    color: var(--accent-hover);
}

.site-card:hover .favicon-icon {
    transform: scale(1.1);
    box-shadow: 0 0 0 1px var(--border-color);
}

.site-card h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-bright);
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: color 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.site-card p {
    font-size: 0.9rem;
    color: var(--nav-item-color);
    margin: 0;
    line-height: 1.4;
    transition: color 0.3s ease;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    max-height: 2.8em;
    word-break: break-word;
    text-overflow: ellipsis;
    width: 100%;
}

/* 添加编辑按钮 */
.edit-buttons {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.site-card:hover .edit-buttons {
    opacity: 1;
}

.edit-btn, .delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.edit-btn:hover, .delete-btn:hover {
    color: var(--text-bright);
    background-color: var(--secondary-bg);
}

/* 添加网站按钮 */
.add-site-btn {
    background: linear-gradient(145deg, var(--site-card-bg-gradient-1), var(--site-card-bg-gradient-2));
    border: 2px dashed var(--border-color);
    border-radius: 14px;
    padding: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    box-shadow: 0 4px 16px var(--shadow-color);
}

.add-site-btn:hover {
    background: linear-gradient(145deg, var(--secondary-bg), var(--site-card-bg-gradient-1));
    border-color: var(--accent-color);
    color: var(--text-bright);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow-color);
}

.add-site-btn i {
    font-size: 2.2rem;
    margin-bottom: 0.8rem;
    transition: transform 0.3s ease;
}

.add-site-btn:hover i {
    transform: scale(1.1);
}

/* 模态框样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
    animation: modalFadeIn 0.3s ease-out forwards;
}

.modal-content {
    background-color: var(--sidebar-bg);
    border-radius: 16px;
    padding: 2.2rem;
    width: 90%;
    max-width: 520px;
    position: relative;
    box-shadow: 0 8px 32px var(--shadow-color);
    transform: scale(0.95);
    opacity: 0;
    animation: modalContentShow 0.3s ease-out forwards;
    transition: background-color 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.modal-header h3 {
    color: var(--text-bright);
    font-size: 1.3rem;
    letter-spacing: 0.3px;
    font-weight: 500;
    transition: color 0.3s ease;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0.5rem;
    transition: all 0.3s ease;
    border-radius: 8px;
}

.close-modal:hover {
    color: var(--text-bright);
    background-color: var(--secondary-bg);
}

/* 表单样式 */
.site-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.form-group label {
    color: var(--text-muted);
    font-size: 0.95rem;
    letter-spacing: 0.2px;
    transition: color 0.3s ease;
}

.form-group input, .form-group select {
    background-color: var(--secondary-bg);
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0.9rem 1.2rem;
    color: var(--text-color);
    font-size: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px var(--shadow-color);
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    background-color: var(--secondary-bg);
    border-color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(74, 158, 255, 0.15);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

.btn {
    padding: 0.9rem 1.8rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px var(--shadow-color);
}

.btn-primary {
    background-color: var(--accent-color);
    color: var(--white-color);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.2);
}

.btn-secondary {
    background-color: var(--secondary-bg);
    color: var(--text-muted);
}

.btn-secondary:hover {
    background-color: var(--secondary-bg);
    color: var(--text-bright);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color);
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .welcome-section {
        padding: 0 4rem 0 1.5rem;
        margin-bottom: 3rem;
    }
    
    .category {
        max-width: 1100px;
        margin-bottom: 2rem;
        margin-left: 1.5rem; /* 增加左边距 */
        margin-right: 1.5rem; /* 增加右边距 */
        width: calc(100% - 3rem); /* 适应新的左右边距 */
    }
}

@media (max-width: 768px) {
    .mobile-buttons {
        display: flex;
    }
    
    .content {
        margin-left: 0;
        width: 100vw;
        max-width: 100vw;
        padding-top: 5rem;
    }
    
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .sidebar .logo {
        padding-top: 1.5rem;
        display: flex;
        align-items: center;
        height: 60px;
    }
    
    /* 移动端下隐藏侧边栏折叠按钮 */
    .sidebar-toggle {
        display: none;
    }
    
    .sidebar.active {
        transform: translateX(0);
        box-shadow: 2px 0 10px var(--shadow-color);
        z-index: 1000; /* 增加侧边栏激活时的z-index，确保显示在按钮之上 */
    }
    
    /* 重置移动端下的侧边栏展开状态 */
    .sidebar.collapsed {
        width: var(--sidebar-width);
    }
    
    .sidebar.collapsed .logo h1,
    .sidebar.collapsed .nav-item .nav-text,
    .sidebar.collapsed .nav-item .external-icon,
    .sidebar.collapsed .copyright {
        opacity: 1;
        transform: none;
        width: auto;
    }
    
    .sidebar.collapsed .nav-item {
        padding: 0.6rem 0.8rem;
        justify-content: flex-start;
    }
    
    .sidebar.collapsed .nav-item .icon-container {
        margin-right: 1rem;
    }
    
    .search-container {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        padding: 1rem;
        transform: translateY(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 95;
        box-shadow: 0 2px 10px var(--shadow-color);
    }
    
    .search-container.active {
        transform: translateY(0);
        z-index: 1000; /* 增加搜索容器激活时的z-index，确保显示在按钮之上 */
    }
    
    .search-box {
        max-width: 100%;
    }
    
    .search-container.active .search-box {
        margin-bottom: 0;
    }
    
    .search-box input {
        padding: 0.8rem 3rem 0.8rem 1.2rem;
        font-size: 0.95rem;
    }
    
    .search-box i {
        right: 1.2rem;
    }
    
    .sidebar .logo h1,
    .sidebar .nav-item span {
        opacity: 1;
        display: block;
    }

    /* 欢迎区域样式 */
    .welcome-section {
        padding: 0 1rem;
        margin-top: 1rem; /* 增加顶部间距 */
    }

    .page {
        padding-left: 0.15rem;
        padding-right: 0.15rem;
    }

    .welcome-section h2 {
        font-size: 2rem;
    }

    .welcome-section h3 {
        font-size: 1.6rem;
        background: var(--gradient-color-simple);
        -webkit-background-clip: text;
        background-clip: text;
        animation: glow 3s ease-in-out infinite alternate;
    }

    /* 分类样式优化 */
    .category {
        margin: 0 0.15rem 0.9rem 0.15rem;
        padding: 1.1rem;
        width: calc(100% - 0.3rem);
    }

    .sites-grid {
        gap: 0.7rem;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    
    .site-card {
        padding: 0.9rem 0.7rem;
    }
    
    .site-card i {
        font-size: 1.5rem;
        margin-bottom: 0.8rem;
    }
    
    .site-card h3 {
        font-size: 0.95rem;
        margin-bottom: 0.4rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    
    .site-card p {
        font-size: 0.85rem;
        line-height: 1.3;
        max-height: 2.6em;
    }
    
    /* 在移动端的主题切换按钮 */
    .theme-toggle {
        bottom: 1rem;
        right: 1rem;
    }

    /* 移动端滚动进度条调整 */
    .scroll-progress {
        height: 4px; /* 移动端略粗一些 */
    }

    .sidebar .submenu {
        margin-left: 1rem;
    }
    
    .sidebar.active .submenu-item {
        padding: 0.5rem 0.6rem;
    }
    
    /* 确保移动设备上子菜单不会出现漏出问题 */
    .sidebar.collapsed .submenu {
        display: none;
    }
}

@media (max-width: 480px) {
    .welcome-section {
        padding: 0 1rem;
        margin-bottom: 2rem;
    }

    .category {
        margin: 0 0.1rem 0.8rem 0.1rem;
        padding: 0.95rem;
        width: calc(100% - 0.2rem);
    }

    .search-container {
        padding: 0 1rem;
    }
    
    .page {
        padding-top: 1rem;
        padding-left: 0.1rem;
        padding-right: 0.1rem;
    }
    
    .sites-grid {
        gap: 0.5rem;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    
    .site-card {
        padding: 0.75rem 0.5rem;
    }
    
    .site-card i {
        font-size: 1.3rem;
        margin-bottom: 0.6rem;
    }

    .site-card h3 {
        font-size: 0.9rem;
        margin-bottom: 0.3rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .site-card p {
        font-size: 0.8rem;
        -webkit-line-clamp: 2;
        max-height: 2.4em;
        line-height: 1.2;
    }
}

@media (max-width: 400px) {
    .category {
        padding: 0.85rem;
        margin: 0 0.05rem 0.6rem 0.05rem;
        width: calc(100% - 0.1rem);
    }
    
    .sites-grid {
        gap: 0.4rem;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    
    .site-card {
        padding: 0.6rem 0.4rem;
    }
    
    .site-card i {
        font-size: 1.2rem;
        margin-bottom: 0.5rem;
    }
    
    .site-card h3 {
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    
    .site-card p {
        font-size: 0.75rem;
        -webkit-line-clamp: 2;
        max-height: 2.5em;
        line-height: 1.15;
    }
}

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

/* 搜索结果页面 */
#search-results {
    position: relative;
    width: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    z-index: 15;
    transform: none !important; /* 确保没有变换 */
    min-height: 400px; /* 确保最小高度，防止内容过少时的布局跳动 */
}

#search-results.active {
    display: flex;
    animation: fadeIn 0.3s ease-out forwards;
}

/* 搜索结果区域 */
.search-section {
    width: calc(100% - 2rem);
    max-width: 1100px;
    margin: 0 1rem 2.5rem 1rem;
    position: relative;
    z-index: 1;
    transform: none !important;
    opacity: 1 !important;
}

/* 确保搜索结果中的网格有正确的间距 */
.search-section .sites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
    gap: 1.2rem;
    margin-top: 1rem;
}

/* 确保搜索结果中的卡片样式一致 */
.search-section .site-card {
    max-width: 100%;
}

/* 加载中动画 */
.page {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.page.active {
    opacity: 1;
}

/* 模态框动画 */
@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modalContentShow {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.sites-grid {
    transition: gap 0.3s ease;
}

/* 侧边栏底部区域 - 版权信息 */
.sidebar .copyright {
    grid-area: footer;
    padding: 1rem 1.2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--sidebar-bg); /* 使用变量 */
    margin-top: 0;
    transition: background-color 0.3s ease, color 0.3s ease, opacity 0.3s ease;
}

.copyright a {
    color: var(--accent-color);
    text-decoration: none;
    transition: all 0.3s ease;
}

.copyright a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* 导航项包装器 - 包含导航项和子菜单 */
.nav-item-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* 子菜单切换图标 */
.submenu-toggle {
    font-size: 0.8rem;
    margin-left: 0.5rem;
    transition: transform 0.3s ease;
}

/* 子菜单展开状态图标旋转 */
.nav-item-wrapper.expanded .submenu-toggle {
    transform: rotate(180deg);
}

/* 子菜单容器 */
.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    margin-left: 1.5rem;
    opacity: 0;
    visibility: hidden;
}

/* 子菜单展开状态 */
.nav-item-wrapper.expanded .submenu {
    max-height: 300px; /* 设置合理的最大高度 */
    overflow-y: scroll; /* 改为scroll确保始终能滚动 */
    opacity: 1;
    visibility: visible;
    scrollbar-width: none; /* Firefox隐藏滚动条 */
}

/* 为WebKit浏览器隐藏滚动条 */
.nav-item-wrapper.expanded .submenu::-webkit-scrollbar {
    display: none;
}

/* 子菜单项样式 */
.submenu-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.8rem;
    color: var(--nav-item-color);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    margin: 0.1rem 0;
}

.submenu-item i {
    margin-right: 0.8rem;
    font-size: 0.85rem;
    width: 16px;
    text-align: center;
}

.submenu-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.submenu-item:hover {
    background-color: var(--secondary-bg);
    color: var(--text-bright);
}

.submenu-item.active {
    background-color: var(--secondary-bg);
    color: var(--text-bright);
}

/* 侧边栏折叠状态下子菜单样式 
   通过精确控制子菜单的位置和显示方式，确保在侧边栏折叠状态下子菜单不会漏出
   使用display: none确保完全隐藏，避免任何可能的视觉问题 */
.sidebar.collapsed .submenu {
    position: absolute;
    left: var(--sidebar-collapsed-width); /* 使用变量确保与侧边栏宽度一致 */
    top: 0;
    background-color: var(--sidebar-bg);
    border-radius: 0 8px 8px 0;
    box-shadow: 4px 0 10px var(--shadow-color);
    margin-left: 0;
    width: 180px;
    opacity: 0;
    visibility: hidden;
    max-height: 0;
    overflow: hidden;
    z-index: 200;
    pointer-events: none;
    transition: all 0.3s ease;
    display: none; /* 添加 display: none 确保完全隐藏 */
}

/* 确保子菜单项在悬停时不会漏出 
   控制子菜单项的文本溢出行为，确保内容不会超出容器范围 */
.sidebar.collapsed .submenu-item {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    box-sizing: border-box;
}

/* 确保子菜单容器在悬停时不会漏出 
   使用static定位是为了让子菜单相对于侧边栏定位，而不是相对于nav-item-wrapper，
   这样可以避免子菜单在折叠状态下漏出的问题 */
.sidebar.collapsed .nav-item-wrapper {
    position: static; /* 改为static，防止子菜单定位问题 */
}

/* 修改子菜单在悬停时的显示位置 
   当用户悬停在导航项上时，显示子菜单，并确保其位置正确
   使用绝对定位确保子菜单相对于侧边栏定位，避免在不同滚动位置出现问题 */
.sidebar.collapsed .nav-item-wrapper:hover .submenu {
    max-height: 300px;
    overflow-y: scroll;
    opacity: 1;
    visibility: visible;
    scrollbar-width: none;
    pointer-events: auto;
    display: block;
    left: var(--sidebar-collapsed-width); /* 确保与侧边栏宽度一致 */
    top: 0; /* 确保从顶部开始 */
    position: absolute; /* 使用绝对定位，更符合文档流 */
}

/* 为WebKit浏览器隐藏滚动条 */
.sidebar.collapsed .nav-item-wrapper:hover .submenu::-webkit-scrollbar {
    display: none;
}

.sidebar.collapsed .submenu-toggle {
    display: none;
}

/* 移动端样式调整 */
@media (max-width: 768px) {
    .sidebar .submenu {
        margin-left: 1rem;
    }
    
    .sidebar.active .submenu-item {
        padding: 0.5rem 0.6rem;
    }
    
    /* 确保移动设备上子菜单不会出现漏出问题 */
    .sidebar.collapsed .submenu {
        display: none;
    }
}

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