:root {
  color-scheme: dark;
  --background: #111417;
  --header: #111417;
  --surface: #181d21;
  --raised: #1d2328;
  --line: #2b3338;
  --text: #eef0ec;
  --body: #c8d0d0;
  --muted: #9daaa9;
  --accent: #c9f572;
  --accent-soft: #252f20;
  --gutter: clamp(20px, 3.6vw, 48px);
  --page-width: 1440px;
  --header-height: 70px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--background);
  color: var(--text);
  scroll-padding-top: calc(var(--header-height) + 1.25rem);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-width: 300px;
  min-height: 100vh;
  margin: 0;
  font-size: 1rem;
  line-height: 1.65;
}

button, input { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-underline-offset: .2em; }
a:hover { color: #e0ffa6; }
h1, h2, h3, p { margin: 0; }
img { display: block; max-width: 100%; height: auto; }
::selection { color: #141a10; background: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.skip-link {
  position: fixed;
  z-index: 30;
  top: .65rem;
  left: var(--gutter);
  transform: translateY(calc(-100% - 1rem));
  padding: .5rem .85rem;
  border-radius: 6px;
  background: var(--accent);
  color: #141a10;
  font-weight: 720;
}

.skip-link:focus { transform: none; }
.skip-link:hover { color: #141a10; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

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

.header-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(235px, 400px) minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  max-width: var(--page-width);
  min-height: var(--header-height);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 11px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}

.brand:hover { color: var(--text); }

.brand-mark {
  display: grid;
  flex: 0 0 37px;
  width: 37px;
  height: 37px;
  place-items: center;
  border-radius: 9px;
  background: var(--accent);
  color: #182010;
  font-size: .88rem;
  font-weight: 850;
  letter-spacing: -.075em;
}

.brand-mark svg { width: 20px; height: 20px; }
.brand-title { display: block; font-size: 1.05rem; font-weight: 760; line-height: 1.2; letter-spacing: -.035em; }
.brand-kind { margin-inline-start: .2em; color: var(--muted); font-size: .82em; font-weight: 580; }

.search, .search-wrap { position: relative; min-width: 0; }
.search input, .search-wrap input {
  width: 100%;
  min-height: 41px;
  padding: .5rem 2.45rem .5rem .85rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: .9rem;
}

.search input::placeholder, .search-wrap input::placeholder { color: var(--muted); opacity: 1; }
.search input:focus, .search-wrap input:focus { border-color: var(--accent); }
.search :is(label, form) { min-width: 0; }
.search-wrap kbd {
  position: absolute;
  inset: 50% .66rem auto auto;
  transform: translateY(-50%);
  min-width: 1.3rem;
  padding: .02rem .28rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--background);
  color: var(--muted);
  font: .78rem / 1.55 ui-monospace, Consolas, monospace;
  text-align: center;
  pointer-events: none;
}

.search-results {
  position: absolute;
  z-index: 2;
  inset: calc(100% + 9px) 0 auto;
  max-height: min(45vh, 360px);
  overflow: auto;
  margin: 0;
  padding: 6px;
  border: 1px solid #38434a;
  border-radius: 10px;
  background: var(--raised);
  box-shadow: 0 16px 36px #06090cb3;
  list-style: none;
}

.search-results :is(a, button, [role="option"]) {
  display: block;
  width: 100%;
  padding: .63rem .75rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: .9rem;
  text-align: start;
  text-decoration: none;
}

.search-results :is(a, button, [role="option"]):hover,
.search-results [aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.search-results :is(p, .empty) { padding: .65rem .75rem; color: var(--muted); font-size: .9rem; }
.search-results p:empty { display: none; }
.search-results small { display: block; color: var(--muted); }

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 41px;
  padding: .42rem .72rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: .88rem;
  font-weight: 630;
}

