/* ==========================================================================
   站点样式：reset、排版、布局与组件。
   令牌全部来自 tokens.css，本文件不写死颜色与间距值。

   两点约定：
   1. 移动优先——基础样式是 ≤767px 的单列，向上用 min-width 媒体查询加列。
   2. 渐进增强反写——导航默认是可见的普通列表；只有 JS 加上了
      html[data-nav-ready] 之后，移动端才允许把它折叠起来。
      这样关闭 JS 时不会有任何内容够不到。
   ========================================================================== */

/* --- reset ---------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-fg);
  font-family: var(--ff-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
}

h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
}

img,
svg {
  max-width: 100%;
  height: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
}

/* --- 基础排版 ------------------------------------------------------------- */

h1,
h2,
h3,
h4 {
  line-height: var(--lh-tight);
  font-weight: 600;
}

h2 {
  font-size: var(--fs-2xl);
}

h3 {
  font-size: var(--fs-xl);
}

h4 {
  font-size: var(--fs-lg);
}

a {
  color: var(--c-brand);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-thickness: 2px;
}

code {
  font-family: var(--ff-mono);
  font-size: 0.92em;
  background: var(--c-bg-sunken);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.35em;
}

/* --- 可访问性 ------------------------------------------------------------- */

:focus-visible {
  outline: 2px solid var(--c-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* 跳转链接：键盘用户的第一个可聚焦元素 */
.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: calc(-1 * var(--sp-9));
  z-index: 20;
  background: var(--c-brand);
  color: var(--c-brand-fg);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  text-decoration: none;
  box-shadow: var(--shadow-2);
  transition: top var(--dur-fast) var(--ease);
}

.skip-link:focus {
  top: var(--sp-4);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- 布局骨架 ------------------------------------------------------------- */

.wrap {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--sp-5);
}

main {
  display: block;
}

/* 锚点跳转时给 sticky 顶栏留出空间 */
:target,
section[id],
[id^="ch-"] {
  scroll-margin-top: var(--sp-8);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-height: 64px;
  padding-block: var(--sp-3);
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  font-size: var(--fs-lg);
  margin-inline-end: auto;
}

.brand__mark {
  width: 28px;
  height: 28px;
  flex: none;
}

.brand__sub {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 400;
  color: var(--c-fg-muted);
  line-height: 1.3;
}

/* 导航：默认（无 JS）就是一列可见链接 */
.site-nav__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-5);
  list-style: none;
}

.site-nav__list a {
  display: inline-block;
  padding: var(--sp-2) 0;
  color: var(--c-fg);
  text-decoration: none;
  font-size: var(--fs-sm);
}

.site-nav__list a:hover,
.site-nav__list a[aria-current="page"] {
  color: var(--c-brand);
  text-decoration: underline;
}

.nav-toggle {
  display: none;
  align-items: center;
  gap: var(--sp-2);
  background: var(--c-bg-elev);
  color: var(--c-fg);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-md);
  padding: var(--sp-2) var(--sp-3);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
}

.nav-toggle__bars {
  display: block;
  width: 16px;
  height: 10px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  position: relative;
}

.nav-toggle__bars::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 4px;
  border-top: 2px solid currentColor;
}

@media (max-width: 767px) {
  /* 只有在 JS 就绪后才折叠——否则导航必须可见 */
  html[data-nav-ready] .nav-toggle {
    display: inline-flex;
  }

  html[data-nav-ready] .site-nav__list {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    border-top: 1px solid var(--c-border);
    margin-top: var(--sp-2);
    padding-top: var(--sp-2);
  }

  html[data-nav-ready] .site-nav.is-open .site-nav__list {
    display: flex;
  }

  html[data-nav-ready] .site-nav__list a {
    padding: var(--sp-3) 0;
    border-bottom: 1px solid var(--c-border);
    font-size: var(--fs-base);
  }
}

/* --- 页脚 ----------------------------------------------------------------- */

