:root {
  --bg: #0a0a0a;
  --border: #262626;
  --text: #f5f5f5;
  --text-dim: #a3a3a3;
  --text-faint: #737373;
  --accent: #818cf8;
  --accent-bright: #a5b4fc;
  --pro: #c084fc;
  --header-h: 61px;
  --sidebar-w: 272px;
  --content-max: 52rem;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  max-width: 100%;
}

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

code, kbd {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.92em;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
}

pre {
  background: #050505;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.65;
}

pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}

/* Python syntax highlighting (build-time via highlight.js) */
.doc-body pre code.hljs {
  display: block;
  padding: 0;
  background: transparent;
  border: 0;
}

.doc-body .hljs-comment,
.doc-body .hljs-quote {
  color: #6a9955;
}

.doc-body .hljs-keyword,
.doc-body .hljs-selector-tag {
  color: #c586c0;
}

.doc-body .hljs-string,
.doc-body .hljs-regexp {
  color: #ce9178;
}

.doc-body .hljs-number,
.doc-body .hljs-literal {
  color: #b5cea8;
}

.doc-body .hljs-title,
.doc-body .hljs-title.function_,
.doc-body .hljs-built_in {
  color: #dcdcaa;
}

.doc-body .hljs-params,
.doc-body .hljs-attr,
.doc-body .hljs-attribute {
  color: #9cdcfe;
}

.doc-body .hljs-variable,
.doc-body .hljs-template-variable {
  color: #9cdcfe;
}

.doc-body .hljs-meta,
.doc-body .hljs-meta .hljs-keyword {
  color: #9cdcfe;
}

.doc-body .hljs-operator,
.doc-body .hljs-punctuation {
  color: #d4d4d4;
}

/* Site header — match landing / changelog */
header.site {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

header.site .site-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

@media (min-width: 901px) {
  nav.site-nav {
    display: flex;
    gap: 28px;
    align-items: center;
    font-size: 14px;
  }

  nav.site-nav a:not(.btn) { color: var(--text-dim); text-decoration: none; }
  nav.site-nav a:not(.btn):hover { color: var(--text); }
  nav.site-nav a[aria-current="page"] { color: var(--text); }
}

.btn {
  display: inline-flex;
  align-items: center;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #0a0a0a; }
.btn-primary:hover { background: var(--accent-bright); color: #0a0a0a; }
.btn-secondary { background: transparent; color: var(--text); border-color: #404040; }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

/* Docs shell */
.docs-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  max-width: 1280px;
  margin: 0 auto;
  min-height: calc(100vh - var(--header-h));
  min-width: 0;
}

.docs-sidebar {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 20px 12px 40px 20px;
  border-right: 1px solid var(--border);
}

.docs-sidebar__search {
  --pagefind-ui-scale: 0.58;
  --pagefind-ui-primary: #818cf8;
  --pagefind-ui-text: #f5f5f5;
  --pagefind-ui-fade: #737373;
  --pagefind-ui-background: #111111;
  --pagefind-ui-border: #262626;
  --pagefind-ui-tag: #1a1a1a;
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: 8px;
  margin-bottom: 16px;
}

.docs-sidebar__search .pagefind-ui {
  width: 100%;
}

.docs-sidebar__search .pagefind-ui__form {
  position: relative;
}

.docs-sidebar__search .pagefind-ui__search-input {
  font-weight: 500;
  padding-right: 4.5rem;
}

.docs-sidebar__search .pagefind-ui__form::after {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-faint);
  pointer-events: none;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  opacity: 0.9;
}

.docs-sidebar__search[data-search-mod='mac'] .pagefind-ui__form::after {
  content: '[⌘K]';
}

.docs-sidebar__search[data-search-mod='win'] .pagefind-ui__form::after {
  content: '[Ctrl+K]';
}

.docs-sidebar__search .pagefind-ui__form:has(.pagefind-ui__search-input:focus)::after,
.docs-sidebar__search .pagefind-ui__form:has(.pagefind-ui__search-input:not(:placeholder-shown))::after {
  display: none;
}

.docs-sidebar__search .pagefind-ui__search-input::placeholder {
  color: var(--text-faint);
  opacity: 1;
}

.docs-sidebar__search .pagefind-ui__search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.45);
}

.docs-sidebar__search .pagefind-ui__search-clear {
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
}

.docs-sidebar__search .pagefind-ui__search-clear:hover {
  color: var(--text);
}

.docs-sidebar__search .pagefind-ui__drawer {
  margin-top: 8px;
}

.docs-sidebar__search .pagefind-ui__result {
  border-color: var(--border);
}

.docs-sidebar__search .pagefind-ui__result-title .pagefind-ui__result-link {
  color: var(--text);
}

.docs-sidebar__search .pagefind-ui__result-excerpt {
  color: var(--text-dim);
}

.docs-sidebar__search .pagefind-ui__message {
  color: var(--text-dim);
}

.docs-nav-group {
  margin-bottom: 18px;
}

