*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:          #0d0d0d;
  --bg-sidebar:  #111111;
  --bg-elevated: #161616;
  --bg-code:     #0a0a0a;
  --border:      #222222;
  --text:        #d4d4d4;
  --text-muted:  #6b6b6b;
  --text-faint:  #3a3a3a;
  --accent:      #e8a020;
  --accent-dim:  rgba(232, 160, 32, 0.12);
  --sidebar-w:   260px;
  --topbar-h:    48px;
  --radius:      6px;
  --mono:        "JetBrains Mono", "Fira Code", "Cascadia Code", ui-monospace, monospace;
  --sans:        "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

[data-theme="light"] {
  --bg:          #ffffff;
  --bg-sidebar:  #f7f7f7;
  --bg-elevated: #f0f0f0;
  --bg-code:     #f5f5f5;
  --border:      #e0e0e0;
  --text:        #1a1a1a;
  --text-muted:  #666666;
  --text-faint:  #bbbbbb;
  --accent:      #c07010;
  --accent-dim:  rgba(192, 112, 16, 0.08);
}

html {
  scroll-behavior: smooth;
  font-size: 15px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--text-faint) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--text-faint); border-radius: 2px; }

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  font-size: 0.87rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.sidebar-nav {
  padding: 12px 0 24px;
  flex: 1;
}

.sidebar-nav ul {
  list-style: none;
}

.nav-section-label {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 16px 20px 4px;
  pointer-events: none;
}

.nav-link {
  display: block;
  padding: 5px 20px;
  font-size: 0.82rem;
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
  border-left: 2px solid transparent;
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-elevated);
  text-decoration: none;
}

.nav-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-dim);
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
  gap: 16px;
}

.breadcrumb {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--mono);
  flex-shrink: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.topbar-link {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.topbar-link:hover {
  color: var(--accent);
  text-decoration: none;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  width: 30px;
  height: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

[data-theme="dark"] .theme-sun  { display: inline; }
[data-theme="dark"] .theme-moon { display: none; }
[data-theme="light"] .theme-sun  { display: none; }
[data-theme="light"] .theme-moon { display: inline; }

.search-wrap {
  position: relative;
}

.search-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.78rem;
  padding: 5px 10px;
  width: 180px;
  outline: none;
  transition: border-color 0.15s, width 0.2s;
}

.search-input:focus {
  border-color: var(--accent);
  width: 220px;
}

.search-input::placeholder {
  color: var(--text-faint);
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 320px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 300;
  max-height: 340px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--text-faint) transparent;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] .search-results {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.search-result-item {
  display: block;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--bg-elevated);
  text-decoration: none;
}

.search-result-item.focused {
  background: var(--accent-dim);
}

.search-result-title {
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 2px;
}

.search-result-preview {
  font-size: 0.73rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-preview mark {
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 2px;
}

.search-empty {
  padding: 14px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

section {
  padding: 56px 40px 0;
  max-width: 860px;
}

section:last-of-type {
  padding-bottom: 80px;
}

h1 {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.0rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 28px;
  margin-bottom: 10px;
}

p {
  margin-bottom: 14px;
  color: var(--text);
}

p.lead {
  font-size: 1.0rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

ul, ol {
  padding-left: 20px;
  margin-bottom: 14px;
}

li {
  margin-bottom: 5px;
  color: var(--text);
}

code {
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: #d7ba7d;
  padding: 1px 5px;
  border-radius: 3px;
}

[data-theme="light"] code {
  color: #7a4f00;
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  overflow-x: auto;
  margin: 16px 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.65;
  scrollbar-width: thin;
  scrollbar-color: var(--text-faint) transparent;
}

pre::-webkit-scrollbar { height: 4px; }
pre::-webkit-scrollbar-thumb { background: var(--text-faint); border-radius: 2px; }

pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: inherit;
}

pre .kw  { color: #569cd6; }
pre .str { color: #ce9178; }
pre .num { color: #b5cea8; }

[data-theme="light"] pre .kw  { color: #0000ff; }
[data-theme="light"] pre .str { color: #a31515; }
[data-theme="light"] pre .num { color: #098658; }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.82rem;
}

thead tr {
  border-bottom: 1px solid var(--border);
}

th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.71rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text);
}

tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: var(--bg-elevated);
}

td code {
  font-size: 0.75rem;
}

.callout {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border-left: 3px solid;
  margin: 18px 0;
  font-size: 0.83rem;
  line-height: 1.6;
}

.callout-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex-shrink: 0;
  padding-top: 2px;
}

.callout-info {
  background: rgba(86, 156, 214, 0.08);
  border-color: #569cd6;
}

.callout-info .callout-label { color: #569cd6; }

.callout-warn {
  background: rgba(244, 71, 71, 0.07);
  border-color: #f44747;
}

.callout-warn .callout-label { color: #f44747; }

.callout-tip {
  background: rgba(78, 201, 160, 0.07);
  border-color: #4ec9a0;
}

.callout-tip .callout-label { color: #4ec9a0; }

[data-theme="light"] .callout-info  { background: rgba(86, 156, 214, 0.06); }
[data-theme="light"] .callout-warn  { background: rgba(244, 71, 71, 0.05); }
[data-theme="light"] .callout-tip   { background: rgba(78, 201, 160, 0.05); }

.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}

.faq-q {
  padding: 13px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-elevated);
}

.faq-a {
  padding: 12px 16px;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  line-height: 1.7;
}

.faq-a code {
  font-size: 0.75rem;
}

.page-footer {
  padding: 20px 40px;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-faint);
  margin-top: auto;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-faint); border-radius: 3px; }

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    height: 100vh;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: flex;
  }

  .topbar {
    padding: 0 12px 0 56px;
  }

  .search-input {
    width: 120px;
  }

  .search-input:focus {
    width: 160px;
  }

  .search-results {
    width: 280px;
    right: 0;
  }

  section {
    padding: 40px 20px 0;
  }

  .page-footer {
    padding: 20px;
  }

  h1 {
    font-size: 1.3rem;
  }

  table {
    font-size: 0.76rem;
    display: block;
    overflow-x: auto;
  }
}
