:root {
  --blog-list-h1: clamp(1.75rem, 1.25rem + 2vw, 3rem);
  --blog-article-h1: clamp(1.5rem, 1.1rem + 1.4vw, 2rem);
  --blog-lead-size: clamp(0.9375rem, 0.85rem + 0.45vw, 1.125rem);
  --blog-h2-size: 1.5rem;
  --blog-h3-size: 1.25rem;
  --blog-meta-size: 0.8125rem;
  --blog-card-size: 1.125rem;
  --blog-code-size: 0.875rem;
}

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

.blog-hero {
  padding-block: 1.5rem 2.5rem;
  border-bottom: 1px solid var(--border);
}

.blog-eyebrow,
.blog-intro,
.blog-result {
  color: var(--muted);
}

.blog-eyebrow {
  margin: 0 0 1rem;
  font-size: var(--blog-meta-size);
}

.blog-hero h1 {
  display: block;
  max-width: 100%;
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--blog-list-h1);
  font-weight: var(--weight-heading);
  line-height: 1.25;
}

.blog-intro {
  max-width: var(--reading);
  margin: 1.25rem 0 0;
  font-size: var(--blog-lead-size);
  line-height: 1.8;
}

.blog-topic-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.blog-topic-line span {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--panel);
  color: var(--muted);
  font-size: var(--blog-meta-size);
}

.blog-catalog {
  padding-top: 2rem;
}

.blog-catalog__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.blog-catalog__head h2 {
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--blog-h2-size);
  font-weight: var(--weight-heading);
}

.blog-result {
  margin: 0;
  font-size: var(--blog-meta-size);
}

.blog-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  margin-block: 1.25rem 1.75rem;
}

.blog-filters button {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--bg);
  color: var(--muted);
  font-family: var(--font-body);
  font-size: var(--small-size);
  line-height: 1.5;
  cursor: pointer;
}

.blog-filters button:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--panel);
}

.blog-filters button[aria-pressed="true"] {
  background: var(--panel-2);
  border-color: var(--border-strong);
  color: var(--text);
}

.blog-filters button:active {
  transform: translateY(1px);
}

.blog-filters button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.blog-filters button:focus-visible,
.blog-main a:focus-visible,
.article-hero a:focus-visible,
.blog-breadcrumb a:focus-visible,
nav.breadcrumb a:focus-visible,
nav.breadcrumbs a:focus-visible,
#related-posts a:focus-visible,
#post-nav a:focus-visible,
.blog-skip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

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

.blog-post-grid .post-card,
#related-posts .post-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-edge), var(--shadow-float);
}

.blog-post-grid .post-card__meta,
#related-posts .post-card__meta,
.article-meta,
.article-hero__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: var(--blog-meta-size);
  line-height: 1.6;
}

.blog-post-grid .tag,
#related-posts .tag,
.article-meta .tag,
.article-hero__meta .tag {
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--panel);
  color: var(--muted);
  font-size: var(--blog-meta-size);
}

.blog-post-grid .post-card h3,
#related-posts .post-card h3 {
  display: block;
  margin: 1rem 0 0;
  font-family: var(--font-display);
  font-size: var(--blog-card-size);
  font-weight: var(--weight-heading);
  line-height: 1.65;
  overflow-wrap: break-word;
}

.blog-post-grid .post-card h3 a,
#related-posts .post-card h3 a {
  color: var(--text);
  text-decoration: none;
}

.blog-post-grid .post-card h3 a:hover,
#related-posts .post-card h3 a:hover {
  color: var(--accent-dark);
}

.blog-post-grid .post-card__summary,
#related-posts .post-card__summary {
  margin: 0.875rem 0 1.25rem;
  color: var(--muted);
  font-size: var(--small-size);
  line-height: 1.85;
}

.blog-post-grid .post-card .read-more,
#related-posts .post-card .read-more {
  align-self: flex-start;
  margin-top: auto;
  color: var(--accent-dark);
  font-size: var(--small-size);
  text-decoration: none;
}

.blog-post-grid .read-more:hover,
#related-posts .read-more:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

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

.blog-empty a {
  color: var(--accent-dark);
}

.blog-skip {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 1000;
  padding: 0.75rem 1rem;
  transform: translateY(-200%);
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

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

main.wrap--reading:has(> article) {
  padding-top: 32px;
}

/* 文章页的首屏与正文使用独立的紧凑节奏。 */
body:has(.article-hero) main,
body:has(.article-header) main {
  padding-top: 0;
}

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

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

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

.blog-breadcrumb [aria-hidden="true"],
nav.breadcrumb [aria-hidden="true"],
nav.breadcrumbs [aria-hidden="true"] {
  flex: 0 0 auto;
  opacity: 0.35;
}

.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;
  text-overflow: ellipsis;
}

