/* ==========================================================================
   机械设计手册 · 在线阅读
   ========================================================================== */

:root {
  --sidebar-w: 318px;
  --reader-size: 17px;

  --bg: #f2f1ec;
  --bg-deep: #e9e7e0;
  --panel: #fbfaf7;
  --paper: #fffefb;
  --ink: #1d2229;
  --ink-2: #363c45;
  --muted: #767d87;
  --faint: #a2a8b0;
  --line: #e4e1d9;
  --line-strong: #d5d1c7;
  --rule: #c8c4ba;
  --accent: #2456c4;
  --accent-strong: #1b47aa;
  --accent-weak: #e9eefb;
  --accent-ink: #173d92;
  --mark: #ffe28a;
  --shadow-paper: 0 1px 2px rgba(24, 28, 36, 0.04), 0 24px 70px -34px rgba(24, 28, 36, 0.28);
  --shadow-pop: 0 18px 50px -12px rgba(20, 24, 32, 0.28);

  --sans: "Inter", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --serif: "Source Han Serif SC", "Noto Serif SC", "Songti SC", SimSun, "Times New Roman", serif;

  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #101216;
  --bg-deep: #0b0d10;
  --panel: #15181d;
  --paper: #1a1e24;
  --ink: #e9e7e1;
  --ink-2: #cfcdc7;
  --muted: #949aa3;
  --faint: #6c727b;
  --line: #262a31;
  --line-strong: #343941;
  --rule: #3d434c;
  --accent: #8db2ff;
  --accent-strong: #a9c5ff;
  --accent-weak: #1c2740;
  --accent-ink: #a9c5ff;
  --mark: #7d6a1f;
  --shadow-paper: 0 1px 2px rgba(0, 0, 0, 0.35), 0 24px 70px -34px rgba(0, 0, 0, 0.8);
  --shadow-pop: 0 18px 50px -12px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body.no-scroll { overflow: hidden; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
::selection { background: var(--accent-weak); color: var(--accent-ink); }

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

/* 顶部阅读进度 */
.progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  z-index: 80;
  background: transparent;
  pointer-events: none;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #5b8def);
  transition: width 80ms linear;
}

/* ==========================================================================
   布局
   ========================================================================== */

.app { display: flex; min-height: 100dvh; }

.main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.main {
  flex: 1;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 34px 36px 72px;
}

/* ==========================================================================
   侧边栏 / 目录
   ========================================================================== */

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 18px 16px 20px;
}
.logo {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #3a6fe0 0%, #1d47a8 100%);
  box-shadow: 0 6px 16px -6px rgba(36, 86, 196, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.logo svg { width: 21px; height: 21px; }
.brand-text { min-width: 0; flex: 1; }
.brand-text h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.sidebar .sidebar-close { display: none; }

.search-wrap {
  position: relative;
  margin: 2px 16px 12px;
}
.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}
#searchInput {
  width: 100%;
  height: 38px;
  padding: 0 44px 0 34px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  appearance: none;
}
#searchInput::placeholder { color: var(--faint); }
#searchInput:focus {
  border-color: var(--accent);
  background: var(--paper);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
#searchInput::-webkit-search-cancel-button { display: none; }
.search-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel);
  color: var(--faint);
  font-family: var(--sans);
  font-size: 11px;
  pointer-events: none;
}

