/* ========== CSS Variables ========== */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans SC', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;

  /* Sizing */
  --navbar-h: 48px;
  --sidebar-w: 260px;
  --toc-w: 220px;
  --content-max: 740px;
  --radius: 8px;
  --radius-sm: 6px;
}

/* Dark theme (default) */
[data-theme="dark"] {
  --bg-body: #22242c;
  --bg-sidebar: #22242c;
  --bg-content: #0f1117;
  --bg-navbar: #22242c;
  --bg-card: #1c1e2a;
  --bg-code: #1c1e2a;
  --bg-code-inline: #262838;
  --bg-hover: #1e2030;
  --bg-active: rgba(99, 146, 255, 0.1);
  --bg-input: #1c1e2a;
  --bg-tab-active: transparent;

  --border: #2a2d3a;
  --border-light: #222436;

  --text-primary: #e1e4ed;
  --text-secondary: #8b8fa7;
  --text-muted: #636780;
  --text-link: #6e9fff;
  --text-group: #d4a843;
  --text-active: #6e9fff;

  --accent: #6e9fff;
  --accent-hover: #5a8bef;
  --warning-bg: rgba(212, 168, 67, 0.1);
  --warning-border: #d4a843;
  --warning-text: #d4a843;
  --tip-bg: rgba(110, 159, 255, 0.1);
  --tip-border: #6e9fff;
  --tip-text: #6e9fff;
  --info-bg: rgba(110, 159, 255, 0.08);
  --info-border: #6e9fff;
  --success-bg: rgba(72, 199, 142, 0.1);
  --success-border: #48c78e;

  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --scrollbar-thumb: #2a2d3a;
  --scrollbar-track: transparent;
}

/* Light theme */
[data-theme="light"] {
  --bg-body: #ffffff;
  --bg-sidebar: #f8f9fb;
  --bg-content: #ffffff;
  --bg-navbar: #f8f9fb;
  --bg-card: #f0f2f5;
  --bg-code: #1e1e2e;
  --bg-code-inline: #eef0f4;
  --bg-hover: #eef0f4;
  --bg-active: rgba(59, 130, 246, 0.08);
  --bg-input: #eef0f4;
  --bg-tab-active: transparent;

  --border: #e2e4ea;
  --border-light: #eef0f4;

  --text-primary: #1a1c24;
  --text-secondary: #5c6070;
  --text-muted: #9ca0b0;
  --text-link: #3b82f6;
  --text-group: #b8860b;
  --text-active: #3b82f6;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --warning-bg: rgba(234, 179, 8, 0.08);
  --warning-border: #eab308;
  --warning-text: #a16207;
  --tip-bg: rgba(59, 130, 246, 0.06);
  --tip-border: #3b82f6;
  --tip-text: #2563eb;
  --info-bg: rgba(59, 130, 246, 0.06);
  --info-border: #3b82f6;
  --success-bg: rgba(34, 197, 94, 0.08);
  --success-border: #22c55e;

  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --scrollbar-thumb: #d1d5db;
  --scrollbar-track: transparent;
}

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

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

body {
  font-family: var(--font-sans);
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.7;
  font-size: 15px;
  overflow: hidden;
  height: 100vh;
}

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

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

/* ========== Navbar ========== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-h);
  background: var(--bg-navbar);
  border-bottom: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
}

.navbar-left { display: flex; align-items: center; gap: 8px; }
.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon { color: var(--accent); }
.logo-text { font-size: 17px; font-weight: 700; color: var(--text-primary); }
.logo-sub { font-size: 14px; color: var(--text-muted); font-weight: 400; margin-left: 2px; }

.navbar-right { display: flex; align-items: center; gap: 4px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  color: var(--text-secondary);
  font-size: 13px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  text-decoration: none;
}
.nav-link:hover { color: var(--text-primary); background: var(--bg-hover); text-decoration: none; }

/* ========== Layout ========== */
.layout {
  display: flex;
  margin-top: var(--navbar-h);
  height: calc(100vh - var(--navbar-h));
}

/* ========== Left Sidebar ========== */
.sidebar {
  position: relative;
  z-index: 3;
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 20px 12px 12px;
  padding: 7px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: text;
}
.search-icon { color: var(--text-muted); flex-shrink: 0; }
.search-box input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-sans);
}
.search-box input::placeholder { color: var(--text-muted); }
.search-kbd {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-body);
  min-width: 38px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  line-height: 1.35;
  text-align: center;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0 20px;
}

.nav-group { margin-bottom: 4px; }
.nav-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-group);
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
  user-select: none;
}
.nav-group-title .chevron {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.nav-group.collapsed .chevron { transform: rotate(-90deg); }
.nav-group.collapsed .nav-group-items { display: none; }

.nav-group-items { list-style: none; }
.nav-item {
  display: block;
  padding: 5px 18px 5px 22px;
  font-size: 13.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s;
  border-left: 2px solid transparent;
  text-decoration: none;
}
.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  text-decoration: none;
}
.nav-item.active {
  color: var(--text-active);
  background: var(--bg-active);
  border-left-color: var(--accent);
  font-weight: 500;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  border-top: 1px solid var(--border-light);
}
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ========== Main Content ========== */
.content {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow-y: auto;
  padding: 40px 50px 80px;
  max-width: 100%;
  background: var(--bg-content);
  border-radius: 32px 0 0 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.content::-webkit-scrollbar { display: none; }

.content-inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

.content h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.3;
  color: var(--text-primary);
}
.content .page-desc {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 32px;
  line-height: 1.6;
}

