@font-face {
  font-family: "Inter";
  src: url("../vendor/Inter-VariableFont_wght.woff2") format("woff2-variations");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

/* ── Shared tokens ─────────────────────────── */

:root {
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --font-sans: "Inter", -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Consolas", "Liberation Mono", Menlo, monospace;
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
  --header-height: 65px;
  --sidebar-width: 260px;
  --toc-width: 220px;
}

/* ── Light theme (default) ─────────────────── */

:root,
[data-theme="light"] {
  color-scheme: light;
  --color-bg: #f7f7f8;
  --color-surface: #ffffff;
  --color-surface-raised: #f0f0f3;
  --color-surface-overlay: #e8e8ec;
  --color-text: #171719;
  --color-text-secondary: #5f5f6a;
  --color-text-tertiary: #8b8b96;
  --color-accent: #5e6ad2;
  --color-accent-light: #4f5bc0;
  --color-accent-hover: #3b44a8;
  --color-accent-muted: rgba(94, 106, 210, 0.08);
  --color-border: rgba(0, 0, 0, 0.06);
  --color-border-strong: rgba(0, 0, 0, 0.1);
  --color-code-bg: #1b1b22;
  --color-code-text: #e4e4e7;
  --color-info: rgba(56, 139, 253, 0.06);
  --color-warning: rgba(227, 179, 65, 0.06);
  --color-danger: rgba(248, 81, 73, 0.06);
  --color-note: rgba(94, 106, 210, 0.04);
  --color-info-strong: #2563eb;
  --color-warning-strong: #b45309;
  --color-danger-strong: #dc2626;
  --color-note-strong: #5e6ad2;
  --color-highlight: rgba(227, 179, 65, 0.25);
  --shadow-soft: 0 16px 40px rgba(0, 0, 0, 0.06);
  --shadow-tight: 0 4px 12px rgba(0, 0, 0, 0.04);
  --header-bg: rgba(247, 247, 248, 0.85);
  --hover-bg: rgba(0, 0, 0, 0.04);
  --scrollbar-thumb: rgba(0, 0, 0, 0.1);
  --scrollbar-thumb-hover: rgba(0, 0, 0, 0.18);
  --sidebar-mobile-bg: rgba(247, 247, 248, 0.96);
  --inline-code-bg: rgba(94, 106, 210, 0.07);
  --inline-code-border: rgba(94, 106, 210, 0.12);
  --inline-code-color: #4f5bc0;
}

/* ── Dark theme ────────────────────────────── */

[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #09090b;
  --color-surface: #111113;
  --color-surface-raised: #19191c;
  --color-surface-overlay: #222225;
  --color-text: #ededef;
  --color-text-secondary: #a0a0a6;
  --color-text-tertiary: #6e6e76;
  --color-accent: #5e6ad2;
  --color-accent-light: #818cf8;
  --color-accent-hover: #a5b4fc;
  --color-accent-muted: rgba(94, 106, 210, 0.15);
  --color-border: rgba(255, 255, 255, 0.07);
  --color-border-strong: rgba(255, 255, 255, 0.12);
  --color-code-bg: #0d0d0f;
  --color-code-text: #e4e4e7;
  --color-info: rgba(56, 139, 253, 0.08);
  --color-warning: rgba(227, 179, 65, 0.08);
  --color-danger: rgba(248, 81, 73, 0.08);
  --color-note: rgba(94, 106, 210, 0.06);
  --color-info-strong: #6cb6ff;
  --color-warning-strong: #e3b341;
  --color-danger-strong: #f85149;
  --color-note-strong: #818cf8;
  --color-highlight: rgba(227, 179, 65, 0.2);
  --shadow-soft: 0 16px 40px rgba(0, 0, 0, 0.4);
  --shadow-tight: 0 4px 12px rgba(0, 0, 0, 0.3);
  --header-bg: rgba(9, 9, 11, 0.8);
  --hover-bg: rgba(255, 255, 255, 0.04);
  --scrollbar-thumb: rgba(255, 255, 255, 0.08);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.15);
  --sidebar-mobile-bg: rgba(9, 9, 11, 0.96);
  --inline-code-bg: var(--color-surface-raised);
  --inline-code-border: var(--color-border);
  --inline-code-color: #818cf8;
}

