.blog-index,
.article-page {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

.blog-main {
  padding-block: 0 4rem;
}

.blog-hero {
  padding-block: 3rem 2rem;
}

.blog-eyebrow {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
}

.blog-hero h1 {
  max-width: 100%;
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 1.2rem + 2vw, 3rem);
  font-weight: 400;
  line-height: 1.3;
  overflow-wrap: break-word;
}

.blog-intro {
  max-width: 48rem;
  margin: 1.25rem 0 0;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.8;
}

.blog-catalog {
  padding-block: 0 1rem;
}

.blog-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
}

.blog-filter button {
  min-height: 44px;
  padding: 0.625rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--panel);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.875rem;
  line-height: 1.5;
  cursor: pointer;
  transition: border-color var(--duration) var(--ease-out),
    color var(--duration) var(--ease-out),
    background-color var(--duration) var(--ease-out);
}

.blog-filter button:hover {
  border-color: var(--accent);
  color: var(--text);
}

.blog-filter button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg);
}

.blog-filter button:focus-visible,
.post-card a:focus-visible,
.post-nav-card:focus-visible,
.blog-breadcrumb a:focus-visible,
nav.breadcrumb a:focus-visible,
nav.breadcrumbs a:focus-visible,
.blog-skip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.blog-count {
  margin: 1.25rem 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.blog-post-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.blog-post-grid > *,
#related-posts > * {
  min-width: 0;
}

.blog-post-grid .post-card,
#related-posts .post-card {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 1.75rem;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--panel);
}

.post-card .post-meta,
.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.625rem 1rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
  line-height: 1.7;
}

.post-card .chip,
.article-meta .chip {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--panel-2);
  color: var(--text-soft);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.post-card h3 {
  margin: 1.125rem 0 0.875rem;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.55;
  overflow-wrap: break-word;
}

.post-card h3 a {
  color: inherit;
  text-decoration: none;
}

.post-card h3 a:hover {
  color: var(--accent);
}

.post-card .post-summary {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.85;
}

.post-card .post-link {
  align-self: flex-start;
  margin-top: auto;
  padding-block: 0.25rem;
  color: var(--accent);
  font-size: 0.875rem;
  line-height: 1.6;
  text-decoration: none;
}

.post-card .post-link:hover {
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.blog-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  color: var(--text-muted);
  line-height: 1.8;
}

.blog-empty a {
  color: var(--accent);
  text-underline-offset: 0.2em;
}

.blog-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.blog-skip {
  position: absolute;
  z-index: 100;
  top: 0.5rem;
  left: 1rem;
  padding: 0.75rem 1rem;
  transform: translateY(-200%);
  border: 1px solid var(--accent);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}

.blog-skip:focus {
  transform: translateY(0);
}

main.reading:has(.article-body) {
  padding-top: 2rem;
}

/* 文章首屏采用紧凑节奏，不继承首页分区留白。 */
.article-page main,
.article-main {
  padding-top: 0;
}

.article-page main > .section:first-child,
.article-page main > .sec:first-child,
.section:has(.blog-breadcrumb),
.section:has(nav.breadcrumb),
.section:has(nav.breadcrumbs),
.sec:has(.blog-breadcrumb),
.sec:has(nav.breadcrumb),
.sec:has(nav.breadcrumbs) {
  padding-top: 0;
  padding-bottom: 0;
}

.blog-breadcrumb,
nav.breadcrumb,
nav.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.5rem;
  max-width: 100%;
  margin-top: 1.5rem;
  margin-bottom: 1.25rem;
  padding-block: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.7;
  white-space: nowrap;
}

.blog-breadcrumb a,
nav.breadcrumb a,
nav.breadcrumbs a {
  flex: 0 0 auto;
  color: var(--text-muted);
  text-decoration: none;
}

.blog-breadcrumb a:hover,
nav.breadcrumb a:hover,
nav.breadcrumbs a:hover {
  color: var(--accent);
}

.blog-breadcrumb [aria-hidden="true"],
nav.breadcrumb [aria-hidden="true"],
nav.breadcrumbs [aria-hidden="true"] {
  flex: 0 0 auto;
  color: var(--text-faint);
}

.blog-breadcrumb [aria-current="page"],
nav.breadcrumb [aria-current="page"],
nav.breadcrumbs [aria-current="page"] {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 30ch;
  overflow: hidden;
  color: var(--text-muted);
  text-overflow: ellipsis;
}

.article-hero,
.article-hero.section,
.article-hero.sec {
  margin: 0;
  padding-block: 0.5rem 1.5rem;
}

.article-hero .article-meta,
.article-hero .post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.625rem 1rem;
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.7;
}

main.reading:has(.article-body) h1,
.article-hero h1,
.article-body h1,
.article-page .prose h1 {
  max-width: 100%;
  margin: 1rem 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2rem);
  font-weight: 400;
  line-height: 1.32;
  overflow-wrap: break-word;
}

.article-hero .article-lead,
.article-hero .article-summary,
.article-hero > p:not(.article-meta):not(.post-meta) {
  margin: 1rem 0 0;
  color: var(--text-muted);
  font-size: clamp(0.9375rem, 0.85rem + 0.45vw, 1.125rem);
  line-height: 1.7;
}

.article-body,
.article-page .prose {
  min-width: 0;
  color: var(--text-soft);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.9;
  overflow-wrap: break-word;
}

