/* ===== 阅读页布局与 Markdown 排版 ===== */
.topbar { height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 60; }
.brand { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; user-select: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(145deg,var(--brand),#0b5f6a); color: #fff; display: grid; place-items: center; font-size: 17px; font-weight: 700; }
.brand-text b { font-size: 15px; letter-spacing: .02em; }
.brand-text small { display: block; color: var(--text-3); font-size: 10px; margin-top: 3px; letter-spacing: .04em; }
.top-search { position: relative; flex: 1 1 300px; max-width: 380px; }
.top-search input { height: 34px; padding-left: 32px; }
.top-search .s-ico { position: absolute; left: 11px; top: 8px; color: var(--text-3); font-size: 14px; pointer-events: none; }
.top-search kbd { position: absolute; right: 9px; top: 8px; font-family: var(--mono); font-size: 11px; color: var(--text-3); background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; pointer-events: none; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.who { font-size: 12px; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; padding: 0 5px; white-space: nowrap; }
.who .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.search-panel { position: absolute; top: 43px; left: 0; width: min(560px,86vw); max-height: min(66vh,540px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 8px; z-index: 90; }
.search-head { font-size: 11px; color: var(--text-3); padding: 6px 10px 8px; }
.search-item { display: block; width: 100%; text-align: left; padding: 9px 10px; border: 0; background: transparent; border-radius: 8px; color: var(--text); }
.search-item:hover { background: var(--brand-soft); }
.search-item .si-title { font-size: 13.5px; font-weight: 600; }
.search-item .si-meta { font-size: 11px; color: var(--brand); }
.search-item .si-snippet { font-size: 12px; color: var(--text-2); margin-top: 4px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-item mark, .md-body mark { background: var(--brand-soft-2); color: var(--brand-strong); border-radius: 2px; }
.search-empty { padding: 22px; text-align: center; color: var(--text-3); font-size: 13px; }
.progress { position: fixed; top: 58px; left: 0; height: 2px; width: 0; background: var(--brand); z-index: 70; transition: width .08s linear; }
.mobile-only { display: none; }

.layout { display: grid; grid-template-columns: 262px minmax(0,1fr); height: calc(100vh - 58px); }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; z-index: 40; }
.side-scroll { overflow: auto; flex: 1; min-height: 0; }
.side-section { border-bottom: 1px solid var(--border); padding: 13px 12px; }
.side-head { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--text-3); padding: 0 7px 9px; text-transform: uppercase; }
.side-head .count { font-weight: 500; letter-spacing: 0; background: var(--surface-3); border-radius: 20px; padding: 1px 7px; font-size: 10.5px; }
.lib-item, .series-item, .article-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); text-align: left; font-size: 13px; line-height: 1.35; margin-bottom: 2px; transition: .15s; }
.lib-item:hover, .series-item:hover, .article-item:hover { background: var(--surface-3); color: var(--text); }
.lib-item.active, .series-item.active, .article-item.active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
.lib-item .ico { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 7px; background: var(--surface-3); color: var(--brand); display: grid; place-items: center; font-size: 13px; }
.lib-item.active .ico { background: var(--brand); color: #fff; }
.side-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-num { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.series-item { font-size: 12.8px; padding-left: 14px; }
.article-item { font-size: 12.4px; padding: 6px 10px 6px 20px; border-left: 2px solid var(--border); border-radius: 0 7px 7px 0; }
.article-item.active { border-left-color: var(--brand); }
.side-foot { border-top: 1px solid var(--border); padding: 11px 12px; font-size: 11.5px; color: var(--text-3); }
.side-foot .stats { display: flex; flex-wrap: wrap; gap: 5px 11px; margin-bottom: 9px; }
.side-foot .stats b { color: var(--text-2); }
.side-empty { padding: 8px 10px; color: var(--text-3); font-size: 12.5px; line-height: 1.65; }

.main { overflow: auto; min-width: 0; padding: 20px clamp(16px,3.4vw,46px) 90px; scroll-behavior: smooth; }
.main-inner { max-width: 848px; margin: 0 auto; }
.zone-label { font-size: 11px; color: var(--text-3); letter-spacing: .08em; font-weight: 700; margin: 0 0 8px; text-transform: uppercase; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 5px; scrollbar-width: thin; }
.chips::-webkit-scrollbar { height: 5px; }
.chips::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
.chip { flex: 0 0 auto; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 12.8px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; transition: .16s; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.chip .n { opacity: .72; font-size: 11px; }
.crumb { font-size: 12px; color: var(--text-3); margin: 15px 0 12px; display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.crumb strong { color: var(--text-2); font-weight: 500; }
.toc { display: none; border-left: 1px solid var(--border); background: var(--surface); padding: 26px 18px; overflow: auto; }
.toc-title { font-size: 11px; letter-spacing: .09em; font-weight: 700; color: var(--text-3); text-transform: uppercase; margin-bottom: 12px; }
.toc a { display: block; font-size: 12.3px; color: var(--text-2); text-decoration: none; padding: 5px 8px; border-left: 2px solid var(--border); line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc a:hover, .toc a.active { color: var(--brand); border-left-color: var(--brand); }
.toc a.active { background: var(--brand-soft); font-weight: 600; border-radius: 0 5px 5px 0; }
.toc a.lv3 { padding-left: 20px; font-size: 11.8px; }
.toc a.lv4 { padding-left: 30px; font-size: 11.5px; }
.inline-toc { border: 1px solid var(--border); border-radius: 9px; background: var(--surface); padding: 10px 14px; margin-bottom: 16px; }
.inline-toc summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); }
.inline-toc a { display: block; padding: 4px 0; font-size: 12.5px; text-decoration: none; }

.paper { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(24px,4vw,50px) clamp(20px,4.6vw,56px) 56px; min-height: 400px; }
.article-meta { border-bottom: 1px solid var(--border); padding-bottom: 17px; margin-bottom: 28px; }
.article-meta h1 { font-size: clamp(23px,3vw,31px); line-height: 1.35; margin: 0 0 11px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 7px 15px; font-size: 12px; color: var(--text-3); }
.meta-row .tag { background: var(--brand-soft); color: var(--brand-strong); border-radius: 4px; padding: 1px 7px; }
.md-body { font-size: var(--reading-size); line-height: 1.85; color: var(--text); overflow-wrap: break-word; }
.md-body > :first-child { margin-top: 0; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 { line-height: 1.4; margin: 1.85em 0 .7em; font-weight: 700; scroll-margin-top: 78px; }
.md-body h1 { font-size: 1.7em; }
.md-body h2 { font-size: 1.4em; padding-bottom: .35em; border-bottom: 1px solid var(--border); }
.md-body h3 { font-size: 1.18em; }
.md-body h4 { font-size: 1.05em; }
.md-body .anchor { opacity: 0; margin-left: 8px; color: var(--brand); font-weight: 400; text-decoration: none; font-size: .8em; }
.md-body h2:hover .anchor, .md-body h3:hover .anchor { opacity: .75; }
.md-body p { margin: 0 0 1.05em; }
.md-body a { text-decoration: none; border-bottom: 1px solid color-mix(in srgb,var(--brand) 40%,transparent); }
.md-body ul, .md-body ol { margin: 0 0 1.1em; padding-left: 1.7em; }
.md-body li { margin: .28em 0; }
.md-body li.task { list-style: none; margin-left: -1.4em; }
.md-body input[type="checkbox"] { margin-right: .55em; accent-color: var(--brand); }
.md-body blockquote { margin: 1.3em 0; padding: .7em 1.1em; border-left: 3px solid var(--brand); background: var(--brand-soft); border-radius: 0 8px 8px 0; color: var(--text-2); }
.md-body blockquote > :last-child { margin-bottom: 0; }
.md-body hr { border: 0; border-top: 1px solid var(--border); margin: 2.2em 0; }
.md-body code { font-family: var(--mono); font-size: .88em; background: var(--code-bg); border: 1px solid var(--border); border-radius: 4px; padding: .12em .38em; }
.md-body .code-block { margin: 1.4em 0; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; background: var(--code-bg); }
.md-body .code-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; background: var(--surface-3); border-bottom: 1px solid var(--border); font-size: 11.5px; color: var(--text-2); font-family: var(--mono); }
.md-body .copy-btn { border: 0; background: transparent; color: var(--text-2); font-size: 11.5px; padding: 2px 6px; border-radius: 4px; }
.md-body .copy-btn:hover { background: var(--surface); color: var(--brand); }
.md-body .code-block pre { padding: 14px 16px; overflow-x: auto; line-height: 1.65; margin: 0; }
.md-body .code-block code { background: none; border: 0; padding: 0; font-size: .85em; }
.md-body .table-wrap { overflow-x: auto; margin: 1.4em 0; border: 1px solid var(--border); border-radius: 9px; }
.md-body table { border-collapse: collapse; width: 100%; font-size: .93em; }
.md-body th, .md-body td { padding: 9px 14px; border-bottom: 1px solid var(--border); text-align: left; }
.md-body th { background: var(--surface-2); font-weight: 600; }
.md-body tbody tr:nth-child(even) { background: var(--surface-2); }
.md-body tbody tr:last-child td { border-bottom: 0; }
.md-body img { max-width: 100%; height: auto; display: block; margin: 1.5em auto; border-radius: 9px; box-shadow: var(--shadow-sm); cursor: zoom-in; }
.md-body .img-missing { display: block; padding: 18px; margin: 1.4em 0; border: 1px dashed var(--border-strong); border-radius: 9px; background: var(--surface-2); color: var(--text-3); text-align: center; font-size: 12.5px; line-height: 1.7; }
.md-body .img-missing b { display: block; color: var(--text-2); margin-bottom: 4px; }
.pager { display: flex; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.pager button { flex: 1 1 220px; min-width: 0; text-align: left; padding: 13px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.pager button:hover:not(:disabled) { border-color: var(--brand); transform: translateY(-1px); }
.pager button:disabled { opacity: .45; cursor: default; }
.pager small { display: block; color: var(--text-3); font-size: 11px; margin-bottom: 4px; }
.pager .p-title { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager .next { text-align: right; }
.empty-state { text-align: center; padding: 60px 20px; }
.empty-art { width: 92px; height: 92px; margin: 0 auto 20px; border-radius: 24px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 42px; }
.empty-state h2 { font-size: 20px; margin: 0 0 10px; }
.empty-state p { color: var(--text-2); line-height: 1.8; max-width: 470px; margin: 0 auto 20px; font-size: 13.5px; }
.lightbox { position: fixed; inset: 0; z-index: 220; background: rgba(8,16,13,.88); display: grid; place-items: center; padding: 30px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: 8px; }
.lightbox .lb-cap { position: absolute; bottom: 18px; width: 100%; text-align: center; color: #dbe6e0; font-size: 12.5px; }
.scrim { display: none; }

@media (min-width: 1400px) { .layout { grid-template-columns: 262px minmax(0,1fr) 224px; } .toc { display: block; } }
@media (max-width: 900px) {
  .mobile-only { display: inline-grid; }
  .layout { grid-template-columns: minmax(0,1fr); }
  .sidebar { position: fixed; top: 58px; bottom: 0; left: 0; width: min(310px,86vw); transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; position: fixed; inset: 58px 0 0; background: rgba(8,20,15,.38); z-index: 35; }
  .brand-text { display: none; }
  .topbar { gap: 8px; padding: 0 10px; }
  .top-search { max-width: none; }
  .top-search kbd { display: none; }
  .main { padding: 16px 15px 80px; }
  .toc { display: none !important; }
}
@media (max-width: 620px) {
  .top-search { flex-basis: 100px; min-width: 0; }
  .top-actions .hide-xs { display: none; }
  .btn .btn-label { display: none; }
  .btn .btn-label-short { display: inline; }
  .paper { padding: 22px 18px 40px; }
  .search-panel { width: calc(100vw - 20px); left: -46px; }
  .pager button { flex-basis: 100%; }
  .who { display: none; }
}
@media print {
  .topbar,.sidebar,.toc,.chips,.zone-label,.crumb,.pager,.progress,.modal,.toast-stack,.lightbox,.inline-toc { display: none !important; }
  body,.layout,.main { display: block; height: auto; overflow: visible; padding: 0; background: #fff; }
  .paper { border: 0; box-shadow: none; padding: 0; }
}