.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;
}

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

.article-meta,
.article-hero__meta {
  margin: 0 0 1rem;
}

main.wrap--reading > article > header h1,
.article-hero h1,
.article-header h1 {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 1rem 0 0.75rem;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--blog-article-h1);
  font-weight: var(--weight-heading);
  line-height: 1.32;
  overflow-wrap: break-word;
}

.article-lead,
.article-hero__lead,
.article-hero > p:not(.article-meta):not(.article-hero__meta),
.article-header > p:not(.article-meta):not(.article-hero__meta) {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: var(--blog-lead-size);
  line-height: 1.7;
}

.article-body,
.article-content {
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--body-size);
  line-height: 1.85;
}

.article-body,
.article-content,
.article-hero + .prose,
.article-header + .prose {
  padding-top: 0;
}

.article-body section,
.article-content section,
.prose section {
  margin-block: 0;
  padding-block: 0;
}

.article-body section + section,
.article-content section + section,
.prose section + section {
  margin-top: 2rem;
}

.article-body h2,
.article-content h2,
.prose h2 {
  display: block;
  margin: 2rem 0 1rem;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--blog-h2-size);
  font-weight: var(--weight-heading);
  line-height: 1.5;
}

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

.article-body h3,
.article-content h3,
.prose h3 {
  display: block;
  margin: 1.5rem 0 0.75rem;
  font-family: var(--font-display);
  font-size: var(--blog-h3-size);
  font-weight: var(--weight-heading);
  line-height: 1.55;
}

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

.article-body ul,
.article-body ol,
.article-content ul,
.article-content ol,
.prose ul,
.prose ol {
  margin-block: 0.75rem 1.25rem;
  padding-left: 1.5rem;
}

.article-body li + li,
.article-content li + li,
.prose li + li {
  margin-top: 0.5rem;
}

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

.article-body pre,
.article-content pre,
.prose pre {
  max-width: 100%;
  margin-block: 1.25rem;
  padding: 1.25rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--panel);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--blog-code-size);
  line-height: 1.75;
  white-space: pre;
}

.article-body code,
.article-content code,
.prose code {
  font-family: var(--font-mono);
  font-size: var(--blog-code-size);
}

.article-body :not(pre) > code,
.article-content :not(pre) > code,
.prose :not(pre) > code {
  padding: 0.1em 0.3em;
  border-radius: var(--r-sm);
  background: var(--panel-2);
  color: var(--text);
  overflow-wrap: anywhere;
}

.article-body pre code,
.article-content pre code,
.prose pre code {
  padding: 0;
  border: 0;
  background: var(--clear);
  white-space: inherit;
  overflow-wrap: normal;
}

.article-body blockquote,
.article-content blockquote,
.prose blockquote {
  margin: 1.25rem 0;
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--border-strong);
  background: var(--panel);
  color: var(--muted);
}

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

.prose table {
  display: block;
  max-width: 100%;
  margin-block: 1.25rem;
  overflow-x: auto;
  border-collapse: collapse;
}

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

.prose th {
  background: var(--panel);
  color: var(--text);
  font-weight: var(--weight-medium);
}

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

.article-download > div {
  flex: 1 1 18rem;
  min-width: 0;
}

.article-download h2,
.prose .article-download h2 {
  margin: 0 0 0.75rem;
  font-size: var(--blog-h2-size);
}

.article-download p,
.prose .article-download p {
  margin: 0;
  color: var(--muted);
}

.article-download__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

#related-posts {
  margin-block: 1.25rem 2rem;
}

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

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

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

.post-nav-card__label,
.post-nav-card time {
  color: var(--muted);
  font-size: var(--blog-meta-size);
}

.post-nav-card__title {
  color: var(--text);
  font-size: var(--body-size);
  line-height: 1.7;
  overflow-wrap: break-word;
}

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

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

@media (max-width: 700px) {
  .blog-post-grid,
  #related-posts,
  #post-nav {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .blog-main {
    padding-block: 1rem 2.5rem;
  }

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

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

  .article-hero h1,
  .article-header h1 {
    font-size: 1.5rem;
  }

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

  .blog-filters {
    gap: 0.5rem;
  }

  .blog-filters button {
    padding: 0.55rem 0.875rem;
  }
}