/* =========================================
   极简科技深蓝主题
   深海蓝 + 浅灰 + 纯白 | 硬核极客风
   ========================================= */

:root {
    --bg: #f0f4f8;
    --surface: #ffffff;
    --nav-bg: rgba(255,255,255,0.82);
    --text: #0f1a2e;
    --text-secondary: #4a5b70;
    --text-muted: #8b9bb5;
    --primary: #0d47a1;
    --primary-light: #1565c0;
    --accent: #1e88e5;
    --accent-dim: #e8f0fe;
    --border: #d8dfe8;
    --border-light: #e8edf4;
    --code-bg: #0d1117;
    --code-inline: #e8f0fe;
    --code-inline-text: #0d47a1;
    --danger: #c0392b;
    --shadow-sm: 0 1px 2px rgba(15,26,46,0.04);
    --shadow-md: 0 2px 8px rgba(15,26,46,0.06);
    --radius: 6px;
    --radius-lg: 10px;
    --max-w: 760px;
}

/* ========== 暗黑模式 ========== */
[data-theme="dark"] {
    --bg: #191928;
    --surface: #24243a;
    --nav-bg: rgba(25,25,40,0.88);
    --text: #e0e0e8;
    --text-secondary: #9a9ab0;
    --text-muted: #6a6a80;
    --primary: #4f8eff;
    --primary-light: #7aabff;
    --accent: #6495ed;
    --accent-dim: #2a2a48;
    --border: #3a3a50;
    --border-light: #2e2e48;
    --code-bg: #0d0d1a;
    --code-inline: #2a2a48;
    --code-inline-text: #7aabff;
    --danger: #e74c3c;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.3);
}

/* ========== 重置 ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

a { color: var(--primary); text-decoration: none; transition: color 0.18s; }
a:hover { color: var(--primary-light); }

/* ========== 导航栏 - 磨砂悬浮 ========== */
.nav {
    background: var(--nav-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 24px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-title {
    font-size: 19px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.nav-links { display: flex; gap: 22px; align-items: center; }
.nav-links a {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.2px;
}
.nav-links a:hover,
.nav-links a.router-link-active { color: var(--primary); text-decoration: none; }

.nav-admin {
    border: 1px solid var(--primary);
    color: var(--primary) !important;
    padding: 4px 14px;
    border-radius: 4px;
    font-size: 13px !important;
    transition: all 0.2s;
}
.nav-admin:hover { background: var(--primary); color: #fff !important; }

/* ========== 主体 ========== */
.main {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 36px 24px 60px;
    min-height: calc(100vh - 110px);
}

/* ========== 标签 ========== */
.tag {
    display: inline-block;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--primary);
    background: var(--accent-dim);
    border-radius: 12px;
    margin: 0 4px 4px 0;
    transition: all 0.15s;
    letter-spacing: 0.2px;
}
.tag:hover { opacity: 0.82; text-decoration: none; }

.article-tags { margin: 14px 0 0; }

/* 热门标签区域 */
.sidebar-tags {
    margin-bottom: 24px;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.sidebar-tags h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 10px;
}
.sidebar-tags .tag { margin: 3px 4px 3px 0; }
.sidebar-tags .tag .count {
    color: var(--text-muted);
    font-size: 11px;
    margin-left: 2px;
}

/* 暗黑模式切换按钮 */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 2px 6px;
    color: var(--text-secondary);
    transition: color 0.15s;
}
.theme-toggle:hover { color: var(--text); }

/* ========== 首页 Hero ========== */
.home-hero {
    text-align: center;
    padding: 52px 0 32px;
    position: relative;
}

/* 几何装饰线 */
.home-hero::after {
    content: "";
    display: block;
    width: 40px;
    height: 3px;
    background: var(--primary);
    margin: 16px auto 0;
    border-radius: 2px;
}

.home-hero h1 {
    font-size: 34px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -1px;
    margin-bottom: 10px;
}
.home-hero p {
    font-size: 16px;
    color: var(--text-muted);
    font-weight: 400;
}

.home-articles { margin-top: 36px; }
.home-articles h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

/* ========== 文章卡片 ========== */
.article-list-item {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, border-color 0.2s;
}

.article-list-item:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border);
}

.article-list-item h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
    line-height: 1.4;
}
.article-list-item h3 a { color: var(--text); }
.article-list-item h3 a:hover { color: var(--primary); text-decoration: none; }

.article-list-item .meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    letter-spacing: 0.3px;
}
.article-list-item .summary {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.65;
}

/* ========== 文章详情 ========== */
.article-detail {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 32px 30px;
    box-shadow: var(--shadow-sm);
}

.article-detail h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.35;
    letter-spacing: -0.5px;
}

.article-detail .meta {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border-light);
}

