:root {
  --blog-size-small: 0.8125rem;
  --blog-size-label: 0.75rem;
  --blog-size-body: 1rem;
  --blog-size-card-title: 1.25rem;
  --blog-size-h2: 1.5rem;
  --blog-list-title: clamp(1.875rem, 1.15rem + 2.4vw, 3rem);
  --blog-article-title: clamp(1.5rem, 1.1rem + 1.4vw, 2rem);
  --blog-lead-size: clamp(0.9375rem, 0.85rem + 0.45vw, 1.125rem);
  --blog-weight-medium: 500;
  --blog-weight-bold: 700;
  --blog-weight-heavy: 800;
  --blog-line-body: 1.8;
  --blog-line-heading: 1.4;
  --blog-line-title: 1.32;
  --blog-tracking: 0.1em;
}

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

.blog-index main,
.article-page main,
.blog-post-grid,
#related-posts,
#post-nav {
  min-width: 0;
}

.blog-list-hero {
  padding-block: 3.5rem 3rem;
  background: linear-gradient(180deg, var(--bg), var(--bg-panel));
  border-bottom: 1px solid var(--border);
}

.blog-eyebrow {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--blog-size-label);
  font-weight: var(--blog-weight-medium);
  letter-spacing: var(--blog-tracking);
  line-height: 1.6;
}

.blog-list-hero h1 {
  margin: 0;
  max-width: 100%;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--blog-list-title);
  font-weight: var(--blog-weight-heavy);
  line-height: var(--blog-line-title);
  overflow-wrap: anywhere;
}

.blog-list-lead {
  max-width: var(--read-max);
  margin: 1.25rem 0 0;
  color: var(--text-muted);
  font-size: var(--blog-lead-size);
  line-height: 1.7;
}

.blog-topic-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem 1.5rem;
  padding: 1.25rem 0 0;
  margin: 1.75rem 0 0;
  border-top: 1px solid var(--border);
  list-style: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--blog-size-small);
}

.blog-list-section {
  padding-block: 2.5rem 4rem;
}

.blog-list-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 1.25rem;
}

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

.blog-result-count {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--blog-size-small);
}

.blog-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  margin-bottom: 2rem;
}

.blog-filters button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.625rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--blog-size-small);
  font-weight: var(--blog-weight-medium);
  line-height: 1.5;
  cursor: pointer;
  transition: border-color var(--motion-fast), background-color var(--motion-fast);
}

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

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

.blog-filters button:focus-visible,
.blog-post-card a:focus-visible,
.blog-related-card a:focus-visible,
.blog-post-nav-card:focus-visible,
.blog-download-dialog-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

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

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

.blog-post-card .article-meta,
.blog-related-card .article-meta,
.article-hero .article-meta,
.article-hero .post-meta,
.article-hero .blog-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.625rem 0.875rem;
  color: var(--text-muted);
  font-size: var(--blog-size-small);
  line-height: 1.6;
}

.blog-post-card time,
.blog-related-card time,
.article-hero time {
  font-family: var(--font-mono);
}

.blog-post-card .tag,
.blog-related-card .tag {
  max-width: 100%;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: var(--blog-size-small);
  white-space: normal;
  overflow-wrap: anywhere;
}

.blog-post-card h3,
.blog-related-card h3 {
  margin: 1rem 0 0;
  max-width: 100%;
  font-family: var(--font-display);
  font-size: var(--blog-size-card-title);
  font-weight: var(--blog-weight-bold);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

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

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

.blog-card-summary {
  margin: 1rem 0 1.5rem;
  color: var(--text-muted);
  font-size: var(--blog-size-body);
  line-height: var(--blog-line-body);
  overflow-wrap: anywhere;
}

.blog-post-card .article-link,
.blog-related-card .article-link {
  align-self: flex-start;
  margin-top: auto;
  padding-block: 0.375rem;
  color: var(--accent-dark);
  font-size: var(--blog-size-small);
  font-weight: var(--blog-weight-bold);
  text-decoration: none;
}

.blog-post-card .article-link:hover,
.blog-related-card .article-link: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(--radius);
  color: var(--text-muted);
  line-height: var(--blog-line-body);
}

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

