:root {
  --bg: #f6f7fb;
  --bg-elevated: rgba(255, 255, 255, 0.86);
  --bg-panel: #ffffff;
  --bg-soft: #eef2f7;
  --bg-hover: #e8eef7;
  --text: #1f2937;
  --text-muted: #6b7280;
  --text-soft: #94a3b8;
  --border: rgba(148, 163, 184, 0.22);
  --border-strong: rgba(148, 163, 184, 0.35);
  --brand: #3a6ff7;
  --brand-strong: #2757d6;
  --brand-soft: rgba(58, 111, 247, 0.12);
  --code-bg: #0f172a;
  --code-fg: #e5edf9;
  --code-toolbar-bg: #f4f7fb;
  --code-panel-border: rgba(148, 163, 184, 0.24);
  --code-panel-shadow: 0 18px 40px rgba(148, 163, 184, 0.18);
  --code-line-number: #94a3b8;
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 4px 16px rgba(15, 23, 42, 0.06);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --sidebar-width: 300px;
  --toolbar-height: 68px;
  --transition: 180ms ease;
  --font-sans: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "SFMono-Regular", "SF Mono", "JetBrains Mono", "Menlo", monospace;
  --body-bg:
    radial-gradient(circle at top left, rgba(58, 111, 247, 0.12), transparent 30%),
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.10), transparent 26%),
    linear-gradient(180deg, #fbfcff 0%, var(--bg) 100%);
  --brand-mark-bg: linear-gradient(135deg, var(--brand), #7c3aed);
  --active-file-bg: linear-gradient(180deg, rgba(58,111,247,0.12), rgba(58,111,247,0.08));
  --active-file-border: rgba(58,111,247,0.18);
  --active-file-shadow: 0 8px 18px rgba(58,111,247,0.08);
  --loading-bar-bg: linear-gradient(90deg, var(--brand), #38bdf8);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--body-bg);
  overflow: hidden;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); }

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  height: 100vh;
  transition: grid-template-columns var(--transition);
}

.app.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 18px 14px 18px 18px;
  border-right: 0;
  background: var(--bg);
  backdrop-filter: none;
  box-shadow: none;
  overflow: hidden;
  transition:
    margin-left var(--transition),
    opacity var(--transition),
    visibility var(--transition);
}
.sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-width));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.sidebar-header { display: grid; gap: 14px; padding-bottom: 14px; }
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  color: var(--text);
  padding: 10px 12px; border-radius: var(--radius-md);
}
.sidebar-brand:hover { background: var(--bg-soft); }
.sidebar-brand-mark {
  width: 36px; height: 36px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--brand-mark-bg);
  color: #fff; font-weight: 700; box-shadow: var(--shadow-sm);
}
.sidebar-brand-text { display: grid; line-height: 1.3; }
.sidebar-brand-text strong { font-size: 16px; }
.sidebar-brand-text small { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.search-box input {
  width: 100%; border: 1px solid var(--border);
  border-radius: 999px; padding: 11px 14px;
  background: var(--bg-panel); color: var(--text);
  outline: none; box-shadow: var(--shadow-sm);
}
.search-box input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.search-box input::placeholder { color: var(--text-soft); }

.sidebar-nav { flex: 1; overflow: auto; padding: 4px 2px 0 0; }
.nav-tree { list-style: none; margin: 0; padding: 0; }
.nav-tree ul { list-style: none; margin: 0; padding: 0; }
.nav-dir { margin-bottom: 4px; letter-spacing: 0.09em; }
.nav-dir-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 12px;
  color: var(--text-muted); font-size: 15px; font-weight: 700;
  cursor: pointer; user-select: none;
}
.nav-dir-header:hover { background: var(--bg-soft); color: var(--text); }
.nav-dir-arrow { display: none; }
.nav-dir.collapsed .nav-dir-arrow { transform: rotate(-90deg); }
.nav-dir-icon { display: none; }
.nav-dir-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-dir-children {
  overflow: hidden;
  margin-left: 14px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}
.nav-dir.collapsed .nav-dir-children { max-height: 0 !important; }

.nav-file {
  display: flex; align-items: center; gap: 10px;
  margin: 2px 0; padding: 10px 15px 10px 12px;
  border-radius: 12px; color: var(--text);
  cursor: pointer; border: 1px solid transparent;
  letter-spacing: 0.09em;
}
.nav-file:hover { background: var(--bg-soft); }
.nav-file.active {
  background: var(--active-file-bg);
  border-color: var(--active-file-border);
  box-shadow: var(--active-file-shadow);
}
.nav-file-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
  flex: 0 0 auto;
}
.nav-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.nav-hidden { display: none !important; }
.nav-empty {
  margin: 14px 10px; padding: 18px 14px; border-radius: 16px;
  background: var(--bg-soft); color: var(--text-muted); text-align: center;
}

