:root {
  --bg: #09090B;
  --panel: #121216;
  --panel-2: #18181B;
  --panel-3: #1f1f24;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(167,139,250,0.28);
  --text: #FAFAFA;
  --text-2: #E4E4E7;
  --muted: #A1A1AA;
  --faint: #71717A;
  --link: #C4B5FD;
  --accent: #A78BFA;
  --accent-2: #8B5CF6;
  --accent-3: #6366F1;
  --pink: #EC4899;
  --callout: rgba(139,92,246,0.10);
  --success: #34D399;
  --danger: #F87171;
  --shadow: 0 18px 50px rgba(0,0,0,0.38);
  --radius: 12px;
  --sidebar-w: 280px;
  --topbar-h: 60px;
  --content-max: 860px;
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1000px 480px at 8% -8%, rgba(124,58,237,0.16), transparent 55%),
    radial-gradient(900px 420px at 92% 0%, rgba(99,102,241,0.12), transparent 50%),
    radial-gradient(700px 360px at 50% 110%, rgba(236,72,153,0.08), transparent 55%),
    var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.nav-open { overflow: hidden; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input { font: inherit; }
code, kbd, pre { font-family: var(--mono); }

.skip-link {
  position: absolute;
  left: 12px;
  top: -40px;
  z-index: 100;
  background: var(--accent-2);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
}
.skip-link:focus { top: 12px; }

.app { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(9,9,11,0.78);
  backdrop-filter: blur(14px);
}

.icon-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(24,24,27,0.9);
  color: var(--text-2);
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--border-strong); color: white; }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: white;
  background: linear-gradient(135deg, #8B5CF6, #7C3AED 45%, #6366F1);
  box-shadow: 0 0 0 1px rgba(168,85,247,0.18), 0 0 24px rgba(139,92,246,0.28);
}
.brand-text {
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-sub {
  color: var(--muted);
  font-weight: 500;
}

.top-search { flex: 1; max-width: 420px; }
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(24,24,27,0.85);
  color: var(--muted);
}
.search-box:focus-within {
  border-color: rgba(167,139,250,0.55);
  box-shadow: 0 0 0 3px rgba(139,92,246,0.15);
}
.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}
.search-box input::placeholder { color: var(--faint); }
.search-box kbd {
  font-size: 11px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--faint);
  background: rgba(255,255,255,0.03);
}

.top-links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
}
.top-links a { color: var(--muted); text-decoration: none; }
.top-links a:hover { color: var(--text); }
.btn-chip {
  padding: 7px 12px !important;
  border-radius: 999px;
  border: 1px solid rgba(167,139,250,0.28);
  background: linear-gradient(180deg, rgba(139,92,246,0.18), rgba(99,102,241,0.08));
  color: #EDE9FE !important;
}
.btn-chip:hover { border-color: rgba(167,139,250,0.5); }

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

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow: auto;
  border-right: 1px solid var(--border);
  background: rgba(18,18,22,0.72);
  backdrop-filter: blur(10px);
}
.sidebar-inner { padding: 18px 12px 28px; }
.sidebar-section + .sidebar-section { margin-top: 22px; }
.sidebar-title {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7a7a86;
  padding: 0 10px 8px;
}
.nav-link {
  display: block;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  border: 1px solid transparent;
}
.nav-link:hover {
  color: var(--text);
  background: rgba(63,63,70,0.35);
  text-decoration: none;
}
.nav-link.active {
  color: #F5F3FF;
  background: rgba(139,92,246,0.14);
  border-color: rgba(167,139,250,0.22);
  box-shadow: inset 0 0 0 1px rgba(139,92,246,0.06);
}
.nav-link.sub { padding-left: 22px; font-size: 13px; }
.nav-link.hidden { display: none; }
.sidebar-foot { margin-top: 28px; padding: 0 8px; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(167,139,250,0.18);
  background: rgba(139,92,246,0.08);
  color: #DDD6FE;
  font-size: 12px;
}

.content {
  width: min(100%, calc(var(--content-max) + 80px));
  padding: 34px 40px 88px;
}
.page-head { margin-bottom: 10px; }
.crumbs {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--faint);
  font-size: 13px;
  margin-bottom: 14px;
}
.crumbs .sep { opacity: 0.5; }
.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
h1 {
  margin: 0 0 12px;
  font-size: clamp(30px, 4vw, 40px);
  line-height: 1.12;
  letter-spacing: -0.03em;
  background: linear-gradient(90deg, #E9D5FF, #F5D0FE 40%, #FDE68A 120%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lead {
  color: var(--muted);
  font-size: 17px;
  margin: 0 0 18px;
  max-width: 64ch;
}
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  color: #D4D4D8;
  font-size: 12px;
}

