/* ==========================================================
   Editorial minimal — 纸、墨、一点朱砂
   ========================================================== */
:root {
  --paper: #f6f4ef;
  --ink: #1d1c1a;
  --ink-2: #5d5a54;
  --ink-3: #9b978e;
  --rule: #e4e0d7;
  --rule-2: #cfcabe;
  --accent: #b4442c;
  --code: #eeebe4;
  --tk-k: #b4442c;
  --tk-s: #5f7a3a;
  --tk-n: #2f5f8a;
  --tk-f: #1d1c1a;

  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", Georgia, "PingFang SC", "Microsoft YaHei", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Consolas, "PingFang SC", "Microsoft YaHei", monospace;

  --measure: 680px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
[data-theme="dark"] {
  color-scheme: dark;
  --paper: #121211;
  --ink: #e7e4dd;
  --ink-2: #a3a097;
  --ink-3: #6c6962;
  --rule: #262523;
  --rule-2: #3a3935;
  --accent: #e07a5f;
  --code: #1b1a18;
  --tk-k: #e07a5f;
  --tk-s: #a3be8c;
  --tk-n: #88b4d8;
  --tk-f: #e7e4dd;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 32px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.7 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
/* 极淡的纸张颗粒 */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 100;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme="dark"] body::before { opacity: .05; }
::selection { background: var(--accent); color: var(--paper); }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 1.5px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

/* ---------- 进度条 ---------- */
#progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 60;
  background: var(--accent);
  transform: scaleX(0); transform-origin: 0 50%;
  opacity: 0; transition: opacity .3s;
}
#progress.on { opacity: 1; }

/* ---------- 页头 ---------- */
.site-header, #app, .site-footer {
  width: 100%;
  max-width: calc(var(--measure) + 48px);
  margin: 0 auto;
  padding-left: 24px; padding-right: 24px;
}
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 40px;
}
.brand {
  display: inline-flex; align-items: center; gap: 12px;
  text-decoration: none;
  font-family: var(--serif); font-weight: 600; font-size: 16px; letter-spacing: .02em;
}
.seal {
  display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 3px;
  background: var(--accent); color: var(--paper);
  font-family: var(--serif); font-size: 13px; font-weight: 600;
  transition: transform .5s var(--ease);
}
.brand:hover .seal { transform: rotate(-8deg); }

.nav { display: flex; align-items: center; gap: 22px; }
.nav a {
  position: relative; text-decoration: none;
  font-size: 14px; color: var(--ink-2);
  transition: color .2s;
}
.nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -5px; height: 1px;
  background: currentColor;
  transform: scaleX(0); transform-origin: right;
  transition: transform .35s var(--ease);
}
.nav a:hover { color: var(--ink); }
.nav a:hover::after, .nav a.active::after { transform: scaleX(1); transform-origin: left; }
.nav a.active { color: var(--ink); }
.nav-btn {
  display: grid; place-items: center;
  width: 28px; height: 28px; margin-left: -6px;
  border: 0; background: none; border-radius: 50%;
  color: var(--ink-2); cursor: pointer;
  transition: color .2s, background .2s;
}
.nav-btn + .nav-btn { margin-left: -14px; }
.nav-btn:hover { color: var(--ink); background: var(--code); }
#theme-btn svg { transition: transform .6s var(--ease); }
[data-theme="dark"] #theme-btn svg { transform: rotate(180deg); }

/* ---------- 主体 ---------- */
#app { flex: 1; padding-top: 96px; padding-bottom: 40px; view-transition-name: main; }

.intro h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(28px, 4.6vw, 38px); line-height: 1.35; letter-spacing: -.005em;
  margin: 0 0 20px; text-wrap: balance;
}
.intro p { margin: 0; font-size: 18px; line-height: 1.85; max-width: 32em; text-wrap: pretty; }
.intro p span { color: var(--ink-3); }
.intro .links { margin-top: 28px; display: flex; gap: 22px; font-size: 14px; }
.intro .links a {
  text-decoration: none; color: var(--ink-2);
  border-bottom: 1px solid var(--rule-2); padding-bottom: 2px;
  transition: color .2s, border-color .2s;
}
.intro .links a:hover { color: var(--accent); border-color: var(--accent); }
.intro .links i { font-style: normal; display: inline-block; margin-left: 3px; font-size: 12px; transition: transform .3s var(--ease); }
.intro .links a:hover i { transform: translate(2px, -2px); }

