:root {
  --blog-column: 56rem;
  --blog-gutter: clamp(1.5rem, 3vw, 2rem);
  --blog-copy-size: 1rem;
  --blog-copy-leading: 1.9;
  --blog-title-spacing: -0.015em;
  --blog-card-shadow: 0 12px 36px rgba(var(--accent-rgb), 0.08);
  --blog-band-grid: rgba(var(--accent-rgb), 0.055);
  --blog-soft-accent: color-mix(in srgb, var(--accent) 9%, var(--bg-panel));
  --blog-soft-warning: color-mix(in srgb, var(--warn) 10%, var(--bg-panel));
  --blog-soft-success: color-mix(in srgb, var(--success) 10%, var(--bg-panel));
  --blog-promo-start: var(--accent-dark);
  --blog-promo-end: color-mix(in srgb, var(--text) 72%, var(--accent));
  --blog-transition: 160ms ease;
}

.blog-index *,
.reading-wrap *,
.article-hero *,
.article-hero-band * {
  box-sizing: border-box;
}

.blog-index {
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

.blog-index h1,
.blog-index h2,
.blog-index h3,
.article-hero h1,
.article-hero-band h1,
.article-body h1,
.article-body h2,
.article-body h3,
#related-posts h2,
#related-posts h3,
.promo-block h2 {
  display: block;
  text-wrap: pretty;
  letter-spacing: var(--blog-title-spacing);
  overflow-wrap: break-word;
  font-family: var(--font-display);
  color: var(--text);
}

.blog-skip {
  position: fixed;
  top: 0.75rem;
  left: 1rem;
  z-index: 1000;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--white);
  transform: translateY(-200%);
}

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

.blog-index a:focus-visible,
.blog-index button:focus-visible,
.reading-wrap a:focus-visible,
.reading-wrap button:focus-visible,
.article-hero a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.reading-wrap,
.article-hero,
.article-hero-band > .reading-wrap,
.blog-breadcrumb.reading-wrap {
  box-sizing: border-box;
  width: 100%;
  max-width: calc(var(--blog-column) + var(--blog-gutter) + var(--blog-gutter));
  margin-inline: auto;
  padding-inline: var(--blog-gutter);
}

.blog-breadcrumb,
.breadcrumb,
.breadcrumbs {
  margin-top: 1.5rem;
  margin-bottom: 1.25rem;
  font-family: var(--font-body);
  font-size: var(--size-small);
  line-height: 1.8;
  color: var(--text-muted);
}

.blog-breadcrumb ol,
.breadcrumb ol,
.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.blog-breadcrumb li,
.breadcrumb li,
.breadcrumbs li {
  min-width: 0;
  overflow-wrap: anywhere;
}

.blog-breadcrumb li + li::before,
.breadcrumb li + li::before,
.breadcrumbs li + li::before {
  content: "/";
  margin-right: 0.6rem;
  color: var(--text-muted);
}

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

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

.blog-kicker {
  margin: 0 0 0.8rem;
  font-family: var(--font-mono);
  font-size: var(--size-small);
  color: var(--text-muted);
}

.blog-list-hero h1 {
  max-width: 24ch;
  margin: 0 0 1rem;
  font-size: clamp(2rem, 4.5vw, 3rem);
  font-weight: var(--weight-display);
  line-height: 1.25;
}

.blog-lede {
  max-width: 48rem;
  margin: 0;
  color: var(--text-muted);
  font-size: var(--size-lede);
  line-height: 1.85;
}

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

.blog-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.blog-filters button {
  min-height: 44px;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg-panel);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: var(--size-small);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: border-color var(--blog-transition), background var(--blog-transition);
}

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

.blog-filters button.is-active {
  background: var(--text);
  border-color: var(--text);
  color: var(--white);
}

.blog-list-status {
  min-height: 1.8em;
  margin: 1rem 0;
  color: var(--text-muted);
  font-size: var(--size-small);
}

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

.article-card.blog-post-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-top: 3px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  box-shadow: var(--blog-card-shadow);
  transition: border-color var(--blog-transition), transform var(--blog-transition);
}