.site-footer {
  margin-top: var(--sp-9);
  padding-block: var(--sp-7);
  background: var(--c-bg-sunken);
  border-top: 1px solid var(--c-border);
  color: var(--c-fg-muted);
  font-size: var(--fs-sm);
}

.site-footer__grid {
  display: grid;
  gap: var(--sp-6);
}

@media (min-width: 768px) {
  .site-footer__grid {
    grid-template-columns: 2fr 1fr;
  }
}

.site-footer h2 {
  font-size: var(--fs-sm);
  color: var(--c-fg);
  margin-bottom: var(--sp-3);
}

.site-footer ul {
  list-style: none;
  display: grid;
  gap: var(--sp-2);
}

.site-footer a {
  color: var(--c-fg-muted);
}

/* --- 联系作者 ------------------------------------------------------------ */

.contact {
  display: grid;
  gap: var(--sp-5);
  justify-items: center;
  text-align: center;
}

.contact__qr {
  width: min(100%, 320px);
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border);
  background: var(--c-bg-elev);
  box-shadow: var(--shadow-1);
}

.contact__name {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--c-fg);
}

.contact__role {
  font-size: var(--fs-sm);
  color: var(--c-fg-muted);
  margin-top: var(--sp-1);
}

.contact__note {
  font-size: var(--fs-sm);
  color: var(--c-fg-muted);
  max-width: 32em;
}

/* --- Hero ----------------------------------------------------------------- */

.hero {
  padding-block: var(--sp-8) var(--sp-7);
  background: var(--c-bg-elev);
  border-bottom: 1px solid var(--c-border);
}

.hero__eyebrow {
  display: inline-block;
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  color: var(--c-brand);
  background: var(--c-brand-soft);
  border-radius: var(--radius-pill);
  padding: var(--sp-1) var(--sp-3);
  margin-bottom: var(--sp-4);
}

.hero h1 {
  font-size: var(--fs-3xl);
  max-width: 20ch;
}

.hero__lead {
  margin-top: var(--sp-5);
  max-width: 62ch;
  font-size: var(--fs-lg);
  line-height: var(--lh-loose);
  color: var(--c-fg-muted);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
}

.hero__note {
  margin-top: var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--c-fg-subtle);
}

/* --- 按钮 ----------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: var(--fs-sm);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}

.btn--primary {
  background: var(--c-brand);
  color: var(--c-brand-fg);
}

.btn--primary:hover {
  background: var(--c-brand);
  filter: brightness(1.08);
}

.btn--ghost {
  background: transparent;
  color: var(--c-fg);
  border-color: var(--c-border-strong);
}

.btn--ghost:hover {
  background: var(--c-bg-sunken);
}

/* --- 通用区块 ------------------------------------------------------------- */

.section {
  padding-block: var(--sp-8);
  border-bottom: 1px solid var(--c-border);
}

.section:last-of-type {
  border-bottom: 0;
}

.section__head {
  max-width: 68ch;
  margin-bottom: var(--sp-6);
}

.section__head p {
  margin-top: var(--sp-4);
  color: var(--c-fg-muted);
}

/* --- 卡片 ----------------------------------------------------------------- */

.cards {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: 1fr;
  list-style: none;
}

@media (min-width: 768px) {
  .cards--2,
  .cards--3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .cards--3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.card {
  background: var(--c-bg-elev);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-1);
}

.card h3,
.card h4 {
  font-size: var(--fs-lg);
  margin-bottom: var(--sp-3);
}

.card p {
  color: var(--c-fg-muted);
  font-size: var(--fs-sm);
}

.card ul {
  margin-top: var(--sp-3);
  padding-left: var(--sp-5);
  color: var(--c-fg-muted);
  font-size: var(--fs-sm);
  display: grid;
  gap: var(--sp-2);
}

.card--problem {
  border-left: 3px solid var(--c-warn);
}

/* --- 徽章（颜色之外必须带中文状态词，色盲安全） --------------------------- */

.badge {
  display: inline-block;
  border-radius: var(--radius-pill);
  padding: 2px var(--sp-3);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
}