/* 搜索面板 */
.search-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0 10px;
  overflow: hidden;
}
.search-status {
  padding: 4px 10px 8px;
  font-size: 11.5px;
  color: var(--faint);
  letter-spacing: 0.02em;
}
.search-results {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 12px;
  scrollbar-width: thin;
}
.search-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.45;
}
.search-item:hover,
.search-item.active { background: var(--accent-weak); }
.search-item .s-name {
  display: block;
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
}
.search-item .s-path {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-item mark {
  background: var(--mark);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
.search-empty {
  padding: 26px 14px;
  text-align: center;
  color: var(--faint);
  font-size: 12.5px;
  line-height: 1.7;
}

/* 目录树 */
.tree {
  flex: 1;
  overflow-y: auto;
  padding: 2px 10px 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  overscroll-behavior: contain;
}
.tree::-webkit-scrollbar,
.search-results::-webkit-scrollbar { width: 8px; }
.tree::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.tree-node { position: relative; }
.tree-row {
  --pad: calc(6px + var(--depth, 0) * 14px);
  display: flex;
  align-items: flex-start;
  border-radius: 8px;
  padding: 0;
  position: relative;
}
.tree-row.leaf { margin: 0; }
.tree-row:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }

.chev {
  flex: 0 0 22px;
  width: 22px;
  height: 30px;
  display: grid;
  place-items: center;
  margin-left: calc(var(--pad) - 2px);
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  border-radius: 6px;
}
.chev svg { width: 12px; height: 12px; transition: transform 0.16s ease; }
.tree-node.open > .tree-row .chev svg { transform: rotate(90deg); }
.chev-spacer { flex: 0 0 22px; width: 22px; margin-left: calc(var(--pad) - 2px); }

.tree-label {
  flex: 1;
  min-width: 0;
  display: block;
  padding: 7px 9px 7px 1px;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 13px;
  line-height: 1.42;
  color: var(--muted);
  cursor: pointer;
  border-radius: 0 8px 8px 0;
  overflow-wrap: anywhere;
}
.tree-row[data-depth="0"] .tree-label {
  font-size: 13.6px;
  font-weight: 600;
  color: var(--ink-2);
  padding-top: 9px;
  padding-bottom: 9px;
}
.tree-row.root { margin-top: 3px; }
.tree-row.root:not(:first-child) { border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.tree-row.leaf .tree-label { font-size: 12.6px; color: var(--muted); }
.tree-row.leaf .tree-label:hover { color: var(--ink); }

.tree-row.active {
  background: var(--accent-weak);
}
.tree-row.active .tree-label {
  color: var(--accent-ink);
  font-weight: 600;
}
.tree-row.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2.5px;
  border-radius: 3px;
  background: var(--accent);
}

.tree-children { display: block; }

.tree-skel { padding: 8px 18px; }
.tree-skel i {
  display: block;
  height: 11px;
  margin: 12px 0;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--line) 25%, color-mix(in srgb, var(--line) 40%, transparent) 37%, var(--line) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

.sidebar-foot {
  flex: 0 0 auto;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--faint);
  letter-spacing: 0.02em;
  display: flex;
  gap: 7px;
  align-items: center;
}
.dotsep { opacity: 0.6; }

/* ==========================================================================
   顶栏
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 58px;
  padding: 0 26px;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
}

.topbar .menu-btn { display: none; }

.crumbs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  mask-image: linear-gradient(90deg, #000 92%, transparent);
  -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent);
}
.crumb { flex: 0 0 auto; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.crumb.cur { color: var(--ink); font-weight: 600; }
.crumb-sep { color: var(--faint); opacity: 0.7; flex: 0 0 auto; }

.tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.font-ctl {
  display: flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  overflow: hidden;
  background: var(--panel);
}
.font-ctl .tool-btn { border-radius: 0; }
.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  min-width: 32px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.tool-btn:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.tool-btn svg { width: 16px; height: 16px; }
.tool-btn:disabled { opacity: 0.35; cursor: default; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.icon-btn svg { width: 19px; height: 19px; }

.icon-sun { display: none; }
html[data-theme="dark"] .icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: block; }

/* ==========================================================================
   文章
   ========================================================================== */

.paper {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-paper);
  padding: 54px 64px 44px;
  min-height: 60vh;
}

.art-head { margin-bottom: 30px; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
}
.eyebrow::before {
  content: "";
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.7;
}
.art-head h1 {
  margin: 12px 0 12px;
  font-family: var(--serif);
  font-size: clamp(26px, 3.2vw, 34px);
  line-height: 1.32;
  font-weight: 700;
  letter-spacing: 0.005em;
  color: var(--ink);
}
.art-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--faint);
}
.art-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: 0.7; }

.stale-banner {
  display: flex;
  gap: 9px;
  align-items: center;
  margin: 0 0 24px;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--mark) 55%, var(--line));
  background: color-mix(in srgb, var(--mark) 14%, transparent);
  color: var(--ink-2);
  border-radius: 10px;
  font-size: 12.5px;
}

