/* ----------------------------------------------------------------
   Variables
   ---------------------------------------------------------------- */
:root {
  --bg:            #080808;
  --bg-sidebar:    #0d0d0d;
  --bg-code:       #101010;
  --bg-surface:    #111111;
  --border:        #1e1e1e;
  --text:          #d4d4d4;
  --text-strong:   #f0f0f0;
  --text-muted:    #737373;
  --text-faint:    #3d3d3d;
  --accent:        #e879f9;
  --accent-dim:    rgba(232, 121, 249, 0.08);
  --accent-border: rgba(232, 121, 249, 0.25);
  --warn:          #fbbf24;
  --warn-dim:      rgba(251, 191, 36, 0.08);
  --sidebar-width: 256px;
  --content-max:   740px;
  --font-sans:     'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:     'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --radius:        5px;
}

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

/* ----------------------------------------------------------------
   Base
   ---------------------------------------------------------------- */
html { font-size: 15px; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ----------------------------------------------------------------
   Layout
   ---------------------------------------------------------------- */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ----------------------------------------------------------------
   Sidebar
   ---------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 200;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-header {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.logo-img {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  flex-shrink: 0;
  display: block;
}

.logo-badge {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  letter-spacing: 0.04em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0 16px;
}

.nav-section {
  margin-bottom: 20px;
}

.nav-section-title {
  display: block;
  padding: 4px 20px 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.nav-item {
  display: block;
  padding: 5px 20px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.5;
  border-left: 2px solid transparent;
  margin-left: -1px;
  transition: color 0.1s, border-color 0.1s, background 0.1s;
}

.nav-item:hover {
  color: var(--text);
  background: var(--accent-dim);
}

.nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-dim);
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-ext-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-faint);
  text-decoration: none;
  transition: color 0.1s;
}

.sidebar-ext-link:hover { color: var(--text-muted); }

/* ----------------------------------------------------------------
   Sidebar toggle (mobile)
   ---------------------------------------------------------------- */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 300;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: 7px;
  cursor: pointer;
  line-height: 0;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 150;
}

/* ----------------------------------------------------------------
   Content
   ---------------------------------------------------------------- */
.content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 60px 56px 96px;
  min-width: 0;
}

.prose {
  max-width: var(--content-max);
}

/* ----------------------------------------------------------------
   Typography
   ---------------------------------------------------------------- */
.prose h1 {
  font-size: 1.875rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: var(--text-strong);
  margin-bottom: 12px;
}

.prose h2 {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.4;
  color: var(--text-strong);
  margin-top: 52px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.prose h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-strong);
  margin-top: 32px;
  margin-bottom: 8px;
}

.prose h4 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 28px;
  margin-bottom: 6px;
}

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

.prose strong {
  font-weight: 600;
  color: var(--text-strong);
}

.prose em {
  font-style: italic;
}

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

.prose a:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.prose ul,
.prose ol {
  margin-bottom: 16px;
  padding-left: 22px;
}

.prose li {
  margin-bottom: 5px;
  color: var(--text);
}

.prose li > p { margin-bottom: 4px; }

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 44px 0;
}

/* ----------------------------------------------------------------
   Inline code
   ---------------------------------------------------------------- */
.prose code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ----------------------------------------------------------------
   Code blocks
   ---------------------------------------------------------------- */
.prose pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  overflow-x: auto;
  margin-bottom: 24px;
  line-height: 1.6;
}

.prose pre code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: none;
  border: none;
  padding: 0;
  color: #d4d4d4;
  border-radius: 0;
}

/* ----------------------------------------------------------------
   Tables
   ---------------------------------------------------------------- */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 28px;
  font-size: 13.5px;
  display: block;
  overflow-x: auto;
}

.prose thead { background: var(--bg-surface); }

.prose th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 9px 14px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.prose td {
  padding: 9px 14px;
  border: 1px solid var(--border);
  vertical-align: top;
  color: var(--text);
}

.prose tr:hover td { background: var(--bg-surface); }

/* ----------------------------------------------------------------
   Blockquote
   ---------------------------------------------------------------- */
.prose blockquote {
  border-left: 2px solid var(--accent-border);
  background: var(--accent-dim);
  padding: 12px 20px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 24px;
  color: var(--text-muted);
  font-size: 14px;
}

.prose blockquote p { margin-bottom: 0; color: var(--text-muted); }

/* ----------------------------------------------------------------
   Page header
   ---------------------------------------------------------------- */