.blog-breadcrumb,
nav.breadcrumb,
nav.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  max-width: 100%;
  padding-top: 0;
  margin-top: 1.5rem;
  margin-bottom: 1.25rem;
  overflow: hidden;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: var(--blog-size-small);
  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-dark);
}

.blog-breadcrumb > span:not([aria-current]),
nav.breadcrumb > span:not([aria-current]),
nav.breadcrumbs > span:not([aria-current]) {
  flex: 0 0 auto;
  color: var(--text-muted);
  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;
  color: var(--text-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section:has(.blog-breadcrumb),
.section:has(nav.breadcrumb),
.section:has(nav.breadcrumbs) {
  padding-top: 0.5rem;
  padding-bottom: 0;
}

.article-page .section,
.blog-article .section {
  padding-block: 1.5rem;
}

.article-page .section:has(.blog-breadcrumb),
.article-page .section:has(nav.breadcrumb),
.article-page .section:has(nav.breadcrumbs),
.blog-article .section:has(.blog-breadcrumb),
.blog-article .section:has(nav.breadcrumb),
.blog-article .section:has(nav.breadcrumbs) {
  padding-top: 0.5rem;
  padding-bottom: 0;
}

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

main.wrap:has(.article-body) h1 {
  font-size: var(--blog-article-title);
  line-height: var(--blog-line-title);
}

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

.article-hero .article-meta,
.article-hero .post-meta,
.article-hero .blog-meta {
  margin: 0 0 1rem;
}

.article-hero h1 {
  max-width: 100%;
  margin: 0.875rem 0 0.75rem;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--blog-article-title);
  font-weight: var(--blog-weight-heavy);
  line-height: var(--blog-line-title);
  overflow-wrap: anywhere;
}

.article-hero .article-lead,
.article-hero .blog-lead,
.article-hero .lead,
.article-hero h1 + p {
  margin: 1rem 0 0;
  color: var(--text-muted);
  font-size: var(--blog-lead-size);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.article-body {
  min-width: 0;
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--blog-size-body);
  line-height: var(--blog-line-body);
  overflow-wrap: anywhere;
}

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

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

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

.article-body h2 {
  max-width: 100%;
  margin: 2rem 0 1rem;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--blog-size-h2);
  font-weight: var(--blog-weight-bold);
  line-height: 1.5;
  scroll-margin-top: 6rem;
}

.article-body h2:first-of-type {
  margin-top: 0;
}

.article-body h3 {
  max-width: 100%;
  margin: 1.5rem 0 0.75rem;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--blog-size-card-title);
  font-weight: var(--blog-weight-bold);
  line-height: 1.5;
}

.article-body p,
.article-body ul,
.article-body ol {
  margin-block: 0 1rem;
}

.article-body ul,
.article-body ol {
  padding-inline-start: 1.5rem;
}

.article-body li + li {
  margin-top: 0.375rem;
}

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

.article-body a:not([class*="btn"]):not([class*="button"]):hover,
.prose a:not([class*="btn"]):not([class*="button"]):hover {
  text-decoration: underline;
}

.article-body :not(pre) > code {
  padding: 0.125rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9em;
  white-space: normal;
  overflow-wrap: anywhere;
}

.article-body pre {
  max-width: 100%;
  margin: 1.25rem 0;
  padding: 1.25rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--on-ink);
  font-family: var(--font-mono);
  font-size: var(--blog-size-small);
  line-height: 1.8;
  tab-size: 2;
}

.article-body pre code {
  padding: 0;
  border: 0;
  background: inherit;
  color: inherit;
  font-family: var(--font-mono);
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
}

.article-body blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-inline-start: 3px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-muted);
}

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

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

.article-body table {
  display: block;
  max-width: 100%;
  margin-block: 1.5rem;
  overflow-x: auto;
  border-collapse: collapse;
  color: var(--text);
  font-size: var(--blog-size-small);
}