/* 年份 · 文章列表 */
.year {
  display: grid; grid-template-columns: 96px 1fr;
  margin-top: 72px;
}
.year + .year { margin-top: 48px; }
.year h2 {
  margin: 0; padding-top: 12px;
  font: 400 13px/1 var(--mono); color: var(--ink-3); letter-spacing: .04em;
  position: sticky; top: 24px; align-self: start;
}
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: baseline; gap: 14px;
  padding: 9px 0;
  text-decoration: none; color: var(--ink);
  transition: opacity .25s, color .25s;
}
.row-title { font-size: 16.5px; line-height: 1.6; }
.row-fill {
  flex: 1; min-width: 24px; height: 1px;
  background-image: linear-gradient(to right, var(--rule-2) 1px, transparent 1px);
  background-size: 5px 1px; background-repeat: repeat-x;
  align-self: center; transform: translateY(2px);
}
.row time { font: 13px var(--mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.pin {
  margin-left: 10px; vertical-align: 2px;
  font: 11px var(--mono); color: var(--accent); letter-spacing: .08em;
}
@media (hover: hover) {
  #app:has(.row:hover) .row:not(:hover) { opacity: .38; }
}
.tally { margin: 72px 0 0; font: 12px var(--mono); color: var(--ink-3); letter-spacing: .04em; }

/* 页面标题 */
.page-head { margin-bottom: 48px; }
.page-head h1 { font-family: var(--serif); font-weight: 600; font-size: 34px; margin: 0; line-height: 1.3; }
.page-head p { margin: 6px 0 0; font: 13px var(--mono); color: var(--ink-3); }
.page-head .back { display: inline-block; margin-bottom: 24px; }
.page-head + .year { margin-top: 0; }
.tag-rows .row-title { font-family: var(--serif); }

/* ---------- 文章 ---------- */
.back {
  font: 13px var(--mono); color: var(--ink-3); text-decoration: none;
  transition: color .2s;
}
.back i { font-style: normal; display: inline-block; transition: transform .3s var(--ease); }
.back:hover { color: var(--ink); }
.back:hover i { transform: translateX(-3px); }

.post-title {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(30px, 5vw, 40px); line-height: 1.3; letter-spacing: -.005em;
  margin: 28px 0 16px; text-wrap: balance;
}
.about .post-title { margin-top: 0; }
.post-meta {
  display: flex; flex-wrap: wrap; gap: 4px 20px;
  margin: 0 0 56px; padding-bottom: 28px;
  border-bottom: 1px solid var(--rule);
  font: 12.5px var(--mono); color: var(--ink-3);
}
.post-tags a { color: var(--ink-2); text-decoration: none; transition: color .2s; }
.post-tags a:hover { color: var(--accent); }

.prose { font-size: 17px; line-height: 1.95; letter-spacing: .01em; overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1.35em; text-wrap: pretty; }
.prose h2, .prose h3, .prose h4 { position: relative; font-family: var(--serif); font-weight: 600; line-height: 1.45; text-wrap: balance; }
.prose h2 { font-size: 1.42em; margin: 2.4em 0 .8em; }
.prose h3 { font-size: 1.15em; margin: 2em 0 .6em; }
.prose h4 { font-size: 1em; margin: 1.8em 0 .5em; }
.anchor {
  position: absolute; left: -1.1em; padding-right: .3em;
  color: var(--ink-3); text-decoration: none; font-weight: 400;
  opacity: 0; transition: opacity .2s;
}
.prose :is(h2, h3, h4):hover .anchor { opacity: 1; }
.anchor:hover { color: var(--accent); }

.prose a {
  text-decoration: underline; text-decoration-thickness: 1px;
  text-underline-offset: .28em; text-decoration-color: var(--rule-2);
  transition: color .2s, text-decoration-color .2s;
}
.prose a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.prose strong { font-weight: 600; }
.prose em { font-style: italic; }
.prose del { color: var(--ink-3); }

.prose ul, .prose ol { margin: 0 0 1.35em; padding-left: 1.4em; }
.prose li { margin: .25em 0; padding-left: .2em; }
.prose ul li::marker { content: "—  "; color: var(--ink-3); }
.prose ol li::marker { font: .85em var(--mono); color: var(--ink-3); }
.prose li.task { list-style: none; margin-left: -1.4em; padding-left: 0; display: flex; gap: .7em; align-items: baseline; }
.prose li.task .box {
  flex: none; width: .82em; height: .82em; transform: translateY(.08em);
  border: 1.5px solid var(--ink-3); border-radius: 2px; position: relative;
}
.prose li.task.done { color: var(--ink-3); }
.prose li.task.done .box { background: var(--ink-3); }
.prose li.task.done .box::after {
  content: ""; position: absolute; left: 30%; top: 8%; width: 30%; height: 60%;
  border: solid var(--paper); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg);
}

.prose blockquote {
  margin: 2em 0; padding: .1em 0 .1em 1.4em;
  border-left: 2px solid var(--accent);
  font-family: var(--serif); color: var(--ink-2);
}
.prose blockquote p { margin: .4em 0; }

.prose code {
  font: .86em var(--mono);
  background: var(--code); padding: .14em .38em; border-radius: 4px;
}
.prose pre {
  position: relative; margin: 1.8em 0; padding: 20px 22px;
  background: var(--code); border-radius: 6px;
  overflow-x: auto; font-size: 13.5px; line-height: 1.75;
  -webkit-overflow-scrolling: touch;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose pre[data-lang]::before {
  content: attr(data-lang);
  position: absolute; top: 9px; right: 14px;
  font: 10.5px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
  transition: opacity .2s;
}
.prose pre:hover::before { opacity: 0; }
.copy {
  position: absolute; top: 6px; right: 8px;
  border: 0; background: var(--paper); color: var(--ink-2);
  font: 11px var(--mono); padding: 3px 9px; border-radius: 4px; cursor: pointer;
  opacity: 0; transition: opacity .2s, color .2s;
}
.prose pre:hover .copy, .copy:focus-visible { opacity: 1; }
.copy:hover { color: var(--accent); }
.tk-k { color: var(--tk-k); }
.tk-s { color: var(--tk-s); }
.tk-n { color: var(--tk-n); }
.tk-f { color: var(--tk-f); font-weight: 600; }
.tk-c { color: var(--ink-3); font-style: italic; }

.prose figure { margin: 2.4em 0; }
.prose figure img { display: block; width: 100%; height: auto; border-radius: 3px; cursor: zoom-in; background: var(--code); }
.prose figcaption { margin-top: .9em; text-align: center; font-size: 13px; color: var(--ink-3); }
.prose p img { max-width: 100%; cursor: zoom-in; }
.prose video { display: block; width: 100%; border-radius: 3px; background: #000; }
.video-box { position: relative; }
.video-shell { position: relative; }
.video-bar {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  display: flex; gap: 4px; opacity: 0; transition: opacity .2s;
}
.video-shell:hover .video-bar, .video-shell.is-mini .video-bar { opacity: 1; }
.video-bar button {
  border: 0; border-radius: 4px; padding: 3px 8px; cursor: pointer;
  background: rgba(18, 18, 17, .72); color: #f6f4ef; backdrop-filter: blur(6px);
  font: 11px var(--mono); line-height: 1.4; transition: background .15s;
}
.video-bar button:hover { background: var(--accent); }
.video-shell:not(.is-mini) .v-back, .video-shell:not(.is-mini) .v-close { display: none; }
.video-shell.is-mini .v-mini { display: none; }
.video-shell.is-mini {
  position: fixed; right: 24px; bottom: 24px; z-index: 70;
  width: min(360px, calc(100vw - 32px));
  border-radius: 8px; overflow: hidden;
  background: #000;
  box-shadow: 0 18px 48px -8px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .12);
  animation: mini-in .22s var(--ease);
}
.video-shell.is-mini video { border-radius: 0; }
@keyframes mini-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }
.prose audio { display: block; width: 100%; }
.prose .embed {
  display: block; height: 480px; min-height: 160px;
  resize: vertical; overflow: hidden;
  border: 1px solid var(--rule); border-radius: 4px; background: #fff;
}
.prose .embed.embed-16x9 {
  height: auto; aspect-ratio: 16 / 9; resize: none; background: #000; border: 0;
}
.prose .embed iframe { display: block; width: 100%; height: 100%; border: 0; }
.prose > iframe { display: block; max-width: 100%; margin: 1.8em auto; border: 0; border-radius: 4px; }
.year.pinned h2 { color: var(--accent); }
@media (min-width: 900px) {
  .prose figure { margin-left: -64px; margin-right: -64px; }
}

.prose hr { border: 0; margin: 3.2em 0; text-align: center; height: auto; overflow: visible; }
.prose hr::after { content: "· · ·"; letter-spacing: 1em; color: var(--ink-3); }

.table-wrap { overflow-x: auto; margin: 1.8em 0; }
.prose table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.6; }
.prose th { text-align: left; font-weight: 600; padding: 10px 16px 10px 0; border-bottom: 1px solid var(--ink); }
.prose td { padding: 10px 16px 10px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }

.fn-ref a { text-decoration: none; font: 11px var(--mono); color: var(--accent); padding: 0 1px; }
.footnotes { margin-top: 3.5em; padding-top: 1.4em; border-top: 1px solid var(--rule); font-size: 14px; color: var(--ink-2); line-height: 1.8; }
.footnotes ol { padding-left: 1.2em; margin: 0; }
.fn-back { text-decoration: none !important; color: var(--ink-3); }

.end-mark {
  display: inline-block; width: .5em; height: .5em; margin-left: .45em;
  background: var(--accent); vertical-align: .05em;
}

.pn {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  margin-top: 88px; padding-top: 28px; border-top: 1px solid var(--rule);
}
.pn a { text-decoration: none; }
.pn small { display: block; margin-bottom: 6px; font: 12px var(--mono); color: var(--ink-3); }
.pn span { font-family: var(--serif); font-size: 16px; line-height: 1.5; transition: color .2s; }
.pn a:hover span { color: var(--accent); }
.pn .next { text-align: right; }

/* 目录：平时是几道刻度，悬停展开 */
.toc {
  position: fixed; top: 50%; transform: translateY(-50%);
  left: calc(50% + var(--measure) / 2 + 56px);
  width: 200px; display: flex; flex-direction: column; gap: 2px;
}
.toc a {
  display: flex; align-items: center; gap: 12px; height: 24px;
  text-decoration: none; color: var(--ink-3); transition: color .25s;
}
.toc .bar { flex: none; width: 14px; height: 1.5px; background: currentColor; border-radius: 1px; transition: width .35s var(--ease), background .25s; }
.toc .l3 .bar { width: 8px; margin-left: 6px; }
.toc .label {
  font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transform: translateX(-6px);
  transition: opacity .3s, transform .35s var(--ease);
}
.toc:hover .label, .toc a.active .label { opacity: 1; transform: none; }
.toc a:hover, .toc a.active { color: var(--ink); }
.toc a.active .bar { width: 24px; background: var(--accent); }
.toc .l3.active .bar { width: 18px; }
@media (max-width: 1180px) { .toc { display: none; } }