/* 正文排版 */
.prose {
  font-family: var(--serif);
  font-size: var(--reader-size);
  line-height: 1.86;
  color: var(--ink-2);
  overflow-wrap: break-word;
  word-break: break-word;
}
.prose p { margin: 0 0 0.52em; }
.prose p:last-child { margin-bottom: 0; }
.prose div { margin: 0; }
.prose .center { text-align: center; }
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  font-family: var(--sans);
  color: var(--ink);
  line-height: 1.45;
  margin: 1.4em 0 0.55em;
  font-weight: 650;
}
.prose h1 { font-size: 1.5em; }
.prose h2 { font-size: 1.3em; }
.prose h3 { font-size: 1.15em; }
.prose h4, .prose h5, .prose h6 { font-size: 1.03em; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.prose a:hover { text-decoration-color: var(--accent); }
.prose strong, .prose b { color: var(--ink); font-weight: 700; }
.prose u { text-decoration: underline; text-underline-offset: 3px; }
.prose sub, .prose sup { font-size: 0.72em; line-height: 0; }
.prose ul, .prose ol { margin: 0.5em 0 0.8em; padding-left: 1.5em; }
.prose li { margin: 0.25em 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }

.prose table {
  border-collapse: collapse;
  margin: 1.1em 0;
  font-family: var(--sans);
  font-size: 0.82em;
  line-height: 1.55;
  color: var(--ink-2);
}
.prose caption { caption-side: bottom; padding-top: 8px; font-size: 0.8em; color: var(--faint); }
.prose td, .prose th {
  padding: 5px 9px;
  vertical-align: middle;
  border: 0;
}
.prose th { font-weight: 650; text-align: center; background: color-mix(in srgb, var(--ink) 3%, transparent); }
.prose td p, .prose th p { margin: 0; }
.prose td > div { margin: 0; }
.prose .bT { border-top: 1px solid var(--rule); }
.prose .bR { border-right: 1px solid var(--rule); }
.prose .bB { border-bottom: 1px solid var(--rule); }
.prose .bL { border-left: 1px solid var(--rule); }
/* 单列表格通常是 Word 的正文/标题布局框架，按正文排版处理 */
.prose table.layout {
  width: 100%;
  font: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  margin: 0.2em 0;
}
.prose table.layout > tbody > tr > td,
.prose table.layout > tr > td {
  padding: 1px 0;
  vertical-align: top;
}
.prose table.layout .table-scroll table { font-size: 0.85em; }

.prose table[data-grid] td,
.prose table[data-grid] th { border: 1px solid var(--rule); }
.prose table[data-grid] tr:first-child td,
.prose table[data-grid] tr:first-child th {
  background: color-mix(in srgb, var(--ink) 4%, transparent);
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 1.1em 0;
  padding-bottom: 2px;
  scrollbar-width: thin;
}
.table-scroll table { margin: 0; min-width: 100%; }
/* 桌面端让数据表收进正文宽度，移动端保持原始宽度横向滑动 */
@media (min-width: 900px) {
  .prose .table-scroll table:not(.layout) {
    width: 100% !important;
    max-width: 100%;
  }
}
.table-scroll.scrollable:not(.at-start) {
  box-shadow: inset 14px 0 14px -14px rgba(15, 20, 30, 0.32);
}
.table-scroll.scrollable:not(.at-end) {
  box-shadow: inset -14px 0 14px -14px rgba(15, 20, 30, 0.32);
}
.table-scroll.scrollable:not(.at-start):not(.at-end) {
  box-shadow:
    inset 14px 0 14px -14px rgba(15, 20, 30, 0.32),
    inset -14px 0 14px -14px rgba(15, 20, 30, 0.32);
}
.table-scroll::-webkit-scrollbar { height: 8px; }
.table-scroll::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  cursor: zoom-in;
}
html[data-theme="dark"] .prose img { background: #fff; }
.prose img[width] { max-width: 100%; }
.prose img.broken {
  min-width: 64px;
  min-height: 32px;
  opacity: 0.4;
  border: 1px dashed var(--line-strong);
  background: transparent;
}

.prose .empty { color: var(--faint); font-family: var(--sans); font-size: 14px; }

/* 上一篇 / 下一篇 */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 46px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}
.pager-card {
  display: block;
  padding: 15px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--paper);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  min-width: 0;
}
.pager-card:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 26px -18px rgba(20, 30, 60, 0.5);
  transform: translateY(-1px);
}
.pager-card.next { text-align: right; }
.pager-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  letter-spacing: 0.1em;
  color: var(--faint);
  margin-bottom: 5px;
}
.pager-card.next .pager-label { justify-content: flex-end; }
.pager-title {
  display: block;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.pager-card:hover .pager-title { color: var(--accent); }
.pager-card.placeholder { border-style: dashed; opacity: 0.45; pointer-events: none; }
.pager-label svg { width: 13px; height: 13px; }

.page-foot {
  text-align: center;
  margin-top: 34px;
  font-size: 11.5px;
  color: var(--faint);
  letter-spacing: 0.03em;
}

/* 骨架屏 */
.skeleton { padding: 6px 0; }
.sk-line, .sk-block {
  border-radius: 6px;
  background: linear-gradient(90deg, var(--line) 25%, color-mix(in srgb, var(--line) 35%, transparent) 37%, var(--line) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.5s ease infinite;
}
.sk-line { height: 13px; margin: 12px 0; }
.sk-line.tall { height: 30px; margin: 20px 0; }
.sk-line.w35 { width: 35%; }
.sk-line.w40 { width: 40%; }
.sk-line.w60 { width: 60%; }
.sk-line.w70 { width: 70%; }
.sk-line.w76 { width: 76%; }
.sk-line.w80 { width: 80%; }
.sk-line.w88 { width: 88%; }
.sk-line.w90 { width: 90%; }
.sk-line.w92 { width: 92%; }
.sk-block { height: 220px; margin: 26px 0; }
.sk-block.short { height: 120px; }
@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* 未选择页面 */
.welcome {
  min-height: 55vh;
  padding: 40px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--sans);
}
.welcome-logo {
  width: 56px;
  height: 56px;
  margin-bottom: 18px;
  color: var(--accent);
  opacity: .85;
}
.welcome-logo svg { width: 100%; height: 100%; }
.welcome h1 { margin: 0 0 10px; font-size: 24px; font-weight: 600; color: var(--ink); }
.welcome p { margin: 0 0 6px; font-size: 14px; color: var(--muted); }
.welcome .welcome-hint { margin-top: 12px; font-size: 13px; color: var(--faint); }
.welcome kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel);
  font-family: var(--sans);
  font-size: 11px;
}

