/* =========================================
   1. 字体与变量定义
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* --- 亮色模式 (Light Mode - 干净明亮) --- */
    --bg-body: #f9fafb;
    /* 整体背景 (Gray-50) */
    --bg-surface: #ffffff;
    /* 表面/卡片背景 (White) */

    --border-color: #e5e7eb;
    /* 核心边界线 (Gray-200) */
    --border-hover: #6366f1;
    /* 激活/悬停色 (Indigo-500) */
    --border-focus: #a5b4fc;
    /* 输入框聚焦 (Indigo-300) */

    --text-main: #111827;
    /* 主要文字 (Gray-900) */
    --text-sub: #6b7280;
    /* 次要文字 (Gray-500) */

    --hover-bg: #f3f4f6;
    /* 悬停背景 (Gray-100) */
    --active-bg: #eef2ff;
    /* 激活项背景 (Indigo-50) */
    --active-text: #4f46e5;
    /* 激活项文字 (Indigo-600) */

    --sidebar-w: 240px;
    /* 侧边栏宽度 */
    --header-h: 64px;
    /* 顶部栏高度 */
}

/* --- 暗色模式 (Dark Mode - 深空蓝灰改良版) --- */
[data-theme="dark"] {
    /* 背景不再是死黑，而是带有通透感的深蓝灰 */
    --bg-body: #0f172a;
    /* Slate-900 */
    --bg-surface: #1e293b;
    /* Slate-800 (比背景亮一级，拉开层次) */

    --border-color: #334155;
    /* Slate-700 (更明显的深色边框) */
    --border-hover: #818cf8;
    /* Indigo-400 (高亮色) */
    --border-focus: #6366f1;

    --text-main: #f8fafc;
    /* Slate-50 (近乎纯白) */
    --text-sub: #cbd5e1;
    /* Slate-300 (亮灰，提高可读性) */

    --hover-bg: #334155;
    /* Slate-700 */
    --active-bg: #312e81;
    /* Indigo-900 (深邃蓝) */
    --active-text: #e0e7ff;
    /* Indigo-100 */
}

/* =========================================
   2. 全局重置
   ========================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    /* 禁止整页滚动，只让内容区滚动 */
    line-height: 1.5;
    /* 增加颜色过渡动画，让切换主题更丝滑 */
    transition: background 0.3s ease, color 0.3s ease;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    font-family: inherit;
}

/* =========================================
   3. 布局框架
   ========================================= */
.layout-wrapper {
    display: flex;
    height: 100%;
    width: 100%;
}

/* --- 左侧侧边栏 --- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 20;
    transition: background 0.3s, border-color 0.3s;
}

.brand {
    height: var(--header-h);
    display: flex;
    align-items: center;
    padding: 0 24px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    gap: 10px;
    flex-shrink: 0;
}

.brand i {
    color: var(--border-hover);
    font-size: 20px;
}

.nav-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
}

/* 导航链接样式 */
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-sub);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.nav-item:hover {
    background: var(--hover-bg);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--active-bg);
    color: var(--active-text);
}

/* 夜间模式下的左侧选中发光条 */
[data-theme="dark"] .nav-item.active {
    box-shadow: inset 3px 0 0 0 #818cf8;
    /* 左侧高亮条 */
}

/* 底部用户/设置区 */
.user-panel {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.user-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    background: transparent;
    border-radius: 6px;
    color: var(--text-main);
    font-size: 14px;
    transition: all 0.2s;
    cursor: pointer;
}

.user-btn:hover {
    background: var(--hover-bg);
    border-color: var(--text-sub);
}

/* =========================================
   4. 右侧主内容区
   ========================================= */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-body);
    min-width: 0;
    /* 防止 Flex 子元素溢出 */
    transition: background 0.3s;
}

/* --- 顶部工具栏 --- */
.top-header {
    height: var(--header-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    flex-shrink: 0;
    transition: background 0.3s, border-color 0.3s;
}

/* 搜索框 */
.search-box {
    position: relative;
    width: 400px;
    max-width: 100%;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-sub);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    height: 40px;
    padding-left: 36px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg-body);
    color: var(--text-main);
    transition: all 0.2s;
}

.search-box input:focus {
    background: var(--bg-surface);
    border-color: var(--border-hover);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    /* 微弱的辉光 */
}

