:root {
  --paper:      #f9f7f1;
  --card:       #fffdf7;
  --cream:      #fff6ed;
  --sand:       #f0ebc8;
  --ink:        #242420;
  --ink-soft:   #5c5a52;
  --muted:      #98958b;
  --line:       #e6e0d2;
  --green:      #007722;
  --green-deep: #005c1a;
  --moss:       #7f9981;
  --flame:      #e76648;
  --flame-deep: #b8462c;
  --maxw: 1060px;
  --content: 46rem;
  --r: 14px;
  --pad-x: 22px;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  --font-serif: "Kaiti SC", STKaiti, KaiTi, "AR PL UKanTW", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;
  color-scheme: light;
  font-size: 16px;
}
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.78;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; }
::selection { background: var(--sand); color: var(--ink); }

/* ---------- 顶栏 ---------- */
.bar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(249, 247, 241, .9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.bar-in {
  max-width: var(--maxw); margin: 0 auto;
  padding: 11px var(--pad-x);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; font-weight: 800; font-size: 1.02rem; letter-spacing: .06em;
}
.logo .mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--green);
  display: grid; place-items: center; flex: none;
}
.logo b { color: var(--green); }
.logo i { font-style: normal; color: var(--flame); }
.progress { height: 2px; background: transparent; }
.progress span {
  display: block; height: 100%; width: 0;
  background: var(--green); transition: width .12s linear;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 38px; padding: 0 16px; border-radius: 999px;
  border: 1.5px solid transparent;
  font-size: .9rem; font-weight: 700; text-decoration: none;
  transition: background-color .12s ease, transform .12s ease;
}
.btn-ghost { color: var(--green); border-color: var(--green); }
.btn-ghost:hover { background: var(--cream); transform: translateY(-1px); }

/* ---------- 版面 ---------- */
.post-wrap {
  width: 100%; max-width: var(--maxw); margin: 0 auto;
  padding: 30px var(--pad-x) 24px;
  display: grid; grid-template-columns: minmax(0, 1fr);
  gap: 28px; align-content: start; flex: 1 0 auto;
}
.post { min-width: 0; }

/* ---------- 文章头 ---------- */
.post-head { margin-bottom: 26px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.kicker {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--green); font-size: .76rem; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase;
}
.kicker::before { content: ""; width: 22px; height: 2px; background: var(--moss); border-radius: 2px; }
.post h1 {
  margin: 12px 0 12px;
  font-size: clamp(1.7rem, 5.4vw, 2.45rem);
  line-height: 1.34; font-weight: 800; letter-spacing: .01em;
}
.post-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  color: var(--muted); font-size: .82rem;
}
.post-meta .sep { color: var(--line); }
.tag {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 999px;
  background: #eaf1e8; color: var(--green); font-weight: 700; font-size: .76rem;
  letter-spacing: .04em;
}

/* ---------- 正文 ---------- */
.prose { font-size: 1.02rem; max-width: var(--content); }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 1.05em 0; }
.prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  line-height: 1.4; font-weight: 800; scroll-margin-top: 84px;
}
.prose h2 {
  position: relative; margin: 2.2em 0 .7em; padding-left: 14px;
  font-size: clamp(1.3rem, 3.6vw, 1.55rem);
}
.prose h2::before {
  content: ""; position: absolute; left: 0; top: .22em; bottom: .22em;
  width: 4px; border-radius: 3px; background: var(--green);
}
.prose h3 { margin: 1.8em 0 .6em; font-size: 1.16rem; }
.prose h4 { margin: 1.6em 0 .5em; font-size: 1.04rem; color: var(--ink-soft); }
.prose h5, .prose h6 { margin: 1.4em 0 .4em; font-size: .96rem; color: var(--muted); letter-spacing: .04em; }
.prose a {
  color: var(--green-deep);
  text-decoration: underline; text-decoration-color: var(--moss);
  text-decoration-thickness: 1.5px; text-underline-offset: 3px;
  transition: color .12s ease, text-decoration-color .12s ease;
}
.prose a:hover { color: var(--green); text-decoration-color: var(--flame); }
.prose strong { font-weight: 800; }
.prose em { font-style: italic; }
.prose del { color: var(--muted); text-decoration-color: var(--flame); }
.prose mark { background: var(--sand); color: inherit; padding: 0 .2em; border-radius: 4px; }