.docs-nav-group__label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 8px 8px;
}

.docs-nav-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.docs-nav-group a {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-dim);
  text-decoration: none;
}

.docs-nav-group a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.docs-nav-group a[aria-current="page"] {
  color: var(--accent-bright);
  background: rgba(129, 140, 248, 0.12);
}

.docs-main {
  padding: 28px 32px 80px;
  max-width: calc(var(--content-max) + 64px);
  min-width: 0;
}

.docs-main--scroll {
  padding-bottom: 120px;
}

.doc-intro {
  margin-bottom: 8px;
}

.doc-ref-callouts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 16px 0 8px;
}

.doc-ref-callout {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  border: 1px solid rgba(129, 140, 248, 0.28);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.08) 0%, rgba(255, 255, 255, 0.02) 60%);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.doc-ref-callout:hover {
  border-color: rgba(129, 140, 248, 0.5);
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.12) 0%, rgba(255, 255, 255, 0.03) 60%);
}

.doc-ref-callout__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.doc-ref-callout__desc {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
}

.doc-section {
  padding: 36px 0;
  border-top: 1px solid var(--border);
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.doc-section__title {
  font-size: clamp(22px, 2.5vw, 28px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
  line-height: 1.2;
  color: var(--text);
  position: relative;
}

/* Click-to-copy anchor link beside section and subsection headings */
.heading-anchor {
  display: inline-block;
  margin-left: 8px;
  color: var(--accent);
  opacity: 0;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.12s;
  user-select: none;
}
.heading-anchor:hover { color: var(--accent-bright); }
.doc-section__title:hover .heading-anchor,
.doc-body h2:hover .heading-anchor,
.doc-body h3:hover .heading-anchor,
.doc-body h4:hover .heading-anchor,
.doc-body h5:hover .heading-anchor,
.heading-anchor:focus { opacity: 1; }
@media (hover: none) {
  .heading-anchor { opacity: 0.5; }
}

.doc-section .doc-body {
  font-size: 15px;
}

.docs-main h1 {
  font-size: clamp(28px, 3vw, 36px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
  line-height: 1.15;
}

.doc-body {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.65;
}

.doc-body h2,
.doc-body h3,
.doc-body h4,
.doc-body h5 {
  position: relative;
  scroll-margin-top: calc(var(--header-h) + 16px);
}

/* Subsection heading: off-blue so it reads as a heading, not a table header */
.doc-body h4 {
  margin: 28px 0 10px;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--accent-bright);
  font-weight: 600;
  text-transform: none;
}

.doc-body h5 {
  margin: 18px 0 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 700;
}

.doc-body p { margin: 0 0 12px; }

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

.doc-body th,
.doc-body td {
  text-align: left;
  padding: 8px 12px 8px 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.doc-body th {
  color: var(--text-faint);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.doc-body td:first-child code { color: var(--accent); }

.doc-body ul,
.doc-body ol {
  margin: 0 0 14px;
  padding-left: 1.25em;
}

.doc-body iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 10px;
  margin: 12px 0 16px;
}

/* Factory preset device dropdowns (factory-presets.md) */
.doc-device-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0 20px;
}

.doc-device {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-1);
  overflow: hidden;
}

.doc-device summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.doc-device summary::-webkit-details-marker { display: none; }

.doc-device summary::before {
  content: '▸';
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-faint);
  transition: transform 0.15s ease;
}

.doc-device[open] summary::before {
  transform: rotate(90deg);
}

.doc-device summary:hover {
  color: var(--accent-bright);
}

.doc-device--plain {
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: default;
}

.doc-device--plain:hover {
  color: var(--text);
}

.doc-device summary a,
.doc-device--plain a {
  color: inherit;
  text-decoration: none;
}

.doc-device summary a:hover,
.doc-device--plain a:hover {
  color: var(--accent-bright);
  text-decoration: underline;
}

.doc-device-plain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
  margin-bottom: 2px;
}

.doc-device-plain-grid .doc-device--plain {
  font-size: 13px;
  font-weight: 500;
}

.doc-device__body {
  padding: 0 14px 12px 32px;
  border-top: 1px solid var(--border);
}

.doc-device__body p {
  margin: 10px 0 0;
  font-size: 14px;
}

.doc-device-list .doc-note {
  margin: 4px 0 8px;
}

.doc-note {
  margin-top: 16px;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 0 6px 6px 0;
  font-size: 13px;
}

.pro-badge {
  font-size: 0.85em;
  color: var(--pro);
  font-weight: 600;
}

.docs-pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.docs-pager a { color: var(--text-dim); }
.docs-pager a:hover { color: var(--accent); }

/* ── Video tutorial hub & per-topic callouts ─────────────────────────────── */

.doc-video-callout {
  margin: 0 0 20px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(129, 140, 248, 0.06);
}

.doc-video-callout__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 14px;
}

.doc-video-callout__icon {
  color: var(--accent-bright);
  font-size: 12px;
}

