/* 千顾教程站（doc82 §三 H6）——设计令牌、系统字体栈、浅色默认 + 深色（系统偏好 / 手动切换）、960/1200 断点、打印。零 CDN。 */

:root {
  --bg: #fafafa;
  --bg-elev: #ffffff;
  --fg: #1f2328;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --code-bg: #f3f4f6;
  --callout-note: #2563eb;
  --callout-note-bg: #eff6ff;
  --callout-tip: #16a34a;
  --callout-tip-bg: #f0fdf4;
  --callout-warn: #d97706;
  --callout-warn-bg: #fffbeb;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .05);
  --radius: 12px;
  --topbar-h: 56px;
  --sidebar-w: 260px;
  --toc-w: 220px;
  --content-w: 760px;
  --font: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Microsoft YaHei", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216;
    --bg-elev: #171b21;
    --fg: #e6e8eb;
    --muted: #9aa3ad;
    --border: #2a3038;
    --accent: #60a5fa;
    --accent-soft: #1e3a5f;
    --code-bg: #20252c;
    --callout-note-bg: #14213a;
    --callout-tip-bg: #10291b;
    --callout-warn-bg: #33250a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216;
  --bg-elev: #171b21;
  --fg: #e6e8eb;
  --muted: #9aa3ad;
  --border: #2a3038;
  --accent: #60a5fa;
  --accent-soft: #1e3a5f;
  --code-bg: #20252c;
  --callout-note-bg: #14213a;
  --callout-tip-bg: #10291b;
  --callout-warn-bg: #33250a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

/* ── 基础 ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 16px); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  color: var(--fg);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; height: auto; }
h1, h2, h3 { line-height: 1.3; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; margin: .2em 0 .5em; }
h2 { font-size: 1.35rem; margin: 2em 0 .7em; }
h3 { font-size: 1.12rem; margin: 1.6em 0 .5em; }
code { font-family: var(--mono); font-size: .92em; background: var(--code-bg); padding: .12em .4em; border-radius: 6px; }
.muted { color: var(--muted); font-size: .92rem; }
.lead { font-size: 1.08rem; color: var(--muted); margin: 0 0 1em; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 1.15em; height: 1.15em; vertical-align: -.2em; fill: none; flex: none; }
.icon.big { width: 1.8em; height: 1.8em; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--fg); cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--code-bg); border-color: var(--border); }
.icon-btn .icon { width: 1.3em; height: 1.3em; }

/* ── 顶栏 ── */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1400px; margin: 0 auto; height: 100%; padding: 0 20px;
  display: flex; align-items: center; gap: 14px;
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--fg); font-size: 1.05rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand .icon { width: 1.4em; height: 1.4em; color: var(--accent); }
.products { display: flex; gap: 4px; margin-left: 6px; overflow-x: auto; scrollbar-width: none; }
.products::-webkit-scrollbar { display: none; }
.products a { padding: 6px 12px; border-radius: 999px; color: var(--muted); white-space: nowrap; font-size: .95rem; }
.products a:hover { color: var(--fg); background: var(--code-bg); text-decoration: none; }
.products a.current { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.search { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar .search { position: relative; }
.topbar .search .icon { position: absolute; left: 10px; color: var(--muted); }
.topbar .search input {
  width: 220px; height: 36px; padding: 0 12px 0 34px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--fg); font: inherit; font-size: .93rem; transition: width .2s;
}
.topbar .search input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); width: 300px; }
.theme-btn .icon-moon { display: none; }
:root[data-theme="dark"] .theme-btn .icon-sun { display: none; }
:root[data-theme="dark"] .theme-btn .icon-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-btn .icon-moon { display: inline; }
}

/* ── 主体版式 ── */
main.page { flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; padding: 28px 20px 60px; }
main.with-sidebar { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); gap: 40px; align-items: start; }
main.with-toc { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.content { min-width: 0; max-width: var(--content-w); }
.sidebar { position: sticky; top: calc(var(--topbar-h) + 20px); max-height: calc(100vh - var(--topbar-h) - 40px); overflow-y: auto; padding-right: 8px; }
.toc { display: none; }
@media (min-width: 1200px) {
  main.with-toc { grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w); }
  .toc { display: block; position: sticky; top: calc(var(--topbar-h) + 20px); max-height: calc(100vh - var(--topbar-h) - 40px); overflow-y: auto; }
}