.article-card.blog-post-card:hover,
.article-card.blog-post-card:focus-within {
  border-color: var(--accent);
  transform: translateY(-3px);
}

.article-meta {
  display: block;
  margin: 0 0 1rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  font-family: var(--font-body);
  font-size: var(--size-small);
  line-height: 1.8;
  color: var(--text-muted);
}

.article-meta time {
  font-family: var(--font-mono);
  font-size: inherit;
}

.article-category {
  color: var(--accent-dark);
}

.blog-post-card h3 {
  margin: 0 0 0.85rem;
  font-size: 1.2rem;
  font-weight: var(--weight-bold);
  line-height: 1.65;
}

.blog-post-card h3 a {
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}

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

.article-summary {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: var(--blog-copy-size);
  line-height: 1.85;
  overflow-wrap: anywhere;
}

.article-read-link {
  align-self: flex-start;
  margin-top: auto;
  color: var(--accent-dark);
  font-size: var(--size-small);
  font-weight: var(--weight-semibold);
  text-underline-offset: 0.25em;
}

.blog-empty {
  grid-column: 1 / -1;
  padding: 1.5rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  color: var(--text-muted);
  line-height: 1.85;
}

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

.article-hero-band {
  width: 100%;
  margin: 0;
  padding-block: 2rem 2.25rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background-color: var(--bg-panel2);
  background-image:
    linear-gradient(var(--blog-band-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--blog-band-grid) 1px, transparent 1px);
  background-size: 28px 28px;
}

.article-hero {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.article-hero:not(.article-hero-band .article-hero) {
  padding-block: 2rem;
  background: var(--bg-panel2);
}

.article-hero h1,
.article-hero-band h1 {
  margin: 0 0 1.1rem;
  font-size: clamp(1.8rem, 3.6vw, 2.6rem);
  font-weight: var(--weight-heavy);
  line-height: 1.4;
}

.article-hero .article-meta,
.article-hero-band .article-meta {
  display: block;
  margin: 0 0 0.8rem;
  text-align: left;
  color: var(--text-muted);
}

.article-hero .article-meta span,
.article-hero-band .article-meta span,
.article-hero .article-meta time,
.article-hero-band .article-meta time {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
}

.article-hero > p:last-child,
.article-hero-band .reading-wrap > p:last-child,
.article-hero .article-summary {
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: var(--blog-copy-size);
  line-height: var(--blog-copy-leading);
}

.prose.article-body,
[data-article-body] {
  counter-reset: blog-section;
  padding-top: 1.75rem;
  padding-bottom: 1.25rem;
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--blog-copy-size);
  line-height: var(--blog-copy-leading);
  overflow-wrap: anywhere;
}

.article-body p,
[data-article-body] p {
  margin-block: 0 1.25rem;
}

.article-body h2,
[data-article-body] h2 {
  display: block;
  position: relative;
  margin: 2.25rem 0 1rem;
  font-size: clamp(1.3rem, 2.5vw, 1.6rem);
  line-height: 1.55;
  font-weight: var(--weight-bold);
  text-wrap: pretty;
  letter-spacing: var(--blog-title-spacing);
  scroll-margin-top: var(--anchor-offset);
}

.article-body h2::before,
[data-article-body] h2::before {
  content: "";
  display: inline-block;
  width: 0.65rem;
  height: 1em;
  margin-right: 0.65rem;
  border-radius: var(--radius-xs);
  background: var(--accent);
  vertical-align: -0.12em;
}

.article-body > h2:first-child,
.article-body > section:first-child > h2:first-child,
[data-article-body] > h2:first-child,
[data-article-body] > section:first-child > h2:first-child {
  margin-top: 0;
}

.article-body h3,
[data-article-body] h3 {
  display: block;
  margin: 1.6rem 0 0.75rem;
  font-size: clamp(1.1rem, 2vw, 1.3rem);
  line-height: 1.65;
  font-weight: var(--weight-semibold);
  text-wrap: pretty;
  letter-spacing: var(--blog-title-spacing);
}

.article-body ul,
.article-body ol,
[data-article-body] ul,
[data-article-body] ol {
  margin-block: 0 1.5rem;
  padding-left: 1.5rem;
}

