:root {
  --blue: #0a85ff;
  --bg-1: #0b1220;
  --bg-2: #0f1b30;
  --card: rgba(255,255,255,0.04);
  --card-border: rgba(255,255,255,0.10);
  --text: #eaf1fb;
  --muted: #93a4bf;
  --code-bg: rgba(255,255,255,0.06);
  --accent: #9cc8ff;
  --sidebar-w: 280px;
  --toc-w: 220px;
  --top-h: 58px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--bg-1); scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg-1), var(--bg-2));
  height: 100vh;
  overflow: hidden; /* only the active page scrolls, not the whole site */
}

/* ---- Top bar ---- */
.docs-top {
  position: fixed; top: 0; left: 0; right: 0; height: var(--top-h); z-index: 40;
  display: flex; align-items: center; gap: 16px; padding: 0 18px;
  background: rgba(9,14,26,0.86); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--card-border);
}
.docs-menu { display: none; background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px; }
.docs-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex: none; }
.docs-brand img { width: 30px; height: 30px; border-radius: 9px; }
.docs-brand span { font-size: 15px; font-weight: 700; white-space: nowrap; }
.docs-brand b { color: var(--accent); font-weight: 800; }
.docs-search-wrap { position: relative; flex: 1; max-width: 460px; margin-left: auto; }
.docs-search {
  width: 100%; font: inherit; font-size: 14px; color: var(--text);
  background: var(--card); border: 1px solid var(--card-border); border-radius: 10px; padding: 9px 13px;
}
.docs-search:focus { outline: none; border-color: rgba(54,161,255,0.5); }
.docs-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 50;
  background: rgba(12,21,38,0.99); border: 1px solid var(--card-border); border-radius: 12px;
  box-shadow: 0 18px 48px rgba(0,0,0,0.5); overflow: hidden; max-height: 60vh; overflow-y: auto;
}
.docs-result { display: block; width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  color: var(--text); font: inherit; padding: 11px 14px; border-bottom: 1px solid var(--card-border); }
.docs-result:last-child { border-bottom: none; }
.docs-result:hover, .docs-result.sel { background: rgba(54,161,255,0.12); }
.docs-result .r-title { font-size: 14px; font-weight: 600; }
.docs-result .r-group { font-size: 11.5px; color: var(--muted); }
.docs-result .r-snip { font-size: 12px; color: var(--muted); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.docs-noresult { padding: 14px; color: var(--muted); font-size: 13px; }
.docs-exit { flex: none; display: inline-flex; align-items: center; gap: 5px; text-decoration: none;
  color: var(--muted); font-size: 13px; font-weight: 600; padding: 7px 11px; border-radius: 9px; border: 1px solid var(--card-border); }
.docs-exit:hover { color: var(--text); border-color: rgba(255,255,255,0.22); }
.docs-support { flex: none; display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  color: #fff; font-size: 13px; font-weight: 600; padding: 7px 12px; border-radius: 9px; background: #5865F2; }
.docs-support:hover { background: #4752c4; }
.docs-support img { width: 15px; height: 15px; filter: brightness(0) invert(1); }

/* ---- Layout ---- */
.docs-body { display: flex; height: 100vh; padding-top: var(--top-h); }
.docs-sidebar {
  position: fixed; top: var(--top-h); bottom: 0; left: 0; width: var(--sidebar-w);
  overflow-y: auto; padding: 22px 14px 40px; border-right: 1px solid var(--card-border);
  background: rgba(8,14,26,0.35);
}
.docs-nav { display: flex; flex-direction: column; gap: 2px; }
.docs-group { margin-top: 20px; }
.docs-group:first-child { margin-top: 0; }
.docs-group-title { font-size: 11px; font-weight: 700; letter-spacing: 0.7px; text-transform: uppercase; color: var(--muted); padding: 0 12px 6px; }
.docs-link { display: block; width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 14px; font-weight: 500; padding: 8px 12px; border-radius: 9px; text-decoration: none; }
.docs-link:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.docs-link.active { background: rgba(54,161,255,0.14); color: var(--accent); font-weight: 600; }

.docs-main { flex: 1; min-width: 0; height: 100%; overflow-y: auto; margin-left: var(--sidebar-w); margin-right: var(--toc-w);
  padding: 38px clamp(20px, 5vw, 56px) 80px; }
.docs-content { max-width: 820px; }
.docs-loading { color: var(--muted); }

.docs-toc { position: fixed; top: var(--top-h); right: 0; width: var(--toc-w); bottom: 0; overflow-y: auto;
  padding: 38px 20px 40px; }
.docs-toc-head { font-size: 11px; font-weight: 700; letter-spacing: 0.7px; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.docs-toc-nav { display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--card-border); }
.docs-toc-link { display: block; color: var(--muted); text-decoration: none; font-size: 13px; line-height: 1.4;
  padding: 4px 0 4px 14px; margin-left: -1px; border-left: 2px solid transparent; }
.docs-toc-link.sub { padding-left: 26px; font-size: 12.5px; }
.docs-toc-link:hover { color: var(--text); }
.docs-toc-link.active { color: var(--accent); border-left-color: var(--accent); }

/* ---- Prev / next ---- */
.docs-prevnext { max-width: 820px; display: flex; gap: 14px; margin-top: 44px; }
.docs-pn { flex: 1; display: block; text-decoration: none; color: var(--text);
  border: 1px solid var(--card-border); border-radius: 12px; padding: 14px 16px; background: var(--card); }
.docs-pn:hover { border-color: rgba(54,161,255,0.45); }
.docs-pn.next { text-align: right; }
.docs-pn .pn-label { font-size: 11.5px; color: var(--muted); }
.docs-pn .pn-title { font-size: 15px; font-weight: 600; margin-top: 3px; }

/* ---- Markdown typography ---- */
.docs-content h1 { font-size: 31px; font-weight: 800; line-height: 1.2; margin: 0 0 8px; scroll-margin-top: 16px; }
.docs-content h2 { font-size: 22px; font-weight: 700; margin: 36px 0 12px; padding-top: 8px; border-top: 1px solid var(--card-border); scroll-margin-top: 16px; }
.docs-content h3 { font-size: 17px; font-weight: 700; margin: 26px 0 8px; scroll-margin-top: 16px; }
.docs-content h4 { font-size: 15px; font-weight: 700; margin: 20px 0 6px; }
.docs-content p { margin: 13px 0; line-height: 1.7; color: #d7e2f2; }
.docs-content a { color: var(--accent); text-decoration: none; }
.docs-content a:hover { text-decoration: underline; }
.docs-content strong { color: #fff; font-weight: 700; }
.docs-content ul, .docs-content ol { margin: 12px 0 12px 24px; line-height: 1.7; color: #d7e2f2; }
.docs-content li { margin: 5px 0; }
.docs-content code { background: var(--code-bg); border: 1px solid var(--card-border); border-radius: 5px;
  padding: 1px 6px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88em; color: #ffd9a8; }
.docs-content pre { background: #0a1322; border: 1px solid var(--card-border); border-radius: 12px;
  padding: 14px 16px; overflow-x: auto; margin: 16px 0; }
.docs-content pre code { background: none; border: none; padding: 0; color: #cfe0f5; font-size: 13px; line-height: 1.6; }
.docs-content blockquote { border-left: 3px solid var(--blue); background: rgba(54,161,255,0.08);
  border-radius: 0 10px 10px 0; padding: 11px 16px; margin: 16px 0; color: #cfe0f5; }
.docs-content blockquote p { margin: 4px 0; }
.docs-content hr { border: none; border-top: 1px solid var(--card-border); margin: 28px 0; }
.docs-content table { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 14px; display: block; overflow-x: auto; }
.docs-content th, .docs-content td { border: 1px solid var(--card-border); padding: 9px 12px; text-align: left; vertical-align: top; }
.docs-content th { background: rgba(255,255,255,0.04); font-weight: 700; }
.docs-content img { max-width: 100%; border-radius: 10px; }
.docs-content .anchor { opacity: 0; color: var(--muted); text-decoration: none; margin-left: 8px; font-weight: 400; }
.docs-content h2:hover .anchor, .docs-content h3:hover .anchor { opacity: 1; }

/* ---- Responsive ---- */
.docs-backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,0.5); }
@media (max-width: 1100px) {
  .docs-toc { display: none; }
  .docs-main { margin-right: 0; }
}
@media (max-width: 820px) {
  .docs-menu { display: inline-flex; }
  .docs-sidebar { transform: translateX(-100%); transition: transform 0.2s ease; z-index: 45; width: min(82vw, 320px); background: var(--bg-2); }
  .docs-sidebar.open { transform: translateX(0); }
  .docs-main { margin-left: 0; padding: 26px 18px 70px; }
  .docs-brand span { display: none; }
  .docs-exit span { display: none; }
  .docs-support span { display: none; }
}
@media (min-width: 821px) { .docs-backdrop { display: none !important; } }