.prose ul, .prose ol { margin: 1em 0; padding-left: 1.5em; }
.prose li { margin: .42em 0; }
.prose ul > li::marker { color: var(--moss); }
.prose ol > li::marker { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.prose li > ul, .prose li > ol { margin: .3em 0; }
.prose li.task-item { position: relative; list-style: none; padding-left: 1.75em; }
.prose li.task-item > input[type="checkbox"] {
  position: absolute; left: 0; top: .55em;
  width: 1.02em; height: 1.02em; margin: 0;
  accent-color: var(--green); cursor: default;
}
.prose li.task-item:has(> input:checked) { color: var(--muted); }

.prose blockquote {
  margin: 1.5em 0; padding: 14px 18px;
  background: var(--cream);
  border-left: 3px solid var(--moss);
  border-radius: 0 10px 10px 0;
  color: var(--ink-soft);
}
.prose blockquote p { margin: .45em 0; }
.prose blockquote blockquote {
  margin: .8em 0; background: var(--card);
  border-left-color: var(--flame); border-radius: 0 8px 8px 0;
}
.prose blockquote > :first-child { margin-top: 0; }
.prose blockquote > :last-child { margin-bottom: 0; }

.prose code { font-family: var(--font-mono); }
.prose :not(pre) > code {
  font-size: .87em; padding: .12em .4em;
  background: var(--cream); border: 1px solid var(--line); border-radius: 6px;
  color: var(--flame-deep); white-space: break-spaces;
}
.prose pre {
  font-family: var(--font-mono); font-size: .88rem; line-height: 1.65;
  overflow-x: auto; padding: 16px 18px; margin: 1.4em 0;
  background: #fbf9f3; border: 1px solid var(--line); border-radius: 12px;
  tab-size: 2;
}

/* 代码块 + 复制按钮 */
.codehilite {
  position: relative; margin: 1.4em 0;
  background: #fbf9f3; border: 1px solid var(--line); border-radius: 12px;
}
.codehilite pre { margin: 0; border: 0; border-radius: 0; }
.codehilite .copy {
  position: absolute; top: 8px; right: 8px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  font: 700 .72rem/1.5 var(--font-sans); letter-spacing: .06em;
  cursor: pointer; opacity: 0;
  transition: opacity .14s ease, color .14s ease, border-color .14s ease;
}
.codehilite:hover .copy, .codehilite .copy:focus-visible { opacity: 1; }
.codehilite .copy:hover { color: var(--green); border-color: var(--moss); }
.codehilite .copy.is-done { color: var(--green); border-color: var(--moss); opacity: 1; }

.prose hr { border: 0; border-top: 1px dashed var(--line); margin: 2.6em 0; }
.prose img {
  margin: 1.4em auto; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card);
  box-shadow: 0 8px 24px rgba(36, 36, 32, .05);
}
.prose figure { margin: 1.4em 0; }
.prose figcaption { margin-top: .5em; color: var(--muted); font-size: .82rem; text-align: center; }

.table-wrap {
  margin: 1.5em 0; overflow-x: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
}
.prose table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.prose th, .prose td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.prose thead th { background: var(--sand); font-weight: 700; white-space: nowrap; }
.prose tbody tr:last-child td { border-bottom: 0; }
.prose tbody tr:hover { background: var(--cream); }

.prose dl { margin: 1.2em 0; }
.prose dt { margin-top: .7em; font-weight: 800; }
.prose dd { margin-left: 1.4em; color: var(--ink-soft); }
.prose abbr[title] { text-decoration: underline dotted var(--moss); cursor: help; }
.prose sup { font-size: .72em; line-height: 0; }
.prose .footnote-ref, .prose .footnote-backref { text-decoration: none; font-weight: 700; }
.prose .footnote ol { padding-left: 1.4em; }
.prose .footnote li { margin: .5em 0; }

.prose .footnote {
  margin-top: 2.4em; padding-top: 1em;
  border-top: 1px dashed var(--line);
  font-size: .86rem; color: var(--ink-soft);
}
.prose .footnote hr { display: none; }

/* ---------- 目录 ---------- */
.toc { display: none; }
.toc-title {
  margin-bottom: 10px;
  font-size: .72rem; font-weight: 800; letter-spacing: .18em;
  color: var(--moss); text-transform: uppercase;
}
.toc ol { list-style: none; display: grid; gap: 2px; max-height: calc(100dvh - 190px); overflow: auto; }
.toc ol ol { padding-left: 12px; margin-top: 2px; }
.toc a {
  display: block; padding: 4px 10px; border-radius: 8px;
  border-left: 2px solid transparent;
  color: var(--ink-soft); font-size: .85rem; line-height: 1.5; text-decoration: none;
  transition: background-color .12s ease, color .12s ease;
}
.toc a:hover { background: var(--cream); color: var(--ink); }
.toc a.is-active {
  background: #eaf1e8; color: var(--green-deep);
  border-left-color: var(--green); font-weight: 700;
}