/* ── 面包屑 / meta ── */
.breadcrumb { display: flex; flex-wrap: wrap; gap: 8px; font-size: .88rem; color: var(--muted); margin-bottom: 14px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.meta { font-size: .88rem; color: var(--muted); margin: -0.4em 0 1.6em; }

/* ── 侧栏树 ── */
.sidebar-tree { font-size: .93rem; }
.tree-product { display: block; font-weight: 700; color: var(--fg); padding: 6px 10px; margin-bottom: 6px; }
.tree-section { border-top: 1px solid var(--border); }
.tree-section summary {
  list-style: none; display: flex; align-items: center; gap: 8px; padding: 9px 10px; cursor: pointer; color: var(--fg); font-weight: 600; border-radius: 8px;
}
.tree-section summary::-webkit-details-marker { display: none; }
.tree-section summary:hover { background: var(--code-bg); }
.tree-section summary a { color: inherit; flex: 1; }
.tree-section summary .chevron { color: var(--muted); transition: transform .2s; }
.tree-section[open] summary .chevron { transform: rotate(90deg); }
.tree-section ul { list-style: none; margin: 0 0 8px; padding: 0 0 0 14px; }
.tree-section li a { display: block; padding: 5px 10px; border-left: 2px solid var(--border); color: var(--muted); border-radius: 0 6px 6px 0; }
.tree-section li a:hover { color: var(--fg); text-decoration: none; background: var(--code-bg); }
.tree-section li a[aria-current="page"] { color: var(--accent); border-left-color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* ── 抽屉（<960） ── */
.drawer-btn { display: none; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 39; }
@media (max-width: 959.98px) {
  main.with-sidebar, main.with-toc { display: block; }
  .drawer-btn { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(84vw, 320px); z-index: 40; max-height: none;
    background: var(--bg-elev); border-right: 1px solid var(--border); padding: 16px; box-shadow: var(--shadow);
    transform: translateX(-105%); transition: transform .22s ease;
  }
  .sidebar.open { transform: none; }
  body.drawer-open { overflow: hidden; }
  .products { display: none; }
  .topbar .search input { width: 150px; }
  .topbar .search input:focus { width: 180px; }
}
@media (max-width: 599.98px) {
  .brand span { display: none; }
  .topbar .search input { width: 120px; }
  main.page { padding: 20px 14px 48px; }
  h1 { font-size: 1.55rem; }
}

/* ── 目录 ── */
.toc-inner { border-left: 1px solid var(--border); padding-left: 14px; font-size: .88rem; }
.toc-title { margin: 0 0 8px; font-weight: 600; color: var(--muted); font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
.toc li.lvl3 { padding-left: 14px; }
.toc a { display: block; padding: 4px 0; color: var(--muted); border-left: 2px solid transparent; margin-left: -15px; padding-left: 13px; }
.toc a:hover { color: var(--fg); text-decoration: none; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }

/* ── 文章正文 ── */
.article .body { font-size: 1.02rem; }
.article .body > *:first-child { margin-top: 0; }
.rich p { margin: 0 0 1em; }
.rich ul, .rich ol { padding-left: 1.4em; margin: 0 0 1em; }
.rich li { margin: .25em 0; }
.figure { margin: 1.6em 0; }
.figure img, .figure video { display: block; width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-elev); }
.figure figcaption { text-align: center; color: var(--muted); font-size: .88rem; margin-top: .6em; }
.callout { border-left: 4px solid var(--callout-note); background: var(--callout-note-bg); border-radius: 0 var(--radius) var(--radius) 0; padding: 14px 18px; margin: 1.5em 0; }
.callout .rich > :last-child { margin-bottom: 0; }
.callout-title { margin: 0 0 .4em; font-weight: 700; }
.callout-tip { border-left-color: var(--callout-tip); background: var(--callout-tip-bg); }
.callout-warn { border-left-color: var(--callout-warn); background: var(--callout-warn-bg); }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 1.5em 0; }
.steps li { position: relative; padding: 0 0 1.2em 44px; }
.steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: .1em; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700; font-size: .9rem; display: flex; align-items: center; justify-content: center;
}
.steps li:not(:last-child)::after { content: ""; position: absolute; left: 13px; top: 32px; bottom: 4px; width: 2px; background: var(--border); }
.steps .rich > :last-child { margin-bottom: 0; }
.link-card {
  display: flex; align-items: center; gap: 14px; margin: 1.2em 0; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); color: var(--fg); box-shadow: var(--shadow);
}
.link-card:hover { text-decoration: none; border-color: var(--accent); }
.link-card .icon { color: var(--accent); }
.link-card span { display: flex; flex-direction: column; min-width: 0; }
.link-card small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-wrap { overflow-x: auto; margin: 1.5em 0; border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--code-bg); font-weight: 600; }
tr:last-child td { border-bottom: 0; }