.article-body,
.article-body.sec,
.article-body.section,
.article-page .prose.sec,
.article-page .prose.section {
  padding-top: 0;
  padding-bottom: 2rem;
}

.article-body section,
.article-page .prose section {
  margin-block: 0 1.75rem;
  padding-block: 0;
}

.article-body h2,
.article-page .prose h2 {
  max-width: 100%;
  margin: 2rem 0 1rem;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 1rem + 0.7vw, 1.5rem);
  font-weight: 500;
  line-height: 1.5;
  scroll-margin-top: calc(var(--topbar-h) + 1rem);
}

.article-body > h2:first-child,
.article-body > section:first-child > h2:first-child,
.article-body > h2:first-of-type,
.article-page .prose > h2:first-child,
.article-page .prose > section:first-child > h2:first-child {
  margin-top: 0;
}

.article-body h3,
.article-page .prose h3 {
  margin: 1.5rem 0 0.75rem;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(1.125rem, 1rem + 0.4vw, 1.25rem);
  font-weight: 500;
  line-height: 1.55;
}

.article-body p,
.article-page .prose p {
  margin: 0 0 1rem;
}

.article-body ul,
.article-body ol,
.article-page .prose ul,
.article-page .prose ol {
  margin: 0 0 1.25rem;
  padding-left: 1.5rem;
}

.article-body li,
.article-page .prose li {
  margin-block: 0.375rem;
}

.article-body a:not([class*="btn"]):not([class*="button"]),
.article-page .prose a:not([class*="btn"]):not([class*="button"]) {
  color: var(--accent);
  text-underline-offset: 0.2em;
}

.article-body code,
.article-page .prose code {
  padding: 0.125rem 0.3rem;
  border-radius: var(--r-xs);
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.875em;
}

.article-body pre,
.article-page .prose pre {
  max-width: 100%;
  margin: 1.25rem 0;
  padding: 1.25rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.75;
  tab-size: 2;
  white-space: pre;
  overflow-wrap: normal;
}

.article-body pre code,
.article-page .prose pre code {
  padding: 0;
  border-radius: var(--r-micro);
  background: var(--clear);
  color: inherit;
  font-size: inherit;
}

.article-body blockquote,
.article-page .prose blockquote {
  margin: 1.25rem 0;
  padding: 0.75rem 1.25rem;
  border-left: 2px solid var(--accent);
  color: var(--text-muted);
}

.article-body blockquote > :last-child,
.article-page .prose blockquote > :last-child {
  margin-bottom: 0;
}

.article-body .table-scroll,
.article-page .prose .table-scroll {
  max-width: 100%;
  margin-block: 1.25rem;
  overflow-x: auto;
}

.article-body table,
.prose table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text-soft);
  font-size: 0.9375rem;
  line-height: 1.7;
}

.article-body th,
.article-body td,
.prose th,
.prose td {
  min-width: 7em;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: normal;
  word-break: normal;
}

.article-body th,
.prose th {
  background: var(--panel-2);
  color: var(--text);
  font-weight: 500;
}

.article-body img,
.article-body svg,
.article-page .prose img {
  max-width: 100%;
  height: auto;
}

.article-download {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  margin-block: 2rem 0;
  padding: 1.75rem;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--panel);
}

.article-download > div {
  min-width: 0;
}

.article-body .article-download h2,
.article-page .prose .article-download h2,
.article-download h2 {
  margin: 0 0 0.625rem;
  font-size: 1.375rem;
  line-height: 1.5;
}

.article-body .article-download p,
.article-page .prose .article-download p,
.article-download p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.75;
}

.article-download .action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0;
}

#related-posts {
  display: grid;
  grid-template-columns: repeat(2, minmax(300px, 1fr));
  gap: 1rem;
  margin-block: 2rem;
  padding-block: 0;
}

#related-posts .related-heading {
  grid-column: 1 / -1;
  margin: 0 0 0.25rem;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.5;
}

#related-posts .post-card {
  padding: 1.5rem;
}

#related-posts .post-card h3 {
  font-size: 1.125rem;
}

#post-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-block: 1.5rem 3rem;
}

#post-nav .post-nav-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

#post-nav .post-nav-card:hover {
  border-color: var(--accent);
}

.post-nav-label {
  color: var(--accent);
  font-size: 0.875rem;
  line-height: 1.6;
}

.post-nav-title {
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.75;
  overflow-wrap: break-word;
}

.post-nav-date {
  margin-top: auto;
  color: var(--text-muted);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.post-nav-next {
  grid-column: 2;
}

#related-posts[hidden],
#post-nav[hidden] {
  display: none;
}

@media (max-width: 700px) {
  .blog-hero {
    padding-block: 2rem 1.5rem;
  }

  .blog-hero h1 {
    font-size: 1.75rem;
  }

  .blog-post-grid,
  #related-posts,
  #post-nav {
    grid-template-columns: minmax(0, 1fr);
  }

  .blog-post-grid .post-card,
  #related-posts .post-card,
  #post-nav .post-nav-card,
  .article-download {
    padding: 1.25rem;
  }

  .post-nav-next {
    grid-column: auto;
  }

  .article-hero h1,
  .article-body h1,
  .article-page .prose h1 {
    font-size: 1.5rem;
  }

  .article-hero,
  .article-hero.section,
  .article-hero.sec {
    padding-block: 0.25rem 1.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .blog-filter button {
    transition: none;
  }
}