/* ==========================================================================
   Field Notes — 个人技术博客样式
   设计语言：编辑排版 × 工程图纸。纸张底色、墨黑文字、信号橙强调色，
   细线网格 + 等宽标注，营造"工程笔记本"的质感。
   ========================================================================== */

:root {
  --bg: #f2f0ea;
  --bg-elev: #faf9f5;
  --ink: #151513;
  --ink-2: #3b3a36;
  --muted: #77746c;
  --line: rgba(21, 21, 19, 0.12);
  --line-strong: rgba(21, 21, 19, 0.28);
  --accent: #ff4a1c;
  --accent-ink: #ffffff;
  --accent-soft: rgba(255, 74, 28, 0.1);
  --code-bg: #1a1a18;
  --code-ink: #e8e6df;
  --selection: rgba(255, 74, 28, 0.22);

  --font-serif: "Instrument Serif", "Noto Serif SC", "Songti SC", "STSong", "SimSun", Georgia, serif;
  --font-cn-serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "PingFang SC", "Hiragino Sans GB",
    "Noto Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --maxw: 1240px;
  --gutter: clamp(16px, 4vw, 48px);
  --radius: 2px;
  --ease: cubic-bezier(0.2, 0.7, 0.1, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f0e;
    --bg-elev: #171715;
    --ink: #eceae3;
    --ink-2: #c4c1b8;
    --muted: #8a877e;
    --line: rgba(236, 234, 227, 0.1);
    --line-strong: rgba(236, 234, 227, 0.24);
    --accent: #ff6236;
    --accent-soft: rgba(255, 98, 54, 0.12);
    --code-bg: #0a0a09;
    --selection: rgba(255, 98, 54, 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0f0e;
  --bg-elev: #171715;
  --ink: #eceae3;
  --ink-2: #c4c1b8;
  --muted: #8a877e;
  --line: rgba(236, 234, 227, 0.1);
  --line-strong: rgba(236, 234, 227, 0.24);
  --accent: #ff6236;
  --accent-soft: rgba(255, 98, 54, 0.12);
  --code-bg: #0a0a09;
  --selection: rgba(255, 98, 54, 0.3);
  color-scheme: dark;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
::selection { background: var(--selection); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* 纸张颗粒感 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.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='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
.mono { font-family: var(--font-mono); font-feature-settings: "zero" 1; }
.label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  gap: 16px;
}
.logo {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}
.logo .tilde { color: var(--accent); }
.logo .cursor {
  display: inline-block;
  width: 8px;
  height: 15px;
  margin-left: 3px;
  background: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
  font-size: 14px;
  padding: 6px 12px;
  color: var(--ink-2);
  border-radius: 999px;
  transition: color 0.2s, background-color 0.2s;
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); background: var(--line); }
.nav-tools { display: flex; align-items: center; gap: 8px; }

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
  transition: border-color 0.2s, color 0.2s;
}
.search-trigger:hover { border-color: var(--ink); color: var(--ink); }
.search-trigger kbd, .kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--muted);
}
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  transition: border-color 0.2s, transform 0.4s var(--ease);
}
.icon-btn:hover { border-color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: block; }
}
.menu-btn { display: none; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.hero .wrap {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0 24px;
  padding-top: clamp(56px, 10vw, 120px);
  padding-bottom: clamp(40px, 6vw, 72px);
}
.hero-meta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin-bottom: clamp(28px, 4vw, 44px);
}
.hero-meta span { display: inline-flex; align-items: center; gap: 8px; }
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2fbf71;
  box-shadow: 0 0 0 0 rgba(47, 191, 113, 0.5);
  animation: pulse 2.2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(47, 191, 113, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(47, 191, 113, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 191, 113, 0); }
}
.hero-title {
  grid-column: 1 / span 8;
  margin: 0;
  font-family: var(--font-cn-serif);
  font-weight: 700;
  font-size: clamp(44px, 8.2vw, 112px);
  line-height: 1.02;
  letter-spacing: -0.035em;
}
.hero-title .line { display: block; overflow: hidden; padding-bottom: 0.06em; }
.hero-title .line > span {
  display: inline-block;
  transform: translateY(105%);
  animation: rise 1s var(--ease) forwards;
}
.hero-title .line:nth-child(2) > span { animation-delay: 0.12s; }
.hero-title em {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
  letter-spacing: -0.02em;
}
@keyframes rise { to { transform: none; } }