.doc-section {
  margin-top: 38px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  scroll-margin-top: 84px;
}
.sub-section {
  margin-top: 22px;
  scroll-margin-top: 84px;
}
.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-head h2,
.section-head h3 { margin: 0; }
h2 {
  margin: 0 0 12px;
  font-size: 26px;
  letter-spacing: -0.02em;
  color: #FAFAFA;
}
h3 {
  margin: 0 0 10px;
  font-size: 18px;
  color: #F4F4F5;
}
.anchor {
  opacity: 0;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  transition: opacity .15s ease;
}
.section-head:hover .anchor,
.section-head:focus-within .anchor { opacity: 1; }
p { margin: 0 0 12px; color: var(--text-2); }
ul { margin: 0 0 12px; padding-left: 20px; color: var(--text-2); }
li + li { margin-top: 4px; }

code {
  font-size: 0.92em;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 6px;
  padding: 0.08em 0.34em;
  color: #EDE9FE;
  word-break: break-word;
}
code.copyable {
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
code.copyable:hover {
  border-color: rgba(167,139,250,0.4);
  background: rgba(139,92,246,0.12);
}

.code-block {
  margin: 12px 0 16px;
  border: 1px solid rgba(167,139,250,0.16);
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(24,24,27,0.95), rgba(12,12,15,0.98));
  box-shadow: var(--shadow), 0 0 0 1px rgba(139,92,246,0.04), 0 0 40px rgba(139,92,246,0.08);
}
.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
}
.code-lang {
  color: var(--faint);
  font-size: 12px;
  text-transform: lowercase;
  letter-spacing: 0.04em;
}
.copy-btn {
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  color: #D4D4D8;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}
.copy-btn:hover {
  border-color: rgba(167,139,250,0.4);
  color: white;
  background: rgba(139,92,246,0.14);
}
.copy-btn.copied {
  color: #D1FAE5;
  border-color: rgba(52,211,153,0.4);
  background: rgba(16,185,129,0.12);
}
pre {
  margin: 0;
  padding: 14px 16px 16px;
  overflow: auto;
  max-height: min(60vh, 520px);
}
pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: #E4E4E7;
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(18,18,22,0.88);
  margin: 12px 0 8px;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}
th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  color: #A1A1AA;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.02);
}
tr:last-child td { border-bottom: 0; }
td { color: var(--text-2); }

.callout {
  margin: 14px 0 8px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(167,139,250,0.24);
  background:
    linear-gradient(180deg, rgba(139,92,246,0.12), rgba(99,102,241,0.05));
}
.callout-title {
  font-weight: 650;
  color: #EDE9FE;
  margin-bottom: 6px;
}
.callout p:last-child { margin-bottom: 0; }

.page-foot {
  margin-top: 56px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.foot-title { color: var(--text-2); font-weight: 600; }
.foot-sub { color: var(--faint); font-size: 13px; margin-top: 2px; }
.btn-ghost {
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  text-decoration: none;
}
.btn-ghost:hover {
  color: white;
  border-color: rgba(167,139,250,0.35);
  text-decoration: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(24,24,27,0.96);
  color: #F4F4F5;
  border: 1px solid rgba(167,139,250,0.28);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 80;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.48);
  backdrop-filter: blur(2px);
  z-index: 35;
}

@media (max-width: 980px) {
  .menu-btn { display: inline-flex; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--topbar-h);
    width: min(88vw, 320px);
    transform: translateX(-105%);
    transition: transform .2s ease;
    z-index: 45;
    box-shadow: var(--shadow);
    background: rgba(12,12,15,0.96);
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 26px 16px 72px; width: 100%; }
  .top-links { display: none; }
  .top-search { max-width: none; }
  h1 { font-size: 30px; }
}

@media (max-width: 560px) {
  .search-box kbd { display: none; }
  .brand-sub { display: none; }
  .topbar { gap: 10px; padding: 0 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}


/* Accessibility polish */
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.nav-link:focus-visible { outline-offset: 0; }
pre::-webkit-scrollbar, .table-wrap::-webkit-scrollbar { height: 10px; width: 10px; }
pre::-webkit-scrollbar-thumb, .table-wrap::-webkit-scrollbar-thumb {
  background: rgba(167,139,250,0.28);
  border-radius: 999px;
}
pre::-webkit-scrollbar-track, .table-wrap::-webkit-scrollbar-track { background: transparent; }
.doc-section.is-target {
  box-shadow: inset 3px 0 0 rgba(167,139,250,0.8);
}
@media (max-width: 980px) {
  .content { padding-bottom: 96px; }
}
