/* ---------- 文章页 ---------- */
.article-head { padding-block: clamp(48px, 9vh, 96px) clamp(28px, 5vh, 48px); position: relative; isolation: isolate; overflow: clip; }
.article-head::before {
  content: ""; position: absolute; inset: -40% -10% auto auto; z-index: -1;
  width: min(70vw, 760px); aspect-ratio: 1; border-radius: 50%;
  background: repeating-radial-gradient(circle, rgb(195 181 255 / .5) 0 2px, transparent 2px 22px);
  mask-image: radial-gradient(circle, #000 20%, transparent 70%);
}
[data-motion="on"] .article-head::before { animation: breathe 9s ease-in-out infinite alternate; }
@keyframes breathe { to { scale: 1.12; rotate: 8deg; } }
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 20px; font-size: .92rem; color: var(--muted); }
.crumbs a { color: var(--muted); text-underline-offset: 4px; }
.crumbs a:hover { color: var(--ink); }
.article-title { margin: 0; font: 700 clamp(2rem, 5vw, 3.6rem)/1.2 var(--f-body); letter-spacing: -0.015em; text-wrap: balance; max-width: 22ch; }
.byline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 22px; color: var(--muted); font-size: .95rem; }
.byline .tags { display: flex; gap: 6px; }

.article-layout {
  display: grid; gap: 40px;
  grid-template-columns: minmax(0, 68ch) minmax(12rem, 15rem);
  justify-content: space-between; align-items: start;
  padding-bottom: clamp(64px, 10vh, 112px);
}
.prose { min-width: 0; }
.prose > p:first-of-type { font-size: 1.15rem; }
.prose p { margin: 0 0 1.25em; text-wrap: pretty; }
.prose section { scroll-margin-top: calc(var(--header-h) + 16px); }
.prose section:focus { outline: none; }
.prose h2 { font: 650 clamp(1.4rem, 2.6vw, 1.75rem)/1.35 var(--f-body); letter-spacing: 0; margin: 56px 0 14px; display: flex; align-items: baseline; gap: 10px; }
.anchor { font: 400 1rem var(--f-mono); color: var(--muted); text-decoration: none; opacity: 0; transition: opacity .2s; }
.prose h2:hover .anchor, .anchor:focus-visible { opacity: 1; }
@media (hover: none) { .anchor { opacity: 1; } }
.prose :not(pre) > code { font: .9em var(--f-mono); padding: .1em .4em; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }
.prose a { color: var(--accent); text-underline-offset: 4px; text-decoration-thickness: 1.5px; }
.prose ul { padding-left: 1.2em; margin: 0 0 1.25em; }
.prose li { margin-bottom: .4em; }

figure { margin: 32px 0; }
figcaption { margin-top: 10px; color: var(--muted); font-size: .9rem; }
.diagram { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.diagram { overflow-x: auto; }
.diagram svg { display: block; width: 100%; min-width: 520px; height: auto; font-family: var(--f-body); }
[data-motion="on"] .diagram .stuck { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.table-wrap { overflow-x: auto; margin: 28px 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 650; background: var(--code-bg); }
tbody tr:last-child td { border-bottom: 0; }
td.num { font-family: var(--f-mono); text-align: right; }
th.num { text-align: right; }

/* 目录：跟随阅读位置高亮 */
.toc { position: sticky; top: calc(var(--header-h) + 24px); scroll-target-group: auto; }
.toc p { margin: 0 0 10px; font-size: .85rem; color: var(--muted); }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.toc a {
  display: block; padding: 6px 0 6px 14px; margin-left: -2px; border-left: 2px solid transparent;
  text-decoration: none; color: var(--muted); font-size: .93rem; line-height: 1.5;
  transition: color .2s, border-color .2s;
}
.toc a:hover { color: var(--ink); }
.toc a:is(:target-current, .target-current) { color: var(--ink); font-weight: 650; border-left-color: var(--accent); }
.toc-mobile { display: none; }

.after { border-top: 1px solid var(--line); margin-top: 48px; padding-top: 28px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
.pager a {
  display: grid; gap: 4px; padding: 18px 20px; border-radius: 16px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); transition: border-color .2s;
}
.pager a:hover { border-color: var(--accent); }
.pager small { color: var(--muted); }
.pager .next { text-align: right; }

@media (max-width: 1000px) {
  .article-layout { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
  .toc-mobile { display: block; margin: 0 0 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
  .toc-mobile summary { padding: 12px 16px; cursor: pointer; font-weight: 600; }
  .toc-mobile ol { margin: 0; padding: 0 16px 14px 36px; }
  .toc-mobile a { color: var(--muted); text-underline-offset: 4px; }
}
@media (max-width: 560px) { .pager { grid-template-columns: 1fr; } .pager .next { text-align: left; } }

/* Markdown 渲染出的元素 */
.prose blockquote { margin: 24px 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--lilac); color: var(--muted); }
.prose blockquote p:last-child, .note p:last-child { margin-bottom: 0; }
.note p { margin: 0 0 .8em; }
.note-warning { background: linear-gradient(120deg, var(--tint-butter), var(--tint-pink)); }
.prose img { display: block; max-width: 100%; height: auto; border-radius: 14px; margin: 28px auto; }
.prose h3 { margin: 32px 0 8px; font-size: 1.2rem; font-weight: 650; }
.prose hr { border: 0; border-top: 1px dashed var(--line); margin: 40px 0; }

th.center, td.center { text-align: center; }
.article-layout.no-toc { grid-template-columns: minmax(0, 68ch); }
.draft-badge { margin-left: 8px; padding: 2px 10px; border-radius: 999px; background: var(--draft-bg); color: var(--draft-fg); font-size: .85rem; }

/* 文章里的示意图：颜色跟随主题 */
.diagram .d-ink { fill: var(--ink); }
.diagram .d-muted { fill: var(--muted); }
.diagram .d-accent { fill: var(--accent); }
.diagram .d-line { stroke: var(--line); }
.diagram .d-accent-line { stroke: var(--accent); }
.diagram .d-muted-line { stroke: var(--muted); }
.diagram .stuck { fill: color-mix(in oklab, var(--pink) 32%, var(--surface)); stroke: light-dark(#E0457F, #FF8CC6); }
.diagram .d-stuck-title { fill: light-dark(#A0124F, #FFC2DD); }
