:root {
  --bg: #0f1218;
  --panel: #171b24;
  --panel-2: #1d2330;
  --border: #2a3344;
  --text: #e7ecf5;
  --muted: #9aa6bd;
  --accent: #5bb0ff;
  --accent-2: #3d8fd9;
  --code-bg: #0b0e14;
  --warn-bg: rgba(196, 138, 42, 0.14);
  --warn-border: #c48a2a;
  --tip-bg: rgba(61, 184, 120, 0.12);
  --tip-border: #3db878;
  --info-bg: rgba(61, 126, 184, 0.14);
  --info-border: #3d7eb8;
  --sidebar-w: 290px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "Consolas", "Courier New", monospace;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: #3d4a62 transparent;
}

.sidebar,
.nav,
pre,
.table-wrap {
  scrollbar-width: thin;
  scrollbar-color: #3d4a62 transparent;
}

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

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #3d4a62;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-2);
  background-clip: content-box;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% -10%, #1a2740 0%, var(--bg) 55%);
  line-height: 1.65;
}

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

a:hover {
  color: #9fd0ff;
  text-decoration: underline;
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, var(--panel) 0%, #12161f 100%);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem 1rem;
}

.brand {
  padding: 0.25rem 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.85rem;
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  line-height: 1.25;
}

.brand-lockup {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.08rem;
}

.brand-lockup.has-logo {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 0.65rem;
  row-gap: 0.08rem;
  align-items: center;
}

.brand-logo {
  width: 2rem;
  height: 2rem;
  object-fit: contain;
  display: block;
  grid-column: 1;
  grid-row: 1 / span 2;
}

.brand-lockup.has-logo .brand-name,
.brand-lockup.has-logo .brand-product {
  grid-column: 2;
}

.brand-lockup.has-logo .brand-name {
  grid-row: 1;
}

.brand-lockup.has-logo .brand-product {
  grid-row: 2;
}

.brand-lockup.has-logo:not(:has(.brand-product)) .brand-logo {
  grid-row: 1;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.brand-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.35rem 0 0;
}

.brand-web {
  flex: 0 0 auto;
  font-size: 0.85rem;
  white-space: nowrap;
}

.nav-search {
  width: 100%;
  margin: 0 0 0.85rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
}

.nav-search::placeholder {
  color: var(--muted);
}

.nav-search:focus {
  outline: none;
  border-color: var(--accent);
}

.nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-bottom: 1rem;
}

.nav a {
  display: block;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  color: var(--text);
  margin: 0.15rem 0;
  font-size: 0.92rem;
}

.nav a:hover,
.nav a.active {
  background: var(--panel-2);
  text-decoration: none;
  color: #fff;
}

.nav a.active {
  border-left: 3px solid var(--accent);
  padding-left: calc(0.65rem - 3px);
}

.nav-group {
  margin: 0.2rem 0;
}

.nav-group.hidden {
  display: none;
}

.nav-row {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.nav-row .nav-page {
  flex: 1;
  margin: 0;
  min-width: 0;
}

.nav-chevron,
.nav-chevron-spacer {
  width: 1.35rem;
  height: 1.35rem;
  flex: 0 0 auto;
}

.nav-chevron {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
  padding: 0;
  position: relative;
}

.nav-chevron::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.4rem;
  height: 0.4rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translate(-60%, -60%) rotate(-45deg);
  transition: transform 0.15s ease;
}

.nav-group.open .nav-chevron::before {
  transform: translate(-50%, -70%) rotate(45deg);
}

.nav-chevron:hover {
  background: var(--panel-2);
  color: #fff;
}

.nav-children {
  display: none;
  /* Chevron + gap (~1.5rem) plus extra nest indent under the parent title. */
  padding: 0.15rem 0 0.35rem 2.55rem;
}

.nav-group.open .nav-children {
  display: block;
}

.nav-children a {
  font-size: 0.84rem;
  color: var(--muted);
  padding: 0.28rem 0.55rem;
  margin: 0.05rem 0;
}

.nav-children a:hover,
.nav-children a.active {
  color: #fff;
  background: var(--panel-2);
  text-decoration: none;
}

.nav-children a.active {
  border-left: 3px solid var(--accent);
  padding-left: calc(0.55rem - 3px);
}

.content-wrap {
  min-width: 0;
  padding: 1.75rem 2.25rem 4rem;
}

.content {
  max-width: 760px;
}

.doc-figure {
  margin: 1.1rem 0;
}

.doc-figure img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}

