:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1f2328;
  --ink-soft: #59636e;
  --ink-faint: #848d97;
  --line: #d9dfe7;
  --line-soft: #e8edf2;
  --accent: #0a66c2;
  --accent-soft: #e7f1fb;
  --cn-tint: #fdfaf5;
  --en-tint: #f5f9fd;
  --flash: #fff3bf;
  --header-h: 56px;
  --mono: "Cascadia Mono", "JetBrains Mono", Consolas, "Courier New", "Sarasa Mono SC", monospace;
  --sans: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.7 var(--sans);
}

/* ============ 顶栏 ============ */
/* 仅顶部 banner 置顶（注意：不能用 header 元素选择器，否则会命中卡片内的 .entry-head） */
body > header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.brand-main { font-size: 20px; font-weight: 800; letter-spacing: .5px; color: var(--accent); }
.brand-sub { font-size: 13px; color: var(--ink-soft); }

.search-box { flex: 1; display: flex; align-items: center; gap: 8px; max-width: 520px; }
#search {
  flex: 1;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--bg);
  font-size: 14px;
  outline: none;
}
#search:focus { border-color: var(--accent); background: #fff; }
.search-count { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }

.lang-switch { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang-switch button {
  border: 0; background: #fff; color: var(--ink-soft);
  font-size: 13px; padding: 7px 14px; cursor: pointer;
}
.lang-switch button + button { border-left: 1px solid var(--line); }
.lang-switch button.active { background: var(--accent); color: #fff; }

/* ============ 布局 ============ */
.layout {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  max-width: 1680px;
  margin: 0 auto;
}

/* ============ 目录 ============ */
.toc {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 14px 10px 40px;
}
.toc-group { margin-bottom: 18px; }
.toc-group-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--ink-faint); padding: 4px 10px;
}
.toc-link {
  display: block; padding: 4px 10px; border-radius: 6px;
  color: var(--ink); text-decoration: none;
  font-size: 13.5px; line-height: 1.45;
  border-left: 3px solid transparent; word-break: break-all;
}
.toc-link:hover { background: var(--accent-soft); }
.toc-link.active {
  background: var(--accent-soft); border-left-color: var(--accent);
  color: var(--accent); font-weight: 600;
}
.toc-link .toc-en { display: block; font-size: 11.5px; color: var(--ink-soft); }
.toc-link.active .toc-en { color: var(--accent); }
.toc-empty { padding: 6px 10px; font-size: 13px; color: var(--ink-soft); }

/* ============ 正文 ============ */
.content { padding: 20px 24px 120px; min-width: 0; }