.doc-video-callout__desc {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.45;
}

.doc-video-callout__links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.doc-video-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border: 1px solid rgba(129, 140, 248, 0.35);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--accent-bright);
  font-family: var(--font, 'Inter', system-ui, sans-serif);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  cursor: pointer;
  text-align: left;
  max-width: 100%;
  white-space: normal;
}

.doc-video-link:hover {
  border-color: var(--accent);
  background: rgba(129, 140, 248, 0.12);
  color: var(--text);
}

.doc-video-link--timestamp {
  padding: 2px 6px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 600;
  border: 0;
  background: transparent;
  color: var(--accent);
}

.doc-video-link--timestamp:hover {
  background: rgba(129, 140, 248, 0.1);
  color: var(--accent-bright);
}

.doc-video-hub {
  margin: 28px 0 36px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(129, 140, 248, 0.08), rgba(0, 0, 0, 0.2));
}

.doc-video-hub__title {
  margin: 0 0 6px;
  font-size: 1.15rem;
  font-weight: 600;
}

.doc-video-hub__lead {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-dim);
  max-width: 42rem;
  line-height: 1.45;
}

.doc-video-hub__embed {
  margin: 0 0 14px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  aspect-ratio: 16 / 9;
}

.doc-video-hub__embed iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.doc-video-hub--embed {
  margin-top: 0;
}

.doc-video-embed {
  margin: 0 0 20px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  aspect-ratio: 16 / 9;
}

.doc-video-embed iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.doc-video-embed__caption {
  margin: 0;
  padding: 8px 12px;
  font-size: 12px;
  text-align: right;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
}

.doc-video-embed__caption a {
  color: var(--text-faint);
}

.doc-video-embed__caption a:hover {
  color: var(--accent-bright);
}

.doc-video-hub__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.doc-video-hub__play {
  font-size: 13px;
  padding: 8px 14px;
}

.doc-video-hub__external {
  font-size: 13px;
  color: var(--text-dim);
}

.doc-video-hub__external:hover {
  color: var(--accent-bright);
}

.doc-video-hub__chapters {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.doc-video-hub__summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.doc-video-hub__summary::-webkit-details-marker {
  display: none;
}

.doc-video-hub__summary::before {
  content: '▸';
  flex-shrink: 0;
  color: var(--text-faint);
  font-size: 11px;
  transition: transform 0.15s ease;
}

.doc-video-hub__chapters[open] > .doc-video-hub__summary::before {
  transform: rotate(90deg);
}

.doc-video-hub__count {
  font-weight: 500;
  color: var(--text-faint);
}

.doc-video-hub__chapters[open] > .doc-video-hub__table-wrap {
  border-top: 1px solid var(--border);
}

.doc-video-hub__table-wrap {
  overflow-x: auto;
}

.doc-video-hub__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.doc-video-hub__table th,
.doc-video-hub__table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.doc-video-hub__table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  background: rgba(0, 0, 0, 0.25);
}

.doc-video-hub__table tr:last-child td {
  border-bottom: 0;
}

.doc-video-hub__docs {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.5;
}

.doc-video-hub__docs a {
  white-space: nowrap;
}

.doc-video-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.doc-video-modal[hidden] {
  display: none !important;
}

.doc-video-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
}

.doc-video-modal__panel {
  position: relative;
  z-index: 1;
  width: min(960px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 16px 16px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0d0d0d;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.65);
}

.doc-video-modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.doc-video-modal__close:hover {
  color: var(--text);
  border-color: var(--border-mid, #404040);
}

.doc-video-modal__title {
  margin: 0 32px 10px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.doc-video-modal__frame-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}

.doc-video-modal__iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.doc-video-modal__youtube {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-faint);
}

.doc-video-modal__youtube:hover {
  color: var(--accent-bright);
}

body.doc-video-modal-open {
  overflow: hidden;
}

.docs-pager__label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.docs-sidebar-toggle {
  display: none;
  margin: 12px 16px 0;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #111;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

@media (max-width: 900px) {
  :root {
    --header-h: 57px;
  }

  .docs-shell {
    grid-template-columns: 1fr;
  }

  .docs-sidebar-toggle {
    display: inline-block;
    margin: 10px 14px 0;
    max-width: calc(100% - 28px);
  }

  .docs-sidebar {
    display: none;
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 12px 14px 16px;
  }

  .docs-sidebar.is-open {
    display: block;
  }

  .docs-main {
    padding: 16px 14px 64px;
  }

  .doc-video-hub {
    padding: 12px 14px;
  }

  .doc-video-callout__links {
    flex-direction: column;
    align-items: stretch;
  }

  .doc-ref-callouts {
    grid-template-columns: 1fr;
  }

  .docs-main h1 {
    font-size: 26px;
  }

  .doc-section__title {
    font-size: 22px;
  }

  .doc-body table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .doc-body thead,
  .doc-body tbody,
  .doc-body tr {
    display: table;
    width: 100%;
    table-layout: fixed;
  }
}