/* ── Reset ─────────────────────────────────── */

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--color-text);
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--color-accent-muted);
  color: var(--color-text);
}

/* ── Skip link ─────────────────────────────── */

.skip-link {
  position: absolute;
  left: -999px;
  top: 12px;
  background: var(--color-accent);
  color: #fff;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  z-index: 999;
  text-decoration: none;
  font-size: 13px;
}

.skip-link:focus {
  left: 16px;
}

/* ── Header ────────────────────────────────── */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--color-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  box-shadow: none;
}

.brand-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

.brand-subtitle {
  display: none;
}

.brand-divider {
  width: 1px;
  height: 16px;
  background: var(--color-border-strong);
  margin: 0 4px;
}

.brand-section {
  font-size: 14px;
  font-weight: 400;
  color: var(--color-text-tertiary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Product switcher ──────────────────────── */

.product-switcher {
  position: relative;
}

.product-switcher-button {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 6px 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  white-space: nowrap;
  color: var(--color-text-tertiary);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast),
    border-color var(--transition-fast);
}

.product-switcher-button:hover {
  background: var(--hover-bg);
  border-color: var(--color-border);
  color: var(--color-text);
}

.product-switcher-button[aria-expanded="true"] {
  background: var(--hover-bg);
  border-color: var(--color-border-strong);
  color: var(--color-text);
}

.product-switcher-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.product-switcher-button[aria-expanded="true"] .product-switcher-chevron {
  transform: rotate(180deg);
}

.product-switcher-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 60;
  min-width: 250px;
  padding: 6px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: var(--color-surface);
  box-shadow: var(--shadow-soft);
}

.product-switcher-menu[hidden] {
  display: none;
}

.product-switcher-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  text-decoration: none;
  transition: background var(--transition-fast);
}

.product-switcher-option:hover {
  background: var(--hover-bg);
}

.product-switcher-option-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.product-switcher-option-title {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.product-switcher-option-desc {
  font-size: 12px;
  line-height: 1.35;
  color: var(--color-text-tertiary);
}

.product-switcher-option.active .product-switcher-option-title {
  color: var(--color-accent);
}

.product-switcher-check {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--color-accent);
  opacity: 0;
}

.product-switcher-option.active .product-switcher-check {
  opacity: 1;
}

/* ── Theme toggle ──────────────────────────── */

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong);
  background: transparent;
  color: var(--color-text-tertiary);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
  padding: 0;
}

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

.theme-toggle svg {
  width: 16px;
  height: 16px;
}

.theme-toggle .icon-sun {
  display: none;
}

.theme-toggle .icon-moon {
  display: block;
}

[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

/* ── Search ────────────────────────────────── */

.search {
  position: relative;
}

.search input {
  width: 200px;
  padding: 7px 34px 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 13px;
  transition: width var(--transition-normal), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search input::placeholder {
  color: var(--color-text-tertiary);
}

.search input:focus {
  width: 320px;
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-muted);
  background: var(--color-surface);
}

.search-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--color-text-tertiary);
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 380px;
  max-height: 400px;
  overflow: auto;
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border-strong);
  box-shadow: var(--shadow-soft);
  padding: 6px;
  display: none;
  z-index: 100;
}

.search-results.active {
  display: block;
}

.search-result {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--color-text);
  transition: background var(--transition-fast);
}

.search-result:hover {
  background: var(--hover-bg);
}

.search-result-title {
  font-weight: 500;
  font-size: 13px;
}

.search-result-snippet {
  color: var(--color-text-tertiary);
  font-size: 12px;
  margin-top: 2px;
  line-height: 1.4;
}

/* ── Mobile nav toggle ─────────────────────── */

.nav-toggle {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 12px;
  transition: background var(--transition-fast);
}

.nav-toggle:hover {
  background: var(--hover-bg);
}

.nav-toggle-lines {
  width: 14px;
  height: 10px;
  position: relative;
}

