/*
 * 博客样式（文档知识库风，参考 VitePress / Docusaurus）：
 * 左侧固定目录树 + 中间正文 + 右侧「本页目录」，代码块带复制按钮，上下篇强导航。
 * 单文件、零外部依赖（不引 CDN、不用外部字体）。
 */

*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --brand: #1668dc;
    --brand-dark: #0f4fa8;
    --ink: #1f2328;
    --ink-soft: #5b6572;
    --ink-faint: #8b95a3;
    --line: #e6e9ef;
    --bg-soft: #f6f8fb;
    --code-bg: #f6f8fa;
    --radius: 8px;
    --sidebar-w: 258px;
    --toc-w: 216px;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: var(--ink);
    line-height: 1.75;
    background: #fff;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

code,
pre,
kbd,
time {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Cascadia Mono", monospace;
}

/* ── 顶栏 ─────────────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(255, 255, 255, .9);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 60px;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 650;
    font-size: 15.5px;
    letter-spacing: .2px;
    white-space: nowrap;
}

.brand .mark {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--brand), #3d8bfd);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 14px;
    font-weight: 700;
}

.topnav {
    margin-left: auto;
    display: flex;
    gap: 18px;
    font-size: 14px;
    color: var(--ink-soft);
    white-space: nowrap;
}

.topnav a:hover {
    color: var(--brand);
}

.menu-toggle {
    display: none;
}

/* ── 三栏布局 ─────────────────────────────────────────────── */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    gap: 44px;
    align-items: start;
    max-width: 1440px;
    margin: 0 auto;
    padding: 26px 24px 76px;
}

/* 有「本页目录」时补上第三栏（:has 不被支持时目录会落到正文下方，仍可用） */
.layout:has(.toc) {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
}

.sidebar,
.toc {
    position: sticky;
    top: 88px;
    max-height: calc(100vh - 118px);
    overflow-y: auto;
    font-size: 14px;
}

/* ── 左侧目录树 ───────────────────────────────────────────── */
.side-title {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 650;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.side-nav .side-title:not(:first-child) {
    margin-top: 26px;
}

.side-year {
    margin: 14px 0 4px;
    font-size: 12.5px;
    color: var(--ink-faint);
}

.side-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.side-list a {
    display: block;
    padding: 5px 10px;
    border-radius: 6px;
    color: var(--ink-soft);
    line-height: 1.5;
}

.side-list a:hover {
    background: var(--bg-soft);
    color: var(--ink);
}

.side-list a.current {
    background: rgba(22, 104, 220, .10);
    color: var(--brand-dark);
    font-weight: 600;
}

.side-tags {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
}

.side-tags a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 12.5px;
    color: var(--ink-soft);
}

.side-tags a:hover {
    border-color: #c9d2e0;
    color: var(--brand);
}

.side-tags .count {
    color: var(--ink-faint);
}

/* ── 右侧本页目录 ─────────────────────────────────────────── */
.toc ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc ul ul {
    padding-left: 12px;
}

.toc a {
    display: block;
    padding: 4px 8px;
    border-left: 2px solid transparent;
    color: var(--ink-soft);
    font-size: 13.5px;
    line-height: 1.55;
}

.toc a:hover {
    color: var(--brand);
}

.toc a.active {
    border-left-color: var(--brand);
    background: rgba(22, 104, 220, .06);
    color: var(--brand-dark);
    font-weight: 600;
}

/* ── 正文（文档排版）──────────────────────────────────────── */
.content {
    min-width: 0;
}

.doc h1,
.doc-home h1 {
    margin: 2px 0 10px;
    font-size: 30px;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -0.4px;
}

.doc-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    color: var(--ink-faint);
}

.tag {
    padding: 2px 9px;
    border-radius: 999px;
    background: rgba(22, 104, 220, .09);
    color: var(--brand);
    font-size: 12px;
    font-weight: 550;
}

.doc-body {
    padding-top: 6px;
    font-size: 16px;
}

.doc-body h2 {
    margin: 46px 0 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    font-size: 22px;
    font-weight: 650;
    letter-spacing: -0.2px;
    scroll-margin-top: 84px;
}

.doc-body h3 {
    margin: 28px 0 10px;
    font-size: 17.5px;
    font-weight: 630;
    scroll-margin-top: 84px;
}

.doc-body p {
    margin: 0 0 16px;
}

.doc-body ul,
.doc-body ol {
    margin: 0 0 16px;
    padding-left: 22px;
}

.doc-body li {
    margin-bottom: 6px;
}

.doc-body strong {
    font-weight: 650;
}

.doc-body img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 22px 0 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.doc-body em {
    display: block;
    margin: 0 0 22px;
    font-style: normal;
    font-size: 13px;
    color: var(--ink-faint);
    text-align: center;
}

.doc-body blockquote {
    margin: 0 0 18px;
    padding: 8px 16px;
    border-left: 3px solid var(--line);
    background: var(--bg-soft);
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--ink-soft);
}