.article-body .table-scroll table {
  display: table;
  min-width: 100%;
  margin: 0;
}

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

.article-body th {
  background: var(--bg);
  color: var(--text);
  font-weight: var(--blog-weight-bold);
}

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

.dl-card {
  margin-block: 2rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--tint-sky);
  color: var(--text);
}

.dl-card h2,
.article-body .dl-card h2 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: var(--blog-size-h2);
  line-height: 1.5;
}

.dl-card p {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.dl-card .article-download-actions,
.dl-card .dl-card-actions,
.dl-card .cta-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.dl-card > .btn {
  margin: 0.25rem 0.5rem 0.25rem 0;
}

#related-posts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 1rem;
  max-width: var(--read-max);
  margin: 1.25rem 0 2rem;
}

#related-posts .blog-related-card {
  padding: 1.25rem;
}

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

.blog-post-nav-card {
  display: block;
  min-width: 0;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  color: var(--text);
  text-decoration: none;
  transition: border-color var(--motion-fast);
}

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

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

.blog-post-nav-label {
  display: block;
  margin-bottom: 0.625rem;
  color: var(--text-muted);
  font-size: var(--blog-size-small);
}

.blog-post-nav-title {
  display: block;
  color: var(--text);
  font-size: var(--blog-size-body);
  font-weight: var(--blog-weight-bold);
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.blog-dialog-open {
  overflow: hidden;
}

.blog-download-dialog {
  width: min(30rem, calc(100% - 2rem));
  max-width: calc(100% - 2rem);
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  color: var(--text);
  font-family: var(--font-body);
  opacity: 1;
  transform: translateY(0);
}

.blog-download-dialog::backdrop {
  background: var(--veil);
}

.blog-download-dialog[open] {
  animation: blog-dialog-enter 160ms ease-out both;
}

.blog-download-dialog[open]::backdrop {
  animation: blog-backdrop-enter 160ms ease-out both;
}

.blog-download-dialog[open].is-closing {
  animation: blog-dialog-leave 160ms ease-in both;
}

.blog-download-dialog[open].is-closing::backdrop {
  animation: blog-backdrop-leave 160ms ease-in both;
}

.blog-download-dialog-panel {
  position: relative;
  padding: 2.25rem 2rem 2rem;
}

.blog-download-dialog-panel .blog-eyebrow {
  padding-right: 2rem;
}

.blog-download-dialog-panel h2 {
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--blog-size-h2);
  font-weight: var(--blog-weight-heavy);
  line-height: 1.5;
}

.blog-download-dialog-description {
  margin: 1rem 0 1.5rem;
  color: var(--text-muted);
  font-size: var(--blog-size-body);
  line-height: 1.8;
}

.blog-download-dialog-close {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--blog-size-h2);
  line-height: 1;
  cursor: pointer;
}

.blog-download-dialog-close:hover {
  border-color: var(--accent);
  background: var(--bg);
  color: var(--text);
}

@keyframes blog-dialog-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes blog-dialog-leave {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(8px); }
}

@keyframes blog-backdrop-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes blog-backdrop-leave {
  from { opacity: 1; }
  to { opacity: 0; }
}

@media (max-width: 1100px) {
  .blog-post-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .blog-list-hero {
    padding-block: 2.5rem 2rem;
  }

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

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

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

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

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

  .blog-post-card,
  .blog-related-card,
  .dl-card {
    padding: 1.25rem;
  }

  .blog-breadcrumb,
  nav.breadcrumb,
  nav.breadcrumbs {
    margin-top: 1.25rem;
  }

  .blog-download-dialog-panel {
    padding: 2.25rem 1.25rem 1.5rem;
  }

  .blog-download-dialog-panel .btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .blog-filters button,
  .blog-post-nav-card {
    transition: none;
  }

  .blog-download-dialog[open],
  .blog-download-dialog[open]::backdrop,
  .blog-download-dialog[open].is-closing,
  .blog-download-dialog[open].is-closing::backdrop {
    animation: none;
  }
}