.menu-toggle:hover, .menu-toggle[aria-expanded="true"] { border-color: #536247; color: var(--accent); }
.menu-toggle svg { width: 18px; height: 18px; }

.layout {
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr) 174px;
  align-items: start;
  gap: clamp(24px, 3.2vw, 48px);
  max-width: var(--page-width);
  min-height: calc(100vh - var(--header-height) - 70px);
  margin-inline: auto;
  padding: 2.25rem var(--gutter) 4.5rem;
}

.sidebar, .toc {
  position: sticky;
  top: calc(var(--header-height) + 2.25rem);
  max-height: calc(100vh - var(--header-height) - 3.5rem);
  overflow: auto;
  scrollbar-width: thin;
}

.sidebar { padding: .16rem 14px .25rem 3px; border-right: 1px solid var(--line); }
.toc { padding: .16rem 3px .25rem 14px; border-left: 1px solid var(--line); }
.nav-title, .toc-title {
  margin: 0 0 .65rem;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 730;
  letter-spacing: .075em;
  text-transform: uppercase;
}

.sidebar .nav-title { padding-inline: .5rem; }
.side-nav .nav-title:not(:first-child) { margin-top: 1.05rem; }
.side-nav, .side-nav ul, .toc-links, .toc-links ul { display: grid; gap: .22rem; margin: 0; padding: 0; list-style: none; }
.side-nav a, .toc-links a {
  display: block;
  border-radius: 6px;
  color: var(--body);
  font-size: .92rem;
  line-height: 1.4;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.side-nav a { padding: .46rem .58rem; border-inline-start: 2px solid transparent; }
.side-nav a:hover, .toc-links a:hover { background: var(--surface); color: var(--text); }
.side-nav a[aria-current="page"] {
  border-inline-start-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 680;
}

.toc-links a { padding: .35rem .45rem; color: var(--muted); font-size: .85rem; }
.toc-links [aria-current], .toc-links .is-active { color: var(--accent); }

.content, .wiki-page { min-width: 0; }
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .25rem .55rem;
  margin: 0 0 1.1rem;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.4;
}

.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: .25rem .55rem; margin: 0; padding: 0; list-style: none; }
.breadcrumbs a { color: var(--body); }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs [aria-current="page"] { color: var(--text); }

.wiki-page h1, .hero h1 {
  margin: 0 0 1rem;
  font-size: clamp(2.2rem, 3.6vw, 3.35rem);
  font-weight: 790;
  line-height: 1.08;
  letter-spacing: -.05em;
  overflow-wrap: anywhere;
}

.wiki-page h2 {
  margin: 2.55rem 0 .78rem;
  padding-bottom: .48rem;
  border-bottom: 1px solid var(--line);
  font-size: clamp(1.38rem, 2.25vw, 1.76rem);
  font-weight: 740;
  line-height: 1.25;
  letter-spacing: -.032em;
}

.wiki-page h3 { margin: 1.5rem 0 .55rem; font-size: 1.08rem; line-height: 1.35; }
.wiki-page :is(p, ul, ol, dl) { color: var(--body); }
.wiki-page > :is(p, ul, ol, dl) { max-inline-size: 74ch; margin-block: .72rem; }
.wiki-page :is(ul, ol) { padding-inline-start: 1.4em; }
.wiki-page li + li { margin-top: .32rem; }
.wiki-page li::marker { color: var(--accent); }
.wiki-page strong { color: var(--text); }
.wiki-page dt { color: var(--text); font-weight: 680; }
.wiki-page dd { margin: .15rem 0 .75rem; }
.wiki-page :is(p, a, li) { overflow-wrap: anywhere; }
.wiki-page .lead { max-inline-size: 62ch; font-size: clamp(1.02rem, 1.4vw, 1.15rem); line-height: 1.65; }

.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: clamp(24px, 4.1vw, 48px);
  border: 1px solid #384333;
  border-radius: 15px;
  background: radial-gradient(ellipse at 93% -10%, #27371d, transparent 56%), linear-gradient(140deg, #1a251b, #171d21 76%);
}