.content {
  min-width: 0; display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
}
.content-toolbar {
  height: var(--toolbar-height);
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 0 18px 0 22px;
  background: var(--bg-elevated);
  border-bottom: 0;
  backdrop-filter: none;
}
.toolbar-breadcrumb-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
.toolbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}
.toolbar-kicker {
  display: inline-flex; align-items: center;
  padding: 5px 10px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 700;
  flex: 0 0 auto;
}
.toolbar-divider,
.toolbar-segment {
  color: var(--text-muted);
  font-size: 14px;
  flex: 0 1 auto;
  min-width: 0;
}
.toolbar-divider {
  flex: 0 0 auto;
}
.toolbar-segment {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toolbar-segment.is-current {
  color: var(--text);
  font-weight: 600;
  flex-shrink: 0;
  max-width: min(42vw, 420px);
}
.toolbar-actions { display: flex; align-items: center; gap: 8px; }
.theme-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-panel);
  box-shadow: var(--shadow-sm);
}
.theme-select-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.theme-select {
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  min-width: 104px;
  outline: none;
  cursor: pointer;
}
.btn-icon {
  width: 38px; height: 38px; border: 1px solid transparent;
  border-radius: 12px; background: transparent; color: var(--text-muted);
  cursor: pointer; display: grid; place-items: center; font-size: 16px;
}
.btn-icon:hover { background: var(--bg-soft); color: var(--text); border-color: var(--border); }
.btn-icon svg,
.btn-icon i svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn-icon i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}
.btn-sidebar-toggle {
  flex: 0 0 auto;
  display: grid;
}
.content-body {
  flex: 1;
  overflow: auto;
  background: var(--bg-elevated);
}
.empty-state {
  display: grid; place-items: center; min-height: 100%;
  padding: 32px;
}
.empty-card {
  max-width: 420px; width: 100%;
  padding: 32px; border-radius: 24px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); text-align: center; backdrop-filter: blur(18px);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-card h2 { margin: 0 0 8px; font-size: 22px; }
.empty-card p { margin: 0; color: var(--text-muted); line-height: 1.7; }

.markdown-body {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding: 36px 0 72px;
}
.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 24px;
  align-items: start;
}
.article-layout.toc-collapsed {
  grid-template-columns: minmax(0, 1fr) 68px;
}
.article-main {
  min-width: 0;
}
.article-header {
  padding: 10px 0 14px;
  margin-bottom: 20px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}
.article-title {
  margin: 0;
  font-size: clamp(30px, 4vw, 44px); line-height: 1.08;
  letter-spacing: -0.03em; color: var(--text);
}
.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  color: var(--text-muted);
  font-size: 13px;
}
.article-meta-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}
.article-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border-radius: 0;
  background: transparent;
}
.article-meta-item em {
  font-style: italic;
  opacity: 0.9;
}
.article-body {
  font-size: 16px; line-height: 1.85; color: var(--text);
}
.article-body > :first-child { margin-top: 0; }
.article-body h1, .article-body h2, .article-body h3, .article-body h4 {
  letter-spacing: -0.02em; line-height: 1.25; scroll-margin-top: 96px;
}
.article-body h1 { font-size: 2rem; margin: 1.5em 0 0.6em; }
.article-body h2 {
  font-size: 1.5rem; margin: 1.8em 0 0.8em; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.article-body h3 { font-size: 1.15rem; margin: 1.4em 0 0.65em; }
.article-body h4, .article-body h5, .article-body h6 { font-size: 1rem; margin: 1.2em 0 0.6em; }
.article-body p { margin: 0.85em 0; color: var(--text); }
.article-body a { text-decoration: underline; text-decoration-color: rgba(58,111,247,0.28); text-underline-offset: 2px; }
.article-body ul, .article-body ol { padding-left: 1.5em; margin: 0.9em 0; }
.article-body li { margin: 0.35em 0; }
.article-body blockquote {
  margin: 1.2em 0; padding: 14px 18px;
  border-left: 4px solid var(--brand); border-radius: 0 16px 16px 0;
  background: var(--bg-soft); color: var(--text-muted);
}
.article-body code {
  font-family: var(--font-mono); font-size: 0.92em;
  padding: 0.18em 0.42em; border-radius: 8px;
  background: rgba(148, 163, 184, 0.14); color: var(--text);
}
.code-block-shell {
  position: relative;
  margin: 1.2em 0;
}
.article-body .code-block-shell pre {
  margin: 0;
  padding: 52px 20px 18px;
  border-radius: 20px;
  overflow: auto;
  color: var(--code-fg);
  border: 1px solid var(--code-panel-border);
  box-shadow: var(--code-panel-shadow);
  background:
    radial-gradient(circle at 24px 18px, #ff5f57 0 5px, transparent 5.5px),
    radial-gradient(circle at 44px 18px, #febc2e 0 5px, transparent 5.5px),
    radial-gradient(circle at 64px 18px, #28c840 0 5px, transparent 5.5px),
    linear-gradient(180deg, var(--code-toolbar-bg) 0 36px, var(--code-bg) 36px 100%) !important;
}
.article-body .code-block-shell pre code {
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: 0.92rem;
  line-height: 1.6;
}
.code-copy-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--code-panel-border);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition), color var(--transition), background var(--transition), border-color var(--transition);
}
.code-copy-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.94);
  border-color: var(--border-strong);
}
.code-block-shell:hover .code-copy-btn,
.code-block-shell:focus-within .code-copy-btn {
  opacity: 1;
  pointer-events: auto;
}
[data-color-mode="light"] .article-body .code-block-shell pre .hljs-ln-n {
  color: var(--code-line-number);
}
[data-color-mode="dark"] .code-copy-btn {
  background: rgba(15, 23, 42, 0.78);
  color: var(--text-muted);
}
[data-color-mode="dark"] .code-copy-btn:hover {
  background: rgba(30, 41, 59, 0.94);
}
.article-body table {
  width: 100%; margin: 1.2em 0; border-collapse: collapse;
  overflow: hidden; border-radius: 16px; border: 1px solid var(--border);
}
.article-body th, .article-body td {
  padding: 11px 14px; border-bottom: 1px solid var(--border); text-align: left;
}
.article-body th { background: var(--bg-soft); font-weight: 700; }
.article-body tr:last-child td { border-bottom: 0; }
.article-body img { max-width: 100%; height: auto; border-radius: 18px; box-shadow: var(--shadow-sm); }
.article-body hr { margin: 2em 0; border: 0; border-top: 1px solid var(--border); }
.article-body input[type="checkbox"] { margin-right: 8px; }

