.site-header-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem 1.75rem 1rem;
}

.brand {
  color: var(--ink);
  flex-shrink: 0;
  font-size: 1.08rem;
  font-weight: 780;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.nav {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  font-size: 1rem;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.nav a:hover {
  color: var(--accent);
}

.header-rule {
  position: relative;
  height: 2.75rem;
}

.header-rule::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 50%;
  height: 1px;
  background: var(--line);
}

.header-rule-inner {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--shell-gap);
  max-width: var(--shell-width);
  height: 100%;
  margin: 0 auto;
  padding-inline: var(--shell-pad-x);
}

.header-tools {
  grid-column: 1;
  justify-self: end;
  align-self: center;
  display: flex;
  gap: 0.5rem;
  padding-inline: 0.5rem;
  background: var(--bg);
  position: relative;
  z-index: 1;
}

.theme-toggle,
.palette-pick {
  flex-shrink: 0;
  width: 2.2rem;
  height: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}

.theme-toggle:hover,
.palette-pick:hover {
  background: var(--code-bg);
  color: var(--ink);
}

.palette-pick {
  font-size: 0.9rem;
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--shell-gap);
  max-width: var(--shell-width);
  margin: 0 auto;
  padding: 5rem var(--shell-pad-x) 6rem;
}

.content {
  width: 100%;
  max-width: var(--content-width);
}

.article-kicker {
  display: flex;
  gap: 0.65rem;
  margin: 0 0 1.15rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-transform: uppercase;
}

.article-kicker span + span::before {
  content: "\00b7";
  margin-right: 0.65rem;
  color: var(--muted);
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin: 0 0 1.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.breadcrumbs a {
  color: var(--muted);
  text-decoration: none;
}

.breadcrumbs a::after {
  content: "/";
  margin-left: 0.4rem;
  color: var(--line);
}

.breadcrumbs a:hover {
  color: var(--accent);
}

.breadcrumbs [aria-current="page"] {
  color: var(--ink);
}

.toc {
  display: none;
}

.toc-title {
  margin-bottom: 0.75rem;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.toc-nav {
  display: grid;
  gap: 0.35rem;
}

.toc-link {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
  text-decoration: none;
}

.toc-link:hover {
  color: var(--accent);
}

.toc-link-h3 {
  padding-left: 0.85rem;
  font-size: 0.84rem;
}

@media (min-width: 1100px) {
  .page-shell {
    grid-template-columns: minmax(0, var(--content-width)) var(--sidebar-width);
    align-items: start;
  }

  .header-rule-inner {
    grid-template-columns: minmax(0, var(--content-width)) var(--sidebar-width);
  }

  .toc:not([hidden]) {
    display: block;
    position: sticky;
    top: 2rem;
    max-height: calc(100vh - 4rem);
    overflow: auto;
    padding-top: 0.35rem;
  }
}

@media (max-width: 640px) {
  .site-header-row {
    padding: 1rem 1.2rem 0.75rem;
    gap: 0.75rem;
  }

  .nav {
    gap: 0.6rem;
  }

  .page-shell {
    padding: 3rem 1.2rem 4rem;
  }

  h1 {
    margin-bottom: 1.5rem;
    font-size: clamp(2rem, 11vw, 3.4rem);
  }

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

.site-footer {
  text-align: center;
  padding: 2rem 1.75rem 3rem;
}

.site-footer a {
  color: var(--muted);
  font-size: 0.82rem;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
}

.footer-sponsor {
  margin-top: 1.25rem;
}

.sponsor-btn {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent) !important;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.sponsor-btn:hover {
  background: color-mix(in oklab, var(--accent), var(--bg) 85%);
  border-color: var(--accent);
}

.sponsor-note {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  max-width: none;
}
