/* Design tokens mirror fiveguard.net */
:root {
  --bg: #101827;
  --bg-deep: #07101b;
  --surface: #1d2839;
  --surface-2: #172232;
  --surface-3: #111b29;
  --line: #2d3a4d;
  --line-soft: rgba(255, 255, 255, 0.08);
  --text: #f6f7fb;
  --text-soft: #d8dde5;
  --muted: #a9b2c1;
  --dim: #7f8b9b;
  --gold: #d6a351;
  --gold-light: #efc56f;
  --gold-tint: rgba(214, 163, 81, 0.14);
  --green: #50ac67;
  --blue: #6fa3d8;
  --red: #e2626f;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);

  --header-h: 68px;
  --sidebar-w: 300px;
  --toc-w: 240px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-padding-top: calc(var(--header-h) + 20px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  max-width: 100%;
  overflow-x: clip;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: linear-gradient(135deg, rgba(214, 163, 81, 0.08), rgba(214, 163, 81, 0.025) 24%, transparent 48%),
    linear-gradient(315deg, rgba(68, 112, 158, 0.09), rgba(68, 112, 158, 0.025) 26%, transparent 52%),
    linear-gradient(rgba(214, 163, 81, 0.08) 1px, transparent 1px), linear-gradient(90deg, rgba(214, 163, 81, 0.06) 1px, transparent 1px);
  background-size: auto, auto, 92px 92px, 92px 92px;
  opacity: 0.42;
}

body.no-scroll {
  overflow: hidden;
}

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

svg {
  width: 1em;
  height: 1em;
  flex: none;
}

::selection {
  background: rgba(214, 163, 81, 0.35);
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

kbd {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--dim);
  font: 600 11px/1.4 var(--font);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--gold);
  color: #fff;
  font-weight: 700;
}

.skip-link:focus {
  top: 12px;
}

/* ------------------------------------------------------------- header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr minmax(0, 440px) 1fr;
  align-items: center;
  gap: 24px;
  height: var(--header-h);
  padding: 0 clamp(16px, 2.4vw, 32px);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(7, 16, 27, 0.92);
  backdrop-filter: blur(14px);
}

.header-left,
.header-actions,
.brand {
  display: flex;
  align-items: center;
}

.header-left {
  gap: 10px;
  min-width: 0;
}

.brand {
  gap: 10px;
}

.brand-mark {
  width: 30px;
  height: 30px;
}

.brand-name {
  font-size: 25px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1;
}

.brand-name b {
  color: var(--gold);
  font-weight: 500;
}

.brand-badge {
  margin-left: 2px;
  padding: 3px 8px;
  border: 1px solid rgba(214, 163, 81, 0.4);
  border-radius: 999px;
  background: var(--gold-tint);
  color: var(--gold-light);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.search-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #121d2b;
  color: var(--dim);
  font: 400 14px var(--font);
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease;
}

.search-trigger:hover {
  border-color: rgba(214, 163, 81, 0.6);
  color: var(--muted);
}

.search-trigger svg {
  font-size: 16px;
}

.search-trigger span {
  flex: 1;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  justify-content: flex-end;
  gap: 10px;
}

.header-link {
  padding: 8px 10px;
  color: var(--text-soft);
  font-size: 15px;
  transition: color 160ms ease;
}

.header-link:hover {
  color: var(--gold-light);
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 15px;
  font-weight: 760;
  line-height: 1;
  white-space: nowrap;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

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

.button.ghost {
  background: #121d2b;
  color: var(--text);
}

.button.gold {
  border-color: var(--gold);
  background: var(--gold);
  color: #fff;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--gold-light);
}

.menu-toggle {
  display: none;
  border: 1px solid var(--line);
  background: #121d2b;
  color: var(--text);
}

/* -------------------------------------------------------------- shell */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  max-width: 1520px;
  margin: 0 auto;
}

.sidebar,
.toc {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
}

.sidebar {
  border-right: 1px solid var(--line-soft);
}

.sidebar-scroll {
  display: block;
  height: 100%;
  overflow-y: auto;
  padding: 22px 14px 40px clamp(12px, 2vw, 24px);
}

.nav-group + .nav-group {
  margin-top: 22px;
}

