:root {
  color-scheme: light dark;
  --bg: #010401;
  --panel: rgba(0, 0, 0, .74);
  --panel-strong: rgba(7, 18, 10, .94);
  --panel-soft: rgba(255, 255, 255, .05);
  --text: #f3fff5;
  --muted: #d7ffdc;
  --accent: #00ff41;
  --accent-strong: #72ff8d;
  --border: rgba(114, 255, 141, .45);
  --shadow: 0 14px 34px rgba(0, 0, 0, .28);
  --loading-y-edge-inline: linear-gradient(90deg, #000000 0%, #063d21 28%, #00ff41 52%, #72ff8d 72%, #000000 100%);
  --loading-y-edge-block: linear-gradient(180deg, #000000 0%, #063d21 24%, #00ff41 54%, #72ff8d 76%, #000000 100%);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #ffffff;
    --panel: rgba(255, 255, 255, .96);
    --panel-strong: #ffffff;
    --panel-soft: #f2f8f4;
    --text: #102217;
    --muted: #385341;
    --accent: #0b6f35;
    --accent-strong: #075528;
    --border: rgba(11, 111, 53, .24);
    --shadow: 0 14px 30px rgba(11, 111, 53, .12);
  }
}

:root[data-theme="light"] {
  --bg: #ffffff;
  --panel: rgba(255, 255, 255, .96);
  --panel-strong: #ffffff;
  --panel-soft: #f2f8f4;
  --text: #102217;
  --muted: #385341;
  --accent: #0b6f35;
  --accent-strong: #075528;
  --border: rgba(11, 111, 53, .24);
  --shadow: 0 14px 30px rgba(11, 111, 53, .12);
}

:root[data-theme="dark"] {
  --bg: #010401;
  --panel: rgba(0, 0, 0, .74);
  --panel-strong: rgba(7, 18, 10, .94);
  --panel-soft: rgba(255, 255, 255, .05);
  --text: #f3fff5;
  --muted: #d7ffdc;
  --accent: #00ff41;
  --accent-strong: #72ff8d;
  --border: rgba(114, 255, 141, .45);
  --shadow: 0 14px 34px rgba(0, 0, 0, .28);
}

* {
  box-sizing: border-box;
}

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

.matrix-background {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

:root[data-theme="light"] .matrix-background {
  opacity: 1;
  filter: none;
}

:root[data-theme="dark"] .matrix-background {
  opacity: 1;
  filter: saturate(1.2) contrast(1.1);
}

a {
  color: var(--accent);
}

.site-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  width: min(1180px, calc(100% - 24px));
  margin: 18px auto;
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 3vw, 34px);
}

.site-header,
.site-footer {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: clamp(14px, 2.6vw, 28px);
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text);
  text-decoration: none;
}

.site-brand img {
  width: clamp(72px, 10vw, 112px);
  aspect-ratio: 1;
  border-radius: 50%;
  object-fit: cover;
}

.site-brand strong,
.site-brand span {
  display: block;
}

.site-brand strong {
  font-family: "Courier New", Courier, monospace;
  font-size: clamp(1.1rem, 2vw, 1.45rem);
  line-height: 1.15;
}