.hero-foot {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 24px;
  margin-top: clamp(36px, 5vw, 64px);
  align-items: end;
}
.hero-intro {
  grid-column: 1 / span 5;
  margin: 0;
  font-size: 17px;
  color: var(--ink-2);
  line-height: 1.75;
}
.hero-intro strong { color: var(--ink); font-weight: 600; }
.hero-stats {
  grid-column: 8 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line-strong);
}
.stat { padding: 14px 0 0; }
.stat + .stat { padding-left: 16px; border-left: 1px solid var(--line); }
.stat b {
  display: block;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(34px, 4vw, 48px);
  line-height: 1;
  letter-spacing: -0.02em;
}

/* ---------- Marquee ---------- */
.marquee {
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  white-space: nowrap;
  padding: 14px 0;
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.marquee-track {
  display: inline-flex;
  gap: 40px;
  animation: marquee 40s linear infinite;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}
.marquee-track span::before {
  /* 奶黄小圆点分隔符 */
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 40px;
  vertical-align: -1px;
  border-radius: 50%;
  background: #ffcf4a;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12);
}
.marquee:hover .marquee-track { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Section ---------- */
.section { padding: clamp(56px, 8vw, 104px) 0; border-bottom: 1px solid var(--line); }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: clamp(28px, 4vw, 48px);
  flex-wrap: wrap;
}
.section-title {
  margin: 0;
  font-family: var(--font-cn-serif);
  font-size: clamp(30px, 4vw, 48px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.section-title .idx {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  vertical-align: top;
  margin-right: 10px;
  letter-spacing: 0;
}

/* ---------- Featured ---------- */
.featured {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  border: 1px solid var(--line-strong);
  background: var(--bg-elev);
  transition: border-color 0.3s;
}
.featured:hover { border-color: var(--ink); }
.featured-art {
  position: relative;
  min-height: 380px;
  border-right: 1px solid var(--line-strong);
  overflow: hidden;
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 24px 24px;
}
.featured-art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.featured-art .ring { transform-origin: 50% 50%; animation: spin 40s linear infinite; }
.featured-art .ring.r2 { animation-duration: 26s; animation-direction: reverse; }
@keyframes spin { to { transform: rotate(360deg); } }
.featured-art .corner {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.06em;
}
.featured-art .tl { top: 14px; left: 16px; }
.featured-art .br { bottom: 14px; right: 16px; }
.featured-body {
  padding: clamp(24px, 3.5vw, 44px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.featured-body h3 {
  margin: 0;
  font-family: var(--font-cn-serif);
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.25;
  letter-spacing: -0.015em;
}
.featured-body p { margin: 0; color: var(--ink-2); line-height: 1.8; }
.featured-body .read-more { margin-top: auto; }

.chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink-2);
  white-space: nowrap;
}
.chip.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.read-more {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
}
.read-more .arrow {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--bg);
  transition: transform 0.4s var(--ease), background-color 0.3s;
}
.featured:hover .read-more .arrow { transform: rotate(-45deg); background: var(--accent); color: #fff; }

/* ---------- Post index ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter {
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 13px;
  color: var(--ink-2);
  transition: all 0.2s;
}
.filter:hover { border-color: var(--ink); color: var(--ink); }
.filter[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.filter sup { font-family: var(--font-mono); font-size: 9px; margin-left: 3px; opacity: 0.6; }

.post-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line-strong); }
.post-row a {
  position: relative;
  display: grid;
  grid-template-columns: 56px 110px 1fr auto 40px;
  align-items: center;
  gap: 20px;
  padding: 22px 8px;
  border-bottom: 1px solid var(--line);
  isolation: isolate;
}
.post-row a::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent-soft);
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform 0.35s var(--ease);
  z-index: -1;
}
.post-row a:hover::before, .post-row a:focus-visible::before { transform: scaleY(1); }
.post-row .num { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.post-row .date { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.post-row .title {
  font-family: var(--font-cn-serif);
  font-size: clamp(18px, 2vw, 22px);
  font-weight: 600;
  line-height: 1.4;
  transition: transform 0.35s var(--ease);
}
.post-row a:hover .title { transform: translateX(6px); }
.post-row .excerpt {
  display: block;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.6;
}
.post-row .go {
  justify-self: end;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  transition: all 0.35s var(--ease);
}
.post-row a:hover .go { background: var(--accent); border-color: var(--accent); color: #fff; transform: rotate(-45deg); }
.post-row.hidden { display: none; }
.post-list-empty { padding: 40px 0; color: var(--muted); text-align: center; display: none; }

/* ---------- Topics ---------- */
.topics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line);
}
.topic {
  position: relative;
  padding: 28px 24px 24px;
  min-height: 240px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  transition: background-color 0.3s;
}
.topic:hover { background: var(--bg-elev); }
.topic .glyph {
  font-family: var(--font-mono);
  font-size: 28px;
  color: var(--accent);
  line-height: 1;
  transition: transform 0.5s var(--ease);
}
.topic:hover .glyph { transform: translateY(-4px) scale(1.08); }
.topic h3 { margin: 0; font-size: 19px; font-family: var(--font-cn-serif); }
.topic p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.7; }
.topic .count { margin-top: auto; }
.topic::after {
  content: attr(data-n);
  position: absolute;
  right: -6px;
  bottom: -26px;
  font-family: var(--font-serif);
  font-size: 120px;
  line-height: 1;
  color: var(--line);
  pointer-events: none;
  transition: color 0.3s;
}
.topic:hover::after { color: var(--accent-soft); }

