/* 使用手册页 —— 沿用官网色板与字体 */
:root {
  --bg: #f5f7fb;
  --bg-soft: #eef2f9;
  --panel: #ffffff;
  --ink: #152033;
  --ink-soft: #4a5870;
  --mute: #7a8699;
  --line: rgba(21, 32, 51, 0.1);
  --blue: #2f6bff;
  --blue-deep: #1d4ed8;
  --max: 1120px;
  --pad: clamp(20px, 5vw, 48px);
  --display: 'Syne', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --serif: 'Instrument Serif', Georgia, serif;
  --toc-w: 240px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--blue-deep);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  display: block;
  max-width: 100%;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 99;
  padding: 10px 14px;
  background: var(--ink);
  color: #fff;
}

.skip:focus {
  left: 12px;
  top: 12px;
}

.top {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px var(--pad);
  overflow: visible;
  background: rgba(245, 247, 251, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.brand img {
  width: 30px;
  height: 30px;
  border-radius: 6px;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  align-items: center;
  margin-left: auto;
  font-size: 0.92rem;
}

.nav a {
  color: var(--ink-soft);
  text-decoration: none;
}

.nav a:hover,
.nav a[aria-current='page'] {
  color: var(--blue-deep);
  text-decoration: none;
}

.nav-src {
  color: var(--blue-deep) !important;
  font-weight: 700;
}

/* 语言切换入口（.nav 之外常驻，窄屏隐藏 .nav 时仍可见） */
.nav-lang {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-decoration: none;
}

.nav-lang:hover {
  border-color: var(--blue);
  color: var(--blue-deep);
  text-decoration: none;
}

.mobile-nav .nav-lang {
  justify-content: center;
  margin-top: 6px;
}

.mobile-menu {
  display: none;
}

.manual-shell {
  width: min(var(--max), 100%);
  margin: 0 auto;
  padding: 28px var(--pad) 72px;
  display: grid;
  grid-template-columns: var(--toc-w) minmax(0, 1fr);
  gap: clamp(24px, 4vw, 48px);
  align-items: start;
}

.toc {
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 96px);
  overflow: auto;
  padding: 16px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.toc h2 {
  margin: 0 0 12px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mute);
  font-weight: 700;
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.toc a {
  display: block;
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.35;
  text-decoration: none;
  padding: 4px 0;
}

.toc a:hover {
  color: var(--blue-deep);
}

.manual {
  min-width: 0;
}

.manual-hero {
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.manual-hero .eyebrow {
  margin: 0 0 8px;
  color: var(--mute);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.manual-hero h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 400;
  letter-spacing: -0.02em;
}

.manual-hero .lede {
  margin: 12px 0 0;
  max-width: 40rem;
  color: var(--ink-soft);
  font-size: 1.02rem;
}

.manual section {
  margin: 0 0 40px;
  scroll-margin-top: 80px;
}

.manual h2 {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-size: clamp(1.55rem, 2.6vw, 1.9rem);
  font-weight: 400;
  letter-spacing: -0.02em;
}

.manual h3 {
  margin: 22px 0 10px;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.manual h4 {
  margin: 16px 0 8px;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.manual p,
.manual li {
  color: var(--ink-soft);
  font-size: 0.98rem;
}

.manual p {
  margin: 0 0 12px;
}

.manual ul,
.manual ol {
  margin: 0 0 14px;
  padding-left: 1.25rem;
}

.manual li {
  margin: 0 0 6px;
}

.manual li strong {
  color: var(--ink);
}

.manual table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 16px;
  font-size: 0.92rem;
  background: var(--panel);
  border: 1px solid var(--line);
}

.table-scroll {
  width: 100%;
  margin: 0 0 16px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  background: var(--panel);
}

.table-scroll:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.manual .table-scroll table {
  min-width: 560px;
  margin: 0;
  border: 0;
}

.manual th,
.manual td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

.manual th {
  background: var(--bg-soft);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.84rem;
}

.manual td {
  color: var(--ink-soft);
}

.manual tr:last-child th,
.manual tr:last-child td {
  border-bottom: none;
}

.manual code,
.manual kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  color: var(--blue-deep);
}

.manual code {
  overflow-wrap: anywhere;
}

.manual kbd {
  font-weight: 700;
  white-space: nowrap;
}

.tip {
  margin: 14px 0;
  padding: 12px 14px;
  background: #eef3ff;
  border-left: 3px solid var(--blue);
  color: var(--ink-soft);
  font-size: 0.94rem;
}

.foot {
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 28px var(--pad) 40px;
}

.foot-row {
  width: min(var(--max), 100%);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 13px;
  color: var(--mute);
}

.foot-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
}

.foot-brand img {
  width: 22px;
  height: 22px;
  border-radius: 5px;
}

.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.foot-links a {
  color: var(--mute);
  text-decoration: none;
}

.foot-links a:hover {
  color: var(--blue-deep);
}

@media (max-width: 1200px) {
  :root {
    --pad: clamp(16px, 4vw, 28px);
  }

  .top {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .top .nav {
    display: none;
  }

  /* 导航折叠后，语言入口补位推到右侧，紧邻汉堡菜单 */
  .nav-lang {
    margin-left: auto;
  }

  .mobile-menu {
    position: static;
    display: block;
    flex: 0 0 auto;
  }

  .mobile-menu summary {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
  }

  .mobile-menu summary::-webkit-details-marker {
    display: none;
  }

  .mobile-menu[open] summary {
    border-color: var(--blue);
    color: var(--blue-deep);
  }

  .mobile-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    width: auto;
    max-height: min(70vh, calc(100svh - 72px));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    display: grid;
    gap: 2px;
    padding: 10px var(--pad) 14px;
    margin: 0;
    background: rgba(255, 255, 255, 0.98);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 18px 40px rgba(21, 32, 51, 0.16);
    backdrop-filter: blur(14px);
  }

  .mobile-nav a {
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 0 14px;
    color: var(--ink-soft);
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 8px;
  }

  .mobile-nav a:hover,
  .mobile-nav a:focus-visible,
  .mobile-nav a[aria-current='page'] {
    color: var(--blue-deep);
    background: var(--bg-soft);
  }

  .manual-shell {
    grid-template-columns: 1fr;
    padding-top: 18px;
    gap: 22px;
  }

  .toc {
    position: relative;
    top: 0;
    max-height: none;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    padding: 12px;
  }

  .toc h2 {
    margin-bottom: 8px;
  }

  .toc ol {
    width: max-content;
    display: flex;
    gap: 8px;
  }

  .toc a {
    min-height: 40px;
    display: flex;
    align-items: center;
    padding: 0 11px;
    border: 1px solid var(--line);
    background: var(--bg-soft);
    white-space: nowrap;
  }

  .manual-hero {
    margin-bottom: 28px;
    padding-bottom: 22px;
  }

  .manual p,
  .manual li,
  .tip {
    overflow-wrap: anywhere;
  }

  .foot-row {
    align-items: flex-start;
  }
}

@media (max-width: 520px) {
  .brand span {
    font-size: 0.92rem;
  }

  .manual-shell {
    padding-bottom: 48px;
  }

  .manual section {
    margin-bottom: 32px;
  }

  .manual h2 {
    font-size: 1.55rem;
  }

  .manual p,
  .manual li {
    font-size: 0.95rem;
    line-height: 1.65;
  }

  .table-scroll .manual table,
  .manual .table-scroll table {
    min-width: 520px;
  }

  .foot-row,
  .foot-links {
    display: grid;
    justify-items: start;
  }

  .foot-links {
    gap: 12px;
  }
}

/* 阅读进度条 */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  width: 0;
  height: 3px;
  background: var(--blue);
  pointer-events: none;
}

/* 目录滚动高亮 */
.toc a.active {
  color: var(--blue-deep);
  font-weight: 700;
  background: var(--bg-soft);
}

/* 章节截图 */
.manual figure.shot {
  margin: 6px 0 18px;
  padding: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
}

.manual figure.shot img {
  display: block;
  width: 100%;
  height: auto;
}

.manual figure.shot figcaption {
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--mute);
}