/* 错误状态 */
.error-state {
  padding: 40px 10px;
  text-align: center;
  font-family: var(--sans);
}
.error-state .error-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, #c2410c 12%, transparent);
  color: #c2410c;
}
.error-state .error-icon svg { width: 24px; height: 24px; }
.error-state h2 { margin: 0 0 8px; font-size: 18px; color: var(--ink); }
.error-state p { margin: 0 auto 20px; max-width: 420px; color: var(--muted); font-size: 13.5px; line-height: 1.7; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn + .btn { margin-left: 10px; }

/* ==========================================================================
   遮罩 / 移动端
   ========================================================================== */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 20, 0.42);
  backdrop-filter: blur(2px);
  z-index: 45;
  opacity: 0;
  transition: opacity 0.2s;
}
.scrim.show { opacity: 1; }

/* 浮动按钮 */
.to-top {
  position: fixed;
  right: 26px;
  bottom: 26px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 10px 30px -12px rgba(20, 26, 40, 0.35);
  z-index: 30;
  transition: transform 0.15s, color 0.15s, border-color 0.15s;
}
.to-top:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-2px); }
.to-top svg { width: 19px; height: 19px; }

/* 图片灯箱 */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(8, 10, 14, 0.88);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vh 4vw;
  cursor: zoom-out;
}
.lightbox img {
  max-width: 100%;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
}
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 22px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.18); }
.lightbox-close svg { width: 20px; height: 20px; }
.lightbox-cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16px;
  text-align: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 12px);
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12.5px;
  z-index: 95;
  opacity: 0;
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: none;
  box-shadow: var(--shadow-pop);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   响应式
   ========================================================================== */

@media (max-width: 1180px) {
  :root { --sidebar-w: 288px; }
  .paper { padding: 46px 48px 40px; }
  .main { padding: 30px 28px 64px; }
}

@media (max-width: 960px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-102%);
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 20px 0 60px -30px rgba(0, 0, 0, 0.5);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar .sidebar-close { display: grid; }
  .topbar .menu-btn { display: grid; }
  .scrim { display: block; }
  .scrim[hidden] { display: none; }
  .main { padding: 24px 20px 56px; }
  .topbar { padding: 0 16px; gap: 8px; }
  .paper { padding: 38px 34px 34px; border-radius: 14px; }
  .crumb { max-width: 160px; }
}

@media (max-width: 640px) {
  .topbar { height: 54px; }
  .crumbs { font-size: 11.5px; }
  .crumb { max-width: 110px; }
  .crumb:not(.cur) { display: none; }
  .crumb-sep { display: none; }
  .font-ctl { display: none; }
  .main { padding: 14px 10px 48px; }
  .paper { padding: 28px 20px 26px; border-radius: 12px; }
  .art-head h1 { font-size: 24px; }
  .prose { font-size: calc(var(--reader-size) - 0.5px); line-height: 1.8; }
  .pager { grid-template-columns: 1fr; }
  .pager-card.next { text-align: left; }
  .pager-card.next .pager-label { justify-content: flex-start; }
  .to-top { right: 16px; bottom: 16px; }
}

/* ==========================================================================
   打印
   ========================================================================== */

@media print {
  :root { --bg: #fff; --paper: #fff; --ink: #000; --ink-2: #111; --muted: #444; --line: #ddd; --line-strong: #ccc; --rule: #999; }
  body { background: #fff; }
  .sidebar, .topbar, .to-top, .progress, .scrim, .pager, .page-foot, .lightbox, .toast { display: none !important; }
  .main { max-width: none; padding: 0; }
  .paper { border: 0; box-shadow: none; padding: 0; border-radius: 0; }
  .art-head h1 { font-size: 26pt; }
  .prose { font-size: 11pt; line-height: 1.65; }
  .prose table { font-size: 9pt; max-width: 100% !important; width: 100% !important; }
  .prose img { max-width: 100%; }
  .table-scroll { overflow: visible; box-shadow: none !important; }
  a { color: inherit; text-decoration: none; }
  @page { margin: 18mm 16mm; }
}

/* 无障碍：减少动效 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
