
/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0d0b10;
  --panel:    #13111a;
  --border:   #2a2040;
  --accent:   #9333ea;
  --accent-l: #c084fc;
  --accent-d: #7c3aed;
  --text:     #e2e0f0;
  --muted:    #7a6f9a;
  --green:    #22c55e;
  --red:      #ef4444;
  --code-bg:  #1a1625;
  --font:     -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono:     'Fira Code', 'Cascadia Code', 'SF Mono', Consolas, monospace;
  --header-h: 60px;
  --sidebar-w: 260px;
  --toc-w:    200px;
}

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 24px); }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 15px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Header ── */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: rgba(13,11,16,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
}
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: 0.2s;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}
.logo:hover { text-decoration: none; }
.logo-text {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent-l), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-nav {
  display: flex;
  gap: 4px;
  margin-left: 16px;
}
.header-nav a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.header-nav a:hover {
  color: var(--text);
  background: rgba(147,51,234,0.1);
  text-decoration: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.btn-ide {
  background: var(--accent);
  color: white !important;
  padding: 6px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
  text-decoration: none !important;
}
.btn-ide:hover { background: var(--accent-d); }

.btn-gh {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted) !important;
  font-size: 13px;
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 7px;
  transition: color 0.15s, border-color 0.15s;
  text-decoration: none !important;
}
.btn-gh:hover { color: var(--text) !important; border-color: var(--accent); }

/* ── Layout ── */
.layout {
  display: flex;
  flex: 1;
  margin-top: var(--header-h);
  max-width: 1400px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--panel);
  z-index: 50;
  flex-shrink: 0;
}

.sidebar-inner { padding: 16px 0 32px; }

.sidebar-anchors {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.anchor-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 8px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.anchor-link:hover { color: var(--text); background: rgba(147,51,234,0.08); text-decoration: none; }

.nav-group { margin-bottom: 20px; padding: 0 12px; }
.nav-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  padding: 0 8px;
  margin-bottom: 6px;
}
.nav-group ul { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.nav-group li a {
  display: block;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 13.5px;
  color: var(--muted);
  transition: color 0.15s, background 0.15s;
  text-decoration: none;
}
.nav-group li a:hover {
  color: var(--text);
  background: rgba(147,51,234,0.08);
}
.nav-group li a.active {
  color: var(--accent-l);
  background: rgba(147,51,234,0.12);
  font-weight: 600;
}

/* ── Content ── */
.content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 0;
  padding: 0;
}

.article {
  flex: 1;
  min-width: 0;
  max-width: 780px;
  padding: 48px 40px 80px;
}

.article-header { margin-bottom: 32px; }

.breadcrumb {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent-l);
  font-weight: 600;
  margin-bottom: 8px;
}

.article h1 {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.description {
  color: var(--muted);
  font-size: 16px;
  margin-top: 8px;
}

/* ── Article body ── */
.article-body h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 40px 0 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.article-body h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin: 28px 0 10px;
}
.article-body h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  margin: 20px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 12px;
}

.article-body p { margin-bottom: 16px; color: var(--text); }

.article-body ul, .article-body ol {
  margin: 0 0 16px 20px;
  color: var(--text);
}
.article-body li { margin-bottom: 6px; }

.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  background: rgba(147,51,234,0.06);
  border-radius: 0 6px 6px 0;
  color: var(--muted);
  margin: 16px 0;
  font-style: italic;
}

.article-body code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-l);
  border: 1px solid var(--border);
}

.code-block {
  position: relative;
  margin: 20px 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--code-bg);
}
.code-lang {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  background: var(--panel);
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.code-block pre {
  overflow-x: auto;
  padding: 18px 20px;
  margin: 0;
}
.code-block code {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.65;
  color: #d6d0f5;
  background: none;
  border: none;
  padding: 0;
  white-space: pre;
}

/* Table */
.table-wrap { overflow-x: auto; margin: 20px 0; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th {
  text-align: left;
  background: var(--panel);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  border: 1px solid var(--border);
}
td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}
tr:nth-child(even) td { background: rgba(255,255,255,0.02); }

/* Prev / next */
.prev-next {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.pn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
  text-decoration: none;
  flex: 1;
  max-width: 240px;
}
.pn.next { margin-left: auto; justify-content: flex-end; text-align: right; }
.pn:hover { border-color: var(--accent); background: rgba(147,51,234,0.06); text-decoration: none; }

/* TOC */
.toc {
  width: var(--toc-w);
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--header-h) + 40px);
  align-self: flex-start;
  padding: 0 0 0 24px;
  margin-top: 48px;
  display: block;
}
.toc-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 10px;
}
.toc ul { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.toc li a {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  padding: 3px 0;
  transition: color 0.15s;
  text-decoration: none;
}
.toc li a:hover { color: var(--text); }
.toc li.toc-h3 { padding-left: 12px; }

/* ── Footer ── */
footer {
  border-top: 1px solid var(--border);
  padding: 24px 20px;
  margin-top: auto;
}
.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.footer-links {
  display: flex;
  gap: 16px;
}
.footer-links a { color: var(--muted); font-size: 13px; }
.footer-links a:hover { color: var(--text); }
.footer-copy { color: var(--muted); font-size: 12px; margin-left: auto; }

/* ── Mobile overlay ── */
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 49;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .toc { display: none; }
  .article { max-width: 100%; }
}

@media (max-width: 768px) {
  .hamburger { display: flex; }
  .header-nav { display: none; }
  .btn-ide { display: none; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-overlay.open { display: block; }

  .content { margin-left: 0; }
  .article { padding: 28px 20px 60px; }
  .article h1 { font-size: 26px; }
  .prev-next { flex-direction: column; }
  .pn.next { margin-left: 0; justify-content: flex-start; text-align: left; }
}
