html, body { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    color-scheme: light;
    --bg-paper: #fdfdfc;
    --text-main: #2b2a27;
    --text-muted: #73726e;
    --border-line: #e3e2de;
    --bg-block: #f2f1ed;
    --font-main: "Maple Mono NF CN", "Maple Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg-paper: #2E3440;
    --text-main: #D8DEE9;
    --text-muted: #81A1C1;
    --border-line: #434C5E;
    --bg-block: #3B4252;
}
/* 代码块底色与页面一致 */
.chroma { background-color: var(--bg-paper) !important; }

html { font-size: 18px; scrollbar-gutter: stable; }

body {
    font: 1rem/1.75 var(--font-main);
    color: var(--text-main);
    background: var(--bg-paper);
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header, footer { flex: none; }
main { flex: 1; overflow: hidden; padding: 1rem 0 3rem; }
header, main, footer { background: var(--bg-paper); }

/* 正文首个标题/段落不带顶部间距，收紧与导航的距离 */
main > .overlay > :first-child { margin-top: 0; }

a { color: var(--text-main); }

.overlay {
    width: 100%;
    max-width: 712px;
    margin: 0 auto;
    padding: 0 1.5rem;
    box-sizing: border-box;
}

h1, h2, h3, h4 { font-weight: 500; line-height: 1.3; color: var(--text-main); }
h1 { font-size: 2.4rem; letter-spacing: -.02em; margin: 0 0 2rem; }
h2 { font-size: 1.3rem; font-weight: 600; margin: 2.5rem 0 1rem; }
h3 { font-size: 1.15rem; font-weight: 600; margin: 2.5rem 0 1rem; }
h4 { font-size: 1rem; margin: 2rem 0 1rem; }
p, li { line-height: 1.75; margin: 1em 0; }
.hero h1 { margin-bottom: .75em; }
h1 .count { margin-left: .4em; font-size: .45em; font-weight: 400; color: var(--text-muted); vertical-align: middle; }

main a {
    text-decoration: underline;
    text-decoration-color: var(--border-line);
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
    transition: text-decoration-color .2s;
}
main a:hover { text-decoration-color: var(--text-main); }

main ul { list-style: none; padding-left: 0; }
main ul > li { margin-bottom: .5rem; }
main ul > li::before { content: "—"; color: var(--text-muted); margin-right: .6rem; }

/* SERIES */

main.series h3 { font-size: 1em; margin: 1.5em 0 .25em; }
main.series h3 + p { margin-top: 0; }

/* POSTS：年份锚点 + 目录式两端对齐 */

.postlist-year {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 2.5rem 0 .75rem;
    padding-bottom: .3rem;
    border-bottom: 1px solid var(--border-line);
}
.postlist p { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: .6em 0; }
.postlist p a { flex: 0 1 auto; min-width: 0; text-decoration: none; }
.postlist p a:hover { text-decoration: underline; }
.dateprefix { flex: none; font-size: .8em; color: var(--text-muted); white-space: nowrap; }

/* HEADER */

header { min-height: 72px; }
header a { text-decoration: none; }
header a:hover { color: var(--text-main); }
header .overlay { min-height: 72px; display: flex; align-items: center; }
.home { font-weight: 600; margin-right: 1.5rem; }
nav { flex: 1; display: flex; align-items: center; font-size: .95rem; }
nav a { margin-right: 1.2rem; color: var(--text-muted); }
nav a:hover, .home a:hover { color: var(--text-main); }

/* FOOTER */

.prevInSection { text-align: left; }
.nextInSection { text-align: right; }
footer .overlay { height: 80px; display: flex; align-items: center; justify-content: flex-end; gap: 1.2rem; padding-bottom: 32px; }
footer .square { display: inline-block; height: 1em; width: 1em; background: var(--text-main); }

/* SINGLE */

.hero { padding-top: 1rem; margin-bottom: 2.5rem; }
.type-page .hero { padding-bottom: 1.5rem; border-bottom: 1px solid var(--border-line); }
.meta { color: var(--text-muted); font-size: .9rem; display: flex; justify-content: space-between; }
.meta-item { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta-item:not(:first-child) { margin-left: 1rem; }

p img { margin: 1.5em 0; width: 100%; max-width: 712px; }
@media (max-width: 600px) {
    h1 { font-size: 1.9rem; }
    p img { width: 100vw; max-width: none; position: relative; left: -1.5rem; }
}

/* TOC */

.toc { margin: 0 0 2.5rem; font-size: .9rem; }
.toc summary { cursor: pointer; color: var(--text-muted); list-style: none; }
.toc summary::-webkit-details-marker { display: none; }
.toc summary::before { content: "[+] "; color: var(--text-muted); }
.toc[open] > summary::before { content: "[-] "; }
.toc summary:hover { color: var(--text-main); }
.toc ul { margin: .6em 0 0; padding-left: 1.1em; }
.toc ul ul { padding-left: 1.1em; }
.toc li { margin: .3em 0; }
.toc li::before { content: none; }
.toc a { text-decoration: none; color: var(--text-muted); }
.toc a:hover { color: var(--text-main); }

/* CODE */

pre, code { font-family: var(--font-main); }
pre { margin: 1.5em 0; background: var(--bg-block); overflow-x: auto; display: flex; }
pre > code { line-height: 1.5; flex-shrink: 0; display: block; padding: 1em; }
code { background: var(--bg-block); }
pre code { background: none; }
.chroma .err { color: inherit !important; background: transparent !important; }
li code, p code { padding: 3px 5px; }

/* 代码块复制按钮 */
.highlight { position: relative; }
.copy { position: absolute; top: .4em; right: .5em; padding: 0; border: 0; background: none; font: inherit; font-size: .75rem; color: var(--text-muted); opacity: .4; cursor: pointer; }
.highlight:hover .copy, .copy:focus { opacity: 1; }
.copy:hover { color: var(--text-main); }
.lang { position: absolute; top: .4em; left: .5em; font-size: .75rem; color: var(--text-muted); opacity: .6; }

/* LIGHTBOX */

#lightbox { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 2rem; background: rgba(0, 0, 0, .85); cursor: zoom-out; }
#lightbox.on { display: flex; }
#lightbox img { max-width: 100%; max-height: 100%; }

/* BUTTONS：终端括号风 [Email] */

.button { display: inline-block; margin: .25rem .8rem .25rem 0; color: var(--text-main); text-decoration: none; font-size: .9rem; }
.button::before { content: "["; color: var(--text-muted); }
.button::after { content: "]"; color: var(--text-muted); }
.button:hover::before, .button:hover::after { color: var(--text-main); }

/* THEME / LANG TOGGLE */

.theme-toggle, .lang-toggle { padding: 0; border: 0; background: none; font: inherit; color: var(--text-muted); cursor: pointer; }
.theme-toggle:hover, .lang-toggle:hover { color: var(--text-main); }

/* i18n：按 data-lang 显示对应语言 */
[data-lang="en"] .zh, [data-lang="zh"] .en { display: none; }
