/* dsh-docs — 全局样式（浅色/深色由 html[data-theme] 切换，语言由 html[data-lang] 切换） */

:root {
  --bg: #ffffff;
  --fg: #1f2328;
  --muted: #656d76;
  --border: #d1d9e0;
  --accent: #0b6bcb;
  --accent-soft: #ddf4ff;
  --code-bg: #f6f8fa;
  --sidebar-bg: #f6f8fa;
  --card-bg: #ffffff;
  --shadow: 0 1px 2px rgba(31, 35, 40, 0.08);
  --admon-warning-bg: #fff8c5;
  --admon-warning-bd: #d4a72c;
  --admon-tip-bg: #dafbe1;
  --admon-tip-bd: #1a7f37;
  --admon-note-bg: #ddf4ff;
  --admon-note-bd: #0969da;
  --admon-danger-bg: #ffebe9;
  --admon-danger-bd: #cf222e;
}
html[data-theme="dark"] {
  --bg: #0d1117;
  --fg: #e6edf3;
  --muted: #8b949e;
  --border: #30363d;
  --accent: #58a6ff;
  --accent-soft: rgba(56, 139, 253, 0.15);
  --code-bg: #161b22;
  --sidebar-bg: #010409;
  --card-bg: #151b23;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --admon-warning-bg: rgba(210, 153, 34, 0.15);
  --admon-warning-bd: #d29922;
  --admon-tip-bg: rgba(46, 160, 67, 0.15);
  --admon-tip-bd: #2ea043;
  --admon-note-bg: rgba(56, 139, 253, 0.15);
  --admon-note-bd: #388bfd;
  --admon-danger-bg: rgba(248, 81, 73, 0.15);
  --admon-danger-bd: #f85149;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.65;
  font-size: 15px;
}

/* ---------- 双语文案：.l-en / .l-zh ---------- */
.l-zh { display: none; }
html[data-lang="zh"] .l-en { display: none; }
html[data-lang="zh"] .l-zh { display: inline; }

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--fg);
  font-weight: 600;
  font-size: 14px;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn, .lang-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 6px;
  cursor: pointer;
  padding: 4px 10px;
  font-size: 13px;
  line-height: 1.4;
}
.icon-btn:hover, .lang-btn:hover { border-color: var(--accent); }
.lang-btn { font-weight: 600; min-width: 52px; }
.source-link { color: var(--muted); font-size: 13px; text-decoration: none; margin-right: 4px; }
.source-link:hover { color: var(--accent); }
#nav-toggle { display: none; }

/* ---------- layout ---------- */
.layout { display: flex; max-width: 1480px; margin: 0 auto; align-items: flex-start; }
.sidebar {
  width: 270px;
  flex: 0 0 270px;
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
  overflow-y: auto;
  padding: 16px 12px 40px;
  border-right: 1px solid var(--border);
  background: var(--sidebar-bg);
}
.content {
  flex: 1;
  min-width: 0;
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 48px 64px;
}
.toc-wrap {
  width: 250px;
  flex: 0 0 250px;
  display: none;
}
@media (min-width: 1180px) {
  .toc-wrap { display: block; }
}