.doc-body code {
    font-size: 13.5px;
    background: var(--code-bg);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 1px 5px;
    color: var(--brand-dark);
}

.doc-body pre {
    position: relative;
    margin: 0 0 18px;
    padding: 14px 16px;
    overflow-x: auto;
    background: var(--code-bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 13.5px;
    line-height: 1.7;
}

.doc-body pre code {
    background: none;
    border: none;
    padding: 0;
    color: inherit;
}

.code-copy {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 3px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink-soft);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    opacity: 0;
    transition: opacity .16s ease, color .16s ease;
}

.doc-body pre:hover .code-copy,
.code-copy:focus-visible {
    opacity: 1;
}

.code-copy:hover {
    color: var(--brand);
}

.code-copy.ok {
    color: #1a7f37;
    border-color: #b7e0c0;
    opacity: 1;
}

.doc-body hr {
    margin: 34px 0;
    border: none;
    border-top: 1px solid var(--line);
}

.doc-body table {
    width: 100%;
    margin: 0 0 20px;
    border-collapse: collapse;
    font-size: 14.5px;
}

.doc-body th,
.doc-body td {
    padding: 9px 12px;
    border: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.doc-body th {
    background: var(--bg-soft);
    font-weight: 600;
}

.doc-body a {
    color: var(--brand);
}

.doc-body a:hover {
    text-decoration: underline;
}

/* ── 上下篇导航 ───────────────────────────────────────────── */
.doc-nav {
    display: flex;
    gap: 12px;
    margin-top: 46px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
    font-size: 14px;
}

.doc-nav a {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink-soft);
    transition: border-color .16s ease, color .16s ease;
    min-width: 0;
}

.doc-nav a:hover {
    border-color: #c9d2e0;
    color: var(--brand);
}

.doc-nav .doc-next {
    text-align: right;
}

.doc-nav .dir {
    font-size: 12.5px;
    color: var(--ink-faint);
}

.doc-nav .title {
    color: var(--ink);
    font-weight: 600;
    line-height: 1.45;
}

.back-home {
    margin: 22px 0 0;
    font-size: 14px;
}

.back-home a {
    color: var(--brand);
}

/* ── 首页 / 列表 ──────────────────────────────────────────── */
.doc-home .lead {
    max-width: 760px;
    margin: 0 0 26px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
    color: var(--ink-soft);
    font-size: 15.5px;
}

.post-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.post-list li {
    padding: 18px 0;
    border-bottom: 1px solid var(--line);
}

.post-list li:last-child {
    border-bottom: none;
}

.post-link {
    font-size: 19px;
    font-weight: 650;
    letter-spacing: -0.2px;
}

.post-link:hover {
    color: var(--brand);
}

.post-list time,
.post-list .muted {
    margin-left: 10px;
    font-size: 13px;
    color: var(--ink-faint);
}

.post-list p {
    margin: 8px 0 0;
    color: var(--ink-soft);
    font-size: 14.5px;
}

/* ── 页脚 ─────────────────────────────────────────────────── */
footer {
    border-top: 1px solid var(--line);
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    max-width: 1440px;
    margin: 0 auto;
    padding: 22px 24px;
    color: var(--ink-soft);
    font-size: 13px;
}

/* 备案信息：ICP 与公安备案并排展示 */
.footer-inner .records {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
}

footer .police {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

footer .police img {
    display: block;
    width: 16px;
    height: 16px;
}

footer a:hover {
    color: var(--brand);
    text-decoration: underline;
}

/* ── 响应式 ───────────────────────────────────────────────── */
.scrim {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(16, 30, 54, .35);
}

.scrim[hidden] {
    display: none;
}

@media (max-width: 1200px) {
    .layout:has(.toc) {
        grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    }

    .toc {
        display: none;
    }
}

@media (max-width: 900px) {
    .menu-toggle {
        display: grid;
        place-items: center;
        width: 34px;
        height: 34px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
        color: var(--ink-soft);
        font-size: 15px;
        cursor: pointer;
    }

    .topbar-inner {
        gap: 12px;
        padding: 0 16px;
    }

    .layout,
    .layout:has(.toc) {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
        padding: 18px 16px 56px;
    }

    .sidebar {
        position: fixed;
        z-index: 40;
        top: 0;
        bottom: 0;
        left: 0;
        width: 286px;
        max-height: none;
        padding: 22px 18px;
        background: #fff;
        border-right: 1px solid var(--line);
        box-shadow: 0 0 30px rgba(16, 30, 54, .12);
        transform: translateX(-102%);
        transition: transform .2s ease;
    }

    body.menu-open .sidebar {
        transform: none;
    }

    .doc h1,
    .doc-home h1 {
        font-size: 25px;
    }

    .doc-body {
        font-size: 15.5px;
    }
}