.hero::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  background-image: linear-gradient(90deg, #bff07115 1px, transparent 1px), linear-gradient(#bff07115 1px, transparent 1px);
  background-size: 28px 28px;
  content: "";
  mask-image: linear-gradient(110deg, transparent 44%, #000);
  pointer-events: none;
}

.hero .eyebrow, .wiki-page .eyebrow {
  margin: 0 0 .7rem;
  color: var(--accent);
  font-size: .77rem;
  font-weight: 760;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.hero .lead { max-inline-size: 56ch; }
.hero > :last-child { margin-bottom: 0; }

.topic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 1rem 0 1.6rem;
}

.topic-card {
  display: block;
  min-width: 0;
  min-height: 138px;
  padding: 1rem 1.08rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: background-color .16s ease, border-color .16s ease;
}

.topic-card:is(a, button):hover, .topic-card:focus-within { border-color: #596953; background: #1d2622; color: var(--text); }
.topic-card :is(h2, h3, strong) {
  display: block;
  margin: .52rem 0 .28rem;
  padding: 0;
  border: 0;
  font-size: .99rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -.01em;
}

.topic-card :is(p, small), .topic-card > span:not(.card-icon) { display: block; color: var(--muted); font-size: .88rem; line-height: 1.55; }

.card-icon {
  display: inline-grid;
  width: 35px;
  height: 35px;
  place-items: center;
  border: 1px solid #3b4b30;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .95rem;
  font-weight: 730;
}

.card-icon svg { width: 19px; height: 19px; }

.callout, .wiki-page blockquote {
  margin: 1.55rem 0;
  padding: .95rem 1.1rem;
  border: 1px solid #394534;
  border-inline-start: 3px solid var(--accent);
  border-radius: 8px;
  background: #1b251e;
  color: var(--body);
}

.callout > :first-child, .wiki-page blockquote > :first-child { margin-top: 0; }
.callout > :last-child, .wiki-page blockquote > :last-child { margin-bottom: 0; }
.callout p + p { margin-top: .45rem; }

.wiki-page code {
  padding: .12em .3em;
  border-radius: 4px;
  background: var(--raised);
  color: #dae7d2;
  font: .9em ui-monospace, Consolas, monospace;
}

.wiki-page pre {
  max-width: 100%;
  overflow-x: auto;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.wiki-page pre code { padding: 0; background: none; }
.wiki-page hr { margin: 2rem 0; border: 0; border-top: 1px solid var(--line); }
.wiki-page table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.wiki-page :is(th, td) { padding: .55rem .75rem; border: 1px solid var(--line); text-align: start; }
.wiki-page th { background: var(--surface); }

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .35rem 1rem;
  max-width: var(--page-width);
  margin-inline: auto;
  padding: 1.12rem var(--gutter) 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .85rem;
}

.site-footer a { color: var(--body); }
.site-footer a:hover { color: var(--accent); }

@media (max-width: 1050px) {
  .layout { grid-template-columns: 175px minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 700px) {
  :root { --header-height: 112px; }
  .header-inner {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 9px 12px;
    padding-block: 10px 12px;
  }
  .brand { grid-area: 1 / 1; }
  .brand-mark { flex-basis: 34px; width: 34px; height: 34px; }
  .header-inner > :is(.search, .search-wrap) { grid-area: 2 / 1 / 3 / -1; }
  .menu-toggle { display: inline-flex; grid-area: 1 / 2; justify-self: end; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; padding-block: 1.45rem 3.1rem; }
  .sidebar { display: none; position: static; max-height: none; padding: .85rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
  .sidebar.is-open { display: block; }
  .wiki-page h2 { margin-top: 2.1rem; }
  .hero { border-radius: 12px; }
}

@media (max-width: 440px) {
  .topic-grid { grid-template-columns: minmax(0, 1fr); }
  .topic-card { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0s !important; }
}