.toc-panel {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 18px;
  margin-top: 48px;
}
.toc-card {
  padding: 16px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px);
}
.toc-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.toc-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.toc-toggle-btn {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  color: var(--text-soft);
}
.toc-toggle-btn i,
.toc-toggle-btn svg,
.toc-toggle-btn i svg {
  width: 15px;
  height: 15px;
}
.toc-nav {
  display: grid;
  gap: 4px;
}
.toc-panel.is-collapsed .toc-card {
  /* padding: 12px 10px; */
  padding-left: 9px;
  padding-right: 9px;
}
.toc-panel.is-collapsed .toc-card-header {
  justify-content: center;
  margin-bottom: 0;
}
.toc-panel.is-collapsed .toc-title,
.toc-panel.is-collapsed .toc-nav {
  display: none;
}
/* .toc-panel.is-collapsed .toc-toggle-btn {
  width: 36px;
  height: 36px;
} */
.toc-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  text-align: left;
  line-height: 1.35;
  cursor: pointer;
}
.toc-link:hover {
  background: var(--bg-soft);
  color: var(--text);
}
.toc-link.toc-level-3 { padding-left: 20px; font-size: 12.5px; }
.toc-link.toc-level-4 { padding-left: 30px; font-size: 12px; }
.toc-bullet {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  flex: 0 0 auto;
}
.toc-empty-state {
  color: var(--text-muted);
  font-size: 13px;
  padding: 6px 2px 2px;
}

.loading-bar {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: var(--loading-bar-bg);
  z-index: 1000; pointer-events: none; transition: width 0.25s ease, opacity 0.2s ease;
}
.loading-bar.visible { width: 55%; }
.loading-bar.done { width: 100%; opacity: 0; }

.mobile-nav-btn { display: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35); border-radius: 999px; border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.5); background-clip: content-box; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 220;
    width: min(86vw, 320px); transform: translateX(-100%);
    visibility: visible;
    opacity: 1;
    transition: transform 220ms ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.mobile-visible { transform: translateX(0); }
  .sidebar.collapsed {
    margin-left: 0;
    visibility: visible;
    opacity: 1;
  }
  .content-toolbar { padding-left: 18px; }
  .toolbar-breadcrumb-group {
    gap: 10px;
  }
  .toolbar-breadcrumb { min-width: 0; }
  .btn-sidebar-toggle-toolbar { display: none !important; }
  .theme-select-wrap { max-width: 150px; }
  .theme-select { min-width: 0; width: 100%; }
  .markdown-body { width: min(100%, calc(100% - 28px)); padding-top: 20px; padding-bottom: 72px; }
  .article-layout { grid-template-columns: minmax(0, 1fr); }
  .toc-panel { display: none !important; }
  .article-header { padding: 8px 0 12px; }
  .mobile-nav-btn {
    display: grid; place-items: center; position: fixed; right: 18px; bottom: 18px;
    width: 52px; height: 52px; border-radius: 18px;
    border: 1px solid var(--border); background: var(--bg-elevated);
    color: var(--text); box-shadow: var(--shadow-lg); z-index: 210;
    backdrop-filter: blur(18px);
  }
}

@media (max-width: 640px) {
  .theme-select-label { display: none; }
  .theme-select-wrap {
    width: 92px;
    padding: 0 10px;
  }
  .code-copy-btn {
    opacity: 1;
    pointer-events: auto;
  }
}

[data-doc-theme="toc"] .content {
  background:
    radial-gradient(circle at top right, rgba(58, 111, 247, 0.08), transparent 28%),
    transparent;
}
[data-doc-theme="toc"] .markdown-body {
  width: min(1180px, calc(100% - 48px));
}
[data-doc-theme="toc"] .article-layout {
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 28px;
}

.sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 210;
  background: rgba(2, 6, 23, 0.34); backdrop-filter: blur(4px);
}
@media (max-width: 900px) {
  .sidebar-overlay.visible { display: block; }
}