.article-content { font-size: 16px; line-height: 1.85; color: var(--text); }
.article-content h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 36px 0 10px;
    color: var(--text);
    letter-spacing: -0.3px;
    padding-left: 12px;
    border-left: 3px solid var(--primary);
}
.article-content h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 28px 0 8px;
    color: var(--text);
}
.article-content p { margin-bottom: 16px; }
.article-content ul, .article-content ol { margin: 8px 0 16px 22px; }
.article-content li { margin-bottom: 6px; padding-left: 2px; }

.article-content blockquote {
    border-left: 3px solid var(--accent);
    background: var(--accent-dim);
    padding: 12px 18px;
    margin: 20px 0;
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-secondary);
    font-size: 15px;
}
.article-content blockquote p { margin-bottom: 4px; }

.article-content strong { color: var(--primary); }

/* 表格 */
.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 14px;
}
.article-content thead { background: var(--primary); color: #fff; }
.article-content th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.article-content th:first-child { border-radius: var(--radius) 0 0 0; }
.article-content th:last-child { border-radius: 0 var(--radius) 0 0; }
.article-content td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--border-light);
}
.article-content tbody tr { background: var(--surface); }
.article-content tbody tr:nth-child(even) { background: #f7f9fc; }
.article-content tbody tr:hover { background: var(--accent-dim); }

/* 图片 */
.article-content img { max-width: 100%; border-radius: var(--radius); margin: 16px 0; }

/* 分隔线 */
.article-content hr {
    border: none;
    border-top: 1px solid var(--border-light);
    margin: 32px 0;
}

/* 任务列表 */
.article-content input[type="checkbox"] { margin-right: 6px; }

/* ========== 代码块 - 暗黑主题 ========== */
.article-content code {
    background: var(--code-inline);
    color: var(--code-inline-text);
    padding: 2px 7px;
    border-radius: 3px;
    font-size: 0.88em;
    font-family: "SF Mono", "Fira Code", "JetBrains Mono", "Cascadia Code", Consolas, monospace;
    font-weight: 500;
}

.article-content pre {
    background: var(--code-bg);
    padding: 20px 22px;
    border-radius: var(--radius-lg);
    overflow-x: auto;
    margin: 20px 0;
    border: 1px solid #1e293b;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    line-height: 1.55;
}

.article-content pre code {
    background: none;
    color: #e2e8f0;
    padding: 0;
    font-size: 13.5px;
    font-weight: 400;
    letter-spacing: 0.1px;
}

/* 简单语法高亮色（行内使用 span 即可） */
.article-content .k { color: #c792ea; } /* keyword */
.article-content .s { color: #c3e88d; } /* string */
.article-content .c { color: #546e7a; } /* comment */
.article-content .n { color: #82aaff; } /* number/func */

/* ========== 分页 ========== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 28px;
}

.pagination button {
    padding: 6px 16px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    border-radius: 4px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.18s;
}
.pagination button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pagination button:disabled { color: var(--text-muted); cursor: not-allowed; opacity: 0.5; }
.pagination button.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    font-weight: 600;
}

/* ========== 关于页面 ========== */
.about-page {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 32px 30px;
    box-shadow: var(--shadow-sm);
}
.about-page h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 20px;
    letter-spacing: -0.3px;
}
.about-page .about-content { font-size: 16px; line-height: 1.85; color: var(--text-secondary); }

/* ========== 管理后台 ========== */
.admin-page h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
    letter-spacing: -0.3px;
}

/* 登录卡片 */
.admin-login {
    max-width: 380px;
    margin: 40px auto;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 32px 30px;
    box-shadow: var(--shadow-sm);
}

.login-form .form-group { margin-bottom: 16px; }
.login-form label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.2px;
}
.login-form input[type="text"],
.login-form input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.login-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13,71,161,0.1);
}

/* 按钮 */
.btn {
    padding: 9px 22px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.2px;
}
.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(13,71,161,0.25); }
.btn-primary:hover { box-shadow: 0 4px 12px rgba(13,71,161,0.3); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 4px 12px; font-size: 12px; }

.error-msg { color: var(--danger); font-size: 13px; margin-top: 10px; }

/* 管理文章列表 */
.admin-actions { display: flex; gap: 10px; margin-bottom: 22px; }

.admin-article-list .admin-article-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    margin-bottom: 8px;
}
.admin-article-item .item-actions { display: flex; gap: 6px; }

/* 编辑器面板 */
.editor-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 24px;
    border-radius: var(--radius-lg);
    margin-bottom: 22px;
    box-shadow: var(--shadow-sm);
}
.editor-panel h2 { font-size: 16px; font-weight: 600; margin-bottom: 14px; }
.editor-panel .form-group { margin-bottom: 14px; }
.editor-panel label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}
.editor-panel input[type="text"],
.editor-panel textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
}
.editor-panel textarea { resize: vertical; min-height: 180px; font-family: "SF Mono", "Fira Code", Consolas, monospace; font-size: 13px; }
.editor-panel input:focus,
.editor-panel textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13,71,161,0.08);
}
.editor-actions { display: flex; gap: 8px; margin-top: 12px; }

