/* ============================================================
   AniLive 知识库 · 文章页  —  工业机能风（与主页/404 统一）
   默认深色；[data-theme="light"] 切换浅色
   ============================================================ */

:root {
  --bg: #0f1114;
  --bg-elev: #16191e;
  --bg-sub: #1b1f25;
  --fg: #eceded;
  --fg-dim: #a7adb4;
  --fg-faint: #6d747c;
  --bd: rgba(236, 237, 237, .13);
  --bd-strong: rgba(236, 237, 237, .26);

  --accent: #f7a600;
  --accent-text: #ffbe3d;
  --accent-on: #171100;
  --accent-soft: rgba(247, 166, 0, .12);
  --accent-bd: rgba(247, 166, 0, .34);

  --code-bg: #14171c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 28px rgba(0, 0, 0, .4);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .65);

  --radius: 4px;
  --wrap: 1180px;
  --sidebar-w: 262px;
  --ease: cubic-bezier(.22, .61, .36, 1);

  --sans: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans SC",
          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --display: "Bahnschrift", "DIN Alternate", "Franklin Gothic Medium",
             "Arial Narrow", "Segoe UI", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
}

[data-theme="light"] {
  --bg: #f2f1ee;
  --bg-elev: #ffffff;
  --bg-sub: #e9e8e3;
  --fg: #16181b;
  --fg-dim: #4d5258;
  --fg-faint: #82888f;
  --bd: rgba(22, 24, 27, .14);
  --bd-strong: rgba(22, 24, 27, .28);

  --accent: #d98a00;
  --accent-text: #b57200;
  --accent-on: #171100;
  --accent-soft: rgba(217, 138, 0, .1);
  --accent-bd: rgba(217, 138, 0, .32);

  --code-bg: #eceae4;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 26px rgba(16, 24, 40, .07);
  --shadow-lg: 0 22px 54px rgba(16, 24, 40, .2);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; scroll-padding-top: 92px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background .3s var(--ease), color .3s var(--ease);
}
body.is-locked { overflow: hidden; }

::selection { background: var(--accent); color: var(--accent-on); }

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
p { margin: 0 0 16px; }
ul, ol { margin: 0 0 18px; padding-left: 22px; }
strong { font-weight: 650; }
code {
  font-family: var(--mono);
  font-size: .875em;
  padding: 2px 6px;
  border-radius: 2px;
  background: var(--code-bg);
  border: 1px solid var(--bd);
  color: var(--fg);
  word-break: break-word;
}

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: 26px; }

/* ---------- 阅读进度 ---------- */
.progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  z-index: 40;
}
.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-text));
  transition: width .12s linear;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  border-bottom: 1px solid transparent;
  transition: border-color .3s var(--ease);
}
.topbar.is-stuck { border-bottom-color: var(--bd); }
@supports not (background: color-mix(in srgb, red, blue)) {
  .topbar { background: var(--bg); }
}
.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  height: 62px;
}
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--fg); }
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 11px; height: 11px;
  border: 1.6px solid var(--accent);
  transform: rotate(45deg);
  flex: none;
}
.brand__text {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .04em;
}

.topnav { display: flex; align-items: center; gap: 4px; }
.topnav a {
  padding: 7px 12px;
  font-size: 13px;
  color: var(--fg-dim);
  transition: color .2s, background .2s;
}
.topnav a:hover { color: var(--fg); background: var(--bg-sub); text-decoration: none; }
.icon-btn {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  padding: 0;
  border: 1px solid var(--bd);
  border-radius: 0;
  background: var(--bg-elev);
  color: var(--fg-dim);
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}
.icon-btn:hover { color: var(--accent-text); border-color: var(--accent-bd); }
#toc-toggle { display: none; }
/* 默认深色 → 显示"切到浅色"的太阳 */
.ico-moon { display: none; }
.ico-sun { display: block; }
[data-theme="light"] .ico-sun { display: none; }
[data-theme="light"] .ico-moon { display: block; }

/* ---------- 布局 ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 52px;
  align-items: start;
  padding-top: 34px;
  padding-bottom: 60px;
}

/* ---------- 侧栏 ---------- */
.sidebar { position: sticky; top: 84px; }
.sidebar__scroll {
  max-height: calc(100vh - 108px);
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
}
.sidebar__scroll::-webkit-scrollbar { width: 6px; }
.sidebar__scroll::-webkit-scrollbar-thumb { background: var(--bd-strong); }