.manual figure.shot figcaption strong {
  color: var(--ink-soft);
}

/* 图片编辑小图网格（2×2） */
.manual .shot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 6px 0 18px;
}

.manual .shot-grid .shot {
  margin: 0;
}

@media (max-width: 640px) {
  .manual .shot-grid {
    grid-template-columns: 1fr;
  }
}

/* 锚点跳转不被吸顶栏遮挡 */
.manual h3[id],
.manual h4[id] {
  scroll-margin-top: 80px;
}

/* 章节标题强调线 */
.manual section > h2 {
  position: relative;
  padding-top: 16px;
}

.manual section > h2::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 36px;
  height: 3px;
  border-radius: 2px;
  background: var(--blue);
}

/* 有序步骤条（LibTV 式数字圆点） */
.manual ol {
  list-style: none;
  counter-reset: step;
  padding-left: 0;
}

.manual ol > li {
  counter-increment: step;
  position: relative;
  padding-left: 34px;
}

.manual ol > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--blue-deep);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
}

/* 深色模式：跟随系统（由 JS 同步类）或手动选择 */
html.dark {
  --bg: #0e1420;
  --bg-soft: #1b2436;
  --panel: #131b2a;
  --ink: #e7ecf6;
  --ink-soft: #b7c2d8;
  --mute: #8291ab;
  --line: rgba(231, 236, 246, 0.12);
  --blue: #6f9bff;
  --blue-deep: #93b1ff;
  color-scheme: dark;
}

