:root {
  color-scheme: dark;
  --bg: #080909;
  --panel: #111313;
  --panel-alt: #0d0f0f;
  --ink: #d8ddd8;
  --muted: #8e9893;
  --line: #303636;
  --soft-line: #202626;
  --accent: #78b7a6;
  --accent-dark: #a3d7c6;
  --code-bg: #252b2a;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 86px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.52;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

a:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  padding: 0 28px;
  background: rgba(8, 9, 9, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand:hover {
  text-decoration: none;
}

.top-nav {
  display: flex;
  gap: 22px;
  align-items: center;
  font-size: 12px;
}

.top-nav a {
  color: var(--muted);
  padding: 4px 0;
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(0, 900px) 220px;
  gap: 26px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 26px 24px 64px;
}

.toc {
  position: sticky;
  top: 88px;
  align-self: start;
  max-height: calc(100vh - 110px);
  overflow: auto;
  padding-right: 8px;
}

.toc h2 {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.toc-section + .toc-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.toc a {
  display: block;
  padding: 5px 0;
  color: #b7c0bb;
  font-size: 12px;
}

.guide-nav a {
  line-height: 1.25;
}

.toc a:hover,
.top-nav a:hover {
  color: var(--accent-dark);
}

.toc {
  border-left: 1px solid var(--line);
  padding-left: 20px;
}

.toc a {
  color: var(--muted);
  font-size: 11px;
}

.content {
  min-width: 0;
  padding: 26px 34px 40px;
  background: var(--panel);
  border: 1px solid var(--soft-line);
  border-radius: 0;
}

.content h1 {
  margin: 0 0 16px;
  font-size: clamp(25px, 4vw, 38px);
  line-height: 1.12;
  letter-spacing: 0;
}

.content h2 {
  margin-top: 32px;
  padding-top: 16px;
  scroll-margin-top: 86px;
  border-top: 1px solid var(--soft-line);
  font-size: 20px;
  line-height: 1.22;
  letter-spacing: 0;
}

.content h3 {
  margin-top: 24px;
  scroll-margin-top: 86px;
  font-size: 16px;
}

.content p,
.content li {
  color: #c6cdc8;
}

.content p {
  margin: 0 0 0.95rem;
}

.content ul,
.content ol {
  padding-left: 1.35rem;
}

.content li + li {
  margin-top: 0.25rem;
}

.content strong {
  color: #9cdcfe;
}

.content code {
  padding: 0.13rem 0.36rem;
  background: var(--code-bg);
  border: 1px solid #3b4542;
  border-radius: 0;
  color: #eef4ef;
  font-family: "Menlo", "Monaco", "Courier New", monospace;
  font-size: 0.9em;
  font-weight: 400;
}

.content pre {
  overflow: auto;
  padding: 16px;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 0;
  font-family: "Menlo", "Monaco", "Courier New", monospace;
}

.content pre code {
  padding: 0;
  background: transparent;
  font-family: inherit;
}

.content figure {
  margin: 28px 0;
}

.content img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--soft-line);
}

.content figure a {
  display: block;
}

.content figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.content .utility-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin: 6px 0 16px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--panel-alt);
  color: var(--ink);
  font-family: "Menlo", "Monaco", "Courier New", monospace;
  font-size: 12px;
}

.content .utility-link:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  text-decoration: none;
}

.content .bibliography {
  margin-top: 14px;
}

.content .bib-entry {
  margin-bottom: 1.05rem;
  padding-left: 1.35rem;
  text-indent: -1.35rem;
}

.content .bib-entry a {
  text-indent: 0;
}

.gallery-mosaic {
  column-count: 3;
  column-gap: 16px;
  margin-top: 20px;
}

.gallery-tile {
  display: block;
  width: 100%;
  height: auto;
  padding: 0;
  margin: 0 0 16px;
  overflow: hidden;
  break-inside: avoid;
  background: transparent;
  border: 0;
  border-radius: 0;
  cursor: pointer;
}