/* ---------- Now / About ---------- */
.about-grid { display: grid; grid-template-columns: 5fr 7fr; gap: clamp(32px, 6vw, 96px); }
.portrait {
  aspect-ratio: 4 / 5;
  border: 1px solid var(--line-strong);
  position: relative;
  overflow: hidden;
  background: var(--bg-elev);
}
.portrait svg { width: 100%; height: 100%; }
.portrait .caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--line-strong);
  background: var(--bg-elev);
}
.about-text h2 { margin-top: 0; }
.about-text p { color: var(--ink-2); font-size: 17px; line-height: 1.85; margin: 0 0 1.2em; }
.now-list { list-style: none; padding: 0; margin: 32px 0 0; border-top: 1px solid var(--line-strong); }
.now-list li {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.stack { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 28px; }

/* ---------- Newsletter ---------- */
.subscribe {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: center;
}
.subscribe h2 {
  margin: 0;
  font-family: var(--font-cn-serif);
  font-size: clamp(30px, 4.4vw, 56px);
  line-height: 1.1;
  letter-spacing: -0.025em;
}
.subscribe h2 em { font-family: var(--font-serif); color: var(--accent); font-weight: 400; }
.sub-form {
  display: flex;
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 5px;
  background: var(--bg-elev);
}
.sub-form input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0 16px;
  font: inherit;
  color: var(--ink);
  outline: none;
}
.sub-form button {
  height: 44px;
  padding: 0 22px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  transition: background-color 0.2s;
}
.sub-form button:hover { background: var(--accent); color: #fff; }
.sub-note { margin-top: 12px; }

/* ---------- Footer ---------- */
.site-footer { padding: clamp(48px, 7vw, 88px) 0 32px; }
.footer-top { display: flex; justify-content: space-between; gap: 32px; flex-wrap: wrap; }
.footer-links { display: flex; gap: clamp(32px, 6vw, 80px); }
.footer-links h4 { margin: 0 0 12px; }
.footer-links ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.footer-links a { font-size: 14px; color: var(--ink-2); }
.footer-links a:hover { color: var(--accent); }
.footer-mark {
  margin: clamp(40px, 6vw, 80px) 0 20px;
  font-family: var(--font-serif);
  font-size: clamp(64px, 17vw, 240px);
  line-height: 0.85;
  letter-spacing: -0.045em;
  white-space: nowrap;
  overflow: hidden;
}
.footer-mark span { color: var(--accent); }
.footer-bottom {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* ---------- Command palette ---------- */
.palette {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
  background: rgba(10, 10, 9, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.palette.open { display: flex; animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; } }
.palette-box {
  width: min(640px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  animation: pop 0.25s var(--ease);
}
@keyframes pop { from { transform: translateY(8px) scale(0.98); opacity: 0; } }
.palette-input {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}
.palette-input svg { width: 18px; color: var(--muted); flex: none; }
.palette-input input {
  flex: 1;
  height: 56px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  outline: none;
}
.palette-results { list-style: none; margin: 0; padding: 8px; max-height: 50vh; overflow-y: auto; }
.palette-results li a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 12px;
  border-radius: 8px;
}
.palette-results li a .t { font-weight: 500; }
.palette-results li a mark { background: var(--accent-soft); color: var(--accent); border-radius: 2px; }
.palette-results li.active a { background: var(--ink); color: var(--bg); }
.palette-results li.active a .label { color: inherit; opacity: 0.6; }
.palette-empty { padding: 28px; text-align: center; color: var(--muted); font-size: 14px; }
.palette-foot { display: flex; gap: 16px; padding: 10px 18px; border-top: 1px solid var(--line); }

/* ---------- Reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

/* ==========================================================================
   Article page
   ========================================================================== */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 100%;
  background: var(--accent);
  transform-origin: 0 50%;
  transform: scaleX(0);
  z-index: 60;
}
.article-head { padding: clamp(48px, 8vw, 96px) 0 clamp(32px, 5vw, 56px); border-bottom: 1px solid var(--line); }
.back-link { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 36px; }
.back-link:hover { color: var(--accent); }
.article-head h1 {
  margin: 18px 0 24px;
  max-width: 18ch;
  font-family: var(--font-cn-serif);
  font-size: clamp(36px, 6vw, 76px);
  line-height: 1.12;
  letter-spacing: -0.03em;
}
.article-head .lede { max-width: 640px; font-size: 19px; line-height: 1.8; color: var(--ink-2); margin: 0; }
.article-meta { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--line-strong); }
.article-meta div { display: grid; gap: 2px; }
.article-meta b { font-weight: 500; font-size: 14px; }

.article-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 680px) 1fr;
  gap: clamp(24px, 4vw, 64px);
  padding-top: clamp(40px, 6vw, 72px);
  padding-bottom: clamp(56px, 8vw, 96px);
}
.toc { position: sticky; top: 92px; align-self: start; }
.toc ol { list-style: none; margin: 14px 0 0; padding: 0; border-left: 1px solid var(--line); }
.toc a {
  display: block;
  padding: 6px 0 6px 14px;
  margin-left: -1px;
  border-left: 1px solid transparent;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  transition: color 0.2s, border-color 0.2s;
}
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--ink); border-left-color: var(--accent); }
.toc .sub a { padding-left: 26px; font-size: 12.5px; }