.entry {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 26px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(20, 30, 50, .05);
}
.entry.flash { animation: flash 1.6s ease-out; }
@keyframes flash {
  0%, 40% { box-shadow: 0 0 0 3px var(--flash); border-color: #e6c200; }
  100% { box-shadow: 0 1px 3px rgba(20, 30, 50, .05); }
}

/* 卡片头部 */
/* 卡片标题栏：普通流内元素，不得置顶（避免盖住顶部 banner） */
.entry-head {
  position: static;
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fafcfe, #f2f5f9);
}
.entry-title { margin: 0; font-size: 18px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cmd-name { font-family: var(--mono); font-weight: 800; color: var(--accent); font-size: 19px; }
.cmd-name.is-cn { font-family: var(--sans); }
.cmd-alias {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 10px; padding: 1px 8px;
  background: #fff;
}
.entry-sub { font-size: 13px; font-weight: 400; color: var(--ink-soft); }
/* 英文模式下以英文名为主标题 */
body[data-lang="en"] .cmd-name.is-cn { display: none; }
body[data-lang="en"] .entry-sub {
  font-family: var(--mono); font-size: 19px; font-weight: 800; color: var(--accent);
}
body[data-lang="en"] .toc-link .toc-main.is-cn { display: none; }

/* 双栏 */
.panes { display: grid; grid-template-columns: 1fr 1fr; }
.pane { min-width: 0; }
.pane + .pane { border-left: 1px solid var(--line); }
.pane-cn { background: var(--cn-tint); }
.pane-en { background: var(--en-tint); }
.pane-label {
  position: sticky; top: var(--header-h); z-index: 5;
  display: block; padding: 3px 18px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 1.5px;
  color: var(--ink-faint);
  background: rgba(255, 255, 255, .8);
  border-bottom: 1px solid var(--line-soft);
}
.pane-body { padding: 14px 18px 18px; }

/* 语言切换 */
body[data-lang="cn"] .pane-en,
body[data-lang="en"] .pane-cn { display: none; }
body[data-lang="cn"] .panes,
body[data-lang="en"] .panes { grid-template-columns: 1fr; }
body[data-lang="en"] .pane-en { border-left: 0; }
body[data-lang="cn"] .entry-sub { display: none; }

/* ============ 内容块 ============ */
.blk { margin: 0 0 18px; }
.blk:last-child { margin-bottom: 0; }

.blk-label {
  font-size: 11.5px; font-weight: 700; letter-spacing: 2px;
  color: var(--ink-faint); text-transform: uppercase;
  margin-bottom: 6px; padding-left: 9px;
  border-left: 3px solid var(--accent);
}
.blk-syntax .blk-label { border-left-color: #6e56cf; }
.blk-desc .blk-label { border-left-color: #1a7f37; }
.blk-params .blk-label { border-left-color: #bf8700; }
.blk-examples .blk-label { border-left-color: #0969da; }
.blk-remarks .blk-label { border-left-color: #cf222e; }

/* 代码块（语法 / 示例） */
.blk-code pre {
  margin: 0; padding: 12px 14px;
  font: 12.5px/1.65 var(--mono);
  background: #f6f8fa;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  overflow-x: auto;
  white-space: pre;
  tab-size: 4;
}
.blk-code pre::-webkit-scrollbar { height: 8px; }
.blk-code pre::-webkit-scrollbar-thumb { background: #c9d2dc; border-radius: 4px; }

/* 语法着色（浅色） */
.tk-cmd { color: #0550ae; font-weight: 700; }
.tk-var { color: #0550ae; }
.tk-opt { color: #8250df; }
.tk-env { color: #953800; background: rgba(149, 56, 0, .07); border-radius: 2px; }
.tk-pe { color: #116329; }
.tk-str { color: #0a3069; }
.tk-cmt { color: #6e7781; font-style: italic; }
.tk-sw { color: #bc4c00; }
.tk-num { color: #953800; }
.tk-op { color: #cf222e; }
.tk-ph { color: #8b949e; }
.blk-code .tk-cmd { font-weight: 700; }
.eg-code .tk-cmd, .blk-code .tk-cmd { background: none; }

/* 示例代码块（正文中的实例代码） */
.eg-code {
  margin: 8px 0;
  padding: 9px 12px;
  font: 12.5px/1.6 var(--mono);
  background: #f6f8fa;
  border: 1px solid var(--line-soft);
  border-left: 3px solid #0969da;
  border-radius: 6px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  tab-size: 4;
}
.eg-code + .eg-code { margin-top: 6px; }
.param-desc .eg-code { margin: 4px 0 0; }

/* 段落 / 列表 */
.blk-para { margin: 0 0 8px; }
.blk-para:last-child { margin-bottom: 0; }
.mk-list { list-style: none; margin: 0; padding: 0; }
.mk-item { display: flex; gap: 8px; margin-bottom: 6px; align-items: flex-start; }
.mk-item:last-child { margin-bottom: 0; }
.mk-bullet {
  flex: none; width: 18px; height: 18px; margin-top: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; border-radius: 5px; color: #fff;
}
.mk-note .mk-bullet { background: #0969da; }
.mk-sq .mk-bullet { background: #6e7781; }
.mk-warn .mk-bullet { background: #bf8700; }
.mk-dia .mk-bullet { background: #8250df; }
.mk-dot .mk-bullet { background: #1a7f37; }
.mk-star .mk-bullet { background: #bf3989; }

/* 小标题 / 签名 */
.blk-head {
  margin: 14px 0 6px; font-size: 14px; font-weight: 700; color: var(--ink);
}
.blk-head:first-child { margin-top: 0; }
.blk-sig {
  margin: 10px 0 0; text-align: right; font-size: 13px; color: var(--ink-soft);
}

/* 参数表 */
.param-list { margin: 0; }
.param-row {
  display: flex; gap: 10px; padding: 7px 0;
  border-bottom: 1px dashed var(--line-soft);
}
.param-row:last-child { border-bottom: 0; }
.param-name {
  flex: none; min-width: 92px; max-width: 40%;
  font-family: var(--mono); font-size: 12.5px; font-weight: 700;
  color: #0550ae; word-break: break-all;
}
.param-desc { margin: 0; flex: 1; font-size: 13.5px; }
.param-mk {
  display: inline-flex; width: 17px; height: 17px; margin-right: 6px;
  align-items: center; justify-content: center;
  font-size: 10.5px; border-radius: 4px; color: #fff; vertical-align: 1px;
}
.mk-note.param-mk, .param-mk.mk-note { background: #0969da; }
.param-mk.mk-sq { background: #6e7781; }
.param-mk.mk-warn { background: #bf8700; }
.param-mk.mk-dia { background: #8250df; }
.param-mk.mk-dot { background: #1a7f37; }
.param-mk.mk-star { background: #bf3989; }

/* 键值表格 */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 6px;
}
.kv {
  display: flex; gap: 8px; align-items: baseline;
  padding: 5px 9px;
  background: #f6f8fa;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  font-size: 12.5px;
}
.kv-k {
  flex: none; font-family: var(--mono); font-weight: 700; color: #0550ae;
  word-break: break-all;
}
.kv-v { color: var(--ink-soft); }

/* ============ 命令超链接 ============ */
.cmd-link {
  color: #0550ae;
  background: rgba(9, 105, 218, .07);
  border-radius: 3px;
  padding: 0 1px;
  text-decoration: none;
  cursor: pointer;
  border-bottom: 1px dotted rgba(9, 105, 218, .5);
}
.cmd-link:hover { background: var(--accent); color: #fff; }
.cmd-link.self { color: inherit; background: none; border-bottom: 0; cursor: text; pointer-events: none; }

/* ============ 分组标题 ============ */
.divider {
  margin: 34px 0 18px; padding: 12px 18px;
  border-left: 5px solid var(--accent);
  background: var(--panel);
  border-radius: 0 10px 10px 0;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(20, 30, 50, .05);
}
.divider h2 { margin: 0; font-size: 16px; }
.divider .divider-en { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }

/* ============ 竖向工具条 ============ */
.toolbar {
  position: fixed; right: 18px; bottom: 24px; z-index: 70;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, .16), inset 0 1px 0 rgba(255, 255, 255, .6);
  backdrop-filter: blur(6px);
}
.tb-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 0; cursor: pointer; text-decoration: none;
  color: var(--ink-soft); background: transparent;
  transition: transform .18s ease, color .18s ease, background .18s ease, box-shadow .18s ease;
  position: relative;
}
.tb-btn svg { width: 19px; height: 19px; display: block; }
.tb-btn:hover, .tb-btn:focus-visible {
  color: #fff; outline: none;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  transform: translateY(-2px);
  box-shadow: 0 5px 14px rgba(29, 78, 216, .38);
}
.tb-btn:active { transform: translateY(0) scale(.94); }
.tb-sep { width: 22px; height: 1px; margin: 3px 0; background: var(--line-soft); }

/* 主题图标切换 */
.tb-theme .icon-sun { display: none; }
body[data-theme="dark"] .tb-theme .icon-moon { display: none; }
body[data-theme="dark"] .tb-theme .icon-sun { display: block; }

/* 悬停提示 */
.tb-btn::after {
  content: attr(data-tip);
  position: absolute; right: calc(100% + 12px); top: 50%;
  transform: translateY(-50%);
  white-space: nowrap; font-size: 12px; line-height: 1;
  color: #fff; background: rgba(15, 23, 42, .9);
  padding: 7px 10px; border-radius: 6px;
  opacity: 0; pointer-events: none;
  transition: opacity .15s ease;
}
.tb-btn:hover::after, .tb-btn:focus-visible::after { opacity: 1; }

/* ============ 深色主题 ============ */
body[data-theme="dark"] {
  --bg: #0b0e14;
  --panel: #141a23;
  --ink: #dde3ea;
  --ink-soft: #98a2ae;
  --ink-faint: #6f7a86;
  --line: #2a323d;
  --line-soft: #20262f;
  --accent: #4c9aff;
  --accent-soft: #16273e;
  --cn-tint: #1a1610;
  --en-tint: #0f1720;
  --flash: #6b5300;
}
body[data-theme="dark"] header { background: rgba(20, 26, 35, .92); }
body[data-theme="dark"] #search { background: #0b0e14; color: var(--ink); }
body[data-theme="dark"] .lang-switch button { background: var(--panel); }
body[data-theme="dark"] .entry-head { background: linear-gradient(180deg, #1a212b, #141a23); }
body[data-theme="dark"] .pane-label { background: rgba(20, 26, 35, .82); }
body[data-theme="dark"] .blk-code pre { background: #0d1117; border-color: var(--line); }
body[data-theme="dark"] .eg-code { background: #0d1117; border-left-color: #4c9aff; }
body[data-theme="dark"] .tk-cmd { color: #6cb6ff; }
body[data-theme="dark"] .tk-var { color: #6cb6ff; }
body[data-theme="dark"] .tk-opt { color: #b083f0; }
body[data-theme="dark"] .tk-env { color: #e3b341; background: rgba(227, 179, 65, .12); }
body[data-theme="dark"] .tk-pe { color: #7ee787; }
body[data-theme="dark"] .tk-str { color: #a5d6ff; }
body[data-theme="dark"] .tk-cmt { color: #8b949e; }
body[data-theme="dark"] .tk-sw { color: #ffa657; }
body[data-theme="dark"] .tk-num { color: #e3b341; }
body[data-theme="dark"] .tk-op { color: #ff7b72; }
body[data-theme="dark"] .tk-ph { color: #8b949e; }
body[data-theme="dark"] .kv { background: #0f141b; }
body[data-theme="dark"] .cmd-alias { background: var(--panel); }
body[data-theme="dark"] .cmd-link { color: #6cb6ff; background: rgba(76, 154, 255, .12); }
body[data-theme="dark"] .cmd-link:hover { background: var(--accent); color: #0b0e14; }
body[data-theme="dark"] .tb-btn::after { background: rgba(226, 232, 240, .94); color: #0b0e14; }
body[data-theme="dark"] .toolbar { box-shadow: 0 8px 28px rgba(0, 0, 0, .5); inset 0 1px 0 rgba(255, 255, 255, .06); }
body[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #30363d; }

/* ============ 窄屏 ============ */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .toc {
    position: static; height: auto; max-height: 40vh;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .panes { grid-template-columns: 1fr; }
  .pane + .pane { border-left: 0; border-top: 1px solid var(--line); }
  .brand-sub { display: none; }
}