.gallery-tile:hover,
.gallery-tile:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
}

.gallery-tile img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  border: 0;
  transition: filter 160ms ease;
}

.gallery-tile:hover img,
.gallery-tile:focus-visible img {
  filter: brightness(1.12);
}

.utility-screenshot {
  display: flex;
  justify-content: center;
  margin: 18px auto 30px;
}

.utility-screenshot-button {
  display: block;
  width: min(100%, 760px);
  padding: 0;
  margin: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  cursor: pointer;
}

.utility-screenshot-button:hover,
.utility-screenshot-button:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 5px;
}

.utility-screenshot-button img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #3f4744;
  background: #050606;
  box-shadow: 0 12px 42px rgba(0, 0, 0, 0.34);
  transition: filter 160ms ease;
}

.utility-screenshot-button:hover img,
.utility-screenshot-button:focus-visible img {
  filter: brightness(1.08);
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 56px 92px;
  background: rgba(12, 14, 14, 0.88);
  box-shadow: inset 0 0 0 9999px rgba(190, 198, 193, 0.035);
}

.gallery-lightbox[aria-hidden="false"] {
  display: flex;
}

.gallery-lightbox img {
  width: auto;
  max-width: calc(100vw - 184px);
  max-height: calc(100vh - 112px);
  object-fit: contain;
  border: 1px solid #55615d;
  background: #050606;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.55);
}

.gallery-close,
.gallery-arrow {
  position: fixed;
  display: grid;
  place-items: center;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  cursor: pointer;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.9);
  transition: color 140ms ease, opacity 140ms ease;
}

.gallery-close:hover,
.gallery-arrow:hover,
.gallery-close:focus-visible,
.gallery-arrow:focus-visible {
  color: var(--accent-dark);
  background: transparent;
  outline: 0;
}

.gallery-close {
  top: 20px;
  right: 24px;
  width: 44px;
  height: 44px;
  font-size: 28px;
  font-weight: 300;
}

.gallery-arrow {
  top: 50%;
  width: 58px;
  height: 86px;
  transform: translateY(-50%);
  font-size: 58px;
  font-weight: 200;
  line-height: 1;
}

.gallery-arrow.prev {
  left: 24px;
}

.gallery-arrow.next {
  right: 24px;
}

body.gallery-open {
  overflow: hidden;
}

.page-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 42px;
  padding-top: 20px;
  border-top: 1px solid var(--soft-line);
}

.page-nav-link {
  display: block;
  min-height: 58px;
  padding: 12px 14px;
  background: var(--panel-alt);
  border: 1px solid var(--soft-line);
  color: var(--ink);
}

.page-nav-link:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.page-nav-link span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.page-nav-link.next {
  text-align: right;
}

@media (max-width: 1120px) {
  .page-shell {
    grid-template-columns: minmax(0, 1fr);
    max-width: 960px;
  }

  .toc {
    display: none;
  }
}

@media (max-width: 780px) {
  .site-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 14px 18px;
  }

  .top-nav {
    flex-wrap: wrap;
    gap: 10px 16px;
  }

  .page-shell {
    display: block;
    padding: 18px;
  }

  .toc {
    display: none;
  }

  .content {
    padding: 24px 22px 34px;
  }

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

  .gallery-mosaic {
    column-count: 1;
  }

  .gallery-lightbox {
    padding: 54px 18px 80px;
  }

  .gallery-lightbox img {
    max-width: calc(100vw - 36px);
    max-height: calc(100vh - 134px);
  }

  .gallery-arrow {
    top: auto;
    bottom: 16px;
    width: 46px;
    height: 46px;
    transform: none;
    font-size: 30px;
  }

  .gallery-arrow.prev {
    left: calc(50% - 56px);
  }

  .gallery-arrow.next {
    right: calc(50% - 56px);
  }

  .page-nav-link.next {
    text-align: left;
  }
}
