:root,
[data-theme="light"] {
  --bg: #ffffff;
  --surface: #f7f7f7;
  --text: #181418;
  --text-secondary: #625c62;
  --border: #d9d5d9;
  --border-strong: #aaa3aa;
  --accent: #8d4f8d;
  --accent-hover: #744074;
  --nav-surface: rgba(255, 255, 255, 0.96);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #050505;
  --surface: #0d0b0e;
  --text: #f5f3f5;
  --text-secondary: #aaa4aa;
  --border: #29262a;
  --border-strong: #555056;
  --accent: #b875b8;
  --accent-hover: #cc8ecc;
  --nav-surface: rgba(5, 5, 5, 0.96);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
}

a {
  color: inherit;
  text-decoration: none;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  transform: translateY(-150%);
  padding: 8px 10px;
  border-radius: 3px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 700;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: var(--nav-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.site-header-inner {
  width: min(1040px, calc(100% - 40px));
  min-height: 58px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 0.98rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 27px;
  height: 27px;
  object-fit: contain;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--text);
}

.site-nav .nav-cta {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 13px;
  border-radius: 4px;
  background: var(--accent);
  color: #ffffff;
}

.site-nav .nav-cta:hover {
  background: var(--accent-hover);
  color: #ffffff;
}

.blog-main,
.article-main {
  width: min(1040px, calc(100% - 40px));
  margin: 0 auto;
  padding: 0 0 64px;
}

.blog-masthead {
  max-width: 760px;
  padding: 54px 0 46px;
}

.blog-masthead h1,
.article-masthead h1 {
  margin: 0;
  font-size: clamp(2.1rem, 3.4vw, 2.65rem);
  line-height: 1.12;
  letter-spacing: -0.04em;
}

.blog-masthead p,
.article-dek {
  max-width: 720px;
  margin: 18px 0 0;
  color: var(--text-secondary);
  font-size: 0.96rem;
  line-height: 1.7;
}

.section-intro {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
  padding: 18px 0;
  border-top: 1px solid var(--border-strong);
}

.section-intro h2 {
  margin: 0;
  color: var(--accent);
  font-size: 0.77rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  line-height: 1.4;
  text-transform: uppercase;
}

.section-intro p {
  max-width: 62ch;
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.86rem;
}

.post-list {
  border-top: 1px solid var(--border);
}

.post-card {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 90px;
  gap: 28px;
  align-items: start;
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
  transition: border-color 160ms ease, color 160ms ease;
}

.post-card:hover {
  border-color: var(--border-strong);
}

.post-meta,
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 14px;
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.065em;
  line-height: 1.45;
  text-transform: uppercase;
}

.post-meta {
  flex-direction: column;
  gap: 4px;
}

.post-meta span:first-of-type,
.article-meta span:first-child {
  color: var(--accent);
}

.post-card h3 {
  max-width: 30ch;
  margin: 0 0 7px;
  font-size: clamp(1.18rem, 2vw, 1.5rem);
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.24;
}

.post-card p {
  max-width: 66ch;
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.86rem;
  line-height: 1.65;
}

.post-card-action {
  align-self: end;
  color: var(--accent);
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: right;
  text-transform: uppercase;
}

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

.article-masthead {
  padding: 46px 0 0;
}

.article-heading {
  max-width: 900px;
}

.article-masthead h1 {
  max-width: 25ch;
  margin-top: 17px;
}

.article-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 30px;
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border);
}

.summary-block {
  padding: 18px 24px 20px 0;
}

.summary-block + .summary-block {
  padding-right: 0;
  padding-left: 24px;
  border-left: 1px solid var(--border);
}

.summary-block strong {
  display: block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  font-weight: 700;
}

.summary-block p {
  max-width: 52ch;
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.6;
}

.article-layout {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 46px;
  align-items: start;
  margin-top: 30px;
}

.article-toc {
  position: sticky;
  top: 82px;
  padding: 0 22px 0 0;
  border-right: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.74rem;
}

.article-toc strong {
  display: block;
  margin-bottom: 10px;
  color: var(--text);
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.article-toc a {
  display: block;
  padding: 3px 0;
}

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

.article-body {
  min-width: 0;
  max-width: 710px;
}

.article-note {
  margin: 0 0 22px;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.79rem;
  line-height: 1.6;
}

.article-note strong {
  color: var(--accent);
}

.article-body h2,
.article-body h3 {
  scroll-margin-top: 86px;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.article-body h2 {
  margin: 44px 0 15px;
  font-size: clamp(1.55rem, 2.4vw, 1.8rem);
}

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

.article-body h3 {
  margin: 30px 0 10px;
  font-size: clamp(1.08rem, 1.8vw, 1.28rem);
}

.article-body p,
.article-body li {
  color: var(--text-secondary);
  font-size: 0.94rem;
  line-height: 1.72;
}

.article-body p {
  margin: 0 0 17px;
}

.article-body strong {
  color: var(--text);
}

.article-body em {
  color: var(--text);
}

.article-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.article-body ol,
.article-body ul {
  margin: 0 0 20px;
  padding-left: 22px;
}

.article-body li + li {
  margin-top: 6px;
}

.table-wrap {
  width: 100%;
  margin: 22px 0 28px;
  overflow-x: auto;
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
}

.article-body table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
  font-size: 0.8rem;
  line-height: 1.48;
}

.article-body th,
.article-body td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.article-body th:last-child,
.article-body td:last-child {
  border-right: 0;
}

.article-body th {
  background: var(--surface);
  color: var(--text);
  font-size: 0.69rem;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.article-body tr:last-child td {
  border-bottom: 0;
}

.equation {
  margin: 20px 0;
  padding: 12px 16px;
  overflow-x: auto;
  border-left: 2px solid var(--accent);
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.equation code,
.inline-equation {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.inline-equation {
  color: var(--text);
  font-size: 0.92em;
}

.data-flow {
  margin: 22px 0 28px;
  padding: 15px 0;
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
}

.data-flow figcaption {
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: 0.78rem;
}

.flow-track {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
}

.flow-step {
  position: relative;
  min-height: 70px;
  display: grid;
  align-content: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 650;
  text-align: center;
}

.flow-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -13px;
  width: 12px;
  height: 1px;
  background: var(--border-strong);
}

.flow-loop {
  margin: 12px 0 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--border);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 650;
  text-align: center;
}

.repository-reference {
  color: var(--text-secondary);
  font-style: italic;
}

#references + p,
#references ~ p {
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.article-footer-cta {
  margin-top: 44px;
  padding: 22px 0;
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border);
}

.article-footer-cta h2 {
  margin: 0 0 7px;
  padding: 0;
  font-size: 1.35rem;
}

.article-footer-cta p {
  max-width: 58ch;
  color: var(--text-secondary);
}

.cta-link {
  display: inline-flex;
  align-items: center;
  min-height: 35px;
  margin-top: 4px;
  padding: 0 13px;
  border-radius: 4px;
  background: var(--accent);
  color: #ffffff !important;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none !important;
}

.cta-link:hover {
  background: var(--accent-hover);
}

.guide-intro {
  margin: 0 0 36px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--border);
}