.panel + .panel { margin-top: 28px; }
.panel__title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.panel__title::before {
  content: "";
  width: 6px; height: 6px;
  background: var(--accent);
  transform: rotate(45deg);
  flex: none;
}
.toc { display: flex; flex-direction: column; }
.toc a {
  display: block;
  padding: 5px 10px 5px 14px;
  border-left: 1.5px solid var(--bd);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--fg-dim);
  transition: color .2s, border-color .2s, background .2s;
}
.toc a:hover { color: var(--fg); background: var(--bg-sub); text-decoration: none; }
.toc a.is-active {
  color: var(--accent-text);
  border-left-color: var(--accent);
  font-weight: 600;
  background: var(--accent-soft);
}
.toc--l3 a { padding-left: 24px; font-size: 13px; }
.toc--l4 a { padding-left: 34px; font-size: 12.5px; color: var(--fg-faint); }
.toc--l5 a { padding-left: 44px; font-size: 12.5px; color: var(--fg-faint); }
.toc--compact a { border-left-color: transparent; padding-left: 4px; }
.toc--compact a:hover { border-left-color: var(--accent-bd); }

/* ---------- 文章 ---------- */
.doc-header {
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--bd);
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--accent-text);
}
.eyebrow::before {
  content: "";
  width: 6px; height: 6px;
  background: var(--accent);
  transform: rotate(45deg);
}
.doc-header h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(27px, 4vw, 40px);
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.2;
}
.doc-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 11px;
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--fg-faint);
}
.doc-meta .dot { width: 3px; height: 3px; background: var(--bd-strong); transform: rotate(45deg); }

.doc-content {
  counter-reset: step;
  font-size: 15.5px;
  color: var(--fg-dim);
}
.doc-content > *:first-child { margin-top: 0; }

.doc-content h2,
.doc-content h3,
.doc-content h4,
.doc-content h5 {
  counter-reset: step;
  color: var(--fg);
  scroll-margin-top: 92px;
}
/* 一级：橙色粗条 + 顶部分割线 */
.doc-content h2 {
  position: relative;
  margin: 56px 0 18px;
  padding: 22px 0 14px 17px;
  border-top: 1px solid var(--bd);
  font-family: var(--display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.32;
}
.doc-content h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 25px;
  bottom: 17px;
  width: 4px;
  background: var(--accent);
}
/* 二级：空心菱形标记 */
.doc-content h3 {
  position: relative;
  margin: 40px 0 14px;
  padding-left: 17px;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.45;
}
.doc-content h3::before {
  content: "";
  position: absolute;
  left: 0;
  top: .5em;
  width: 7px; height: 7px;
  border: 1.4px solid var(--accent);
  transform: rotate(45deg) translateY(-50%);
}
/* 三级 */
.doc-content h4 {
  margin: 32px 0 13px;
  font-size: 16.5px;
  font-weight: 650;
}
/* 四级：终端标签样式 */
.doc-content h5 {
  margin: 26px 0 12px;
  padding-left: 12px;
  border-left: 2px solid var(--accent);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--fg);
}

.doc-content blockquote {
  margin: 0 0 20px;
  padding: 13px 18px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--fg-dim);
}
.doc-content blockquote p:last-child { margin-bottom: 0; }

.doc-content hr {
  margin: 44px 0;
  border: 0;
  border-top: 1px solid var(--bd);
}

/* 连续编号：同一小节内跨 <ol> 累加 */
.doc-content ol { list-style: none; padding-left: 0; margin-bottom: 12px; }
.doc-content ol > li {
  counter-increment: step;
  position: relative;
  padding-left: 38px;
  margin-bottom: 9px;
}
.doc-content ol > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 4px;
  display: grid;
  place-items: center;
  width: 23px; height: 23px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-on);
  background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%);
}
.doc-content ul { padding-left: 20px; }
.doc-content ul li { margin-bottom: 6px; }
.doc-content ul li::marker { color: var(--accent); }

/* 代码块 */
.doc-content pre {
  position: relative;
  margin: 0 0 22px;
  padding: 15px 18px;
  padding-right: 64px;
  border: 1px solid var(--bd);
  border-left: 3px solid var(--accent);
  border-radius: 0;
  background: var(--code-bg);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.7;
}
.doc-content pre code {
  padding: 0;
  border: 0;
  background: none;
  font-size: 13px;
  white-space: pre;
  color: var(--fg);
}
.copy-btn {
  position: absolute;
  top: 9px; right: 9px;
  padding: 4px 10px;
  border: 1px solid var(--bd);
  border-radius: 0;
  background: var(--bg-elev);
  color: var(--fg-faint);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}
.copy-btn:hover { color: var(--accent-text); border-color: var(--accent-bd); }
.copy-btn.is-done { color: var(--accent-text); border-color: var(--accent-bd); background: var(--accent-soft); }