/* 夜间模式输入框颜色微调 */
[data-theme="dark"] .search-box input {
    background: #0f172a;
}

[data-theme="dark"] .search-box input:focus {
    background: #1e293b;
}

/* 顶部右侧工具按钮 */
.top-tools button {
    background: transparent;
    border: 1px solid transparent;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--text-sub);
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.top-tools button:hover {
    background: var(--hover-bg);
    color: var(--text-main);
    border-color: var(--border-color);
}

/* --- 内容滚动区域 --- */
.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    scroll-behavior: smooth;
}

/* =========================================
   5. 卡片与分区样式
   ========================================= */
.section-wrapper {
    margin-bottom: 48px;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 24px;
    padding-left: 12px;
    border-left: 4px solid var(--border-hover);
    line-height: 1.2;
}

.sub-section-title {
    font-size: 14px;
    color: var(--text-sub);
    margin: 24px 0 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 分区横线 */
.sub-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
    opacity: 0.6;
}

/* --- 卡片网格 --- */
.card-grid {
    display: grid;
    /* 响应式 Grid：最小宽度 220px */
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.nav-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    /* 克制的圆角 */
    padding: 16px;
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: all 0.2s ease-in-out;
    position: relative;
    text-decoration: none;
}

/* 通用悬停效果 */
.nav-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    /* 轻微上浮 */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    /* 极淡阴影 */
    z-index: 2;
}

/* 夜间模式专属悬停效果：微光 */
[data-theme="dark"] .nav-card:hover {
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.15);
    /* 蓝紫色光晕 */
    border-color: #6366f1;
    background: #252f42;
    /* 稍微提亮一点点背景 */
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.card-icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: var(--hover-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-sub);
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}

.card-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.card-desc {
    font-size: 13px;
    color: var(--text-sub);
    line-height: 1.5;
    /* 限制显示两行 */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: auto;
}

/* --- 搜索高亮 --- */
.highlight {
    background-color: rgba(251, 191, 36, 0.15);
    /* 淡黄色背景 */
    border-color: #f59e0b;
}

[data-theme="dark"] .highlight {
    background-color: rgba(251, 191, 36, 0.1);
}

/* =========================================
   6. 响应式适配 (Mobile)
   ========================================= */
@media (max-width: 768px) {
    .sidebar {
        display: none;
        /* 移动端简单隐藏侧边栏 */
    }

    .top-header {
        padding: 0 16px;
    }

    .search-box {
        width: 100%;
        margin-right: 10px;
    }

    .content-body {
        padding: 16px;
    }

    .card-grid {
        grid-template-columns: 1fr;
        /* 单列显示 */
    }
}

/* --- 页脚特效样式 (style.css 末尾追加) --- */

.site-footer {
    padding: 40px 20px;
    margin-top: auto;
    /* 推到底部 */
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface);
    text-align: center;
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* 行间距 */
    align-items: center;
    font-size: 14px;
    color: var(--text-sub);
}

.footer-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    line-height: 1.6;
}

/* 链接样式 */
.site-footer a {
    color: var(--text-sub);
    transition: color 0.2s;
}

.site-footer a:hover {
    color: var(--border-hover);
    text-decoration: underline;
}

/* 胶囊 Tag 样式 */
.footer-tag {
    background: rgba(99, 102, 241, 0.1);
    /* 淡紫色背景 */
    color: var(--border-hover);
    /* 深紫色文字 */
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
}

[data-theme="dark"] .footer-tag {
    background: rgba(129, 140, 248, 0.15);
    color: #a5b4fc;
}

/* 分割线 */
.divider {
    color: var(--border-color);
    margin: 0 4px;
}

/* 运行时间样式 */
#runtime_span {
    font-family: 'JetBrains Mono', monospace;
    /* 等宽字体更有极客感 */
    font-size: 13px;
}

/* Glitch 特效文字 */
.footer-glitch {
    font-weight: 700;
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    min-width: 60px;
}

/* 移动端优化 */
@media (max-width: 768px) {
    .site-footer {
        padding: 30px 15px 80px;
    }

    /* 底部留多点空给手机操作条 */
    .footer-row {
        gap: 6px;
    }
}