.content h2 {
  font-size: 22px;
  font-weight: 650;
  margin-top: 40px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}
.content h3 {
  font-size: 17px;
  font-weight: 600;
  margin-top: 28px;
  margin-bottom: 12px;
  color: var(--text-primary);
}
.content p {
  margin-bottom: 16px;
  color: var(--text-primary);
}
.content ul, .content ol {
  margin-bottom: 16px;
  padding-left: 24px;
}
.content li { margin-bottom: 6px; }
.content strong { font-weight: 600; }
.content code:not(pre code) {
  background: var(--bg-code-inline);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ========== Tabs Component ========== */
.tabs {
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.tabs-header {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.tab-btn {
  padding: 10px 20px;
  font-size: 13.5px;
  font-family: var(--font-sans);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ========== Code Block ========== */
.code-block {
  position: relative;
  background: var(--bg-code);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}
.tabs .code-block { border-radius: 0; }
.code-block pre {
  margin: 0;
  padding: 16px 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
  color: #e1e4ed;
}
.code-block .copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  opacity: 0;
}
.code-block:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: rgba(255,255,255,0.12); color: var(--text-primary); }
.copy-btn.copied { color: var(--success-border); }

/* standalone code block (not inside tabs) */
.code-standalone {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}
.code-standalone .code-block { border-radius: var(--radius); }
.code-with-title .code-block { border-radius: 0 0 var(--radius) var(--radius); }
.code-file-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 16px;
  background: rgba(255,255,255,0.05);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
}
.code-file-title .copy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.code-file-title .copy-btn:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}
.code-file-title .copy-btn.copied { color: var(--success-border); }

.config-steps {
  padding: 32px 0 0;
}

/* ========== Steps Component ========== */
.steps { margin-bottom: 24px; }
.step {
  display: flex;
  gap: 16px;
  padding: 0 0 24px;
  position: relative;
}
.step:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 36px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}
.step-number {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-sidebar);
}
.step-content { flex: 1; min-width: 0; }
.step-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  padding-top: 4px;
  color: var(--text-primary);
}
.step-body { color: var(--text-secondary); }
.step-body p { margin-bottom: 12px; }

/* ========== Callout ========== */
.callout {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.6;
  border-left: 3px solid;
}
.callout-warning {
  background: var(--warning-bg);
  border-left-color: var(--warning-border);
  color: var(--warning-text);
}
.callout-tip {
  background: var(--tip-bg);
  border-left-color: var(--tip-border);
  color: var(--tip-text);
}
.callout-info {
  background: var(--info-bg);
  border-left-color: var(--info-border);
  color: var(--text-primary);
}
.callout-icon { font-size: 16px; flex-shrink: 0; line-height: 1.6; }
.callout-content { flex: 1; }

/* ========== Card ========== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.card {
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  color: var(--text-primary);
}
.card:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}
.card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ========== Right TOC ========== */
.toc {
  width: var(--toc-w);
  min-width: var(--toc-w);
  --toc-shift-x: clamp(-320px, calc(638px - 50vw), 0px);
  padding: 48px 16px 28px 0;
  overflow: visible;
  position: sticky;
  top: var(--navbar-h);
  height: calc(100vh - var(--navbar-h));
  background: var(--bg-content);
  z-index: 2;
}
.toc-title,
.toc-nav {
  width: 176px;
  transform: translateX(var(--toc-shift-x));
}
.toc-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 14px;
  padding-left: 0;
}
.toc-nav {
  list-style: none;
  border-left: 2px solid var(--border);
  padding: 3px 0;
}
.toc-link {
  display: block;
  padding: 6px 0 6px 14px;
  margin-left: -2px;
  font-size: 13px;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: all 0.12s;
  text-decoration: none;
  line-height: 1.55;
}
.toc-link:hover { color: var(--text-primary); text-decoration: none; }
.toc-link.active {
  color: var(--text-primary);
  border-left-color: var(--text-primary);
  font-weight: 600;
}
.toc-link.level-3 { padding-left: 26px; font-size: 12.5px; }

/* ========== Page Navigation ========== */
.page-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border-light);
  gap: 16px;
}
.page-nav-btn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  min-width: 0;
  max-width: 48%;
}
.page-nav-btn:hover { border-color: var(--accent); text-decoration: none; }
.page-nav-btn .label {
  font-size: 12px;
  color: var(--text-muted);
}
.page-nav-btn .title {
  font-size: 14px;
  color: var(--text-link);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-nav-btn.prev { align-items: flex-start; }
.page-nav-btn.next { align-items: flex-end; margin-left: auto; }

/* ========== Responsive ========== */
@media (max-width: 1100px) {
  .toc { display: none; }
}
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    top: var(--navbar-h);
    height: calc(100vh - var(--navbar-h));
    z-index: 90;
    transition: left 0.25s;
  }
  .sidebar.open { left: 0; }
  .content { padding: 24px 20px 60px; }
}

/* ========== Transition ========== */
.content-inner {
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
