:root {
    --primary: #667eea;
    --accent: #764ba2;
    --bg: #f5f7fa;
    --card-bg: #fff;
    --text: #2d3748;
    --text-light: #718096;
    --border: #e2e8f0;
    --sidebar-w: 260px;
    --radius: 12px;
    --hero-gradient: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    --card-shadow: 0 1px 8px rgba(0,0,0,0.06);
    --card-shadow-hover: 0 4px 20px rgba(0,0,0,0.1);
    --card-header-bg: #fafbfc;
    --card-header-hover: #f0f2f8;
    --pre-bg: #1e1e2e;
    --status-bg: #f7f8fc;
    --article-h2: #1a202c;
}

/* ---- 暗色模式 ---- */
body.theme-dark {
    --bg: #0f1117;
    --card-bg: #1a1d27;
    --text: #e2e8f0;
    --text-light: #94a3b8;
    --border: #2d3348;
    --hero-gradient: linear-gradient(135deg, #3b3285 0%, #4a2758 100%);
    --card-shadow: 0 1px 8px rgba(0,0,0,0.4);
    --card-shadow-hover: 0 4px 20px rgba(0,0,0,0.5);
    --card-header-bg: #151822;
    --card-header-hover: #1e2235;
    --pre-bg: #0d0f16;
    --status-bg: #151822;
    --article-h2: #e2e8f0;
}
body.theme-dark .sidebar { background: #13161f; border-right-color: var(--border); }
body.theme-dark .sidebar-nav a:hover,
body.theme-dark .sidebar-nav a.active { background: var(--card-header-hover); }
body.theme-dark .card-header { background: var(--card-header-bg); }
body.theme-dark .card-header:hover { background: var(--card-header-hover); }
body.theme-dark .btn { background: var(--card-bg); border-color: var(--border); color: var(--text); }
body.theme-dark .btn:hover { background: #252a3a; border-color: var(--primary); color: var(--primary); }
body.theme-dark .btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
body.theme-dark .btn-danger { border-color: #fc8181; color: #fc8181; }
body.theme-dark .btn-danger:hover { background: #e53e3e; color: #fff; }
body.theme-dark .status-bar { background: var(--status-bg); }
body.theme-dark .field-table th { background: var(--card-header-bg); }
body.theme-dark .field-table code { background: #2d3348; color: #a0b4f8; }
body.theme-dark .feature-card { background: var(--card-bg); box-shadow: var(--card-shadow); }
body.theme-dark .feature-card:hover { box-shadow: var(--card-shadow-hover); }
body.theme-dark .overlay { background: rgba(0,0,0,0.5); }
body.theme-dark .menu-toggle { background: var(--card-bg); }
body.theme-dark:not(.sidebar-open) .menu-toggle { color: var(--text); }
body.theme-dark .article h2 { color: var(--article-h2); }
body.theme-dark pre { background: var(--pre-bg); }
body.theme-dark .sidebar-header { border-bottom-color: var(--border); }
body.theme-dark .sidebar-footer { border-top-color: var(--border); color: #4a5568; }
body.theme-dark #diversity-comments { border-top-color: var(--border); }
body.theme-dark .hero { background: var(--hero-gradient); }
body.theme-dark .back-to-top { background: var(--card-bg); color: var(--text); }
body.theme-dark .back-to-top:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.4); }

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

#container {
    margin: 0;
    padding: 0;
}

/* ========== 左侧目录 ========== */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    box-shadow: 2px 0 16px rgba(0,0,0,0.04);
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid var(--border);
}
.sidebar-header .logo {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar-header .logo svg { flex-shrink: 0; }
.sidebar-header .version {
    font-size: 0.72rem;
    color: #a0aec0;
    margin-top: 4px;
    margin-left: 28px;
}

.sidebar-nav { padding: 8px 0; flex: 1; }
.sidebar-group {
    padding: 16px 20px 6px;
    font-size: 0.7rem;
    color: #a0aec0;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 20px;
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.88rem;
    border-left: 3px solid transparent;
    transition: all 0.2s;
}
.sidebar-nav a:hover {
    background: #f7f8fc;
    color: var(--primary);
    border-left-color: var(--primary);
}
.sidebar-nav a.active {
    background: #eef0ff;
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
}
.sidebar-nav a .nav-icon {
    width: 18px; height: 18px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.85rem; flex-shrink: 0;
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: #cbd5e0;
    text-align: center;
}

/* ========== 主体内容区 ========== */
.main {
    margin-left: var(--sidebar-w);
    padding: 0;
    min-height: 100vh;
}

.content-wrap {
    max-width: 1060px;
    margin: 0 auto;
    padding: 32px 40px 40px;
}

/* ========== Hero ========== */
.hero {
    background: var(--hero-gradient);
    color: #fff;
    padding: 48px 40px;
    border-radius: var(--radius);
    margin-bottom: 28px;
    position: relative;
    overflow: hidden;
}
.hero::after {
    content: '';
    position: absolute;
    top: -40%; right: -10%;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, transparent 70%);
    border-radius: 50%;
}
.hero h1 { font-size: 2rem; margin-bottom: 10px; position: relative; z-index: 1; }
.hero p { opacity: 0.92; font-size: 1.05rem; position: relative; z-index: 1; max-width: 560px; }
.hero .tag-row {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-top: 18px; position: relative; z-index: 1;
}
.hero .tag {
    background: rgba(255,255,255,0.18);
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    backdrop-filter: blur(4px);
}

/* ========== 特性网格 ========== */
.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}
.feature-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px 20px;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}
.feature-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}
.feature-card .icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 12px;
}
.feature-card h3 { font-size: 0.95rem; margin-bottom: 6px; }
.feature-card p { font-size: 0.82rem; color: var(--text-light); line-height: 1.6; }

