/* =========================================================================
   幻想藏书 — QQ自由幻想单机资料

   布局：顶栏（56）+ 左目录（252）+ 正文（≤940）+ 右页内目录（208）
   主题：明亮（默认）／暗黑，<html data-theme="light|dark">
   颜色全部走语义令牌；界面只用中性灰，唯一彩色「印泥红」只做记号。
   ========================================================================= */

:root {
  color-scheme: light;

  --bg: #fcfcfa;
  --bg-soft: #f6f6f3;
  --card: #ffffff;
  --sunk: #f1f1ed;
  --art: #101110;

  --line: rgba(26, 30, 26, .10);
  --line-strong: rgba(26, 30, 26, .22);

  --tx: #1a1d1a;
  --tx-body: #2f3430;
  --tx-2: #5b615b;
  --tx-3: #878d86;

  --mark: #b2452f;
  --mark-soft: rgba(178, 69, 47, .07);
  --mark-line: rgba(178, 69, 47, .28);

  --hover: rgba(26, 30, 26, .04);
  --shadow-sm: 0 1px 2px rgba(24, 30, 24, .05);
  --shadow-lg: 0 24px 60px rgba(20, 26, 20, .16);

  --serif: "Source Han Serif SC", "Noto Serif SC", "Songti SC", STSong, "SimSun", serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Mono", Consolas, "Courier New", monospace;

  --topbar: 56px;
  --side: 252px;
  --rail: 224px;

  --ease: cubic-bezier(.22, .61, .36, 1);
  --t: 150ms;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #161715;
  --bg-soft: #111210;
  --card: #1c1e1b;
  --sunk: #212320;
  --art: #0d0e0d;

  --line: rgba(236, 236, 226, .10);
  --line-strong: rgba(236, 236, 226, .24);

  --tx: #edebe1;
  --tx-body: #d3d1c6;
  --tx-2: #a6a99f;
  --tx-3: #7c8077;

  --mark: #d1705a;
  --mark-soft: rgba(209, 112, 90, .12);
  --mark-line: rgba(209, 112, 90, .32);

  --hover: rgba(236, 236, 226, .05);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
}

/* ------------------------------- 基础 --------------------------------- */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--tx);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.lock { overflow: hidden; }
.sec:focus { outline: none; }
.sec:focus-visible { outline: 2px solid var(--mark); outline-offset: 6px; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }

::selection { background: var(--mark-line); color: var(--tx); }
:focus-visible { outline: 2px solid var(--mark); outline-offset: 2px; }

kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-color: var(--line-strong);
  border-radius: 3px;
  background: var(--card);
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
  color: var(--tx-3);
}

* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 6px;
}

/* ------------------------------- 顶栏 --------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--topbar);
  padding: 0 18px 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
@supports (background: color-mix(in srgb, red, blue)) {
  .topbar { background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); }
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
  width: calc(var(--side) - 26px);
  color: var(--tx);
}
.brand-seal {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border: 1px solid var(--mark-line);
  color: var(--mark);
  font-family: var(--serif);
  font-size: 13px;
  line-height: 1;
  user-select: none;
}
.brand-name {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .12em;
  white-space: nowrap;
}

.trail {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: 11.5px;
  color: var(--tx-3);
  white-space: nowrap;
  overflow: hidden;
}
.trail a { color: var(--tx-3); transition: color var(--t) var(--ease); }
.trail a:hover { color: var(--tx); }
.trail .sep { color: var(--line-strong); }
.trail .here { color: var(--tx-2); }

.topbar-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.search-trigger {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  width: 232px;
  padding: 0 8px 0 9px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--card);
  color: var(--tx-3);
  font-size: 12px;
  transition: border-color var(--t) var(--ease), color var(--t) var(--ease);
}
.search-trigger:hover { border-color: var(--line-strong); color: var(--tx-2); }
.search-trigger svg { width: 13px; height: 13px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; }
.st-label { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; }
.search-trigger kbd { border: 0; background: none; padding: 0; font-size: 9.5px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--tx-2);
  transition: color var(--t) var(--ease), border-color var(--t) var(--ease), background var(--t) var(--ease);
}
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { color: var(--tx); border-color: var(--line); background: var(--hover); }
.menu-btn { display: none; }

.theme-btn .ic-sun { display: none; }
html[data-theme="dark"] .theme-btn .ic-sun { display: block; }
html[data-theme="dark"] .theme-btn .ic-moon { display: none; }

.mode-tag {
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-size: 10.5px;
  color: var(--tx-3);
  white-space: nowrap;
  transition: border-color var(--t) var(--ease), color var(--t) var(--ease);
}
.mode-tag:hover { border-color: var(--line-strong); color: var(--tx-2); }
body[data-mode="offline"] .mode-tag { border-color: var(--mark-line); color: var(--mark); }

/* ------------------------------- 骨架 --------------------------------- */

