:root {
  color-scheme: dark;
  --bg: #080a0f;
  --nav-bg: rgba(8, 10, 15, 0.88);
  --text: #f3f5f8;
  --body: #cbd2dc;
  --muted: #8d99aa;
  --faint: #667285;
  --line: rgba(255, 255, 255, 0.13);
  --line-strong: rgba(255, 255, 255, 0.22);
  --surface: #0e1219;
  --surface-soft: #0b0f15;
  --orange: #f4ad45;
  --blue: #72aef2;
  --cyan: #67d9ca;
  --button-text: #11151c;
  --media-bg: #ffffff;
  --selection: rgba(114, 174, 242, 0.28);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f9fc;
  --nav-bg: rgba(247, 249, 252, 0.9);
  --text: #142033;
  --body: #35445a;
  --muted: #5f6d7e;
  --faint: #7c8897;
  --line: rgba(15, 23, 42, 0.12);
  --line-strong: rgba(15, 23, 42, 0.2);
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --orange: #b86b08;
  --blue: #3477c5;
  --cyan: #0f8e82;
  --button-text: #ffffff;
  --media-bg: #ffffff;
  --selection: rgba(52, 119, 197, 0.2);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

::selection {
  background: var(--selection);
}

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

img {
  display: block;
  max-width: 100%;
}

button,
input,
textarea,
select {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
}

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

.nav {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand img {
  width: 31px;
  height: 31px;
}

.brand-wordmark-wrap {
  display: inline-flex;
  align-items: center;
}

.brand .brand-wordmark {
  display: block;
  width: 118px;
  height: auto;
}

.brand .logo-light {
  display: none;
}

html[data-theme="light"] .brand .logo-dark {
  display: none;
}

html[data-theme="light"] .brand .logo-light {
  display: block;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.nav-link,
.language-switch,
.theme-toggle {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 11px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.nav-link:hover,
.language-switch:hover,
.theme-toggle:hover {
  color: var(--text);
}

.language-switch,
.theme-toggle {
  border-color: var(--line);
  color: var(--text);
  background: var(--surface);
}

.theme-toggle {
  gap: 7px;
  cursor: pointer;
}

.theme-icon {
  width: 15px;
  height: 15px;
}

html[data-theme="light"] .theme-toggle .sun,
html:not([data-theme="light"]) .theme-toggle .moon {
  display: none;
}

.hero {
  padding: clamp(68px, 9vw, 112px) 0 54px;
  border-bottom: 1px solid var(--line);
}

.hero-inner {
  width: min(850px, 100%);
  margin: 0 auto;
}

.eyebrow {
  margin: 0 0 22px;
  color: var(--orange);
  font: 600 12px/1.3 "JetBrains Mono", ui-monospace, monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

h1 {
  max-width: 840px;
  margin: 0;
  font-size: clamp(43px, 6.6vw, 72px);
  line-height: 1.02;
  letter-spacing: -0.055em;
}

.subtitle {
  max-width: 760px;
  margin: 26px 0 0;
  color: var(--body);
  font-size: clamp(19px, 2.1vw, 23px);
  line-height: 1.55;
  letter-spacing: -0.018em;
}

.intro {
  max-width: 760px;
  margin: 24px 0 0;
  color: var(--body);
  font-size: 17px;
  line-height: 1.78;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 11px;
  margin-top: 28px;
}

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0 15px;
  color: var(--text);
  background: var(--surface);
  font-size: 14px;
  font-weight: 750;
}

.button.primary {
  border-color: transparent;
  color: var(--button-text);
  background: var(--orange);
}

.button:hover {
  transform: translateY(-1px);
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 22px;
  color: var(--muted);
  font-size: 13px;
}

.article-meta span:not(:last-child)::after {
  content: "·";
  margin-left: 18px;
  color: var(--faint);
}

.reading-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 760px);
  justify-content: center;
  gap: clamp(42px, 7vw, 84px);
  padding: 60px 0 100px;
}

.toc {
  position: sticky;
  top: 96px;
  align-self: start;
  max-height: calc(100vh - 126px);
  overflow: auto;
}

.toc-title {
  margin: 0 0 15px;
  color: var(--faint);
  font: 600 11px/1.3 "JetBrains Mono", ui-monospace, monospace;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc li {
  margin: 0;
}

.toc a {
  display: block;
  padding: 7px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.article {
  min-width: 0;
}

.article section {
  padding: 0 0 58px;
  scroll-margin-top: 96px;
}

.article section + section {
  padding-top: 6px;
}

.article h2 {
  margin: 0 0 23px;
  font-size: clamp(31px, 4.1vw, 43px);
  line-height: 1.16;
  letter-spacing: -0.04em;
}

.article h3 {
  margin: 36px 0 14px;
  font-size: clamp(22px, 2.8vw, 27px);
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.article p,
.article li {
  color: var(--body);
  font-size: 17px;
  line-height: 1.82;
}

.article p {
  margin: 0 0 21px;
}

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

.article a:not(.button) {
  color: var(--blue);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--blue) 40%, transparent);
  text-underline-offset: 3px;
}

.article ul,
.article ol {
  margin: 18px 0 24px;
  padding-left: 24px;
}

.article li {
  margin: 8px 0;
  padding-left: 5px;
}

.article li::marker {
  color: var(--orange);
  font-weight: 700;
}

.lead {
  color: var(--text) !important;
  font-size: 20px !important;
  line-height: 1.72 !important;
  letter-spacing: -0.012em;
}

.callout {
  margin: 32px 0;
  border-left: 3px solid var(--orange);
  padding: 3px 0 3px 24px;
}

.callout p {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.68;
}

.callout.blue {
  border-left-color: var(--blue);
}

.figure-breakout {
  width: min(1000px, calc(100vw - 48px));
  margin: 38px 0 42px 50%;
  transform: translateX(-50%);
}

.figure-frame {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: var(--surface);
}

.article-figure-image {
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  object-position: center;
  border-radius: 9px;
  background: var(--media-bg);
}

.workflow-image {
  aspect-ratio: 65 / 36;
}

.mismatch-image {
  aspect-ratio: 3 / 2;
}

figcaption {
  max-width: 820px;
  margin: 12px auto 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.58;
}

.table-wrap {
  width: min(940px, calc(100vw - 48px));
  margin: 30px 0 36px 50%;
  transform: translateX(-50%);
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.58;
}

th,
td {
  min-width: 150px;
  padding: 16px 17px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--text);
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 750;
}

td {
  color: var(--body);
}

tbody tr:last-child td {
  border-bottom: 0;
}

td:first-child {
  color: var(--text);
  font-weight: 700;
}

code,
.run-modes {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}

code {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.12em 0.34em;
  color: var(--cyan);
  background: var(--surface-soft);
  font-size: 0.88em;
}

.run-modes {
  margin: 24px 0 28px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.closing {
  border-top: 1px solid var(--line);
  padding-top: 42px !important;
}

.closing p:last-child {
  margin-bottom: 0;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 42px 0 58px;
}

.footer-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 30px;
}

.footer-copy {
  max-width: 620px;
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

@media (max-width: 940px) {
  .reading-layout {
    grid-template-columns: minmax(0, 760px);
    gap: 38px;
  }

  .toc {
    position: static;
    max-height: none;
    overflow: visible;
    border-bottom: 1px solid var(--line);
    padding-bottom: 24px;
  }

  .toc ol {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 18px;
  }

  .toc a {
    padding: 4px 0;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 28px, 1180px);
  }

  .nav {
    min-height: 62px;
  }

  .brand span,
  .nav-link {
    display: none;
  }

  .site-header .brand .brand-wordmark-wrap {
    display: inline-flex;
  }

  .site-header .brand .brand-wordmark {
    width: 104px;
  }

  .language-switch,
  .theme-toggle {
    min-height: 34px;
    padding: 0 10px;
  }

  .hero {
    padding: 54px 0 42px;
  }

  h1 {
    font-size: clamp(39px, 12vw, 56px);
  }

  .subtitle {
    font-size: 18px;
  }

  .intro,
  .article p,
  .article li {
    font-size: 16px;
  }

  .lead {
    font-size: 18px !important;
  }

  .reading-layout {
    padding: 40px 0 72px;
  }

  .article section {
    padding-bottom: 46px;
  }

  .figure-breakout,
  .table-wrap {
    width: calc(100vw - 28px);
  }

  .figure-frame {
    padding: 7px;
    border-radius: 12px;
  }

  th,
  td {
    padding: 13px 14px;
  }

  .footer-inner {
    flex-direction: column;
  }
}

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

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
