/* manual tokens begin */
/* 手册专用变量：配色由 product-ui.css 提供，组件只引变量。
   三态顺序与控制台一致。长文保留 16px / 1.75。
   顶栏照控制台单行导航：上下各 8px，导航字 15px × 1.6，
   导航上下各 6px，底边 1px；深浅主题同高。 */
:root {
  --manual-fs: 16px;
  --manual-lh: 1.75;
  --manual-top: calc(8px + 15px * var(--lh) + 6px + 6px + 8px + 1px);
  --manual-brand-track: normal;
  --manual-code-bg: var(--ground);
  --manual-code-fg: var(--text);
  --manual-top-bg: color-mix(in srgb, var(--surface) 92%, transparent);
  --manual-note-bg: var(--soft);
  --manual-note-line: var(--accent-text);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --manual-code-bg: var(--ground);
    --manual-code-fg: var(--text);
    --manual-top-bg: color-mix(in srgb, var(--surface) 92%, transparent);
    --manual-note-bg: var(--soft);
    --manual-note-line: var(--accent-text);
  }
}
:root[data-theme="dark"] {
  --manual-code-bg: var(--ground);
  --manual-code-fg: var(--text);
  --manual-top-bg: color-mix(in srgb, var(--surface) 92%, transparent);
  --manual-note-bg: var(--soft);
  --manual-note-line: var(--accent-text);
}
/* manual tokens end */

/* 用户手册站。不引站外资源，字体与配色和控制台共用。 */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--manual-fs);
  line-height: var(--manual-lh);
  color: var(--text);
  background-color: var(--ground);
}

code, pre {
  font-family: var(--mono);
}

/* ---- 顶栏 ---- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--manual-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px 0 20px;
  background: var(--manual-top-bg);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.top-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font);
  font-weight: 700;
  font-size: var(--fs);
  letter-spacing: var(--manual-brand-track);
}

.top-brand:hover { color: var(--accent); }

.dot {
  width: 12px;
  height: 12px;
  border-radius: var(--r-pill);
  flex: none;
  background: var(--brand-fill);
}

.top-actions { display: flex; align-items: center; gap: 8px; }

.gh, .theme {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--r-ctl);
  font-size: 14px;
  font-weight: 500;
  padding: 7px 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  line-height: 1.2;
  text-decoration: none;
  font-family: inherit;
  cursor: pointer;
}

.gh-ico, .theme-opt svg { display: block; width: 18px; height: 18px; flex: none; }

.theme-opt { display: none; align-items: center; gap: 6px; }
html[data-mode="dark"] .opt-dark,
html[data-mode="light"] .opt-light,
html[data-mode="system"] .opt-system { display: inline-flex; }

.layout { display: flex; min-height: calc(100vh - var(--manual-top)); min-width: 0; max-width: 100%; }

/* ---- 左侧目录 ---- */

.toc {
  width: 264px;
  flex: none;
  padding: 18px 12px 32px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  position: sticky;
  top: var(--manual-top);
  max-height: calc(100vh - var(--manual-top));
}

.toc .brand { font-weight: 700; margin: 0 8px 12px; font-size: 13px; }
.toc .brand a { color: var(--dim); text-decoration: none; }

.toc a {
  display: block;
  padding: 6px 12px;
  border-radius: var(--r-ctl);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.45;
}

/* ---- 搜索 ---- */

.search { margin: 0 4px 14px; }

.search input {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
}

.search input:focus {
  border-color: var(--accent);
  outline: 2px solid var(--softline);
}

.hits { margin-top: 8px; }

.hits a {
  display: block;
  padding: 8px 10px;
  font-size: 13px;
  border-radius: var(--r-ctl);
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  margin-bottom: 6px;
  border: 1px solid var(--line);
}

.hits .ex { display: block; color: var(--dim); font-size: 12px; }

/* ---- 正文 ---- */

main { flex: 1; min-width: 0; padding: 28px 24px 64px; }

article {
  max-width: 46em;
  margin: 0 auto;
  min-width: 0;
  overflow-wrap: break-word;
}

article h1 {
  font-size: 1.85em;
  line-height: 1.3;
  margin: 0 0 0.55em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--line);
}

article h2 {
  font-size: 1.28em;
  margin: 1.7em 0 0.5em;
  padding-top: 0.35em;
  border-top: 1px solid var(--line);
}

article h3 { font-size: 1.08em; margin: 1.35em 0 0.4em; }

/* 跳到锚点时标题整行落在吸顶顶栏下面。
   顶栏 height 就是 var(--manual-top)，按 border-box，底边算在这截里（深浅主题同高）。
   窄屏还要加上目录条，见下方媒体查询。 */
article h2[id],
article h3[id],
article h4[id],
article h5[id],
article h6[id] {
  scroll-margin-top: var(--manual-top);
}

article a { color: var(--accent-text); font-weight: 700; }
article a:hover { color: var(--accent2); }

article code {
  background: var(--soft);
  color: var(--accent-text);
  padding: 0.12em 0.4em;
  border-radius: var(--r-ctl);
  font-size: 0.9em;
  word-break: normal;
  overflow-wrap: normal;
}

/* 整段窄于容器就不拆开；超出容器才折，符号处优先，没有符号再按字折。
   折行点只当折行用、不算进最小宽度：列保得住代码本身的宽，表太宽在 .table-wrap 里横滚。
   行高压在正文行高里，含代码的行不比不含的高；上下内边距仍把底色块垫开。 */