.page-header {
  margin-bottom: 40px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.page-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.page-header h1 { margin-bottom: 8px; }

.page-description {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 0;
  line-height: 1.6;
}

/* ----------------------------------------------------------------
   Callout
   ---------------------------------------------------------------- */
.callout {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  font-size: 14px;
  line-height: 1.65;
}

.callout p { margin-bottom: 0; }
.callout strong { display: block; margin-bottom: 3px; }

.callout-note {
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  color: var(--text-muted);
}

.callout-warning {
  background: var(--warn-dim);
  border: 1px solid rgba(251, 191, 36, 0.25);
  color: var(--text-muted);
}

/* ----------------------------------------------------------------
   Step list
   ---------------------------------------------------------------- */
.steps {
  list-style: none;
  padding-left: 0;
  counter-reset: step;
  margin-bottom: 24px;
}

.steps li {
  counter-increment: step;
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
}

.steps li::before {
  content: counter(step);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  border-radius: 50%;
  margin-top: 2px;
  flex-shrink: 0;
}

/* ----------------------------------------------------------------
   Rouge syntax highlighting (Monokai dark)
   ---------------------------------------------------------------- */
.highlight { background: var(--bg-code); }
.highlight .hll { background-color: #1e1e1e; }
.highlight .c  { color: #6a737d; font-style: italic; }
.highlight .cm { color: #6a737d; font-style: italic; }
.highlight .cp { color: #6a737d; }
.highlight .c1 { color: #6a737d; font-style: italic; }
.highlight .cs { color: #6a737d; font-style: italic; }
.highlight .k  { color: #66d9ef; }
.highlight .kc { color: #66d9ef; }
.highlight .kd { color: #66d9ef; }
.highlight .kn { color: #f92672; }
.highlight .kp { color: #66d9ef; }
.highlight .kr { color: #66d9ef; }
.highlight .kt { color: #66d9ef; }
.highlight .ld { color: #e6db74; }
.highlight .m  { color: #ae81ff; }
.highlight .mf { color: #ae81ff; }
.highlight .mh { color: #ae81ff; }
.highlight .mi { color: #ae81ff; }
.highlight .mo { color: #ae81ff; }
.highlight .il { color: #ae81ff; }
.highlight .s  { color: #e6db74; }
.highlight .s1 { color: #e6db74; }
.highlight .s2 { color: #e6db74; }
.highlight .sb { color: #e6db74; }
.highlight .sc { color: #e6db74; }
.highlight .sd { color: #e6db74; }
.highlight .se { color: #ae81ff; }
.highlight .sh { color: #e6db74; }
.highlight .si { color: #e6db74; }
.highlight .sx { color: #e6db74; }
.highlight .sr { color: #e6db74; }
.highlight .ss { color: #e6db74; }
.highlight .na { color: #a6e22e; }
.highlight .nb { color: #f8f8f2; }
.highlight .nc { color: #a6e22e; }
.highlight .nd { color: #a6e22e; }
.highlight .ne { color: #a6e22e; }
.highlight .nf { color: #a6e22e; }
.highlight .ni { color: #f8f8f2; }
.highlight .nl { color: #f8f8f2; }
.highlight .nn { color: #f8f8f2; }
.highlight .no { color: #66d9ef; }
.highlight .nx { color: #a6e22e; }
.highlight .py { color: #f8f8f2; }
.highlight .nt { color: #f92672; }
.highlight .nv { color: #f8f8f2; }
.highlight .bp { color: #f8f8f2; }
.highlight .vc { color: #f8f8f2; }
.highlight .vg { color: #f8f8f2; }
.highlight .vi { color: #f8f8f2; }
.highlight .n  { color: #f8f8f2; }
.highlight .o  { color: #f92672; }
.highlight .ow { color: #f92672; }
.highlight .p  { color: #f8f8f2; }
.highlight .w  { color: #f8f8f2; }
.highlight .l  { color: #ae81ff; }
.highlight .gd { color: #f92672; }
.highlight .ge { font-style: italic; }
.highlight .gi { color: #a6e22e; }
.highlight .gu { color: #6a737d; }
.highlight .err { color: #960050; background-color: #1e0010; }

/* ----------------------------------------------------------------
   Responsive
   ---------------------------------------------------------------- */
@media (max-width: 900px) {
  .content {
    margin-left: 0;
    padding: 56px 28px 72px;
  }

  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .overlay.visible {
    display: block;
  }
}

@media (max-width: 540px) {
  .content { padding: 52px 20px 64px; }
  .prose h1 { font-size: 1.5rem; }
}