.badge--ok {
  background: var(--c-ok-soft);
  color: var(--c-ok);
}

.badge--warn {
  background: var(--c-warn-soft);
  color: var(--c-warn);
}

.badge--danger {
  background: var(--c-danger-soft);
  color: var(--c-danger);
}

.badge--info {
  background: var(--c-info-soft);
  color: var(--c-info);
}

.badge--muted {
  background: var(--c-bg-sunken);
  color: var(--c-fg-muted);
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  list-style: none;
}

/* --- 业务闭环步骤 --------------------------------------------------------- */

.steps {
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: var(--sp-3);
}

.steps li {
  counter-increment: step;
  position: relative;
  padding: var(--sp-4) var(--sp-5) var(--sp-4) var(--sp-8);
  background: var(--c-bg-elev);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: var(--sp-4);
  top: var(--sp-4);
  width: 24px;
  height: 24px;
  border-radius: var(--radius-pill);
  background: var(--c-brand);
  color: var(--c-brand-fg);
  font-size: var(--fs-xs);
  font-weight: 600;
  display: grid;
  place-items: center;
}

.steps strong {
  display: block;
}

.steps span {
  color: var(--c-fg-muted);
  font-size: var(--fs-sm);
}

/* --- 表格 ----------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
}

.table-wrap table {
  min-width: 520px;
  font-size: var(--fs-sm);
}

.table-wrap th,
.table-wrap td {
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--c-border);
  vertical-align: top;
}

.table-wrap thead th {
  background: var(--c-bg-sunken);
  font-weight: 600;
  white-space: nowrap;
}

.table-wrap tbody tr:last-child th,
.table-wrap tbody tr:last-child td {
  border-bottom: 0;
}

.table-wrap tbody th {
  font-weight: 600;
  white-space: nowrap;
}

/* 首列窄、其余自适应的角色表 */
.table--roles td:first-child {
  white-space: nowrap;
}

/* --- 截图占位框 ----------------------------------------------------------- */

.shots {
  display: grid;
  gap: var(--sp-5);
}

@media (min-width: 768px) {
  .shots {
    grid-template-columns: repeat(2, 1fr);
  }
}

.shot {
  margin: 0;
}

/* 真图就位后：把 .shot-ph 换成 <img>，样式随之失效 */
.shot-ph {
  aspect-ratio: 16 / 10; /* 1440×900 */
  display: grid;
  place-content: center;
  gap: var(--sp-2);
  text-align: center;
  background: var(--c-bg-sunken);
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
}

.shot-ph__key {
  font-family: var(--ff-mono);
  font-size: var(--fs-sm);
  color: var(--c-fg-muted);
}

.shot-ph__hint {
  font-size: var(--fs-xs);
  color: var(--c-fg-subtle);
}

.shot img {
  display: block;
  width: 100%;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  /* 截图是浅色主题采集，暗色下垫一层浅底避免晃眼 */
  background: #ffffff;
}

.shot figcaption {
  margin-top: var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--c-fg-muted);
}

/* --- 常见问题（原生 details，不依赖 JS） --------------------------------- */

.faq {
  display: grid;
  gap: var(--sp-3);
}

.faq details {
  background: var(--c-bg-elev);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: var(--sp-4) var(--sp-5);
}

.faq summary {
  cursor: pointer;
  font-weight: 600;
}

.faq summary::marker {
  color: var(--c-brand);
}

.faq details[open] summary {
  margin-bottom: var(--sp-3);
}

.faq p {
  color: var(--c-fg-muted);
  font-size: var(--fs-sm);
}

/* --- 提示块 --------------------------------------------------------------- */

.callout {
  border-left: 3px solid var(--c-info);
  background: var(--c-info-soft);
  border-radius: var(--radius-md);
  padding: var(--sp-4) var(--sp-5);
  font-size: var(--fs-sm);
}

.callout--warn {
  border-left-color: var(--c-warn);
  background: var(--c-warn-soft);
}

.callout strong {
  color: var(--c-fg);
}