.guide-section {
  padding: 36px 0 0;
  border-top: 1px solid var(--border);
  scroll-margin-top: 82px;
}

.guide-intro + .guide-section {
  border-top: 0;
}

.guide-section + .guide-section {
  margin-top: 40px;
}

.guide-section h2 {
  margin: 0 0 15px;
}

.guide-callout {
  margin: 22px 0 0;
  padding: 7px 0 7px 15px;
  border-left: 2px solid var(--accent);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.65;
}

.guide-comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 22px 0 4px;
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
}

.guide-example {
  padding: 16px 18px 16px 0;
}

.guide-example:nth-child(even) {
  padding-right: 0;
  padding-left: 18px;
  border-left: 1px solid var(--border);
}

.guide-example:nth-child(n + 3) {
  border-top: 1px solid var(--border);
}

.guide-example h3 {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.guide-example p {
  margin: 0;
  font-size: 0.86rem;
}

.guide-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
}

.guide-secondary-link {
  color: var(--accent) !important;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none !important;
}

.guide-secondary-link:hover {
  color: var(--accent-hover) !important;
}

.site-footer {
  border-top: 1px solid var(--border);
}

.site-footer-inner {
  width: min(1040px, calc(100% - 40px));
  min-height: 70px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--text-secondary);
  font-size: 0.78rem;
}

.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 17px;
  font-weight: 600;
}

@media (max-width: 900px) {
  .post-card {
    grid-template-columns: 125px minmax(0, 1fr) 78px;
    gap: 20px;
  }

  .article-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .article-toc {
    position: static;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2px 16px;
    padding: 14px 0;
    border-top: 1px solid var(--border);
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .article-toc strong {
    grid-column: 1 / -1;
  }

  .article-body {
    max-width: 710px;
  }
}

@media (max-width: 720px) {
  .site-header-inner,
  .blog-main,
  .article-main,
  .site-footer-inner {
    width: min(100% - 32px, 1040px);
  }

  .site-header-inner {
    min-height: 56px;
  }

  .brand-mark {
    width: 24px;
    height: 24px;
  }

  .site-nav {
    gap: 10px;
  }

  .site-nav a:not(.nav-cta) {
    display: none;
  }

  .site-nav .nav-cta {
    min-height: 33px;
    padding: 0 12px;
  }

  .blog-main,
  .article-main {
    padding-bottom: 48px;
  }

  .blog-masthead {
    padding: 34px 0 32px;
  }

  .blog-masthead h1,
  .article-masthead h1 {
    font-size: clamp(1.85rem, 9vw, 2.15rem);
    line-height: 1.14;
  }

  .blog-masthead p,
  .article-dek {
    margin-top: 14px;
    font-size: 0.9rem;
  }

  .section-intro {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 14px 0;
  }

  .post-card {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 20px 0;
  }

  .post-meta {
    flex-direction: row;
    gap: 5px 12px;
  }

  .post-card h3 {
    font-size: 1.18rem;
  }

  .post-card-action {
    align-self: start;
    text-align: left;
  }

  .article-masthead {
    padding-top: 32px;
  }

  .article-masthead h1 {
    margin-top: 13px;
  }

  .article-summary {
    grid-template-columns: 1fr;
    margin-top: 24px;
  }

  .summary-block {
    padding: 15px 0;
  }

  .summary-block + .summary-block {
    padding: 15px 0;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .article-layout {
    margin-top: 22px;
  }

  .article-toc {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    font-size: 0.72rem;
  }

  .article-body h2 {
    margin-top: 38px;
    font-size: 1.55rem;
  }

  .article-body h3 {
    margin-top: 27px;
  }

  .article-body p,
  .article-body li {
    font-size: 0.91rem;
  }

  .guide-intro {
    margin-bottom: 28px;
  }

  .guide-section {
    padding-top: 30px;
  }

  .guide-section + .guide-section {
    margin-top: 32px;
  }

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

  .guide-example,
  .guide-example:nth-child(even) {
    padding: 14px 0;
    border-left: 0;
  }

  .guide-example + .guide-example {
    border-top: 1px solid var(--border);
  }

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

  .flow-step {
    min-height: 56px;
  }

  .flow-step:not(:last-child)::after {
    display: none;
  }

  .site-footer-inner {
    min-height: 0;
    align-items: flex-start;
    flex-direction: column;
    padding: 22px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