.doc-figure figcaption {
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.perf-figure {
  margin: 1.1rem 0 1.4rem;
}

.perf-chart {
  width: 100%;
  height: auto;
  display: block;
}

.perf-advantage {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  margin-top: 0.85rem;
  padding: 0.95rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background:
    linear-gradient(90deg, rgba(91, 176, 255, 0.16), rgba(91, 176, 255, 0) 42%),
    #12161f;
}

.perf-advantage-value {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.95;
}

.perf-advantage-title {
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
}

.perf-advantage-note {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.demo-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.75rem;
  margin: 0.2rem 0 1.4rem;
}

.demo-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  min-width: 0;
  padding: 0.95rem 1.05rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background:
    linear-gradient(105deg, rgba(91, 176, 255, 0.2), rgba(91, 176, 255, 0.04) 48%, #12161f);
  color: var(--text);
  text-decoration: none;
}

.demo-button:hover {
  border-color: var(--accent);
  color: var(--text);
  text-decoration: none;
}

.demo-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.demo-title {
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.25;
}

.demo-note {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.3;
}

.demo-arrow {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 1.35rem;
  line-height: 1;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin: 0 0 1.1rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.breadcrumb a {
  color: var(--muted);
}

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

.breadcrumb .sep {
  opacity: 0.55;
}

.breadcrumb .current {
  color: var(--text);
}

.section > h1 {
  margin: 0 0 0.85rem;
  font-size: 2rem;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

h2 {
  margin-top: 2.35rem;
  margin-bottom: 0.75rem;
  font-size: 1.32rem;
  width: fit-content;
  border-bottom: 3px solid var(--accent);
  padding-bottom: 0.4rem;
  scroll-margin-top: 1rem;
  line-height: 1.3;
}

h3 {
  margin-top: 1.55rem;
  margin-bottom: 0.45rem;
  font-size: 1.08rem;
  line-height: 1.35;
}

h4 {
  margin-top: 1.2rem;
  font-size: 1rem;
  color: var(--muted);
}

p {
  margin: 0.75rem 0;
}

p, li {
  color: #d5dced;
}

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

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  color: #d4d4d4;
}

/* IDE-like fenced blocks (VS Code Dark+ colours) */
.code-block {
  margin: 1.1rem 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #1e1e1e;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.85rem;
  background: #252526;
  border-bottom: 1px solid #2b2b2b;
}

.code-lang {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9d9d9d;
}

.code-block pre {
  margin: 0;
  padding: 0.9rem 1.05rem 1rem;
  overflow: auto;
  background: transparent;
  border: none;
  border-radius: 0;
  line-height: 1.55;
  tab-size: 4;
}

.code-block pre code,
pre code {
  border: none;
  background: transparent;
  padding: 0;
  font-size: 0.84rem;
  color: #d4d4d4;
  white-space: pre;
}

pre {
  background: #1e1e1e;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.95rem 1.05rem;
  overflow: auto;
  margin: 1rem 0;
}

.tok-comment { color: #6a9955; font-style: italic; }
.tok-string { color: #ce9178; }
.tok-number { color: #b5cea8; }
.tok-keyword { color: #569cd6; }
.tok-control { color: #c586c0; }
.tok-type { color: #4ec9b0; }
.tok-function { color: #dcdcaa; }
.tok-macro { color: #c586c0; }
.tok-property { color: #9cdcfe; }

.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: 0.94rem;
}

th, td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 0.6rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

th:last-child,
td:last-child {
  border-right: none;
}

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

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

tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.callout {
  margin: 1.15rem 0;
  padding: 0.85rem 1rem 0.95rem;
  border-left: 4px solid var(--info-border);
  background: var(--info-bg);
  border-radius: 0 10px 10px 0;
}

.callout-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
  color: var(--accent);
}

.callout-tip {
  border-left-color: var(--tip-border);
  background: var(--tip-bg);
}

.callout-tip .callout-title {
  color: #7ddeb0;
}

.callout-warning {
  border-left-color: var(--warn-border);
  background: var(--warn-bg);
}

.callout-warning .callout-title {
  color: #e0b15c;
}

.callout-note .callout-title {
  color: #8ec5f5;
}

.callout-body > :first-child {
  margin-top: 0;
}

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

blockquote {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--info-border);
  background: var(--info-bg);
  border-radius: 0 8px 8px 0;
  color: var(--text);
}

ul, ol {
  padding-left: 1.35rem;
  margin: 0.75rem 0;
}

li + li {
  margin-top: 0.25rem;
}

.badge {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}

.page-nav {
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  margin: 1.5rem 0;
  padding: 0;
}

.page-nav.top {
  margin: 0 0 1.5rem;
}

.page-nav a {
  display: inline-flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  max-width: 48%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  text-decoration: none;
}

.page-nav a:hover {
  border-color: var(--accent);
  color: #fff;
  text-decoration: none;
}

.page-nav a .label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.page-nav a .title {
  font-size: 0.98rem;
  font-weight: 600;
}

.page-nav a.prev {
  align-items: flex-start;
}

.page-nav a.next {
  margin-left: auto;
  align-items: flex-end;
  text-align: right;
}

.page-nav .spacer {
  flex: 1;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    overflow: visible;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .nav {
    overflow: visible;
    flex: none;
    min-height: 0;
  }

  .content-wrap {
    padding: 1.25rem 1rem 3rem;
  }

  .page-nav {
    flex-direction: column;
  }

  .page-nav a,
  .page-nav a.next {
    max-width: none;
    margin-left: 0;
    align-items: flex-start;
    text-align: left;
  }

  .demo-row {
    grid-template-columns: 1fr;
  }
}