.shell {
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr) var(--rail);
  align-items: start;
}

body.no-rail .shell { grid-template-columns: var(--side) minmax(0, 1fr); }
body.no-rail .rail { display: none; }

/* ------------------------------- 左栏 --------------------------------- */

.side {
  position: sticky;
  top: var(--topbar);
  height: calc(100vh - var(--topbar));
  display: flex;
  flex-direction: column;
  padding: 18px 12px 12px;
  border-right: 1px solid var(--line);
  background: var(--bg-soft);
}

.nav { flex: 1; min-height: 0; overflow-y: auto; padding: 0 4px 8px; }

.nav-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 8px 5px;
  font-size: 10px;
  letter-spacing: .18em;
  color: var(--tx-3);
}
.nav-h:first-child { padding-top: 2px; }
.nav-h em {
  font-style: normal;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0;
  color: var(--tx-3);
  opacity: .8;
}

.nav-i {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 3px;
  font-size: 13px;
  color: var(--tx-2);
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.nav-i .dot {
  width: 3px;
  height: 3px;
  flex: none;
  border-radius: 50%;
  background: var(--line-strong);
}
.nav-i .n {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--tx-3);
  font-variant-numeric: tabular-nums;
}
.nav-vol { position: relative; }
.nav-vol .nav-i { padding-right: 34px; }
.nav-vol .nav-i .t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-caret {
  position: absolute;
  right: 3px;
  top: 50%;
  width: 24px;
  height: 24px;
  margin-top: -12px;
  display: grid;
  place-items: center;
  border-radius: 2px;
  color: var(--tx-2);
  transition: color var(--t) var(--ease), background var(--t) var(--ease);
}
.nav-caret svg {
  width: 12px;
  height: 12px;
  opacity: .75;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 160ms var(--ease);
}
.nav-caret:hover { color: var(--tx); background: var(--active); }
.nav-caret:hover svg { opacity: 1; }
.nav-caret[aria-expanded="true"] svg { transform: rotate(90deg); }

.nav-sub {
  display: flex;
  flex-direction: column;
  margin: 1px 0 6px 9px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}
.nav-sub.hide { display: none; }
.nav-sub a {
  position: relative;
  display: flex;
  gap: 7px;
  padding: 3px 6px;
  border-radius: 2px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--tx-3);
  transition: color var(--t) var(--ease), background var(--t) var(--ease);
}
.nav-sub a i {
  flex: none;
  font-style: normal;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--tx-3);
  opacity: .75;
  padding-top: 2px;
}
.nav-sub a span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-sub a:hover { color: var(--tx); background: var(--hover); }
.nav-sub a.on { color: var(--mark); }
.nav-sub a.on::before {
  content: "";
  position: absolute;
  left: -11px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--mark);
}

.nav-i:hover { background: var(--hover); color: var(--tx); }
.nav-i.on { background: var(--card); color: var(--tx); box-shadow: inset 2px 0 0 var(--mark); }
.nav-i.on .dot { background: var(--mark); }
.nav-i.on .n { color: var(--mark); }

.side-foot {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--tx-3);
}

/* ------------------------------- 正文 --------------------------------- */

.main { min-width: 0; display: flex; flex-direction: column; }

.page {
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
  padding: 40px 32px 72px;
}

/* 页头 */
.page-head { padding-bottom: 26px; border-bottom: 1px solid var(--line); }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 10.5px;
  letter-spacing: .2em;
  color: var(--tx-3);
}
.eyebrow::before { content: ""; width: 18px; height: 1px; background: var(--mark); }