.nav-title {
  margin: 0 0 6px;
  padding: 0 12px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidebar li ul {
  display: none;
  margin: 2px 0 4px 16px;
  padding-left: 6px;
  border-left: 1px solid var(--line-soft);
}

.sidebar li.is-open > ul {
  display: block;
}

.nav-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-link {
  display: block;
  flex: 1;
  min-width: 0;
  margin: 1px 0;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.35;
  transition: background 140ms ease, color 140ms ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.nav-link.is-active {
  background: var(--gold-tint);
  color: var(--gold-light);
  font-weight: 650;
}

.nav-toggle {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--dim);
  font-size: 14px;
  cursor: pointer;
}

.nav-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.nav-toggle svg {
  transition: transform 160ms ease;
}

.is-open > .nav-row .nav-toggle svg {
  transform: rotate(90deg);
}

.sidebar-backdrop {
  display: none;
}

/* --------------------------------------------------------------- main */

.main {
  min-width: 0;
  padding: 44px clamp(18px, 4vw, 64px) 0;
}

.doc {
  max-width: 800px;
  margin: 0 auto;
}

.kicker {
  margin: 0 0 12px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.kicker .sep {
  margin: 0 8px;
  color: var(--dim);
  font-weight: 400;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 40px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.lead {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.prose {
  margin-top: 30px;
  padding-top: 30px;
  border-top: 1px solid var(--line-soft);
  color: var(--text-soft);
  font-size: 16px;
  line-height: 1.7;
  overflow-wrap: break-word;
}

.prose > :first-child,
.hint-body > :first-child,
.tab-panel > :first-child,
.prose blockquote > :first-child {
  margin-top: 0;
}

.prose > :last-child,
.hint-body > :last-child,
.tab-panel > :last-child,
.prose blockquote > :last-child {
  margin-bottom: 0;
}

.prose h2,
.prose h3,
.prose h4 {
  position: relative;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.prose h2 {
  margin: 44px 0 14px;
  font-size: 26px;
}

.prose h3 {
  margin: 36px 0 12px;
  font-size: 21px;
}

.prose h4 {
  margin: 28px 0 10px;
  font-size: 17px;
}

.prose h2 strong,
.prose h3 strong,
.prose h4 strong {
  font-weight: inherit;
}

.anchor {
  position: absolute;
  left: -22px;
  width: 22px;
  color: var(--gold);
  font-weight: 500;
  opacity: 0;
  transition: opacity 140ms ease;
}

.prose :is(h2, h3, h4):hover .anchor,
.anchor:focus-visible {
  opacity: 1;
}

.prose p,
.prose ul,
.prose ol {
  margin: 16px 0;
}

.prose ul,
.prose ol {
  padding-left: 24px;
}

.prose li {
  margin: 6px 0;
}

.prose li::marker {
  color: var(--gold);
}

.prose li > ul,
.prose li > ol {
  margin: 6px 0;
}

.prose a:not(.ref-card) {
  color: var(--gold-light);
  text-decoration: underline;
  text-decoration-color: rgba(214, 163, 81, 0.45);
  text-underline-offset: 3px;
  transition: text-decoration-color 140ms ease;
}

.prose a:not(.ref-card):hover {
  text-decoration-color: var(--gold-light);
}

.prose strong {
  color: var(--text);
  font-weight: 700;
}

.prose mark {
  background: none;
  color: var(--gold-light);
  font-weight: 650;
}

.prose hr {
  margin: 32px 0;
  border: 0;
  border-top: 1px solid var(--line-soft);
}

.prose :not(pre) > code {
  padding: 2px 6px;
  border: 1px solid rgba(214, 163, 81, 0.2);
  border-radius: 5px;
  background: rgba(214, 163, 81, 0.1);
  color: var(--gold-light);
  font: 500 0.875em var(--mono);
  overflow-wrap: anywhere;
}

.prose blockquote {
  margin: 12px 0 20px;
  padding: 12px 16px;
  border-left: 3px solid var(--gold);
  border-radius: 0 8px 8px 0;
  background: var(--surface-2);
  color: var(--text-soft);
}

.prose blockquote + blockquote {
  margin-top: -8px;
}

.prose figure {
  margin: 20px 0;
}

.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  cursor: zoom-in;
}

.prose figcaption:empty {
  display: none;
}

.prose figcaption {
  margin-top: 8px;
  color: var(--dim);
  font-size: 14px;
  text-align: center;
}

.table-wrap {
  margin: 20px 0;
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.prose th,
.prose td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}

.prose th {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
}

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

.empty {
  color: var(--dim);
  font-style: italic;
}

/* --------------------------------------------------------------- code */

.code-block {
  position: relative;
  margin: 18px 0;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-3);
}

.code-block pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  font: 13.5px/1.65 var(--mono);
  tab-size: 4;
}

.code-block code {
  display: block;
  width: max-content;
  min-width: 100%;
  color: #dbe2ee;
  font: inherit;
}

.line {
  display: block;
  min-height: 1.65em;
}

.code-opts.wrap pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.code-opts.wrap code {
  width: auto;
}

.code-opts.ln code {
  counter-reset: line;
}

.code-opts.ln .line {
  position: relative;
  padding-left: 34px;
}

.code-opts.ln .line::before {
  content: counter(line);
  counter-increment: line;
  position: absolute;
  left: 0;
  width: 20px;
  color: var(--dim);
  text-align: right;
  opacity: 0.7;
  user-select: none;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font: 600 12px var(--font);
  cursor: pointer;
  opacity: 0;
  transition: opacity 140ms ease, color 140ms ease, border-color 140ms ease;
}

.code-block:hover .copy-btn,
.copy-btn:focus-visible,
.copy-btn.is-copied {
  opacity: 1;
}

.copy-btn:hover {
  border-color: rgba(214, 163, 81, 0.6);
  color: var(--gold-light);
}

.copy-btn.is-copied {
  border-color: var(--green);
  color: var(--green);
}

@media (hover: none) {
  .copy-btn {
    opacity: 1;
  }
}

.hljs-comment,
.hljs-quote {
  color: var(--dim);
  font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-section,
.hljs-meta {
  color: var(--gold-light);
}

.hljs-string,
.hljs-regexp,
.hljs-addition {
  color: #8fd3a0;
}

.hljs-number,
.hljs-literal,
.hljs-symbol,
.hljs-bullet {
  color: #f0a878;
}

.hljs-title,
.hljs-title.function_,
.hljs-built_in,
.hljs-name {
  color: #8dbcec;
}

.hljs-attr,
.hljs-attribute,
.hljs-variable,
.hljs-template-variable,
.hljs-type {
  color: #c9b3f0;
}

.hljs-deletion {
  color: var(--red);
}

/* -------------------------------------------------------------- hints */

.hint {
  --tone: var(--blue);
  display: flex;
  gap: 12px;
  margin: 18px 0;
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--tone) 34%, transparent);
  border-left: 3px solid var(--tone);
  border-radius: 8px;
  background: color-mix(in srgb, var(--tone) 9%, var(--surface-3));
}

.hint-warning {
  --tone: var(--gold);
}

.hint-danger {
  --tone: var(--red);
}

.hint-success {
  --tone: var(--green);
}

.hint-icon {
  display: flex;
  margin-top: 3px;
  color: var(--tone);
  font-size: 20px;
}

.hint-body {
  flex: 1;
  min-width: 0;
}

.hint-body p {
  margin: 10px 0;
}

.hint .code-block {
  background: rgba(7, 16, 27, 0.6);
}

/* --------------------------------------------------------------- tabs */

.tabs {
  margin: 18px 0;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-2);
}