article :not(pre) > code {
  display: inline-block;
  max-width: 100%;
  vertical-align: baseline;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  line-height: 1.25;
}

article pre {
  background: var(--manual-code-bg);
  color: var(--manual-code-fg);
  border-radius: var(--r-ctl);
  padding: 14px 16px;
  overflow-x: auto;
  max-width: 100%;
  line-height: 1.6;
  border: 1px solid var(--line);
}

article pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: 0.88em;
  word-break: normal;
  overflow-wrap: normal;
  white-space: pre;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  margin: 1em 0;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
}

article table {
  border-collapse: collapse;
  width: 100%;
  margin: 0;
  font-size: 0.94em;
}

article th, article td {
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

article img { max-width: 100%; height: auto; border-radius: var(--r-card); box-shadow: var(--shadow); }
.alert {
  border: 1px solid var(--line);
  border-left: 4px solid var(--dim);
  border-radius: var(--r-ctl);
  padding: 12px 16px;
  margin: 1em 0;
  background: var(--surface);
}

.alert .al {
  display: block;
  font-weight: 800;
  margin-bottom: 2px;
  font-family: var(--font);
}

.alert.note { background: var(--manual-note-bg); border-left-color: var(--manual-note-line); }
.alert.note .al { color: var(--manual-note-line); }
.alert.tip { background: var(--oksoft); border-left-color: var(--ok); }
.alert.tip .al { color: var(--ok); }
.alert.warn { background: var(--warnsoft); border-left-color: var(--warn); }
.alert.warn .al { color: var(--warn); }

blockquote {
  margin: 1em 0;
  padding: 10px 16px;
  border: none;
  border-left: 5px solid var(--accent);
  border-radius: var(--r-ctl);
  background: var(--soft);
  color: var(--dim);
}

.sect {
  margin: 0.4em 0 1.8em;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--r-ctl);
  font-size: 0.92em;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.sect > span {
  color: var(--dim);
  font-weight: 700;
  font-family: var(--font);
}

.sect ul { margin: 6px 0 0; padding-left: 1.2em; }
.sect li { margin: 3px 0; }

.pager {
  max-width: 46em;
  margin: 2.4em auto 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pager:empty { display: none; }

.pager a {
  color: var(--text);
  text-decoration: none;
  border-radius: var(--r-ctl);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 8px 14px;
  font-weight: 700;
}

/* ---- 首页 ---- */

.home { max-width: 52em; }
.home h1 { border-bottom: none; padding-bottom: 0; }

.hero {
  background: var(--surface);
  border-radius: var(--r-card);
  padding: 32px 32px 28px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero h1 { margin-bottom: 0.35em; }

.lead {
  margin: 0 0 1.1em;
  font-size: 1.08rem;
  color: var(--text);
}

article a.start {
  display: inline-flex;
  align-items: center;
  padding: 11px 22px;
  border-radius: var(--r-ctl);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 800;
  text-decoration: none;
}

.band {
  margin: 26px 4px 10px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  font-family: var(--font);
  color: var(--accent-text);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

article a.card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border-radius: var(--r-card);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  line-height: 1.35;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.ci-wrap {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--r-ctl);
  display: grid;
  place-items: center;
  background: var(--soft);
  color: var(--accent-text);
}

.ci { width: 22px; height: 22px; }
.ct { line-height: 1.35; }

.gh:focus-visible, .theme:focus-visible, article a:focus-visible, .toc a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.gh:hover, .theme:hover { color: var(--accent); border-color: var(--accent); }
.toc > a { position: relative; padding: 8px 10px; font-size: 15px; line-height: var(--lh); }
.toc > a:hover, .toc > a.cur { background: var(--soft); }
.toc > a.cur { font-weight: 600; }
.toc > a.cur::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 2px;
  background: var(--nav-ind);
}
.hits a:hover { background: var(--soft); }
.hits .where { color: var(--accent-text); font-weight: 700; }
article tr:last-child td { border-bottom: none; }
article th { background: var(--soft); font-weight: 700; }
.pager a:hover { color: var(--accent-text); border-color: var(--accent); }
article a.start:hover { color: var(--on-accent); filter: brightness(1.05); }
article a.card:hover { color: var(--text); border-color: var(--accent); }

/* ---- 窄屏 ---- */

.nav-toggle { display: none; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .toc {
    position: static;
    max-height: none;
    width: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .layout > .toc { display: none; }
  .nav-toggle {
    display: block;
    position: sticky;
    top: var(--manual-top);
    z-index: 20;
    background: var(--manual-top-bg);
    border-bottom: 1px solid var(--line);
  }
  .nav-toggle summary {
    padding: 10px 16px;
    cursor: pointer;
    font-weight: 700;
  }
  .nav-toggle[open] summary { border-bottom: 1px solid var(--line); }
  .nav-toggle .toc { display: block; border-bottom: none; }
  main { padding: 18px 14px 48px; }
  .hero { padding: 22px 18px; border-radius: var(--r-card); }
  .cards { grid-template-columns: 1fr; }
  /* 目录条与顶栏叠着吸顶。条高 = summary 上 10px + 下 10px
     + 正文 16px × 行高 1.75 + 这条的底边 1px。 */
  article h2[id],
  article h3[id],
  article h4[id],
  article h5[id],
  article h6[id] {
    scroll-margin-top: calc(var(--manual-top) + 10px + var(--manual-fs) * var(--manual-lh) + 10px + 1px);
  }
}

@media (max-width: 520px) {
  .topbar { padding: 0 12px 0 16px; }
  .gh { padding: 8px; }
  .gh span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}
