:root {
  color-scheme: dark;
  --bg: #0b1326;
  --bg-gradient: rgba(6, 182, 212, 0.06);
  --bg-soft: #101a31;
  --surface: #131d33;
  --surface-2: #18243c;
  --surface-3: #202c45;
  --text: #e5edf8;
  --muted: #97a8bd;
  --muted-2: #6f8197;
  --border: rgba(134, 147, 151, 0.22);
  --border-strong: rgba(6, 182, 212, 0.5);
  --accent: #06b6d4;
  --accent-strong: #4cd7f6;
  --warning: #f59e0b;
  --code-bg: #071025;
  --code-text: #e5edf8;
  --inline-code-text: #4cd7f6;
  --mark-text: #042430;
  --control-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  --radius: 8px;
  --header-h: 64px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f8fb;
  --bg-gradient: rgba(8, 145, 178, 0.08);
  --bg-soft: #e9f1f7;
  --surface: #ffffff;
  --surface-2: #eef4f8;
  --surface-3: #dfe9f1;
  --text: #111827;
  --muted: #475569;
  --muted-2: #64748b;
  --border: rgba(15, 23, 42, 0.16);
  --border-strong: rgba(8, 145, 178, 0.6);
  --accent: #0e7490;
  --accent-strong: #0f6f87;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --inline-code-text: #e2e8f0;
  --mark-text: #f0fdfa;
  --control-shadow: 0 18px 46px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, var(--bg-gradient), transparent 280px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
}

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

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

button,
input {
  font: inherit;
}

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

.devbrain-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: var(--header-h);
  padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

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

.brand {
  gap: 10px;
  color: var(--text);
  font-weight: 750;
  letter-spacing: 0;
}

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

.brand-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: var(--mark-text);
  font-size: 0.78rem;
  font-weight: 800;
}

.icon-button {
  color: var(--muted);
  font-size: 0.9rem;
}

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

.header-actions {
  gap: 10px;
  margin-left: auto;
}

.icon-button {
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

button.icon-button {
  color: var(--muted);
}

.home-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 56px 0 80px;
}

.search-hero {
  max-width: 860px;
  margin: 0 auto 44px;
  text-align: center;
}

.eyebrow,
.sidebar-kicker,
.toc-title {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.search-hero h1 {
  margin: 0;
  font-size: clamp(3rem, 8vw, 5.8rem);
  line-height: 1;
  letter-spacing: 0;
}

.intro {
  max-width: 680px;
  margin: 18px auto 28px;
  color: var(--muted);
  font-size: 1.05rem;
}

.global-search,
.section-filter {
  display: grid;
  gap: 8px;
  text-align: left;
}

.global-search span,
.section-filter span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.global-search input,
.section-filter input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--text);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 8%, transparent), var(--control-shadow);
}

.global-search input {
  min-height: 62px;
  padding: 0 20px;
  font-size: 1.05rem;
}

.section-filter input {
  min-height: 46px;
  padding: 0 14px;
}

.global-search input:focus,
.section-filter input:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.12);
}

.search-results,
.index-list,
.recent-list,
.tree-section ul,
.toc-panel ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.search-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
  max-height: 310px;
  overflow: auto;
  padding-right: 4px;
  text-align: left;
}

.doc-result {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.doc-result[hidden] {
  display: none;
}

.doc-result a {
  color: var(--text);
  font-weight: 700;
}

.doc-result span,
.recent-list span,
.article-meta {
  color: var(--muted-2);
  font-size: 0.86rem;
}

.home-section {
  margin-top: 34px;
}

.section-title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.home-section h2,
.section-header h1,
.article-header h1 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: 0;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

.topic-card {
  display: grid;
  gap: 8px;
  min-height: 168px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.topic-card:hover {
  border-color: var(--border-strong);
  text-decoration: none;
}

.topic-icon {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--surface-3);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
}

.topic-card span,
.topic-card small {
  color: var(--muted);
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);
  gap: 18px;
}

.two-column > div {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.88rem;
}

.recent-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.recent-list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.docs-layout,
.section-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 220px;
  gap: 28px;
  width: min(1480px, calc(100% - 36px));
  margin: 0 auto;
  padding: 28px 0 72px;
}

.section-layout {
  grid-template-columns: 280px minmax(0, 900px);
}