.page-head h1 {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.35;
  font-weight: 600;
  letter-spacing: .06em;
}

.lede {
  margin-top: 10px;
  max-width: 64ch;
  font-size: 13px;
  line-height: 1.85;
  color: var(--tx-2);
}

.page-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 16px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--tx-3);
}
.page-meta span + span::before { content: "·"; margin: 0 8px; color: var(--line-strong); }

/* 小节 */
.sec { padding: 34px 0 6px; scroll-margin-top: 74px; }
.sec + .sec { border-top: 1px solid var(--line); }

.sec-head {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-bottom: 16px;
}
.sec-num {
  flex: none;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  color: var(--mark);
  opacity: .9;
  transform: translateY(-1px);
}
.sec-head h2 {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: .03em;
}

.sec-body > * + * { margin-top: 14px; }

/* 正文块 */
.lead {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.65;
  color: var(--tx);
  margin-top: 6px;
}
.para {
  max-width: 76ch;
  font-size: 14px;
  line-height: 1.95;
  color: var(--tx-body);
}
.para b, .para strong { color: var(--tx); font-weight: 600; }
.para a, .lead a, .note a { color: var(--mark); border-bottom: 1px solid var(--mark-line); }

a.jump {
  color: var(--tx-2);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
}
a.jump:hover { color: var(--mark); text-decoration-color: var(--mark-line); }

.note {
  max-width: 76ch;
  padding: 10px 14px;
  border-left: 2px solid var(--mark-line);
  background: var(--sunk);
  font-size: 12.5px;
  line-height: 1.85;
  color: var(--tx-2);
}

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 14px; }
.tag-row span {
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-size: 11.5px;
  color: var(--tx-2);
  background: var(--card);
}

/* ------------------------------- 首页 --------------------------------- */

.home { padding-top: 48px; }

.home-hero { padding-bottom: 34px; border-bottom: 1px solid var(--line); }
.home-hero h1 {
  font-family: var(--serif);
  font-size: 40px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: .12em;
}
.home-hero .lede { margin-top: 14px; font-size: 13.5px; }

.home-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
}
.btn {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--tx);
  border-radius: 3px;
  background: var(--tx);
  color: var(--bg);
  font-size: 12.5px;
  letter-spacing: .04em;
  white-space: nowrap;
  transition: opacity var(--t) var(--ease);
}
.btn:hover { opacity: .82; color: var(--bg); }
.btn.ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--tx-2);
}
.btn.ghost:hover { opacity: 1; border-color: var(--tx-3); color: var(--tx); }

/* 总目 */
.index { margin-top: 38px; }
.index-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-strong);
}
.index-head h2 {
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: .1em;
}
.index-head span {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--tx-3);
}

.groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 48px;
}

.grp { padding: 16px 0 6px; }
.grp-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-bottom: 8px;
}
.grp-no { font-family: var(--mono); font-size: 10px; color: var(--tx-3); }
.grp-head h3 {
  font-family: var(--serif);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: .04em;
}
.grp-head em {
  margin-left: auto;
  font-style: normal;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--tx-3);
}
.grp p {
  margin: -2px 0 8px;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--tx-3);
}

.sheet-link {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 8px;
  margin: 0 -8px;
  border-radius: 3px;
  color: var(--tx);
  transition: background var(--t) var(--ease);
}
.sheet-link:hover { background: var(--hover); }
.sheet-link .t { font-size: 13.5px; white-space: nowrap; }
.sheet-link .d {
  flex: 1;
  min-width: 0;
  font-size: 11.5px;
  color: var(--tx-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sheet-link .n {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--tx-3);
  font-variant-numeric: tabular-nums;
}
.sheet-link:hover .t { color: var(--mark); }

/* 掠影 */
.strip { margin-top: 44px; padding-top: 22px; border-top: 1px solid var(--line); }
.strip-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  font-size: 10px;
  letter-spacing: .16em;
  color: var(--tx-3);
}
.strip-head a { font-size: 11px; letter-spacing: 0; color: var(--tx-3); }
.strip-head a:hover { color: var(--mark); }
.strip-row {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}
.strip-row a {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 128px;
  padding: 6px 4px 0;
  overflow: hidden;
  background: var(--art);
}
.strip-row img {
  height: 94%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: center bottom;
  transition: transform 240ms var(--ease);
}
.strip-row a:hover img { transform: translateY(-2px); }