/* 图片 */
.doc-content figure.doc-image { margin: 0 0 22px; }
.doc-content figure.doc-image img {
  display: block;
  width: 100%;
  max-width: 480px;
  height: auto;
  border: 1px solid var(--bd);
  border-radius: 0;
  background: var(--bg-sub);
  cursor: zoom-in;
  transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s var(--ease);
}
.doc-content figure.doc-image img:hover {
  transform: translateY(-3px);
  border-color: var(--accent-bd);
  box-shadow: var(--shadow);
}
.doc-content figcaption {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--fg-faint);
  max-width: 480px;
}
/* 宽图（如错误截图）更宽一些 */
.doc-content figure.doc-image img[alt="错误：超出设备数量限制"],
.doc-content figure.doc-image img[alt="错误1002"] { max-width: 100%; }
.doc-content figure.doc-image img[alt="错误：超出设备数量限制"] + figcaption,
.doc-content figure.doc-image img[alt="错误1002"] + figcaption { max-width: 100%; }

/* ---------- 大图弹窗 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(8, 10, 12, .86);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: zoom-out;
  animation: lb-in .22s var(--ease);
}
.lightbox[hidden] { display: none; }
@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }

.lightbox__backdrop {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-out;
}
.lightbox__figure {
  position: relative;
  margin: 0;
  max-width: min(1400px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: lb-zoom .26s var(--ease);
}
@keyframes lb-zoom { from { transform: scale(.94); opacity: .4; } to { transform: none; opacity: 1; } }
.lightbox__figure img {
  max-width: 100%;
  max-height: calc(100vh - 130px);
  width: auto;
  height: auto;
  background: #fff;
  border: 1px solid var(--bd);
  box-shadow: var(--shadow-lg);
  cursor: zoom-out;
}
.lightbox__figure figcaption {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .06em;
  color: rgba(255, 255, 255, .75);
  text-align: center;
}
.lightbox__hint {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 14px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .16);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .1em;
  color: rgba(255, 255, 255, .72);
  pointer-events: none;
}

/* ---------- 回到顶部 ---------- */
.to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 25;
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  padding: 0;
  border: 1px solid var(--bd);
  border-radius: 0;
  background: var(--bg-elev);
  color: var(--fg-dim);
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity .25s var(--ease), transform .25s var(--ease),
              visibility .25s, color .2s, border-color .2s;
}
.to-top.is-visible { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { color: var(--accent-text); border-color: var(--accent-bd); }

/* ---------- 页脚 ---------- */
.site-footer {
  position: relative;
  border-top: 1px solid var(--bd);
  background: var(--bg-sub);
  padding: 28px 0 40px;
}
.footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.footer__note {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--fg-faint);
}
.footer__beian {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.footer__beian a {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .03em;
  color: var(--fg-faint);
}
.footer__beian a:hover { color: var(--accent-text); }
/* 底部警示条纹带 */
.site-footer::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 6px;
  background: repeating-linear-gradient(-45deg, var(--accent) 0 12px, var(--bg) 12px 24px);
}

/* ---------- 侧栏遮罩（移动端） ---------- */
.sidebar-mask {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(8, 10, 12, .5);
  backdrop-filter: blur(2px);
}
.sidebar-mask[hidden] { display: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding-top: 26px;
  }
  #toc-toggle { display: grid; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 36;
    width: min(84vw, 320px);
    padding: 22px 18px;
    background: var(--bg-elev);
    border-right: 1px solid var(--bd);
    transform: translateX(-102%);
    transition: transform .3s var(--ease);
    overflow-y: auto;
  }
  .sidebar.is-open { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar__scroll { max-height: none; overflow: visible; }
  .toc--l5 a { padding-left: 34px; }
}

@media (max-width: 560px) {
  .wrap { padding-inline: 18px; }
  .doc-header h1 { font-size: 25px; }
  .doc-content h2 { font-size: 21px; margin-top: 42px; }
  .doc-content h3 { font-size: 17px; }
  .doc-content figure.doc-image img,
  .doc-content figcaption { max-width: 100%; }
  .lightbox { padding: 14px; }
  .lightbox__hint { bottom: 14px; }
  .topnav a { padding: 7px 9px; }
  .footer__inner { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox, .lightbox__figure { animation: none; }
  * { transition-duration: .01ms !important; }
}

/* 打印 */
@media print {
  .topbar, .sidebar, .progress, .to-top, .site-footer, .lightbox, .copy-btn { display: none !important; }
  .layout { display: block; padding: 0; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .doc-content h2::before, .doc-content h3::before, .doc-content ol > li::before { display: none; }
  .doc-content h2, .doc-content h3, .doc-content ol > li { padding-left: 0; }
}