.nav-toggle-lines::before,
.nav-toggle-lines::after,
.nav-toggle-lines span {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 1.5px;
  background: currentColor;
  border-radius: 2px;
}

.nav-toggle-lines::before { top: 0; }
.nav-toggle-lines::after { bottom: 0; }
.nav-toggle-lines span { top: 4px; }

.nav-toggle-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

/* ── Layout ────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--toc-width);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────── */

.sidebar {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 4px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

.sidebar-inner {
  background: transparent;
  border-right: 1px solid var(--color-border);
  padding: 16px 12px;
}

/* Drawer chrome — only ever visible in the mobile drawer, where the site
   header is covered and the nav needs its own close affordance. */

.sidebar-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-header-title {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-tertiary);
}

.sidebar-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.sidebar-close:hover {
  color: var(--color-text);
  background: var(--hover-bg);
}

.sidebar-close svg {
  width: 18px;
  height: 18px;
}

.sidebar-search {
  margin-bottom: 12px;
}

.nav-group {
  margin-bottom: 15px;
}

.nav-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: none;
  background: none;
  font-weight: 500;
  padding: 6px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-tertiary);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: color var(--transition-fast);
}

.nav-group-title:hover {
  color: var(--color-text-secondary);
}

.nav-group-items {
  display: grid;
  gap: 1px;
  padding: 2px 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 400;
  transition: color var(--transition-fast), background var(--transition-fast);
  line-height: 1.4;
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity var(--transition-fast);
}

.nav-link:hover .nav-icon {
  opacity: 0.75;
}

.nav-link.active .nav-icon {
  opacity: 1;
}

.nav-link:hover {
  color: var(--color-text);
  background: var(--hover-bg);
}

.nav-link.active {
  color: var(--color-accent-light);
  background: var(--color-accent-muted);
  font-weight: 500;
}

/* ── Content area ──────────────────────────── */

.content {
  min-width: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

.content::-webkit-scrollbar { width: 4px; }
.content::-webkit-scrollbar-track { background: transparent; }
.content::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 4px;
}
.content::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

.doc-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 50px;
}

/* ── Typography ────────────────────────────── */

.doc-content h1 {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin: 0 0 8px;
  color: var(--color-text);
}

.doc-badge {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  transform: translateY(-3px);
  margin-left: 12px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.doc-badge--soon {
  color: var(--color-warning-strong);
  background: rgba(227, 179, 65, 0.14);
  border: 1px solid rgba(227, 179, 65, 0.4);
}

.doc-content h1 + p {
  font-size: 16px;
  color: var(--color-text-secondary);
  margin-top: 0;
}

.doc-content h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin: 48px 0 16px;
  padding-top: 24px;
  border-top: 1px solid var(--color-border);
  color: var(--color-text);
  scroll-margin-top: 80px;
}

.doc-content h2:first-child,
.doc-content h1 + h2 {
  border-top: none;
  margin-top: 32px;
  padding-top: 0;
}

.doc-content h3 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.4;
  margin: 32px 0 12px;
  color: var(--color-text);
  scroll-margin-top: 80px;
}

.doc-content p {
  color: var(--color-text-secondary);
  line-height: 1.7;
  margin: 12px 0;
}

.doc-content a {
  color: var(--color-accent-light);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.doc-content a:hover {
  color: var(--color-accent-hover);
}

.doc-content strong {
  color: var(--color-text);
  font-weight: 600;
}

.doc-content ul,
.doc-content ol {
  color: var(--color-text-secondary);
  line-height: 1.7;
  padding-left: 20px;
  margin: 12px 0;
}

.doc-content li {
  margin: 4px 0;
}

.doc-content li::marker {
  color: var(--color-text-tertiary);
}

/* ── Inline code ───────────────────────────── */

.doc-content code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--inline-code-bg);
  color: var(--inline-code-color);
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--inline-code-border);
}

/* ── Code blocks ───────────────────────────── */

.doc-content pre {
  background: var(--color-code-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  overflow-x: auto;
  position: relative;
  margin: 16px 0;
}

.doc-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-code-text);
  font-size: 13px;
  line-height: 1.6;
}