/* ------------------------------- 页面目录 ------------------------------ */

.rail {
  position: sticky;
  top: var(--topbar);
  height: calc(100vh - var(--topbar));
  overflow-y: auto;
  padding: 40px 20px 40px 0;
  border-left: 1px solid var(--line);
  font-size: 11.5px;
}
.rail-title {
  padding: 0 0 10px 16px;
  border-left: 1px solid var(--line);
  font-size: 9.5px;
  letter-spacing: .16em;
  color: var(--tx-3);
}
.rail-list { display: flex; flex-direction: column; border-left: 1px solid var(--line); }
.rail-list a {
  display: flex;
  gap: 7px;
  padding: 5px 0 5px 15px;
  margin-left: -1px;
  border-left: 1px solid transparent;
  color: var(--tx-3);
  line-height: 1.5;
  transition: color var(--t) var(--ease), border-color var(--t) var(--ease);
}
.rail-list a i {
  flex: none;
  font-style: normal;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--tx-3);
  opacity: .7;
  padding-top: 1px;
}
.rail-list a span { min-width: 0; }
.rail-list a:hover { color: var(--tx); }
.rail-list a.on { color: var(--mark); border-left-color: var(--mark); }
.rail-list a.on i { color: var(--mark); opacity: 1; }

.rail-empty {
  padding: 0 0 0 13px;
  border-left: 1px solid var(--line);
  font-size: 10.5px;
  line-height: 1.8;
  color: var(--tx-3);
}

/* ------------------------------- 表格 --------------------------------- */

.tbl { position: relative; margin: 14px 0 22px; }
.tbl-scroll { overflow-x: auto; }

/* 横向溢出时才出现的右缘渐隐 */
.tbl.scrollable::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 30px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--bg) 78%);
  transition: opacity var(--t) linear;
}
.tbl.at-end::after { opacity: 0; }

table.d {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.7;
  color: var(--tx-body);
}
table.d th {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-strong);
  background: var(--sunk);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--tx-2);
  text-align: left;
  white-space: nowrap;
  vertical-align: bottom;
}
table.d td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  overflow-wrap: anywhere;
}
table.d th + th,
table.d td + td { border-left: 1px solid var(--line); }
table.d tbody tr:last-child td { border-bottom: 0; }
table.d tbody tr:hover td { background: var(--hover); }
table.d td.num { font-family: var(--mono); font-size: 12px; color: var(--tx-2); }
table.d td.nowrap { white-space: nowrap; }

table.d img.ic {
  display: inline-block;
  width: 36px;
  height: 36px;
  object-fit: contain;
  margin-right: 7px;
  padding: 3px;
  vertical-align: middle;
  border: 0;
  border-radius: 2px;
  background: var(--sunk);
}
table.d img.icon-only { display: block; margin: 0; }

.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 22px;
  margin: 4px 0 22px;
}
.panels .tbl { margin: 0; }

/* ------------------------------- 图片 --------------------------------- */

.gal { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin: 14px 0 22px; }
.gal figure {
  margin: 0;
  padding: 3px;
  max-width: 100%;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: zoom-in;
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.gal figure:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.gal img { display: block; max-width: 100%; height: auto; }

/* ------------------------------ 链接卡片 ------------------------------- */

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  margin: 6px 0 22px;
  border: 1px solid var(--line);
  border-right: 0;
  border-bottom: 0;
}
.link-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  background: var(--bg);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--tx-2);
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
a.link-card:hover { background: var(--hover); color: var(--tx); }
.link-card .idx { font-family: var(--mono); font-size: 9.5px; color: var(--tx-3); }
.link-card .arrow { margin-left: auto; font-size: 11px; color: var(--tx-3); }