.tab-list {
  display: flex;
  gap: 4px;
  padding: 6px 6px 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--line-soft);
}

.tab-list button {
  padding: 9px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: 650 14px var(--font);
  white-space: nowrap;
  cursor: pointer;
}

.tab-list button:hover {
  color: var(--text);
}

.tab-list button[aria-selected="true"] {
  border-bottom-color: var(--gold);
  color: var(--gold-light);
}

.tab-panel {
  padding: 14px;
}

/* ---------------------------------------------------------- ref cards */

.ref-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 12px 0;
  padding: 14px 16px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color 160ms ease, transform 160ms ease;
}

.ref-card:hover {
  border-color: rgba(214, 163, 81, 0.62);
  transform: translateY(-1px);
}

.ref-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border: 1px solid rgba(214, 163, 81, 0.4);
  border-radius: 6px;
  background: var(--gold-tint);
  color: var(--gold-light);
  font-size: 18px;
}

.ref-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.ref-title {
  color: var(--text);
  font-weight: 700;
  line-height: 1.35;
}

.ref-desc {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.ref-arrow {
  display: flex;
  color: var(--gold);
  font-size: 18px;
}

.embed {
  position: relative;
  margin: 18px 0;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-3);
}

.embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* -------------------------------------------------------------- pager */

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 56px;
}

.pager-link {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 16px 18px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  line-height: 1.35;
  transition: border-color 160ms ease, transform 160ms ease;
}

.pager-link:hover {
  border-color: rgba(214, 163, 81, 0.62);
  transform: translateY(-1px);
}