/* --- 帮助页：目录 + 正文 -------------------------------------------------- */

.help-intro {
  background: var(--c-bg-sunken);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: var(--sp-4) var(--sp-5);
  font-size: var(--fs-sm);
  color: var(--c-fg-muted);
  margin-bottom: var(--sp-6);
}

.help-layout {
  display: grid;
  gap: var(--sp-7);
  align-items: start;
}

@media (min-width: 1024px) {
  .help-layout {
    grid-template-columns: 260px 1fr;
  }
}

.toc {
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  background: var(--c-bg-elev);
  padding: var(--sp-4) var(--sp-5);
}

@media (min-width: 1024px) {
  .toc {
    position: sticky;
    top: var(--sp-7);
    max-height: calc(100vh - var(--sp-8));
    overflow-y: auto;
  }
}

.toc > summary {
  font-weight: 600;
  cursor: pointer;
}

.toc__list {
  list-style: none;
  display: grid;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  font-size: var(--fs-sm);
}

.toc__list a {
  display: block;
  color: var(--c-fg-muted);
  text-decoration: none;
  padding: 2px 0;
}

.toc__list a:hover {
  color: var(--c-brand);
  text-decoration: underline;
}

.toc__list a[aria-current="true"] {
  color: var(--c-brand);
  font-weight: 600;
}

.toc__sub {
  list-style: none;
  display: grid;
  gap: var(--sp-1);
  margin: var(--sp-2) 0 var(--sp-2) var(--sp-4);
  padding-left: var(--sp-3);
  border-left: 1px solid var(--c-border);
  font-size: var(--fs-xs);
}

/* --- 帮助页正文 ----------------------------------------------------------- */

.prose {
  max-width: 72ch;
}

.prose section {
  padding-bottom: var(--sp-7);
  margin-bottom: var(--sp-7);
  border-bottom: 1px solid var(--c-border);
}

.prose section:last-of-type {
  border-bottom: 0;
  margin-bottom: 0;
}

.prose h2 {
  margin-bottom: var(--sp-5);
}

.prose h3 {
  font-size: var(--fs-lg);
  margin-top: var(--sp-6);
  margin-bottom: var(--sp-3);
}

.prose p {
  margin-bottom: var(--sp-4);
}

.prose section > p:first-of-type {
  color: var(--c-fg-muted);
}

.prose ol,
.prose ul {
  margin-bottom: var(--sp-4);
  padding-left: var(--sp-5);
  display: grid;
  gap: var(--sp-2);
}

.prose li > ul,
.prose li > ol {
  margin-top: var(--sp-2);
}

.prose table {
  font-size: var(--fs-sm);
}

.prose .shots {
  margin-top: var(--sp-5);
}

.prose .faq {
  margin-top: var(--sp-4);
}

.prose .callout {
  margin: var(--sp-5) 0;
}

.prose .table-wrap {
  margin-bottom: var(--sp-5);
}

/* --- 打印（帮助页会被打印或另存 PDF） ------------------------------------ */

@media print {
  .site-header,
  .site-nav,
  .nav-toggle,
  .toc,
  .skip-link,
  .site-footer,
  .hero__actions {
    display: none !important;
  }

  body {
    background: #ffffff;
    color: #000000;
    font-size: 11pt;
  }

  a {
    color: #000000;
    text-decoration: none;
  }

  /* 打印时把链接目标写在后面，纸面上仍可追溯 */
  .prose a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
  }

  .help-layout {
    display: block;
  }

  .prose {
    max-width: none;
  }

  .prose section {
    border-bottom: 0;
    padding-bottom: var(--sp-5);
    margin-bottom: var(--sp-5);
    break-inside: avoid;
  }

  .card,
  .steps li,
  .faq details,
  .shot-ph {
    border-color: #999999;
    break-inside: avoid;
  }

  .faq details {
    /* 打印时展开所有问答，纸面上不能折叠 */
    display: block;
  }

  .faq details > summary {
    list-style: none;
  }
}

/* --- 降低动效 ------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}