/* 外链提示与降级 */
.page-tail { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line); }
.tail-title {
  margin-bottom: 12px;
  font-size: 10px;
  letter-spacing: .16em;
  color: var(--tx-3);
}
.outbound { display: flex; flex-wrap: wrap; gap: 8px; }
.outbound a,
a.ext {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-size: 11.5px;
  color: var(--tx-2);
  transition: border-color var(--t) var(--ease), color var(--t) var(--ease), background var(--t) var(--ease);
}
.outbound a::after,
a.ext::after { content: "↗"; font-size: 10px; color: var(--tx-3); }
.outbound a:hover,
a.ext:hover { border-color: var(--mark-line); color: var(--mark); background: var(--mark-soft); }
.ext-off { color: var(--tx-2); }
.ext-off::after { content: "（外链）"; font-size: 10px; color: var(--tx-3); }

.outbound-hint {
  margin-top: 16px;
  padding: 9px 12px;
  border-left: 2px solid var(--mark-line);
  background: var(--sunk);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--tx-2);
}

/* ------------------------------- 检索 --------------------------------- */

.finder {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 11vh 20px 20px;
  background-color: rgba(12, 14, 12, .55);
  backdrop-filter: blur(5px);
}
html[data-theme="dark"] .finder { background-color: rgba(0, 0, 0, .62); }

.finder-box {
  width: 100%;
  max-width: 600px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--card);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.finder-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
}
.finder-field svg { width: 15px; height: 15px; flex: none; fill: none; stroke: var(--tx-3); stroke-width: 1.7; }
.finder-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--tx);
  outline: none;
}
.finder-field input::placeholder { color: var(--tx-3); }
.finder-field input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.finder-list { flex: 1; overflow-y: auto; padding: 6px; }
.f-item {
  display: block;
  padding: 8px 10px;
  border-left: 2px solid transparent;
  border-radius: 2px;
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease);
}
.f-item .w { font-size: 12.5px; color: var(--tx); }
.f-item .w b { font-weight: 600; }
.f-item .t {
  margin-top: 3px;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--tx-3);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.f-item mark { background: var(--mark-soft); color: var(--mark); padding: 0 1px; }
.f-item.on { background: var(--sunk); border-left-color: var(--mark); }

.finder-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 13px;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: 10.5px;
  color: var(--tx-3);
}
.finder-foot span { display: inline-flex; align-items: center; gap: 3px; }
.finder-foot span:last-child { margin-left: auto; }

/* ------------------------------- 灯箱 --------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 44px 36px;
  background: rgba(10, 12, 10, .94);
  cursor: zoom-out;
}
.lightbox figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; max-height: 100%; }
.lightbox img {
  max-width: 100%;
  max-height: calc(100vh - 120px);
  object-fit: contain;
  background: var(--art);
  border: 1px solid rgba(255, 255, 255, .12);
}
.lightbox figcaption { font-family: var(--mono); font-size: 10.5px; color: rgba(255, 255, 255, .5); }
.lb-close {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 3px;
  color: rgba(255, 255, 255, .7);
}
.lb-close:hover { color: #fff; border-color: rgba(255, 255, 255, .4); }
.lb-close svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; }

/* ------------------------------ 其它 ---------------------------------- */

.up {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 35;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--card);
  color: var(--tx-2);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity var(--t) var(--ease), transform var(--t) var(--ease), color var(--t) var(--ease);
}
.up.on { opacity: 1; pointer-events: auto; transform: none; }
.up:hover { color: var(--mark); }
.up svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }

.empty { padding: 50px 0; font-size: 13px; color: var(--tx-3); }
.empty a { color: var(--mark); border-bottom: 1px solid var(--mark-line); }

.flash { animation: flash 1.5s var(--ease); }
@keyframes flash {
  0%, 30% { background: var(--mark-soft); }
  100% { background: transparent; }
}

.veil { display: none; }

.foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
  padding: 20px 32px 36px;
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--tx-3);
}
.foot span:last-child { text-align: right; }

/* ------------------------------ 响应式 --------------------------------- */

@media (max-width: 1240px) {
  .shell,
  body.no-rail .shell { grid-template-columns: var(--side) minmax(0, 1fr); }
  .rail { display: none; }
}