.prose { font-size: 17px; line-height: 1.9; color: var(--ink-2); }
.prose > * + * { margin-top: 1.25em; }
.prose p { margin: 0; }
.prose h2, .prose h3 { color: var(--ink); font-family: var(--font-cn-serif); scroll-margin-top: 90px; }
.prose h2 { font-size: 30px; line-height: 1.3; margin: 2.2em 0 0; letter-spacing: -0.015em; }
.prose h2::before {
  content: attr(data-n);
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}
.prose h3 { font-size: 21px; margin: 1.8em 0 0; }
.prose a { color: var(--ink); background: linear-gradient(var(--accent), var(--accent)) 0 100% / 100% 1px no-repeat; transition: background-size 0.3s, color 0.2s; }
.prose a:hover { color: var(--accent); }
.prose strong { color: var(--ink); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 0.4em; }
.prose li::marker { color: var(--accent); }
.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  padding: 0.12em 0.4em;
  background: var(--line);
  border-radius: 4px;
  color: var(--ink);
}
.prose blockquote {
  margin-left: 0;
  margin-right: 0;
  padding: 4px 0 4px 24px;
  border-left: 2px solid var(--accent);
  font-family: var(--font-cn-serif);
  font-size: 21px;
  line-height: 1.7;
  color: var(--ink);
}
.prose hr { border: 0; text-align: center; margin: 3em 0; }
.prose hr::after { content: "✦ ✦ ✦"; color: var(--accent); letter-spacing: 1em; font-size: 12px; }

.callout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  padding: 18px 20px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 6px;
  font-size: 15.5px;
  line-height: 1.75;
}
.callout .ico { font-family: var(--font-mono); color: var(--accent); font-weight: 700; }

