:root {
    --bg-color: #f4f4f5;
    --card-bg: #ffffff;
    --text-primary: #18181b;
    --text-secondary: #71717a;
    --accent: #2563eb;
    --sidebar-width: 200px; /* 定义侧边栏宽度 */
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    scroll-behavior: smooth; /* 增加平滑滚动效果 */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

header {
    background-color: var(--card-bg); /* 给头部加个背景色区分 */
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    padding: 20px 0;
    margin-bottom: 30px;
    position: sticky; /* 头部也可以吸顶，或者去掉这两行 */
    top: 0;
    z-index: 100;
}

h1 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--accent);
}

/* --- 核心布局修改 --- */

.layout-wrapper {
    display: flex; /* 开启左右布局 */
    gap: 30px;     /* 侧边栏和内容的间距 */
    padding-bottom: 50px;
}

/* 侧边栏样式 */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0; /* 防止侧边栏被压缩 */
}

#sidebar-nav {
    position: sticky; /* 关键：让侧边栏跟随滚动 */
    top: 100px;       /* 距离顶部的距离 */
    background: var(--card-bg);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.sidebar-link {
    display: block;
    text-decoration: none;
    color: var(--text-secondary);
    padding: 10px;
    border-radius: 6px;
    transition: all 0.2s;
    margin-bottom: 5px;
}

.sidebar-link:hover {
    background-color: var(--bg-color);
    color: var(--accent);
}

.sidebar-link.active {
    background-color: #eff6ff;
    color: var(--accent);
    font-weight: 600;
}

/* 主内容区域 */
#app {
    flex: 1;     /* 占满剩余宽度 */
    min-width: 0; /* 防止内容溢出 */
}

/* 分类卡片样式修改 */
.category-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 30px; /* 每个大分类之间的间距 */
    scroll-margin-top: 100px; /* 锚点跳转时留出头部空间 */
}

.category-card h2 {
    font-size: 1.2rem;
    margin-top: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
}

.category-card h2::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 18px;
    background-color: var(--accent);
    margin-right: 10px;
    border-radius: 2px;
}

/* --- 链接列表修改为网格 --- */
/* 以前是外层Grid，现在改成内部Grid */
.link-list {
    list-style: none;
    padding: 0;
    display: grid; /* 开启网格 */
    /* 自动适应列数，每列最小240px */
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); 
    gap: 15px;
}

.link-list li {
    margin-bottom: 0; /* Grid模式下不需要下边距 */
}

.link-list a {
    text-decoration: none;
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    background-color: #f9fafb; /* 链接卡片轻微背景 */
}

.link-list a:hover {
    background-color: #fff;
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
    transform: translateY(-2px);
}

/* 图标和文字样式保持不变 */
.link-icon {
    width: 32px;
    height: 32px;
    margin-right: 12px;
    border-radius: 4px;
    object-fit: contain;
    background-color: #fff;
    padding: 2px;
    border: 1px solid #eee;
    transition: opacity 0.3s ease;
}

.link-icon:not([src]) { opacity: 0; }

.link-text-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* 防止文字撑开布局 */
}

.link-name {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.link-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.loading { text-align: center; padding: 50px; color: var(--text-secondary); }

/* 移动端适配 */
@media (max-width: 768px) {
    .layout-wrapper {
        flex-direction: column; /* 手机上改为上下排列 */
    }
    .sidebar {
        width: 100%;
        margin-bottom: 20px;
    }
    #sidebar-nav {
        position: static; /* 手机上取消吸顶 */
        display: flex;
        overflow-x: auto; /* 允许横向滚动 */
        white-space: nowrap;
        padding: 10px;
    }
    .sidebar-link {
        display: inline-block;
        margin-right: 10px;
        margin-bottom: 0;
    }
}