/* ================= 主题变量（gruvbox 风） ================= */
:root, :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #1d2021;
    --bg-soft: #282828;
    --fg: #ebdbb2;
    --fg-dim: #928374;
    --accent: #fabd2f;
    --link: #83a598;
    --border: #3c3836;
    --chip-bg: #282828;
    --syn-comment: #928374;
    --syn-keyword: #fb4934;
    --syn-string: #b8bb26;
    --syn-number: #d3869b;
    --syn-func: #fabd2f;
    --syn-type: #83a598;
    --syn-operator: #8ec07c;
    --syn-punct: #a89984;
    --syn-fg: #ebdbb2;
}
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #fbf1c7;
    --bg-soft: #ebdbb2;
    --fg: #3c3836;
    --fg-dim: #7c6f64;
    --accent: #b57614;
    --link: #076678;
    --border: #d5c4a1;
    --chip-bg: #ebdbb2;
    --syn-comment: #928374;
    --syn-keyword: #9d0006;
    --syn-string: #79740e;
    --syn-number: #8f3f71;
    --syn-func: #b57614;
    --syn-type: #427b58;
    --syn-operator: #427b58;
    --syn-punct: #7c6f64;
    --syn-fg: #3c3836;
}
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]):not([data-theme="light"]) {
        color-scheme: light;
        --bg: #fbf1c7;
        --bg-soft: #ebdbb2;
        --fg: #3c3836;
        --fg-dim: #7c6f64;
        --accent: #b57614;
        --link: #076678;
        --border: #d5c4a1;
        --chip-bg: #ebdbb2;
        --syn-comment: #928374;
        --syn-keyword: #9d0006;
        --syn-string: #79740e;
        --syn-number: #8f3f71;
        --syn-func: #b57614;
        --syn-type: #427b58;
        --syn-operator: #427b58;
        --syn-punct: #7c6f64;
        --syn-fg: #3c3836;
    }
}

/* ================= 基础 ================= */
* { box-sizing: border-box; }
html { font-size: 16px; }

body {
    margin: 0 auto;
    padding: 0 1.25rem;
    max-width: 44rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--fg);
    font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
    line-height: 1.8;
}

main { flex: 1; }

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

::selection { background: var(--accent); color: var(--bg); }

/* ================= 头部 / 底部 ================= */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    padding: 1.2rem 0;
    border-bottom: 2px solid var(--fg);
}

.site-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--fg);
}
.site-title:hover { color: var(--accent); text-decoration: none; }

.site-header nav { display: flex; align-items: center; gap: 1.1rem; }
.site-header nav a { color: var(--fg-dim); }
.site-header nav a:hover { color: var(--accent); text-decoration: none; }

#theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--fg-dim);
    width: 1.9rem;
    height: 1.9rem;
    cursor: pointer;
    font-size: .9rem;
    line-height: 1;
}
#theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

.site-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: .5rem;
    padding: 1.6rem 0;
    border-top: 1px solid var(--border);
    color: var(--fg-dim);
    font-size: .85rem;
    margin-top: 2.5rem;
}
.site-footer .sep { opacity: .4; }
.dim { opacity: .7; }

/* ================= 首页 ================= */
.hero { padding: 2.8rem 0 2rem; }

.hero-title {
    margin: 0 0 .3rem;
    font-size: 1.9rem;
    color: var(--fg);
}
.hero-title::after { content: " _"; color: var(--fg-dim); }

.hero-desc { margin: 0 0 1rem; color: var(--fg-dim); }

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem;
    color: var(--fg-dim);
    font-size: .88rem;
    font-family: "Cascadia Code", Consolas, monospace;
}
.hero-meta .dot { opacity: .45; }
.hero-meta b { color: var(--accent); font-weight: 700; }

/* ================= 文章列表（扁平清单） ================= */
.post-item {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}
.post-item:last-child { border-bottom: none; }

.post-item-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.post-item-link { color: var(--fg); font-weight: 600; }
.post-item-link:hover { color: var(--accent); text-decoration: none; }

.post-item-link::before { content: "» "; color: var(--fg-dim); }
.post-item:hover .post-item-link::before { content: "» "; color: var(--accent); }

.post-date {
    color: var(--fg-dim);
    font-size: .82rem;
    white-space: nowrap;
    font-family: "Cascadia Code", Consolas, monospace;
}

.post-summary {
    margin: .35rem 0 0;
    color: var(--fg-dim);
    font-size: .9rem;
}

.post-tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }

.chip {
    color: var(--fg-dim);
    font-size: .8rem;
    padding: 0;
}
.chip:hover { color: var(--accent); text-decoration: none; }

.pager {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.2rem;
    margin: 1.8rem 0 0;
    color: var(--fg-dim);
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: .88rem;
}

/* ================= 文章页 ================= */
.post-header { margin: 2.6rem 0 1.6rem; }
.post-title { margin: 0 0 .6rem; line-height: 1.4; }

.post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
    color: var(--fg-dim);
    font-size: .86rem;
    font-family: "Cascadia Code", Consolas, monospace;
}
.post-meta .sep { opacity: .5; }

.post-content img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border);
}

.post-content h1, .post-content h2, .post-content h3 { line-height: 1.4; margin-top: 1.8em; }
.post-content h2 {
    padding-bottom: .3em;
    border-bottom: 1px solid var(--border);
}

.post-content code {
    background: var(--bg-soft);
    border-radius: 3px;
    padding: .1em .4em;
    font-size: .87em;
    font-family: "Cascadia Code", Consolas, "JetBrains Mono", monospace;
}

.post-content pre {
    padding: 1rem 1.1rem;
    border-radius: 4px;
    overflow-x: auto;
    line-height: 1.6;
    border: 1px solid var(--border);
    background: var(--bg-soft);
}
.post-content pre code { background: none; padding: 0; }

.post-content blockquote {
    margin: 1rem 0;
    padding: .2rem 1rem;
    border-left: 3px solid var(--fg-dim);
    color: var(--fg-dim);
}

.post-content table {
    border-collapse: collapse;
    margin: 1rem 0;
    display: block;
    overflow-x: auto;
}
.post-content th, .post-content td {
    border: 1px solid var(--border);
    padding: .4rem .8rem;
}
.post-content th { background: var(--bg-soft); }

/* ================= 标签 / 分类页 ================= */
.page-title { margin: 2rem 0 1rem; }

.term-list { list-style: none; padding: 0; margin: 1rem 0 2rem; }
.term-list li { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; }
.term-list .count {
    color: var(--fg-dim);
    font-size: .78rem;
    font-family: "Cascadia Code", Consolas, monospace;
}
.term-list .count::before { content: "("; }
.term-list .count::after { content: ")"; }

/* ================= 404 ================= */
.not-found { text-align: center; padding: 4rem 0; }
.not-found h1 {
    font-size: 4.5rem;
    margin: 0;
    font-family: "Cascadia Code", Consolas, monospace;
    color: var(--accent);
}