.site-brand span {
  color: var(--muted);
  font-size: .95rem;
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a,
.site-footer a {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

.site-nav .nav-label--stack {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  max-width: 230px;
  line-height: 1.18;
  text-align: center;
}

.site-nav .nav-line {
  display: block;
}

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

.site-main {
  flex: 1 0 auto;
}

.site-footer {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.theme-toggle {
  position: fixed;
  right: clamp(10px, 3vw, 24px);
  bottom: clamp(10px, 3vw, 24px);
  z-index: 20;
  min-width: 138px;
  min-height: 40px;
  padding: 8px 12px;
  border: 2px solid var(--accent-strong);
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-align: center;
  box-shadow: var(--shadow);
}

.theme-toggle:hover {
  background: var(--accent-strong);
  color: var(--bg);
}

.article-header,
.article-page,
.article-list {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
}

.article-header {
  padding: 48px 0 24px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 28px;
  background: var(--panel);
  color: var(--accent-strong);
  text-decoration: none;
  font-weight: 700;
}

.eyebrow,
.tag {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  line-height: 1.15;
}

h1 {
  max-width: 860px;
  margin: 0;
  font-size: clamp(2.1rem, 6vw, 4.4rem);
}

h2 {
  margin: 44px 0 12px;
  font-size: clamp(1.35rem, 3vw, 2rem);
}

h3 {
  margin: 28px 0 10px;
  font-size: 1.05rem;
}

.lead {
  max-width: 780px;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 1.14rem;
}

.github-note {
  margin: 20px 0 0;
}

.github-note a {
  font-weight: 700;
}

.hero-image {
  display: block;
  width: min(420px, 100%);
  margin-top: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
  box-shadow: var(--shadow);
}

.hero-image--wide {
  width: min(760px, 100%);
}

.article-page {
  padding-bottom: 64px;
}

.article-page section {
  margin-top: 18px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.article-page section h2:first-child {
  margin-top: 0;
}

.article-page p,
.article-page li {
  color: var(--muted);
}

code {
  color: var(--text);
  background: var(--panel-soft);
  border-radius: 4px;
  padding: 0.08em 0.32em;
}

pre {
  overflow-x: auto;
  margin: 12px 0 24px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-strong);
}

pre code {
  display: block;
  padding: 0;
  background: transparent;
  color: #f7f3ea;
  font-size: 0.92rem;
  line-height: 1.55;
}

.article-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 40px;
}

.article-actions a,
.article-card a {
  font-weight: 700;
}

.article-actions a {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--accent-strong);
  text-decoration: none;
}

.article-actions a:hover,
.back-link:hover {
  background: var(--accent-strong);
  color: var(--bg);
}

.article-list {
  display: grid;
  gap: 18px;
  padding-bottom: 64px;
}

.article-card {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 20px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.article-card img {
  width: 132px;
  aspect-ratio: 1;
  object-fit: contain;
}

.article-card h2 {
  margin: 0 0 8px;
}

.article-card p {
  margin: 0;
  color: var(--muted);
}

.article-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
  gap: 28px;
  align-items: center;
}

.article-hero-grid .hero-image {
  margin-top: 0;
  justify-self: end;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 22px;
}

.module-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-strong);
}

.module-card h3 {
  margin-top: 0;
  color: var(--accent);
}

.module-card p,
.module-card ul {
  margin-bottom: 0;
}

.principle-list {
  display: grid;
  gap: 12px;
  padding-left: 0;
  list-style: none;
}

.principle-list li {
  padding: 12px 14px;
  border-left: 4px solid var(--accent-strong);
  background: var(--panel-soft);
}

.page-blocks {
  display: grid;
  gap: 18px;
  width: min(960px, calc(100% - 32px));
  margin: 0 auto 64px;
}

.page-block {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow:
    var(--shadow),
    0 0 0 1px rgba(0, 255, 65, .08);
}

.page-block--split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 38%);
}

.page-block--split-reverse {
  grid-template-columns: minmax(220px, 38%) minmax(0, 1fr);
}

.page-block__text {
  position: relative;
  padding: 22px;
}

.page-block__text::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--loading-y-edge-block);
}

.page-block--split-reverse .page-block__text::before {
  inset: 0 0 0 auto;
}

.page-block__text h2,
.page-block__text h3 {
  margin-top: 0;
}

.page-block__text p:last-child,
.page-block__text ul:last-child {
  margin-bottom: 0;
}

.page-block__media {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 18px;
  background: var(--panel-soft);
}

.page-block__media img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
}

.page-block__list {
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--muted);
}

@media (max-width: 620px) {
  .site-shell {
    width: min(100% - 16px, 680px);
    margin: 8px auto;
  }

  .site-header__inner {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .site-brand {
    justify-content: center;
  }

  .site-nav ul {
    justify-content: center;
  }

  .article-hero-grid,
  .article-card,
  .page-block--split,
  .page-block--split-reverse {
    grid-template-columns: 1fr;
  }

  .article-hero-grid .hero-image {
    justify-self: start;
  }

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

  .article-card img {
    width: 112px;
  }

  .page-block--split-reverse .page-block__media {
    order: 2;
  }
}

@media (max-width: 420px) {
  .site-brand img {
    display: none;
  }

  .site-nav a {
    display: inline-flex;
    padding: 6px 8px;
  }
}