/* ========== 卡片 ========== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    margin-bottom: 24px;
    overflow: hidden;
}
.card-header {
    background: var(--card-header-bg);
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}
.card-header:hover { background: var(--card-header-hover); }
.card-header-left { display: flex; align-items: center; gap: 8px; }
.card-toggle-icon {
    width: 20px; height: 20px;
    transition: transform 0.3s;
    color: #999;
}
.card.collapsed .card-toggle-icon { transform: rotate(-90deg); }
.card.collapsed .card-body { display: none; }
.card-body { padding: 24px; }

/* ---- 按钮 ---- */
.btn-group { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text);
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.btn:hover { background: var(--card-header-hover); border-color: var(--primary); color: var(--primary); }
.btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-danger { border-color: #fc8181; color: #e53e3e; }
.btn-danger:hover { background: #e53e3e; color: #fff; }

/* ---- 状态栏 ---- */
.status-bar {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px;
    background: var(--status-bg);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 16px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #d0d5dd; }
.status-dot.ready { background: #48bb78; }
.status-dot.loading { background: #ed8936; animation: pulse 1s infinite; }
.status-dot.error { background: #f56565; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ---- 代码 ---- */
pre {
    background: var(--pre-bg);
    color: #cdd6f4;
    border-radius: 8px;
    padding: 16px 20px;
    overflow-x: auto;
    font-size: 0.84rem;
    line-height: 1.7;
    margin-top: 12px;
}
pre code { font-family: "SF Mono","Fira Code","Consolas",monospace; }

/* ---- 表格 ---- */
.field-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 0.84rem;
}
.field-table th, .field-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.field-table th { background: var(--status-bg); font-weight: 600; color: var(--text); }
.field-table code {
    background: #eef0ff; padding: 2px 6px; border-radius: 4px;
    font-size: 0.8rem; color: var(--primary);
}
.field-table .required { color: #e53e3e; font-size: 0.72rem; margin-left: 4px; }
.field-table .default { color: #a0aec0; font-size: 0.8rem; }

/* ---- 配置参考链接 ---- */
.config-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    font-size: 0.82rem;
    color: var(--text-light);
    text-decoration: none;
    transition: color 0.2s;
}
.config-link:hover { color: var(--primary); }
.config-link svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ---- 文章 ---- */
.article { padding: 30px 24px; }
.article h2 { font-size: 1.5rem; margin-bottom: 12px; color: var(--article-h2); }
.article time { color: #a0aec0; font-size: 0.85rem; display: block; margin-bottom: 20px; }
.article p { margin-bottom: 14px; color: var(--text-light); }
#diversity-comments {
    min-height: 150px;
    border-top: 1px solid var(--border);
    margin-top: 30px;
    padding-top: 20px;
}

/* ---- 页脚 ---- */
.footer {
    text-align: center;
    padding: 32px;
    color: #a0aec0;
    font-size: 0.85rem;
}
.footer a {
    color: var(--text-light);
    text-decoration: none;
    transition: color 0.2s;
}
.footer a:hover { color: var(--primary); }

/* ========== 移动端菜单按钮 ========== */
.menu-toggle {
    display: none;
    position: fixed;
    top: 14px; left: 14px;
    z-index: 200;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(102,126,234,0.4);
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 90;
}
.overlay.show { display: block; }

/* ========== 响应式 ========== */

/* Pad 竖屏及以上 (≥769px): sidebar 保持 */
/* Pad 横屏 / 小桌面 (769-1024px): sidebar 窄化 + 内容区缩进 */
@media (max-width: 1024px) {
    :root { --sidebar-w: 220px; }
    .content-wrap { padding: 24px 28px 32px; }
    .features { grid-template-columns: repeat(2, 1fr); gap: 16px; }
    .hero { padding: 36px 28px; }
    .hero h1 { font-size: 1.6rem; }
}

/* 手机端 (<769px): sidebar 隐藏, 全宽 */
@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 280px;
    }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .content-wrap { padding: 16px; }
    .menu-toggle {
        display: flex !important;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    /* sidebar 展开时，菜单按钮跟随滑入侧栏右侧*/
    body.sidebar-open .menu-toggle,
    body.theme-dark.sidebar-open .menu-toggle {
        left: 228px;
        background: var(--card-header-hover) !important;
        color: var(--primary) !important;
        box-shadow: none;
        width: 40px;
        height: 40px;
        line-height: 1;
        padding: 0 0 2px 0;
        border-radius: 6px;
    }
    body.sidebar-open .menu-toggle:hover,
    body.theme-dark.sidebar-open .menu-toggle:hover {
        background: var(--card-header-hover) !important;
        color: var(--primary) !important;
    }
    .hero { padding: 28px 20px; border-radius: 8px; }
    .hero h1 { font-size: 1.4rem; }
    .hero p { font-size: 0.92rem; }
    .features { grid-template-columns: 1fr; gap: 12px; }
    .feature-card { padding: 18px 16px; }
    .card-body { padding: 16px; }
    .article { padding: 24px 16px; }
    .field-table { font-size: 0.78rem; }
    .field-table th, .field-table td { padding: 8px 8px; }
    pre { font-size: 0.78rem; padding: 12px 14px; }
}

/* 小手机 (<480px) */
@media (max-width: 480px) {
    .article { padding: 20px 12px; }
    .hero { padding: 24px 16px; }
    .hero h1 { font-size: 1.2rem; }
    .hero .tag-row { gap: 6px; }
    .hero .tag { font-size: 0.72rem; padding: 3px 10px; }
    .btn { padding: 6px 12px; font-size: 0.82rem; }
    .btn-group { gap: 8px; }
}

/* 返回顶部按钮 */
#back-to-top {
    position: fixed;
    right: 24px;
    bottom: 32px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent, #4f46e5);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
    z-index: 9999;
}
#back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
#back-to-top:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

/* ========== 主题切换按钮 ========== */
.theme-toggle {
    position: fixed;
    top: 18px;
    right: 20px;
    z-index: 9999;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: color 0.2s, background 0.2s;
}
.theme-toggle:hover {
    background: var(--card-header-hover);
    color: var(--primary);
}
body.theme-dark .theme-toggle { color: var(--text-light); }
body.theme-dark .theme-toggle:hover { background: #2d3348; color: #e2e8f0; }

@media (max-width: 768px) {
    .theme-toggle { top: 14px; right: 16px; }
}