/* 空状态 / 404 */
.empty { padding: 40px 0; }
.empty h1 { font-family: var(--serif); font-weight: 600; font-size: 64px; line-height: 1; margin: 0 0 20px; letter-spacing: -.02em; }
.empty p { color: var(--ink-2); margin: 0 0 10px; }
.empty a { color: var(--accent); text-decoration: none; }
.empty code { font: .9em var(--mono); background: var(--code); padding: .1em .35em; border-radius: 3px; }

/* ---------- 页脚 ---------- */
.site-footer {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  margin-top: 96px; padding-top: 28px; padding-bottom: 48px;
  font: 12px var(--mono); color: var(--ink-3);
  position: relative;
}
.site-footer::before {
  content: ""; position: absolute; top: 0; left: 24px; right: 24px; height: 1px; background: var(--rule);
}
.footer-right { display: flex; gap: 20px; align-items: center; }
.site-footer a { text-decoration: none; transition: color .2s; }
.site-footer a:hover { color: var(--ink); }
kbd {
  display: inline-block; min-width: 1.6em; text-align: center;
  font: 11px/1.6 var(--mono); color: var(--ink-2);
  border: 1px solid var(--rule-2); border-bottom-width: 2px; border-radius: 4px;
  padding: 0 4px; margin-right: 3px;
}