.pager-link span {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.pager-link small {
  display: block;
  color: var(--dim);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pager-link svg {
  color: var(--gold);
  font-size: 18px;
}

.pager-link.next {
  text-align: right;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  max-width: 800px;
  margin: 64px auto 0;
  padding: 24px 0 32px;
  border-top: 1px solid var(--line-soft);
  color: var(--dim);
  font-size: 14px;
}

.site-footer p {
  margin: 0;
}

.site-footer b {
  color: var(--muted);
}

.site-footer nav {
  display: flex;
  align-items: center;
  gap: 6px 16px;
  color: var(--muted);
}

.site-footer nav a:not(.icon-btn):hover {
  color: var(--gold-light);
}

.site-footer .icon-btn {
  width: 32px;
  height: 32px;
  font-size: 18px;
}

/* ---------------------------------------------------------------- toc */

.toc-inner {
  height: 100%;
  overflow-y: auto;
  padding: 48px 20px 40px 8px;
}

.toc-title {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.toc ul {
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--line-soft);
  list-style: none;
}

.toc a {
  display: block;
  margin-left: -1px;
  padding: 5px 0 5px 14px;
  border-left: 1px solid transparent;
  color: var(--dim);
  font-size: 13.5px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  transition: color 140ms ease, border-color 140ms ease;
}

.toc .d1 a {
  padding-left: 26px;
}

.toc .d2 a {
  padding-left: 38px;
}

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

.toc a.is-active {
  border-left-color: var(--gold);
  color: var(--gold-light);
}

/* ------------------------------------------------------------- search */

.search-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 16px 16px;
  background: rgba(4, 9, 16, 0.72);
  backdrop-filter: blur(4px);
}

.search-modal[hidden],
.lightbox[hidden] {
  display: none;
}

.search-panel {
  display: flex;
  flex-direction: column;
  width: min(640px, 100%);
  max-height: min(70vh, 620px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  box-shadow: var(--shadow);
}

.search-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--gold);
  font-size: 18px;
}

.search-input-row input {
  flex: 1;
  min-width: 0;
  height: 56px;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text);
  font: 400 16px var(--font);
}

.search-input-row input::-webkit-search-cancel-button {
  display: none;
}

.search-results {
  overflow-y: auto;
  padding: 8px;
}

.search-results:empty {
  display: none;
}

.search-hit {
  display: block;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
}

.search-hit.is-selected {
  border-color: rgba(214, 163, 81, 0.45);
  background: var(--gold-tint);
}

.search-hit-title {
  display: block;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.search-hit-title small {
  margin-left: 8px;
  color: var(--dim);
  font-size: 12px;
  font-weight: 600;
}

.search-hit-text {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-hit mark {
  background: none;
  color: var(--gold-light);
  font-weight: 700;
}

.search-empty {
  margin: 0;
  padding: 28px 12px;
  color: var(--dim);
  font-size: 14px;
  text-align: center;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 9, 16, 0.88);
  cursor: zoom-out;
}

.lightbox img {
  max-width: 100%;
  max-height: calc(100vh - 48px);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

/* --------------------------------------------------------- responsive */

@media (max-width: 1240px) {
  .shell {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }

  .toc {
    display: none;
  }
}

@media (max-width: 1080px) {
  .header-link,
  .header-actions .icon-btn {
    display: none;
  }
}

@media (max-width: 900px) {
  .site-header {
    grid-template-columns: auto 1fr auto;
    gap: 12px;
  }

  .menu-toggle {
    display: inline-grid;
  }

  .shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    width: min(320px, 86vw);
    height: 100dvh;
    border-right: 1px solid var(--line);
    background: var(--bg-deep);
    transform: translateX(-100%);
    transition: transform 220ms ease;
  }

  .nav-open .sidebar {
    transform: none;
  }

  .nav-open .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: block;
    background: rgba(4, 9, 16, 0.7);
  }

  .main {
    padding-top: 30px;
  }

  .anchor {
    display: none;
  }
}

@media (max-width: 640px) {
  .brand-name {
    font-size: 21px;
  }

  .brand-mark {
    width: 26px;
    height: 26px;
  }

  .brand-badge,
  .button.ghost,
  .search-trigger span,
  .search-trigger kbd {
    display: none;
  }

  .search-trigger {
    justify-self: end;
    justify-content: center;
    width: 40px;
    padding: 0;
    color: var(--text);
  }

  .button {
    min-height: 38px;
    padding: 9px 12px;
    font-size: 14px;
  }

  .lead {
    font-size: 17px;
  }

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

  .pager > span:empty {
    display: none;
  }

  .search-modal {
    padding-top: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