/* ---------- 文末 & 页脚 ---------- */
.post-foot {
  margin-top: 44px; padding-top: 18px; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between;
  color: var(--muted); font-size: .82rem;
}
.site-foot { border-top: 1px solid var(--line); padding: 22px var(--pad-x) 30px; }
.site-foot .in {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 8px 16px;
  align-items: center; justify-content: space-between;
  color: var(--muted); font-size: .78rem; letter-spacing: .03em;
}

/* ---------- 列表页 ---------- */
.shell {
  width: 100%; max-width: 50rem; margin: 0 auto;
  padding: 32px var(--pad-x) 48px; flex: 1 0 auto;
}
.home-head { padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.home-head h1 {
  margin: 12px 0 8px;
  font-size: clamp(1.6rem, 5vw, 2.15rem); line-height: 1.36; font-weight: 800;
}
.home-sub { color: var(--muted); font-size: .86rem; }
.post-list { list-style: none; display: grid; gap: 14px; margin-top: 26px; }
.card {
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r);
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--moss);
  box-shadow: 0 10px 26px rgba(36, 36, 32, .06);
}
.card-link { display: block; padding: 18px 20px 20px; color: inherit; text-decoration: none; }
.card-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  color: var(--muted); font-size: .76rem;
}
.card-meta .sep { color: var(--line); }
.card h2 {
  margin: 8px 0 6px;
  font-size: 1.16rem; line-height: 1.45; font-weight: 800;
  transition: color .14s ease;
}
.card:hover h2 { color: var(--green); }
.card-excerpt {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden;
  color: var(--ink-soft); font-size: .92rem;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.empty { padding: 44px 0; color: var(--muted); text-align: center; }

/* ---------- 断点 ---------- */
@media (min-width: 760px) {
  :root { --pad-x: 24px; }
  .post-wrap { padding: 44px var(--pad-x) 32px; }
  .shell { padding: 44px var(--pad-x) 56px; }
  .card-link { padding: 20px 24px 22px; }
  .prose { font-size: 1.05rem; }
}
@media (min-width: 1024px) {
  .post-wrap {
    grid-template-columns: minmax(0, 1fr) 232px;
    gap: 56px; padding-top: 56px;
  }
  .post-wrap > .post { grid-column: 1; grid-row: 1; }
  .post-wrap > .toc { grid-column: 2; grid-row: 1; display: block; position: sticky; top: 78px; align-self: start; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .progress span { transition: none; }
}
@media print {
  .bar, .toc, .post-foot, .site-foot, .codehilite .copy { display: none !important; }
  body { background: #fff; color: #000; }
  .post-wrap { display: block; padding: 0; }
  .prose { max-width: none; }
}

/* ---------- 代码高亮（Pygments · paper） ---------- */
.codehilite pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.codehilite .hll { background-color: #ffffcc }
.codehilite { background: #fbf9f3; color: #242420 }
.codehilite .c { color: #98958B; font-style: italic } /* Comment */
.codehilite .err { border: 1px solid #E76648 } /* Error */
.codehilite .k { color: #005C1A; font-weight: bold } /* Keyword */
.codehilite .n { color: #242420 } /* Name */
.codehilite .o { color: #5C5A52 } /* Operator */
.codehilite .p { color: #6F6C63 } /* Punctuation */
.codehilite .ch { color: #98958B; font-style: italic } /* Comment.Hashbang */
.codehilite .cm { color: #98958B; font-style: italic } /* Comment.Multiline */
.codehilite .cp { color: #7F9981; font-style: italic } /* Comment.Preproc */
.codehilite .cpf { color: #98958B; font-style: italic } /* Comment.PreprocFile */
.codehilite .c1 { color: #98958B; font-style: italic } /* Comment.Single */
.codehilite .cs { color: #98958B; font-style: italic } /* Comment.Special */
.codehilite .gd { color: #B8462C } /* Generic.Deleted */
.codehilite .ge { font-style: italic } /* Generic.Emph */
.codehilite .gh { color: #005C1A; font-weight: bold } /* Generic.Heading */
.codehilite .gi { color: #005C1A } /* Generic.Inserted */
.codehilite .gs { font-weight: bold } /* Generic.Strong */
.codehilite .gu { color: #7F9981; font-weight: bold } /* Generic.Subheading */
.codehilite .kc { color: #005C1A; font-weight: bold } /* Keyword.Constant */
.codehilite .kd { color: #005C1A; font-weight: bold } /* Keyword.Declaration */
.codehilite .kn { color: #7F9981; font-weight: bold } /* Keyword.Namespace */
.codehilite .kp { color: #005C1A; font-weight: bold } /* Keyword.Pseudo */
.codehilite .kr { color: #005C1A; font-weight: bold } /* Keyword.Reserved */
.codehilite .kt { color: #7F9981; font-weight: bold } /* Keyword.Type */
.codehilite .m { color: #B8462C } /* Literal.Number */
.codehilite .s { color: #8A5A17 } /* Literal.String */
.codehilite .na { color: #B8462C } /* Name.Attribute */
.codehilite .nb { color: #005C1A } /* Name.Builtin */
.codehilite .nc { color: #B8462C; font-weight: bold } /* Name.Class */
.codehilite .no { color: #B8462C } /* Name.Constant */
.codehilite .nd { color: #7F9981 } /* Name.Decorator */
.codehilite .ni { color: #242420 } /* Name.Entity */
.codehilite .ne { color: #242420 } /* Name.Exception */
.codehilite .nf { color: #B8462C; font-weight: bold } /* Name.Function */
.codehilite .nl { color: #242420 } /* Name.Label */
.codehilite .nn { color: #242420 } /* Name.Namespace */
.codehilite .nx { color: #242420 } /* Name.Other */
.codehilite .py { color: #242420 } /* Name.Property */
.codehilite .nt { color: #005C1A; font-weight: bold } /* Name.Tag */
.codehilite .nv { color: #242420 } /* Name.Variable */
.codehilite .ow { color: #5C5A52 } /* Operator.Word */
.codehilite .pm { color: #6F6C63 } /* Punctuation.Marker */
.codehilite .w { color: #242420 } /* Text.Whitespace */
.codehilite .mb { color: #B8462C } /* Literal.Number.Bin */
.codehilite .mf { color: #B8462C } /* Literal.Number.Float */
.codehilite .mh { color: #B8462C } /* Literal.Number.Hex */
.codehilite .mi { color: #B8462C } /* Literal.Number.Integer */
.codehilite .mo { color: #B8462C } /* Literal.Number.Oct */
.codehilite .sa { color: #8A5A17 } /* Literal.String.Affix */
.codehilite .sb { color: #8A5A17 } /* Literal.String.Backtick */
.codehilite .sc { color: #8A5A17 } /* Literal.String.Char */
.codehilite .dl { color: #8A5A17 } /* Literal.String.Delimiter */
.codehilite .sd { color: #7F9981; font-style: italic } /* Literal.String.Doc */
.codehilite .s2 { color: #8A5A17 } /* Literal.String.Double */
.codehilite .se { color: #8A5A17 } /* Literal.String.Escape */
.codehilite .sh { color: #8A5A17 } /* Literal.String.Heredoc */
.codehilite .si { color: #8A5A17 } /* Literal.String.Interpol */
.codehilite .sx { color: #8A5A17 } /* Literal.String.Other */
.codehilite .sr { color: #8A5A17 } /* Literal.String.Regex */
.codehilite .s1 { color: #8A5A17 } /* Literal.String.Single */
.codehilite .ss { color: #8A5A17 } /* Literal.String.Symbol */
.codehilite .bp { color: #005C1A } /* Name.Builtin.Pseudo */
.codehilite .fm { color: #B8462C; font-weight: bold } /* Name.Function.Magic */
.codehilite .vc { color: #242420 } /* Name.Variable.Class */
.codehilite .vg { color: #242420 } /* Name.Variable.Global */
.codehilite .vi { color: #242420 } /* Name.Variable.Instance */
.codehilite .vm { color: #242420 } /* Name.Variable.Magic */
.codehilite .il { color: #B8462C } /* Literal.Number.Integer.Long */

/* Pygments 生成的规则之后统一收口，避免覆盖页面排版 */
.codehilite pre {
  padding: 16px 18px;
  font-size: .88rem;
  line-height: 1.66;
  background: transparent;
  border: 0;
  border-radius: 0;
}
.codehilite pre span { background: transparent !important; }