.docs-sidebar,
.toc-panel {
  position: sticky;
  top: calc(var(--header-h) + 22px);
  align-self: start;
  max-height: calc(100vh - var(--header-h) - 40px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.mobile-docs-nav {
  display: none;
}

.tree-section + .tree-section {
  margin-top: 18px;
}

.tree-section h2 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.tree-link {
  display: block;
  padding: 7px 9px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.tree-link:hover,
.tree-link.is-active {
  background: var(--surface-3);
  color: var(--text);
  text-decoration: none;
}

.tree-link.is-active {
  box-shadow: inset 2px 0 0 var(--accent);
}

.article-shell,
.section-shell {
  min-width: 0;
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  color: var(--muted-2);
  font-size: 0.88rem;
}

.article-header,
.section-header {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.article-header h1,
.section-header h1 {
  font-size: clamp(2rem, 4vw, 3rem);
}

.section-header p {
  max-width: 680px;
  color: var(--muted);
}

.section-filter {
  margin: 24px 0 16px;
}

.article-content {
  max-width: 76ch;
  padding-top: 8px;
}

.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4 {
  line-height: 1.25;
  letter-spacing: 0;
}

.article-content h1 {
  margin-top: 1.6em;
  font-size: 1.8rem;
}

.article-content h2 {
  margin-top: 2.1em;
  font-size: 1.45rem;
}

.article-content h3 {
  margin-top: 1.7em;
  font-size: 1.15rem;
}

.article-content p,
.article-content ul,
.article-content ol,
.article-content blockquote,
.article-content pre,
.article-content table {
  margin-top: 1em;
  margin-bottom: 1em;
}

.article-content p,
.article-content li {
  color: color-mix(in srgb, var(--text) 88%, var(--muted));
}

code {
  border-radius: 6px;
  background: var(--code-bg);
  color: var(--inline-code-text);
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 0.9em;
  padding: 0.12em 0.34em;
}

pre {
  position: relative;
  overflow-x: auto;
  tab-size: 2;
  padding: 42px 18px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 34px),
    var(--code-bg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  scrollbar-color: var(--surface-3) var(--code-bg);
  scrollbar-width: thin;
}

pre::-webkit-scrollbar {
  height: 10px;
}

pre::-webkit-scrollbar-track {
  background: var(--code-bg);
}

pre::-webkit-scrollbar-thumb {
  border: 2px solid var(--code-bg);
  border-radius: 999px;
  background: var(--surface-3);
}

pre code {
  display: block;
  min-width: max-content;
  padding: 0;
  background: transparent;
  color: var(--code-text);
  line-height: 1.65;
}

.copy-code {
  position: absolute;
  top: 8px;
  right: 8px;
  min-height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
}

blockquote {
  margin-left: 0;
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
}

table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

th {
  background: var(--surface-2);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

.toc-panel {
  max-height: min(680px, calc(100vh - var(--header-h) - 40px));
  padding: 14px;
  font-size: 0.82rem;
  line-height: 1.35;
  scrollbar-color: var(--surface-3) transparent;
  scrollbar-width: thin;
}

.toc-panel::-webkit-scrollbar {
  width: 8px;
}

.toc-panel::-webkit-scrollbar-track {
  background: transparent;
}

.toc-panel::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--surface-3);
}

.toc-panel li + li {
  margin-top: 5px;
}

.toc-panel a {
  display: block;
  padding: 2px 0;
  color: var(--muted);
}

.toc-panel a.is-active,
.toc-panel a:hover {
  color: var(--text);
  text-decoration: none;
}

.toc-level-3 {
  padding-left: 10px;
}

.toc-empty {
  color: var(--muted-2);
  font-size: 0.86rem;
}

.article-pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 42px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.pager-link {
  display: grid;
  gap: 4px;
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
}

.pager-link span {
  color: var(--muted-2);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.pager-link.is-disabled {
  opacity: 0.55;
}

@media (max-width: 1180px) {
  .docs-layout {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .toc-panel {
    display: none;
  }
}

@media (max-width: 860px) {
  .devbrain-header {
    gap: 12px;
    padding: 12px 18px;
  }

  .home-shell,
  .docs-layout,
  .section-layout {
    width: min(100% - 28px, 720px);
  }

  .docs-layout,
  .section-layout,
  .two-column {
    grid-template-columns: 1fr;
  }

  .search-results {
    grid-template-columns: 1fr;
  }

  .docs-sidebar {
    position: relative;
    top: auto;
    max-height: none;
    overflow: visible;
    padding: 0;
    background: transparent;
    border: 0;
  }

  .desktop-docs-nav {
    display: none;
  }

  .mobile-docs-nav {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
  }

  .mobile-docs-summary {
    display: list-item;
    padding: 14px 16px;
    cursor: pointer;
    color: var(--text);
    font-weight: 750;
  }

  .mobile-docs-summary::marker {
    color: var(--accent);
  }

  .mobile-docs-content {
    max-height: 52vh;
    overflow: auto;
    padding: 0 16px 16px;
    scrollbar-color: var(--surface-3) transparent;
    scrollbar-width: thin;
  }

  .article-shell,
  .section-shell {
    padding: 22px 18px;
  }

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