@media (max-width: 960px) {
  .shell,
  body.no-rail .shell { grid-template-columns: minmax(0, 1fr); }

  .topbar { padding: 0 12px; gap: 10px; }
  .brand { width: auto; }
  .brand-name { font-size: 14px; }
  .trail { display: none; }

  .menu-btn { display: inline-grid; }

  .side {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 55;
    width: 274px;
    height: auto;
    padding-top: 14px;
    transform: translateX(-100%);
    transition: transform 220ms var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .side.open { transform: none; }

  .veil {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(10, 12, 10, .44);
  }

  .search-trigger { width: 30px; padding: 0; justify-content: center; border-color: transparent; background: none; }
  .search-trigger .st-label,
  .search-trigger kbd { display: none; }
  .mode-tag { display: none; }

  .page { padding: 26px 18px 56px; }
  .page-head h1 { font-size: 25px; }
  .home { padding-top: 30px; }
  .home-hero h1 { font-size: 32px; }
  .groups { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .grp { padding: 14px 0 4px; }
  .grp + .grp { border-top: 1px solid var(--line); }

  .strip-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .strip-row a { height: 116px; }
  .strip-row a:nth-child(n+5) { display: none; }

  table.d { min-width: 520px; font-size: 12.5px; }
  table.d th { padding: 7px 9px; }
  table.d td { padding: 7px 9px; }
  table.d img.ic { width: 32px; height: 32px; margin-right: 5px; }

  .panels { grid-template-columns: minmax(0, 1fr); }

  .finder { padding: 8vh 12px 12px; }
  .finder-box { max-height: 76vh; }
  .foot { flex-direction: column; gap: 4px; padding: 18px 18px 30px; }
  .foot span:last-child { text-align: left; }
  .up { right: 14px; bottom: 14px; }
}

@media (max-width: 520px) {
  .home-hero h1 { font-size: 29px; letter-spacing: .08em; }
  .page-meta { font-size: 10px; }
  .sec-head h2 { font-size: 17.5px; }
  .lede { font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* =========================================================================
   悬浮目录 · 阅读进度 · 跳转链接
   ========================================================================= */

/* 阅读进度：顶栏上沿的一根线 */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 60;
  background: var(--mark);
  opacity: .75;
  transform: scaleX(0);
  transform-origin: 0 50%;
  pointer-events: none;
}

/* 键盘跳到正文 */
.skip {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 90;
  padding: 7px 13px;
  border-radius: 3px;
  background: var(--tx);
  color: var(--bg);
  font-size: 12px;
  transform: translateY(-200%);
  transition: transform 140ms var(--ease);
}
.skip:focus { transform: none; }

/* 悬浮目录：右侧下角，只在没有右栏的宽度出现 */
.fly-toc {
  display: none;
  position: fixed;
  right: 20px;
  bottom: 66px;
  z-index: 36;
}
@media (max-width: 1240px) {
  body.has-toc .fly-toc { display: block; }
}

.fly-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: var(--card);
  color: var(--tx-2);
  font-size: 12px;
  box-shadow: var(--shadow-sm);
  transition: color var(--t) var(--ease), border-color var(--t) var(--ease);
}
.fly-btn:hover { color: var(--tx); border-color: var(--tx-3); }
.fly-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.fly-btn em {
  font-style: normal;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--tx-3);
}

.fly-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: 306px;
  max-height: min(62vh, 520px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--card);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.fly-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  letter-spacing: .16em;
  color: var(--tx-3);
}
.fly-head span:last-child { font-family: var(--mono); letter-spacing: 0; }
.fly-list { overflow-y: auto; padding: 6px; overscroll-behavior: contain; }
.fly-list a {
  display: flex;
  gap: 8px;
  padding: 6px 9px;
  border-left: 2px solid transparent;
  border-radius: 2px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--tx-2);
  transition: background var(--t) var(--ease), color var(--t) var(--ease), border-color var(--t) var(--ease);
}
.fly-list a i {
  flex: none;
  font-style: normal;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--tx-3);
  opacity: .8;
  padding-top: 2px;
}
.fly-list a:hover { background: var(--hover); color: var(--tx); }
.fly-list a.on { background: var(--sunk); border-left-color: var(--mark); color: var(--mark); }
.fly-list a.on i { color: var(--mark); opacity: 1; }

@media (max-width: 520px) {
  .fly-toc { right: 14px; bottom: 60px; }
  .fly-panel { width: calc(100vw - 28px); }
}