html.light {
  color-scheme: light;
}

html.dark .top {
  background: rgba(14, 20, 32, 0.92);
}

html.dark .skip {
  color: var(--panel);
}

html.dark .tip {
  background: rgba(111, 155, 255, 0.12);
}

html.dark .mobile-nav {
  background: rgba(19, 27, 42, 0.98);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

/* 主题切换按钮 */
.theme-toggle {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  flex: none;
}

.theme-toggle:hover {
  color: var(--blue-deep);
  border-color: var(--blue);
}

/* 新手路径入口卡片 */
.entry-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 12px;
  margin: 0 0 34px;
}

.entry-card {
  display: grid;
  gap: 5px;
  align-content: start;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.entry-card:hover {
  border-color: var(--blue);
  transform: translateY(-1px);
}

.entry-card strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.entry-card span {
  color: var(--mute);
  font-size: 0.84rem;
  line-height: 1.5;
}

@media (max-width: 860px) {
  .entry-cards {
    grid-template-columns: 1fr;
  }
}

/* 打印样式 */
@media print {
  :root,
  html.dark {
    --bg: #ffffff;
    --bg-soft: #f0f2f6;
    --panel: #ffffff;
    --ink: #111827;
    --ink-soft: #374151;
    --mute: #6b7280;
    --line: #d1d5db;
    --blue: #1d4ed8;
    --blue-deep: #1d4ed8;
  }

  .top,
  .toc,
  .progress,
  .skip,
  .foot,
  .mobile-menu,
  .entry-cards {
    display: none !important;
  }

  .manual-shell {
    display: block;
    max-width: none;
    padding: 0;
  }

  body {
    background: #ffffff;
  }

  .manual h2 {
    break-after: avoid;
  }

  .manual figure.shot,
  .manual .table-scroll,
  .tip {
    break-inside: avoid;
  }

  .manual a {
    color: inherit;
  }
}

/* 返回顶部按钮 */
.to-top {
  position: fixed;
  right: 22px;
  bottom: 26px;
  z-index: 55;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--ink-soft);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(21, 32, 51, 0.16);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.to-top:hover {
  color: var(--blue-deep);
  border-color: var(--blue);
}

/* 截图点击放大 */
.manual figure.shot img {
  cursor: zoom-in;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: rgba(6, 10, 18, 0.86);
  cursor: zoom-out;
}

.lightbox img {
  max-width: min(1400px, 94vw);
  max-height: 84vh;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.lightbox-cap {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.9rem;
}

/* 章节标题点击复制链接 */
.manual section[id] > h2,
.manual h3[id],
.manual h4[id] {
  cursor: pointer;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  z-index: 80;
  transform: translateX(-50%);
  padding: 9px 16px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--panel);
  font-size: 0.88rem;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

/* 打印：分章分页 */
@media print {
  .to-top,
  .lightbox,
  .toast {
    display: none !important;
  }

  .manual section {
    break-before: page;
  }

  .manual section:first-of-type {
    break-before: auto;
  }
}

.lightbox[hidden] {
  display: none;
}