.code-block {
  position: relative;
  margin-left: 0;
  margin-right: 0;
  background: var(--code-bg);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.prose > .code-block { margin-top: 1.6em; margin-bottom: 0.4em; }
.code-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: #8f8c84;
}
.code-head .dots { display: inline-flex; gap: 6px; margin-right: 12px; vertical-align: middle; }
.code-head .dots i { width: 9px; height: 9px; border-radius: 50%; background: #3a3936; }
.copy-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  color: #b9b6ad;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: all 0.2s;
}
.copy-btn:hover { color: #fff; border-color: rgba(255, 255, 255, 0.35); }
.copy-btn.done { color: #2fbf71; border-color: #2fbf71; }
.code-block pre {
  margin: 0;
  padding: 18px 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--code-ink);
  tab-size: 2;
}
/* 简易语法高亮 token */
.tk-k { color: #ff7a59; }
.tk-s { color: #b5d68a; }
.tk-c { color: #6f6c65; font-style: italic; }
.tk-f { color: #7fc8f8; }
.tk-n { color: #e8b86d; }
.tk-t { color: #c6a0f6; }

.figure { margin-left: 0; margin-right: 0; }
.figure .frame {
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 20px 20px,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 20px 20px,
    var(--bg-elev);
  padding: 24px;
}
.figure figcaption { margin-top: 10px; }

.article-aside { align-self: start; position: sticky; top: 92px; display: grid; gap: 24px; }
.share { display: flex; gap: 8px; }

.article-end { border-top: 1px solid var(--line); }
.pager { display: grid; grid-template-columns: 1fr 1fr; }
.pager a { padding: 36px 0; display: grid; gap: 8px; transition: color 0.2s; }
.pager a + a { text-align: right; border-left: 1px solid var(--line); padding-left: 24px; }
.pager a:first-child { padding-right: 24px; }
.pager a:hover { color: var(--accent); }
.pager .t { font-family: var(--font-cn-serif); font-size: clamp(18px, 2.2vw, 24px); font-weight: 600; line-height: 1.4; }

/* ==========================================================================
   吉祥物：奶龙（视频素材）
   ========================================================================== */
.mascot {
  position: relative;
  grid-column: 9 / -1;
  grid-row: 2;
  align-self: end;
  justify-self: end;
  width: 100%;
  max-width: 300px;
  margin: 0;
}
.mascot-screen {
  display: block;
  width: 100%;
  text-align: left;
  position: relative;
  transition: transform 0.4s var(--ease);
}
.mascot-screen:hover { transform: translateY(-4px) rotate(-1.5deg); }
.mascot.sound-on .mascot-screen { animation: mascot-shake 0.16s ease-in-out infinite alternate; }
@keyframes mascot-shake { from { transform: rotate(-1.2deg); } to { transform: rotate(1.2deg) translateY(-2px); } }
.mascot-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 0 2px 6px;
  color: var(--muted);
  border-bottom: 1px dashed var(--line-strong);
}
.mascot-sound {
  padding: 2px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  transition: border-color 0.2s, color 0.2s;
}
.mascot-screen:hover .mascot-sound { border-color: var(--ink); color: var(--ink); }
.mascot.sound-on .mascot-sound { color: var(--accent); border-color: var(--accent); }
.rec {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: #ff4a1c;
  vertical-align: 1px;
  animation: blink 1.2s steps(1) infinite;
}
.mascot-video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}
/* 抠像：原视频隐藏在 canvas 下方继续播放 */
.keyed-src { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.mascot figcaption { display: flex; justify-content: space-between; margin-top: 10px; }
.mascot-bubble {
  position: absolute;
  right: 78%;
  top: 14%;
  z-index: 3;
  padding: 7px 12px;
  border-radius: 14px 14px 2px 14px;
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(6px) scale(0.9);
  transform-origin: 100% 100%;
  transition: opacity 0.25s, transform 0.35s var(--ease);
  pointer-events: none;
}
.mascot.talk .mascot-bubble { opacity: 1; transform: none; }
.mascot-ha { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.mascot-ha i {
  position: absolute;
  left: 50%;
  top: 40%;
  font-style: normal;
  font-family: var(--font-cn-serif);
  font-weight: 700;
  font-size: var(--s, 20px);
  color: var(--accent);
  white-space: nowrap;
  text-shadow: 0 0 6px var(--bg);
  animation: mascot-ha 1.1s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
@keyframes mascot-ha {
  0% { transform: translate(-50%, 0) scale(0.4); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--x, 0px)), var(--y, -80px)) scale(1) rotate(var(--r, 0deg)); opacity: 0; }
}

/* 关于我：视频头像 */
.portrait {
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 20px 20px,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 20px 20px,
    var(--bg-elev);
}
.portrait-video { display: block; width: 100%; height: calc(100% - 40px); object-fit: contain; }
.portrait-video.keyed-src { height: calc(100% - 40px); }
.portrait-coord, .portrait-hint { position: absolute; top: 14px; color: var(--muted); line-height: 1.6; }
.portrait-coord { left: 16px; }
.portrait-hint { right: 16px; transition: opacity 0.3s; }
.portrait:hover .portrait-hint { opacity: 0; }

/* 回到顶部：奶龙头像 */
.frog-top {
  position: fixed;
  right: clamp(16px, 3vw, 32px);
  bottom: clamp(16px, 3vw, 32px);
  z-index: 70;
  display: grid;
  justify-items: center;
  gap: 4px;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 0.3s, transform 0.4s var(--ease);
}
.frog-top.show { opacity: 1; transform: none; pointer-events: auto; }
.frog-top img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.25));
  transition: transform 0.3s var(--ease);
}
.frog-top span {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
}
.frog-top:hover img { transform: translateY(-4px) rotate(-8deg); }
.frog-top.hop img { animation: avatar-hop 0.5s cubic-bezier(0.3, 0.7, 0.4, 1); }
@keyframes avatar-hop {
  0% { transform: scale(1.08, 0.9); }
  40% { transform: translateY(-18px) scale(0.95, 1.06); }
  75% { transform: scale(1.05, 0.94); }
  100% { transform: none; }
}

/* 文章页：骑在进度条上的奶龙 */
.progress-frog {
  position: fixed;
  top: 3px;
  left: 0;
  width: 28px;
  height: 28px;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
  z-index: 61;
  pointer-events: none;
  transition: opacity 0.3s;
}
.frog-end { display: grid; justify-items: center; gap: 10px; text-align: center; }
.frog-end img { width: 84px; height: 84px; object-fit: contain; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.2)); }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .article-layout { grid-template-columns: minmax(0, 1fr); max-width: 760px; }
  .toc, .article-aside { display: none; }
  .topics { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .hero-title { grid-column: 1 / -1; }
  .hero-intro, .hero-stats { grid-column: 1 / -1; }
  .mascot { grid-column: 1 / -1; grid-row: auto; justify-self: start; max-width: 240px; margin-top: 32px; }
  .mascot-bubble { right: auto; left: 62%; border-radius: 14px 14px 14px 2px; transform-origin: 0 100%; }
  .featured { grid-template-columns: 1fr; }
  .featured-art { min-height: 240px; border-right: 0; border-bottom: 1px solid var(--line-strong); }
  .about-grid, .subscribe { grid-template-columns: 1fr; }
  .portrait { max-width: 360px; }
  .post-row a { grid-template-columns: 90px 1fr 32px; gap: 14px; }
  .post-row .num, .post-row .chips { display: none; }
}
@media (max-width: 720px) {
  .nav { display: none; }
  .nav.open {
    display: flex;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    padding: 12px var(--gutter) 20px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }
  .nav.open a { padding: 12px 4px; border-radius: 0; border-bottom: 1px solid var(--line); background: none; font-size: 16px; }
  .menu-btn { display: grid; }
  .search-trigger .txt, .search-trigger kbd { display: none; }
  .search-trigger { width: 34px; padding: 0; justify-content: center; }
  .post-row a { grid-template-columns: 1fr 32px; padding: 18px 0; }
  .post-row .date { grid-column: 1 / -1; order: -1; margin-bottom: -10px; }
  .topics { grid-template-columns: 1fr; }
  .topic { min-height: 0; }
  .now-list li { grid-template-columns: 1fr; gap: 2px; }
  .pager { grid-template-columns: 1fr; }
  .pager a + a { text-align: left; border-left: 0; border-top: 1px solid var(--line); padding-left: 0; }
  .prose { font-size: 16.5px; }
  .prose h2 { font-size: 25px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .reveal { opacity: 1; transform: none; }
  .hero-title .line > span { transform: none; }
}