.article-body li,
[data-article-body] li {
  margin-block: 0.4rem;
}

.article-body a,
[data-article-body] a {
  color: var(--accent-dark);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

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

.article-body blockquote,
[data-article-body] blockquote {
  margin: 1.75rem 0;
  padding: 1.2rem 1.5rem;
  border-left: 4px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  color: var(--text-muted);
}

.article-body blockquote p:last-child,
[data-article-body] blockquote p:last-child {
  margin-bottom: 0;
}

.article-body .table-scroll,
[data-article-body] .table-scroll {
  max-width: 100%;
  margin-block: 1.5rem;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.article-body table,
[data-article-body] table {
  width: 100%;
  margin-block: 1.5rem;
  border-collapse: collapse;
  background: var(--bg-panel);
  font-size: var(--size-small);
  line-height: 1.8;
}

.article-body .table-scroll table,
[data-article-body] .table-scroll table {
  min-width: 660px;
  margin: 0;
}

.article-body th,
.article-body td,
[data-article-body] th,
[data-article-body] td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.article-body thead th,
[data-article-body] thead th {
  background: var(--bg-panel2);
  color: var(--text);
  font-weight: var(--weight-bold);
}

.article-body tbody tr:nth-child(even),
[data-article-body] tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--bg-panel2) 35%, var(--bg-panel));
}

.article-body tbody tr:hover,
[data-article-body] tbody tr:hover {
  background: var(--blog-soft-accent);
}

.article-body pre,
[data-article-body] pre {
  position: relative;
  max-width: 100%;
  margin: 1.5rem 0;
  padding: 2.7rem 1.25rem 1.25rem;
  overflow-x: auto;
  border: 1px solid var(--text-muted);
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg-panel);
  font-family: var(--font-mono);
  font-size: var(--size-small);
  line-height: 1.85;
  white-space: pre;
  overflow-wrap: normal;
}

.article-body pre::before,
[data-article-body] pre::before {
  content: "";
  position: absolute;
  top: 1rem;
  left: 1.25rem;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: var(--radius-dot);
  background: var(--error);
  box-shadow: 1rem 0 0 var(--warn), 2rem 0 0 var(--success);
}

.article-body code,
[data-article-body] code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.article-body :not(pre) > code,
[data-article-body] :not(pre) > code {
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-xs);
  background: var(--bg-panel2);
  color: var(--text);
  overflow-wrap: anywhere;
}

.article-body pre code,
[data-article-body] pre code {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: inherit;
}

.callout {
  position: relative;
  margin: 1.5rem 0;
  padding: 1.1rem 1.25rem 1.1rem 3.25rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--blog-soft-accent);
  color: var(--text);
}

.callout::before {
  content: "i";
  position: absolute;
  top: 1.15rem;
  left: 1rem;
  width: 1.3rem;
  height: 1.3rem;
  border: 1px solid var(--accent-dark);
  border-radius: var(--radius-dot);
  color: var(--accent-dark);
  font-family: var(--font-mono);
  font-size: var(--size-small);
  font-weight: var(--weight-bold);
  line-height: 1.2rem;
  text-align: center;
}

.callout.warning,
.callout.is-warning,
.callout-warning {
  border-left-color: var(--warn);
  background: var(--blog-soft-warning);
}

.callout.warning::before,
.callout.is-warning::before,
.callout-warning::before {
  content: "!";
  border-color: var(--warn);
  color: var(--text);
}

.callout.success,
.callout.is-success,
.callout-success {
  border-left-color: var(--success);
  background: var(--blog-soft-success);
}

.callout.success::before,
.callout.is-success::before,
.callout-success::before {
  border-color: var(--success);
  color: var(--text);
}

.callout p:last-child,
.verdict p:last-child {
  margin-bottom: 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  gap: 1rem;
  margin-block: 1.5rem;
}

.stat-card {
  min-width: 0;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--blog-soft-accent);
}

.stat-card:nth-child(even) {
  border-top-color: var(--text-muted);
  background: var(--bg-panel2);
}

.stat-num {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: var(--weight-bold);
  line-height: 1.4;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  display: block;
  color: var(--text-muted);
  font-size: var(--size-small);
  line-height: 1.8;
}