/* 搜索框 */
.search-input {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.2s;
}
.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13,71,161,0.08);
}

/* Markdown 编辑器 */
.md-toolbar { margin-bottom: 8px; }
.md-toolbar .btn.active { background: var(--primary); color: #fff; }
.md-editor {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: "SF Mono", "Fira Code", "JetBrains Mono", Consolas, monospace !important;
    font-size: 13px !important;
    line-height: 1.6;
    color: var(--text);
    background: #f8f9fb;
    tab-size: 4;
}
.md-preview {
    min-height: 180px;
    padding: 14px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--surface);
}

/* ========== 空状态 ========== */
.empty {
    text-align: center;
    padding: 60px 0;
    color: var(--text-muted);
    font-size: 15px;
}

/* ========== 页脚 ========== */
.footer {
    border-top: 1px solid var(--border-light);
    padding: 28px 24px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}
.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--primary); }

/* ========== 代码块复制按钮 ========== */
.copy-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 13px;
    cursor: pointer;
    color: #8b949e;
    transition: all 0.15s;
    z-index: 2;
    line-height: 1.4;
}
.copy-btn:hover { background: rgba(255,255,255,0.12); color: #e2e8f0; }
.article-content pre:hover .copy-btn { opacity: 1; }
.article-content pre .copy-btn { opacity: 0.6; }

/* ========== Mermaid 图表 ========== */
.article-content .mermaid {
    background: var(--code-bg);
    padding: 20px 22px;
    border-radius: var(--radius-lg);
    margin: 20px 0;
    border: 1px solid #1e293b;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    overflow-x: auto;
    text-align: center;
}
.article-content .mermaid svg { max-width: 100%; height: auto; }

/* ========== 上一篇/下一篇 ========== */
.article-nav {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}
.article-nav a {
    font-size: 14px;
    font-weight: 500;
    max-width: 45%;
    padding: 10px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    transition: all 0.15s;
    background: var(--surface);
}
.article-nav a:hover {
    border-color: var(--primary);
    color: var(--primary);
    text-decoration: none;
}
.nav-prev { text-align: left; }
.nav-next { text-align: right; }

/* ========== TOC 浮动目录 ========== */
.article-layout { display: block; }
.article-layout .article-content { width: 100%; }

.toc-float {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 50;
    max-width: 260px;
}

.toc-toggle {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-right: none;
    border-radius: 6px 0 0 6px;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--primary);
    box-shadow: 0 2px 12px rgba(15,26,46,0.08);
    transition: all 0.2s;
    letter-spacing: 0.5px;
}
.toc-toggle:hover { background: var(--accent-dim); }

.toc-panel {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-right: none;
    border-radius: 6px 0 0 6px;
    padding: 10px 14px 14px;
    margin-top: 4px;
    box-shadow: 0 4px 16px rgba(15,26,46,0.1);
    max-height: 60vh;
    overflow-y: auto;
    font-size: 13px;
}
.toc-panel ul { list-style: none; padding: 0; margin: 0; }
.toc-panel li { margin: 2px 0; }
.toc-panel li a {
    display: block;
    padding: 3px 8px;
    color: var(--text-muted);
    border-radius: 4px;
    line-height: 1.5;
    transition: all 0.1s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.toc-panel li a:hover { color: var(--primary); background: var(--accent-dim); text-decoration: none; }
.toc-panel li.toc-active a { color: var(--primary); font-weight: 600; background: var(--accent-dim); }
.toc-panel li.toc-h1 { padding-left: 0; font-size: 13px; font-weight: 600; }
.toc-panel li.toc-h2 { padding-left: 12px; font-size: 13px; }
.toc-panel li.toc-h3 { padding-left: 24px; font-size: 12px; }

/* 无 TOC 时隐藏浮动元素 */
.toc-float:not(:has(.toc-panel)) { display: none; }

/* ========== 响应式 ========== */
@media (max-width: 640px) {
    .nav-inner { padding: 0 16px; }
    .nav-title { font-size: 16px; }
    .nav-links { gap: 14px; }
    .nav-links a { font-size: 13px; }
    .nav-admin { padding: 3px 10px; }

    .main { padding: 24px 16px 40px; }

    .home-hero { padding: 36px 0 24px; }
    .home-hero h1 { font-size: 26px; }

    .article-detail { padding: 24px 18px; }
    .article-detail h1 { font-size: 22px; }

    .article-list-item { padding: 18px; }

    .admin-actions { flex-direction: column; }
    .about-page { padding: 24px 18px; }
    .article-layout { flex-direction: column; }
    .toc { width: 100%; position: static; max-height: none; margin-bottom: 16px; }
    .article-nav { flex-direction: column; }
    .article-nav a { max-width: 100%; }
    .toc-float { right: -6px; }
    .toc-toggle { font-size: 12px; padding: 6px 8px; }
}
