/* 文章页专属排版样式。 */
header.site { border-bottom: 1px solid var(--line); }

/* ---------- 阅读排版 ---------- */
.article { padding: 68px 0 24px; }
/* 底板增加留白，宽屏正文仍保留原有的 680px 阅读宽度。 */
main.article { max-width: 794px; padding: 36px 24px 24px; }
.article-surface {
  position: relative;
  padding: 32px; border: 1px solid var(--line); border-radius: 20px;
  background: rgba(var(--accent-rgb), 0.045);
}
.back { font-size: 14px; color: var(--muted); transition: color 0.25s; }
.back:hover { color: var(--accent); }

.article-head { padding-bottom: 30px; border-bottom: 1px solid var(--line); margin-bottom: 38px; }
.article h1 { font-size: 30px; font-weight: 700; line-height: 1.45; letter-spacing: 0.5px; margin-top: 24px; }
.meta {
  display: flex; gap: 18px; margin-top: 16px;
  font-size: 13px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.article p {
  font-size: 17px; line-height: 1.95; letter-spacing: 0.2px;
  color: var(--ink); margin-bottom: 24px;
}
.article h2 { font-size: 21px; font-weight: 700; letter-spacing: 0.3px; margin: 46px 0 20px; }
.article h3 { font-size: 17px; font-weight: 600; margin: 34px 0 14px; }
.article ul, .article ol { margin: 0 0 24px; padding-left: 24px; }
.article li { font-size: 17px; line-height: 1.95; letter-spacing: 0.2px; margin-bottom: 10px; }
.article li::marker { color: var(--muted); }
.article li:last-child { margin-bottom: 0; }

.article hr { border: none; height: 1px; background: var(--line); margin: 42px 0; }
.article img { display: block; max-width: 100%; border-radius: 10px; margin: 30px auto; }
.article figure { margin: 30px 0; }
.article figure img { margin: 0 auto; }
.article figcaption { text-align: center; font-size: 13px; color: var(--muted); margin-top: 12px; }
.article table { width: 100%; border-collapse: collapse; margin: 30px 0; font-size: 15px; }
.article th, .article td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.article th { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 1px; }

:is(.article-body, .preview-body) :is(span[data-math="inline"], div[data-math="display"]) { overflow-wrap: anywhere; }
:is(.article-body, .preview-body) div[data-math="display"]:not(.math-rendered) { white-space: pre-wrap; }
:is(.article-body, .preview-body) span[data-math="inline"].math-rendered {
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
  vertical-align: bottom;
}
:is(.article-body, .preview-body) div[data-math="display"].math-rendered { overflow-x: auto; }
:is(.article-body, .preview-body) div[data-math="display"].math-rendered > .katex-display { min-width: max-content; }

.article a { border-bottom: 1px solid var(--line); transition: color 0.25s, border-color 0.25s; }
.article a:hover { color: var(--accent); border-color: var(--accent); }

.article code { font-family: var(--mono); }
.article :not(pre) > code {
  font-size: 0.84em;
  background: var(--inline-bg);
  color: var(--ink);
  padding: 2px 7px;
  border-radius: 5px;
}

.code {
  margin: 30px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--code-bg);
  overflow: hidden;
}
.code-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 8px 16px;
  border-bottom: 1px solid var(--line);
}
.code-head .file { min-width: 0; overflow-wrap: anywhere; font-size: 12px; color: var(--muted); }
.code-head .file, .code pre code { font-family: var(--mono); }
.code-head .lang { max-width: 40%; margin-left: auto; overflow-wrap: anywhere; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.code-head .code-copy {
  flex: 0 0 auto; display: inline-flex; justify-content: center; align-items: center;
  width: 28px; height: 28px; min-width: 28px; margin-left: auto; padding: 5px;
  border: 1px solid transparent; border-radius: 5px;
  background: transparent; color: var(--ink-soft); font: inherit; font-size: 12px; line-height: 1.5;
  white-space: nowrap; cursor: pointer;
}
.code-copy svg { display: block; width: 16px; height: 16px; pointer-events: none; }
.code-copy-status { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.code-head .lang + .code-copy { margin-left: 0; }
.code-head .code-copy:hover, .code-head .code-copy:focus-visible { color: var(--accent); background: var(--inline-bg); border-color: transparent; }
.code-head .code-copy:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.code-head .code-copy[aria-busy="true"] { opacity: 0.65; cursor: wait; }
.code pre { padding: 16px 18px; overflow-x: auto; }
.code pre code { font-size: 13.5px; line-height: 1.8; color: var(--ink-soft); }
.code .k { color: var(--accent); }
.code .c { color: var(--muted); }

.article blockquote {
  margin: 30px 0;
  padding: 2px 0 2px 20px;
  border-left: 2px solid var(--accent);
}
.article blockquote p { font-size: 16px; line-height: 1.9; color: var(--ink-soft); margin-bottom: 10px; }
.article blockquote p:last-child { margin-bottom: 0; }
.article blockquote .src { font-size: 13px; color: var(--muted); margin-top: 10px; }

.article-end { margin-top: 64px; padding-top: 26px; border-top: 1px solid var(--line); }

/* 目录独立放在阅读底板左侧，保留正文的宽度和居中位置。 */
.article-toc[hidden] { display: none; }
.article-toc { --toc-toggle-size: 28px; margin-bottom: 32px; }
.article-toc-panel {
  padding: 16px; border: 1px solid var(--line); border-radius: 12px;
  background:
    linear-gradient(rgba(var(--accent-rgb), 0.045), rgba(var(--accent-rgb), 0.045)),
    rgba(var(--bg-rgb), 0.5);
}
.article-toc-heading {
  display: grid; grid-template-columns: minmax(0, 1fr) var(--toc-toggle-size); align-items: center; gap: 16px;
  min-height: 36px; color: var(--ink-soft); font-size: 12px; letter-spacing: 2px;
  list-style: none; cursor: pointer;
}
.article-toc-heading::-webkit-details-marker { display: none; }
.article-toc-heading > .article-toc-chevron { justify-self: center; }
.article-toc-panel[open] > .article-toc-heading { padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.article-toc-chevron {
  display: block; flex: 0 0 auto; width: 7px; height: 7px;
  border: solid currentColor; border-width: 0 1.5px 1.5px 0;
  transform: rotate(-45deg); pointer-events: none;
}
.article-toc-panel[open] > .article-toc-heading .article-toc-chevron,
.article-toc-toggle[aria-expanded="true"] .article-toc-chevron { transform: rotate(45deg); }
.article .article-toc-list, .article .article-toc-children { list-style: none; padding: 0; margin: 0; }
.article .article-toc li { font-size: 13px; line-height: 1.7; letter-spacing: 0; margin: 0; }
.article .article-toc-group + .article-toc-group { margin-top: 14px; }
.article-toc-row { display: grid; grid-template-columns: minmax(0, 1fr) var(--toc-toggle-size); gap: 4px; align-items: start; border-radius: 5px; }
.article .article-toc-link { display: block; padding: 6px 8px; border: 0; border-radius: 5px; color: var(--ink-soft); overflow-wrap: anywhere; }
.article .article-toc-chapter { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 8px; padding-left: 0; padding-right: 0; }
.article-toc-number { padding-top: 2px; font-size: 11px; font-variant-numeric: tabular-nums; }
.article-toc-label { text-wrap: balance; }
.article-toc-toggle {
  display: flex; align-items: center; justify-content: center; width: var(--toc-toggle-size); height: 34px;
  padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--ink-soft); cursor: pointer;
}
.article .article-toc-link:hover, .article-toc-toggle:hover,
.article .article-toc-link[aria-current="location"] { color: var(--ink); }
.article-toc-row:hover, .article-toc-row:has(> .article-toc-link[aria-current="location"]),
.article .article-toc-children .article-toc-link:hover,
.article .article-toc-children .article-toc-link[aria-current="location"] { background: var(--inline-bg); }
.article .article-toc-link:focus-visible, .article-toc-toggle:focus-visible,
.article-toc-heading:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.article .article-toc-children { padding-top: 4px; margin-left: 28px; }
.article-toc-children[hidden] { display: none; }
.article-toc-group.is-current .article-toc-number { color: var(--accent); }
.article-body :is(h2, h3) { scroll-margin-top: 32px; }

@media (min-width: 1200px) {
  .article-toc { position: absolute; top: 32px; bottom: 0; right: calc(100% + 24px); width: min(240px, calc((100vw - 794px) / 2 - 16px)); margin: 0; }
  .article-toc-panel { position: sticky; top: 24px; }
  .article-toc-panel nav { max-height: calc(100dvh - 136px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
}

@media (max-width: 1199px) {
  .article-toc { --toc-toggle-size: 44px; }
  .article-toc-heading, .article .article-toc-link { min-height: 44px; }
  .article-toc-toggle { height: 44px; }
  .article-toc-row .article-toc-link { padding-top: 10px; }
}

@media (max-width: 600px) {
  main.article { padding: 24px 12px; }
  .article-surface { padding: 24px 16px; border-radius: 16px; }
}