.prev-next { display: flex; justify-content: space-between; gap: 16px; margin-top: 3em; padding-top: 1.5em; border-top: 1px solid var(--border); }
.prev-next a { display: flex; flex-direction: column; max-width: 48%; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--fg); font-weight: 600; }
.prev-next a:hover { border-color: var(--accent); text-decoration: none; color: var(--accent); }
.prev-next small { color: var(--muted); font-weight: 400; font-size: .8rem; }
.prev-next .next { text-align: right; margin-left: auto; }

/* ── 卡片 / 列表 ── */
.cards { display: grid; gap: 18px; margin: 1.5em 0 2.5em; }
.products-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.sections-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card {
  display: flex; flex-direction: column; gap: 6px; padding: 20px; color: var(--fg);
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.card h2 { margin: 0; font-size: 1.1rem; }
.card p { margin: 0; color: var(--muted); font-size: .93rem; }
.card .link { color: var(--accent); font-size: .9rem; margin-top: auto; }
.card-icon { display: inline-flex; width: 42px; height: 42px; align-items: center; justify-content: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.card-icon .icon { width: 1.5em; height: 1.5em; }
.product-card { padding: 0; overflow: hidden; }
.product-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.product-card .card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 6px; }
.hero-home { text-align: center; padding: 30px 0 10px; }
.hero-home h1 { font-size: 2.2rem; }
.hero-home .lead { max-width: 640px; margin: 0 auto; }
.hero-product { display: grid; gap: 24px; align-items: center; margin-bottom: 1em; }
@media (min-width: 960px) { .hero-product:has(.hero-img) { grid-template-columns: 1.2fr 1fr; } }
.hero-img { border-radius: var(--radius); border: 1px solid var(--border); }
.standard-links { display: flex; gap: 18px; justify-content: center; color: var(--muted); }
.section-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 1em; }
.section-head h1 { margin-top: 0; }
.article-list { list-style: none; padding: 0; margin: 0; }
.article-list li { display: flex; gap: 16px; align-items: baseline; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border); }
.article-list li a { display: flex; flex-direction: column; gap: 2px; color: var(--fg); min-width: 0; }
.article-list li a span { color: var(--muted); font-size: .92rem; }
.article-list li a:hover strong { color: var(--accent); }
.article-list time, .article-list .muted { white-space: nowrap; color: var(--muted); font-size: .85rem; }
.article-list.compact li { padding: 8px 0; }
.recent h2 { margin-top: 1em; }
.search-big { gap: 10px; margin: 0 0 1.5em; max-width: 560px; }
.search-big input { flex: 1; height: 42px; padding: 0 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-elev); color: var(--fg); font: inherit; }
.search-big button { height: 42px; padding: 0 18px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }

/* ── 页脚 ── */
.footer { border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; background: var(--bg-elev); }
.footer-inner { max-width: 1400px; margin: 0 auto; padding: 18px 20px; display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; }
.footer a { color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.footer a:hover { color: var(--accent); }

/* ── 打印 ── */
@media print {
  .topbar, .footer, .sidebar, .toc, .prev-next, .drawer-backdrop, .breadcrumb { display: none !important; }
  main.page, main.with-sidebar, main.with-toc { display: block; padding: 0; max-width: none; }
  .content { max-width: none; }
  body { background: #fff; color: #000; font-size: 12pt; }
  a { color: inherit; text-decoration: underline; }
  .figure img { border: 0; }
  .callout, .link-card, .card { box-shadow: none; }
}