.article-body .check-list,
[data-article-body] .check-list {
  margin: 1.5rem 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  list-style: none;
}

.verdict {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--blog-soft-accent);
  color: var(--text);
}

.verdict strong:first-child {
  color: var(--accent-dark);
  font-weight: var(--weight-bold);
}

.blog-list-promo {
  padding-block: 0.5rem 2.5rem;
}

.promo-block {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-block: 1.5rem;
  padding: 2rem;
  overflow: hidden;
  border: 1px solid var(--accent-dark);
  border-radius: var(--radius-lg);
  background: linear-gradient(125deg, var(--blog-promo-start), var(--blog-promo-end));
  color: var(--white);
  box-shadow: var(--blog-card-shadow);
}

.promo-block::before {
  content: "";
  position: absolute;
  inset: 0.65rem;
  z-index: -1;
  border: 1px solid rgba(var(--white-rgb), 0.22);
  border-radius: var(--radius);
  pointer-events: none;
}

.promo-block .promo-copy {
  flex: 1 1 18rem;
  min-width: 0;
}

.promo-block h2 {
  margin: 0 0 0.6rem;
  color: var(--white);
  font-size: 1.5rem;
  line-height: 1.4;
}

.promo-block p {
  margin: 0;
  color: var(--white);
  font-size: var(--blog-copy-size);
  line-height: 1.8;
}

.blog-promo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.promo-block .btn-primary {
  border-color: var(--white);
  background: var(--white);
  color: var(--accent-dark);
}

.promo-block .btn-primary:hover {
  background: var(--bg-panel2);
  border-color: var(--bg-panel2);
  color: var(--text);
}

.promo-block .btn-secondary {
  border-color: rgba(var(--white-rgb), 0.7);
  background: transparent;
  color: var(--white);
}

.promo-block .btn-secondary:hover {
  background: rgba(var(--white-rgb), 0.12);
}

#related-posts {
  padding-block: 1.5rem;
}

#related-posts:empty,
#post-nav:empty {
  display: none;
}

#related-posts > h2 {
  margin: 0 0 1.1rem;
  font-size: 1.5rem;
  line-height: 1.5;
}

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

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

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

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

.post-nav-card:hover,
.post-nav-card:focus-visible {
  border-color: var(--accent);
  transform: translateY(-3px);
}

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

.post-nav-label {
  display: block;
  margin-bottom: 0.55rem;
  color: var(--accent-dark);
  font-family: var(--font-mono);
  font-size: var(--size-small);
}

.post-nav-card strong {
  display: block;
  font-size: var(--blog-copy-size);
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.post-nav-card .article-meta {
  margin: 0.8rem 0 0;
}

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

  .blog-related-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .article-body table,
  [data-article-body] table {
    display: block;
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
  }

  .article-body .table-scroll table,
  [data-article-body] .table-scroll table {
    display: table;
    width: 100%;
    max-width: none;
  }
}

@media (max-width: 640px) {
  .no-break {
    white-space: normal;
  }

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

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

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

  .blog-list-hero h1 {
    font-size: clamp(1.8rem, 8vw, 2.5rem);
  }

  .blog-lede {
    font-size: var(--blog-copy-size);
  }

  .article-hero-band {
    padding-block: 1.5rem 1.75rem;
  }

  .article-hero h1,
  .article-hero-band h1 {
    font-size: clamp(1.65rem, 6.5vw, 2rem);
  }

  .article-card.blog-post-card {
    padding: 1.25rem;
  }

  .promo-block {
    padding: 1.5rem;
  }

  .promo-block .promo-copy {
    flex-basis: 100%;
  }

  .article-body h2,
  [data-article-body] h2 {
    margin-top: 1.8rem;
  }

  .article-body pre,
  [data-article-body] pre {
    font-size: var(--size-caption);
  }
}

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

  .article-card.blog-post-card:hover,
  .article-card.blog-post-card:focus-within,
  .post-nav-card:hover,
  .post-nav-card:focus-visible {
    transform: none;
  }

  .blog-index,
  .reading-wrap {
    scroll-behavior: auto;
  }
}