:root {
  color-scheme: dark;
  --bg: #050505;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-strong: #111111;
  --text: #f5f5f5;
  --muted: #a4a4a4;
  --faint: #686868;
  --line: rgba(255, 255, 255, 0.13);
  --line-strong: rgba(255, 255, 255, 0.28);
  --accent: #ffffff;
  --accent-ink: #050505;
  --secondary: #bfc2c6;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #ededed;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: #ffffff;
  --text: #111111;
  --muted: #555555;
  --faint: #858585;
  --line: rgba(17, 17, 17, 0.12);
  --line-strong: rgba(17, 17, 17, 0.28);
  --accent: #111111;
  --accent-ink: #ffffff;
  --secondary: #5d5d5d;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 82% 8%, rgba(255, 255, 255, 0.08), transparent 27rem),
    radial-gradient(circle at 8% 45%, rgba(185, 185, 185, 0.08), transparent 24rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  transition: background 280ms ease, color 280ms ease;
}
body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: 0.42;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, black, transparent 65%);
}
a { color: inherit; text-decoration: none; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.article-shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; }
.article-header { display: flex; align-items: center; justify-content: space-between; min-height: 84px; border-bottom: 1px solid var(--line); }
.article-wordmark { display: inline-flex; align-items: center; gap: 10px; font-size: 0.86rem; font-weight: 800; letter-spacing: 0.18em; }
.article-mark { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 0.86rem; letter-spacing: 0; }
.article-nav { display: flex; align-items: center; gap: 12px; }
.back-link, .theme-button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: transparent; transition: border-color 180ms ease, color 180ms ease, background 180ms ease, transform 180ms ease; }
.back-link { gap: 8px; padding: 0 14px; font-size: 0.8rem; }
.theme-button { width: 38px; cursor: pointer; }
.back-link:hover, .back-link:focus-visible, .theme-button:hover, .theme-button:focus-visible { border-color: var(--line-strong); background: var(--panel); color: var(--text); transform: translateY(-1px); }

.article-hero { width: min(860px, 100%); padding: clamp(74px, 11vw, 150px) 0 clamp(62px, 9vw, 112px); }
.article-kicker { margin: 0 0 18px; color: var(--accent); font-size: 0.71rem; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; }
.article-hero h1 { max-width: 850px; margin: 0; font-size: clamp(3.2rem, 8.4vw, 7.8rem); letter-spacing: -0.085em; line-height: 0.9; }
.article-deck { max-width: 650px; margin: 26px 0 0; color: var(--muted); font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.25rem, 2.4vw, 1.75rem); line-height: 1.35; }
.article-meta { display: flex; flex-wrap: wrap; gap: 9px 18px; margin-top: 30px; color: var(--faint); font-size: 0.78rem; }
.article-meta span + span::before { margin-right: 18px; color: var(--line-strong); content: "/"; }

.article-layout { display: grid; grid-template-columns: minmax(0, 760px) minmax(180px, 260px); gap: clamp(44px, 9vw, 126px); align-items: start; padding-bottom: 120px; }
.article-body { min-width: 0; font-size: 1.08rem; }
.article-body > p:first-child { color: var(--text); font-size: 1.28rem; line-height: 1.55; }
.article-body p { margin: 0 0 1.5rem; color: var(--muted); }
.article-body h2 { margin: 3.2rem 0 1rem; color: var(--text); font-size: clamp(1.65rem, 3vw, 2.25rem); letter-spacing: -0.045em; line-height: 1.05; }
.article-body h3 { margin: 2.25rem 0 0.7rem; color: var(--text); font-size: 1.2rem; letter-spacing: -0.02em; }
.article-body ul { margin: 0 0 1.65rem; padding-left: 1.15rem; color: var(--muted); }
.article-body li { padding-left: 0.3rem; margin: 0.52rem 0; }
.article-body li::marker { color: var(--secondary); }
.article-body strong { color: var(--text); font-weight: 700; }
.article-body a { color: var(--text); text-decoration: underline; text-decoration-color: var(--secondary); text-underline-offset: 4px; }
.article-body a:hover { color: var(--secondary); }
.article-body blockquote { margin: 2.4rem 0; padding: 2px 0 2px 25px; border-left: 2px solid var(--accent); color: var(--text); font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.35rem, 3vw, 2rem); line-height: 1.28; }

.article-aside { position: sticky; top: 28px; }
.aside-label { margin: 0 0 12px; color: var(--faint); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; }
.aside-rule { width: 100%; height: 1px; margin-bottom: 16px; background: var(--line); }
.aside-copy { margin: 0; color: var(--muted); font-size: 0.85rem; }
.aside-links { display: grid; gap: 6px; margin-top: 20px; }
.aside-links a { color: var(--muted); font-size: 0.82rem; }
.aside-links a:hover { color: var(--text); }

.callout { margin: 2.5rem 0; padding: 22px 24px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(145deg, rgba(255, 255, 255, 0.08), transparent 55%), var(--panel); }
.callout-label { margin: 0 0 11px; color: var(--faint); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.15em; text-transform: uppercase; }
.callout p:last-child { margin-bottom: 0; color: var(--text); }
.layer-diagram { display: grid; gap: 9px; margin: 2.5rem 0; }
.layer { display: grid; grid-template-columns: 115px 1fr; gap: 18px; align-items: center; min-height: 72px; padding: 15px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.layer strong { color: var(--text); font-size: 0.92rem; letter-spacing: 0.04em; text-transform: uppercase; }
.layer span { color: var(--muted); font-size: 0.88rem; }
.layer:nth-child(2) { margin-left: 28px; }
.layer:nth-child(3) { margin-left: 56px; }
.code-note { overflow-x: auto; margin: 2rem 0; padding: 18px 20px; border: 1px solid var(--line); border-radius: 14px; background: #090909; color: #d7d7d7; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 0.82rem; line-height: 1.65; }
.spec-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin: 2rem 0; }
.spec { padding: 15px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.spec small { display: block; margin-bottom: 5px; color: var(--faint); font-size: 0.68rem; letter-spacing: 0.13em; text-transform: uppercase; }
.spec strong { color: var(--text); font-size: 0.92rem; font-weight: 600; }

.article-end { display: flex; justify-content: space-between; gap: 20px; padding: 26px 0 38px; border-top: 1px solid var(--line); color: var(--faint); font-size: 0.78rem; }
.article-end a { color: var(--muted); }
.article-end a:hover { color: var(--text); }

@media (max-width: 820px) {
  .article-layout { grid-template-columns: 1fr; }
  .article-aside { position: static; order: -1; display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .aside-rule { display: none; }
  .aside-copy { grid-column: 1 / -1; }
  .aside-links { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 3px; }
}
@media (max-width: 620px) {
  .article-shell { width: min(100% - 28px, 1120px); }
  .article-header { min-height: 72px; }
  .article-hero { padding: 72px 0 70px; }
  .article-hero h1 { font-size: clamp(3.05rem, 16vw, 5.7rem); }
  .article-body { font-size: 1rem; }
  .article-body > p:first-child { font-size: 1.16rem; }
  .layer { grid-template-columns: 1fr; gap: 5px; }
  .layer:nth-child(2), .layer:nth-child(3) { margin-left: 0; }
  .spec-grid { grid-template-columns: 1fr; }
  .article-end { flex-direction: column; }
  .back-link { padding: 0 11px; }
  .back-link .back-label { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.001ms !important; }
}