.copy-button {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.4);
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 11px;
  font-family: var(--font-sans);
  font-weight: 500;
  transition: all var(--transition-fast);
  opacity: 0;
}

.doc-content pre:hover .copy-button {
  opacity: 1;
}

.copy-button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.6);
}

/* ── Tables ────────────────────────────────── */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 16px 0;
}

.table-wrap {
  overflow-x: auto;
  margin: 16px 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.table-wrap .table {
  margin: 0;
  min-width: 720px;
}

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

.table th {
  color: var(--color-text-tertiary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--color-surface-raised);
}

.table td {
  color: var(--color-text-secondary);
}

.table tr:last-child td {
  border-bottom: none;
}

.table td code {
  font-size: 12px;
}

/* ── Callouts ──────────────────────────────── */

.callout {
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 20px 0;
  border: 1px solid var(--color-border);
}

.callout > strong:first-child {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.callout p {
  font-size: 14px;
  margin: 0;
}

.callout p:last-child {
  margin-bottom: 0;
}

.callout.info {
  background: var(--color-info);
}

.callout.info strong {
  color: var(--color-info-strong);
}

.callout.warning {
  background: var(--color-warning);
}

.callout.warning strong {
  color: var(--color-warning-strong);
}

.callout.danger {
  background: var(--color-danger);
}

.callout.danger strong {
  color: var(--color-danger-strong);
}

.callout.note {
  background: var(--color-note);
}

.callout.note strong {
  color: var(--color-note-strong);
}

/* ── Figures (screenshots) ─────────────────── */

.doc-figure {
  margin: 24px 0 28px;
}

/* Screenshots are captured at 2x, so their intrinsic pixel size is double
   what should be drawn. The width/height attributes in the markup carry the
   intended CSS size — deliberately no `width` here, so those attributes are
   what sizes the image. Add --fill or --wide when a figure should stretch
   instead. */
.doc-figure img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  box-shadow: var(--shadow-tight);
  cursor: zoom-in;
}

.doc-figure--fill img,
.doc-figure--wide img {
  width: 100%;
}

/* Screenshots ship in a pair — one taken with the product in light mode,
   one in dark — so the image matches the theme the reader chose. Only
   one of the pair is ever in the layout. */
.doc-figure img.fig-dark {
  display: none;
}

[data-theme="dark"] .doc-figure img.fig-light {
  display: none;
}

[data-theme="dark"] .doc-figure img.fig-dark {
  display: block;
}

.doc-figure figcaption {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--color-text-secondary);
}

/* Numbered legend under an annotated screenshot. The numbers match the
   badges drawn on the image. */
.doc-figure ol.fig-legend {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: fig-step;
}

.doc-figure ol.fig-legend li {
  position: relative;
  counter-increment: fig-step;
  margin: 0 0 6px;
  padding-left: 30px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--color-text-secondary);
}