/* ---------- sidebar nav ---------- */
.nav-filter { padding: 0 4px; }
.nav-filter input {
  width: 100%;
  padding: 6px 10px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-size: 13px;
}
.nav-filter input:focus { outline: none; border-color: var(--accent); }
.nav-section { margin-bottom: 14px; }
.nav-section.hidden { display: none; }
.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 4px;
  padding: 0 8px;
}
.nav-item {
  display: block;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--fg);
  text-decoration: none;
  font-size: 13.5px;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-item:hover { background: var(--accent-soft); color: var(--accent); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.hidden { display: none; }
.badge {
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 6px;
  margin-left: 6px;
  vertical-align: 1px;
}

/* ---------- article prose ---------- */
.article h1, .article h2, .article h3, .article h4 { scroll-margin-top: 64px; }
html[data-lang="zh"] #article-en { display: none; }
html[data-lang="en"] #article-zh { display: none; }

.article h1 {
  font-size: 1.9em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3em;
  margin: 0 0 0.8em;
}
.article h2 {
  font-size: 1.45em;
  margin: 1.6em 0 0.6em;
  padding-bottom: 0.25em;
  border-bottom: 1px solid var(--border);
}
.article h3 { font-size: 1.2em; margin: 1.4em 0 0.5em; }
.article h4 { font-size: 1.05em; margin: 1.2em 0 0.4em; }
.article p { margin: 0.7em 0; }
.article a { color: var(--accent); text-decoration: none; }
.article a:hover { text-decoration: underline; }
.article ul, .article ol { padding-left: 1.6em; margin: 0.7em 0; }
.article li { margin: 0.25em 0; }
.article blockquote {
  margin: 0.8em 0;
  padding: 0.2em 1em;
  color: var(--muted);
  border-left: 3px solid var(--border);
}
.article code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  border-radius: 4px;
  padding: 0.15em 0.35em;
}
.article pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  line-height: 1.55;
  margin: 0.9em 0;
}
.article pre code { background: none; padding: 0; font-size: 0.85em; }
.article table {
  border-collapse: collapse;
  margin: 1em 0;
  display: block;
  overflow-x: auto;
  max-width: 100%;
}
.article th, .article td { border: 1px solid var(--border); padding: 6px 12px; text-align: left; }
.article th { background: var(--code-bg); }
.article img { max-width: 100%; border-radius: 6px; }
.article hr { border: none; border-top: 1px solid var(--border); margin: 1.5em 0; }
.article .notice {
  background: var(--admon-note-bg);
  border: 1px solid var(--admon-note-bd);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13.5px;
  margin-bottom: 1em;
}
.article .mermaid { margin: 1em 0; text-align: center; }
.article .mermaid svg { max-width: 100%; height: auto; }

/* ---------- admonitions ---------- */
.admonition {
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 10px 16px;
  margin: 1em 0;
}
.admonition > :first-child { margin-top: 0; }
.admonition > :last-child { margin-bottom: 0; }
.admonition-title { font-weight: 700; margin: 0 0 0.4em; }
.admonition-warning { background: var(--admon-warning-bg); border-left-color: var(--admon-warning-bd); }
.admonition-tip { background: var(--admon-tip-bg); border-left-color: var(--admon-tip-bd); }
.admonition-note, .admonition-info { background: var(--admon-note-bg); border-left-color: var(--admon-note-bd); }
.admonition-danger { background: var(--admon-danger-bg); border-left-color: var(--admon-danger-bd); }
.admonition-details { background: var(--card-bg); }
.admonition-details summary { cursor: pointer; font-weight: 600; }

/* ---------- toc ---------- */
.toc-panel {
  position: sticky;
  top: 52px;
  max-height: calc(100vh - 68px);
  overflow-y: auto;
  padding: 24px 12px 40px;
  font-size: 13px;
}
.toc-link {
  display: block;
  color: var(--muted);
  text-decoration: none;
  padding: 3px 6px;
  border-left: 2px solid transparent;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toc-link:hover { color: var(--accent); }
.toc-link.active { color: var(--accent); border-left-color: var(--accent); }
.toc-3 { padding-left: 18px; }
.toc-empty { color: var(--muted); }

/* ---------- landing ---------- */
.hero { padding: 48px 8px 24px; }
.hero h1 { font-size: 2.1em; margin: 0 0 0.3em; }
.hero-sub { color: var(--muted); font-size: 1.05em; margin: 0 0 0.5em; }
.hero-stats { color: var(--muted); font-size: 13px; margin: 0 0 1.4em; }
.hero-links { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}
.btn:hover { filter: brightness(1.1); }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
  padding: 8px 8px 24px;
}
.card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--card-bg);
  text-decoration: none;
  color: var(--fg);
  box-shadow: var(--shadow);
}
.card:hover { border-color: var(--accent); }
.card h3 { margin: 0 0 6px; font-size: 15px; }
.card p { margin: 0; color: var(--muted); font-size: 12.5px; }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .toc-wrap { display: none; }
}
@media (max-width: 860px) {
  #nav-toggle { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: 52px;
    left: 0;
    bottom: 0;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 24px 20px 48px; }
}