/* ---------- 命令面板 ---------- */
#palette {
  width: min(580px, calc(100vw - 32px)); max-height: 70vh;
  margin: 14vh auto auto; padding: 0;
  border: 1px solid var(--rule-2); border-radius: 10px;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .3);
  overflow: hidden;
}
#palette[open] { display: flex; flex-direction: column; animation: pop .22s var(--ease); }
#palette::backdrop { background: rgba(24, 22, 18, .22); backdrop-filter: blur(4px); animation: fade .2s; }
@keyframes pop { from { opacity: 0; transform: translateY(-8px) scale(.985); } }
@keyframes fade { from { opacity: 0; } }
#q {
  width: 100%; padding: 20px 22px;
  border: 0; border-bottom: 1px solid var(--rule); outline: none;
  background: transparent; color: var(--ink);
  font: 17px var(--sans);
}
#q::placeholder { color: var(--ink-3); }
#results { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
#results a {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 16px;
  padding: 11px 14px; border-radius: 6px; text-decoration: none;
}
#results li.sel a { background: var(--code); }
.r-title { font-size: 15px; }
#results time { font: 11.5px var(--mono); color: var(--ink-3); align-self: center; }
.r-snip { grid-column: 1 / -1; font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-snip mark { background: none; color: var(--accent); }
#results .none { padding: 28px 14px; text-align: center; color: var(--ink-3); font-size: 14px; }
.palette-foot { display: flex; gap: 18px; padding: 10px 18px; border-top: 1px solid var(--rule); font: 11.5px var(--mono); color: var(--ink-3); }

/* ---------- Toast / 图片放大 ---------- */
#toast {
  position: fixed; left: 50%; bottom: 32px; z-index: 80;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper);
  font: 12px var(--mono); padding: 8px 14px; border-radius: 999px;
  transition: opacity .25s, transform .35s var(--ease);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.zoom {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center; padding: 4vmin;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  cursor: zoom-out; opacity: 0; transition: opacity .25s;
}
.zoom img { max-width: 100%; max-height: 100%; border-radius: 3px; transform: scale(.96); transition: transform .35s var(--ease); }
.zoom.open { opacity: 1; }
.zoom.open img { transform: none; }

/* ---------- View Transitions ---------- */
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
::view-transition-old(main) { animation: vt-out .16s ease-in both; }
::view-transition-new(main) { animation: vt-in .38s var(--ease) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-4px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px); } }
html.theme-vt #app { view-transition-name: none; }
html.theme-vt::view-transition-old(root), html.theme-vt::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
html.theme-vt::view-transition-new(root) { z-index: 2; }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .site-header { padding-top: 28px; }
  .brand span:last-child { display: none; }
  .nav { gap: 18px; }
  #app { padding-top: 64px; }
  .intro p { font-size: 17px; }
  .year { grid-template-columns: 1fr; margin-top: 56px; }
  .year h2 { position: static; padding: 0 0 8px; }
  .row-title { font-size: 16px; }
  .prose { font-size: 16.5px; }
  .anchor { display: none; }
  .pn { grid-template-columns: 1fr; }
  .pn .next { text-align: left; }
  .hint { display: none; }
  .palette-foot { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