.doc-figure ol.fig-legend li::before {
  content: counter(fig-step);
  position: absolute;
  left: 0;
  top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  border-radius: 999px;
  background: var(--color-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

/* Wide figures escape the prose column — a full-editor screenshot is
   unreadable at 720px. Capped so it never collides with the TOC. */
.doc-figure--wide {
  width: 100%;
  max-width: 100%;
}


/* ── Lightbox ──────────────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: rgba(9, 9, 11, 0.82);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility 0s linear var(--transition-normal);
}

.lightbox.open {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--transition-normal), visibility 0s;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  cursor: zoom-out;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* ── Anchor links ──────────────────────────── */

.anchor-link {
  margin-left: 8px;
  font-size: 14px;
  color: var(--color-text-tertiary);
  text-decoration: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.doc-content h2:hover .anchor-link,
.doc-content h3:hover .anchor-link {
  opacity: 1;
}

.anchor-link:hover {
  color: var(--color-accent-light);
}

/* ── Table of contents ─────────────────────── */

.toc {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

.toc::-webkit-scrollbar { width: 4px; }
.toc::-webkit-scrollbar-track { background: transparent; }
.toc::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 4px;
}
.toc::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

.toc-inner {
  background: transparent;
  border-left: 1px solid var(--color-border);
  padding: 0 16px;
  margin-top: 50px;
}

.toc-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-tertiary);
  font-weight: 500;
  margin-bottom: 8px;
  padding: 0 8px;
}

.toc a {
  display: block;
  text-decoration: none;
  color: var(--color-text-tertiary);
  font-size: 12px;
  padding: 8px 8px;
  border-radius: var(--radius-xs);
  line-height: 1.4;
  transition: color var(--transition-fast), background var(--transition-fast);
}

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

/* ── Search highlights ─────────────────────── */

mark.search-hit {
  background: var(--color-highlight);
  color: var(--color-text);
  padding: 1px 4px;
  border-radius: 3px;
}

/* ── Syntax highlighting (always dark) ─────── */

.syntax-keyword { color: #c084fc; }
.syntax-string { color: #86efac; }
.syntax-comment { color: #525259; }
.syntax-number { color: #93c5fd; }
.syntax-function { color: #fbbf24; }

/* ── Responsive ────────────────────────────── */

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

  .toc {
    display: none;
  }

  /* No TOC column to avoid any more. */
  .doc-figure--wide {
    width: min(calc(100vw - var(--sidebar-width) - 100px), 1040px);
  }
}

@media (max-width: 900px) {
  .site-header {
    height: auto;
    padding: 12px 16px;
    gap: 10px;
  }

  /* Anchor the menu to the right of the switcher so a narrow viewport
     can't push it off-screen. */
  .product-switcher-menu {
    left: auto;
    right: 0;
    min-width: 220px;
    max-width: calc(100vw - 32px);
  }

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

  /* The sidebar is a drawer here, so there is no column to break out of. */
  .doc-figure--wide {
    width: 100%;
    margin-left: 0;
    transform: none;
  }

  /* Full-screen drawer: its own header stays put while the nav scrolls under
     it. Hidden rather than merely off-screen so it's not tabbable when shut. */
  .sidebar {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--sidebar-mobile-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transform: translateX(-100%);
    visibility: hidden;
    /* Hiding waits for the slide-out to finish; showing is immediate, so the
       drawer is focusable the moment it opens. */
    transition: transform 0.3s ease, visibility 0s linear 0.3s;
    z-index: 100;
    padding: 0;
    overflow: hidden;
  }

  .sidebar.open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.3s ease, visibility 0s;
  }

  .sidebar-header {
    display: flex;
  }

  .sidebar-inner {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    border: none;
    padding: 16px 12px calc(32px + env(safe-area-inset-bottom, 0px));
  }

  .nav-toggle {
    display: inline-flex;
    order: 1;
  }

  /* Search now lives in the drawer: full-width field, and results drop into
     the flow so they scroll with the nav instead of floating over it. */
  .sidebar-search .search input,
  .sidebar-search .search input:focus {
    width: 100%;
    padding: 10px 36px 10px 12px;
    font-size: 16px; /* 16px keeps iOS from zooming the page on focus */
  }

  /* Results sit inside .search, so the icon can't centre on the whole box
     any more — pin it to the input row (42px tall) instead. */
  .sidebar-search .search-icon {
    top: 21px;
  }

  .sidebar-search .search-results {
    position: static;
    width: 100%;
    max-height: none;
    margin-top: 10px;
    padding: 4px;
    box-shadow: none;
  }

  .doc-content {
    padding: 24px 20px 60px;
  }
}

@media (max-width: 640px) {
  .doc-content {
    padding: 20px 16px 60px;
  }

  .doc-content h1 {
    font-size: 24px;
  }

  .doc-content h2 {
    font-size: 18px;
  }

  .brand {
    gap: 8px;
  }

  /* Icon-only menu button, so the brand and product switcher keep their
     single line on narrow phones. */
  .nav-toggle {
    width: 32px;
    height: 32px;
    justify-content: center;
    padding: 0;
  }

  .nav-toggle-label {
    display: none;
  }
}
