@font-face {
  font-family: 'ChongxiSeal';
  src: url('../fonts/ChongxiSeal.otf') format('opentype');
  font-display: swap;
}
@font-face {
  font-family: 'QuanZiKuShuowen';
  src: url('../fonts/QuanZiKuShuowen.ttf') format('truetype');
  font-display: swap;
}

:root {
  --fg: #e8dcc8;
  --fg-muted: #9a8870;
  --bg: #0d0905;
  --bg-box: #160d08;
  --bg-nav: #0a0604;
  --accent: #c89030;
  --accent-dim: #5a3a10;
  --link: #d4a040;
  --link-broken: #f85149;
  --border: #2a1608;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  --sans: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --bg-code: #160d08;
  --bg-table: #0d0905;
  --bg-stripe: #0f1419;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--fg);
  background: var(--bg);
  line-height: 1.8;
  font-size: 16px;
}

.topnav {
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  font-family: var(--sans);
  font-size: 14px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topnav-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: .6em 1.2em;
  display: flex;
  align-items: center;
  gap: 1em;
}
.topnav .brand { color: var(--accent); text-decoration: none; font-weight: 600; font-size: 15px; }
.topnav .crumb { color: var(--fg-muted); }
.topnav .spacer { flex: 1; }
.topnav-search { display: flex; align-items: center; }
.topnav-search input {
  width: 160px; padding: .3em .6em;
  border: 1px solid var(--border);
  border-radius: 4px; font-size: 13px;
  font-family: var(--sans);
  outline: none;
  background: var(--bg-code);
  color: var(--fg);
}
.topnav-search input:focus { border-color: var(--accent); width: 220px; transition: width .2s; }
body.is-home .topnav-search { display: none; }
.topnav .status { color: var(--fg-muted); font-style: italic; font-size: 12px; }
.topnav-link { color: var(--fg-muted); text-decoration: none; white-space: nowrap; }
.topnav-link:hover { color: var(--accent); }

.page {
  max-width: 1440px;
  margin: 2em auto;
  padding: 0 1.2em;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2em;
}
@media (min-width: 1200px) {
  .page { grid-template-columns: 240px minmax(0, 1fr) 380px; }
  .page > .toc-sidebar { grid-column: 1; grid-row: 1; }
  .page > article { grid-column: 2; grid-row: 1; }
  .page > aside.sidebar { grid-column: 3; grid-row: 1; }
}
body.is-home .page {
  grid-template-columns: 1fr;
}
body.is-home .page > article {
  grid-column: 1;
}
body.is-home .toc-sidebar {
  display: none;
}
@media (max-width: 1199px) {
  .toc-sidebar { display: none; }
}

article {
  padding-left: 0;
}

article h1 {
  font-size: 2em;
  margin-top: 0;
  padding-bottom: .3em;
  border-bottom: 2px solid var(--accent);
  color: var(--accent);
  display: flex;
  align-items: baseline;
  gap: .5em;
  flex-wrap: wrap;
}
article h1 .src-tab,
article h1 .orig-tab {
  font-size: .35em;
  font-weight: 400;
  font-family: var(--sans);
  color: var(--fg-muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 6px;
  margin-left: auto;
  white-space: nowrap;
}
article h1 .src-tab:first-of-type { margin-left: auto; }
article h1 .src-tab + .src-tab,
article h1 .src-tab + .orig-tab { margin-left: 0; }
article h1 .src-tab:hover,
article h1 .orig-tab:hover { color: var(--accent); border-color: var(--accent); }
article h2 {
  font-size: 1.35em;
  margin-top: 1.8em;
  padding-bottom: .2em;
  border-bottom: 1px solid var(--border);
  color: #c8a860;
  scroll-margin-top: 60px;
}
article h3 {
  font-size: 1.1em;
  margin-top: 1.4em;
  color: #c8b898;
  scroll-margin-top: 60px;
}
article h4 { font-size: 1em; margin-top: 1.2em; scroll-margin-top: 60px; }

/* H1-H6 标题内链接去样式化（排除工具栏按钮） */
h1 a:not(.src-tab):not(.orig-tab),
h2 a, h3 a, h4 a, h5 a, h6 a {
  color: inherit;
  text-decoration: none;
  pointer-events: none;
  cursor: default;
}

article p { margin: .75em 0; }
article ul, article ol { padding-left: 1.8em; margin: .5em 0; }
article li { margin: .25em 0; }

article a { color: var(--link); text-decoration: none; }
article a:hover { text-decoration: underline; }
article a.wikilink.broken { color: var(--link-broken); }
article a.wikilink.self { color: var(--fg-muted); cursor: default; pointer-events: none; }

/* 页底分类/标签 */
.entity-tags { text-align: left; margin-top: .5em; }
.tag-label { font-weight: 700; color: var(--fg-muted); font-size: .85em; font-family: var(--sans); }

/* infobox 链接与正文保持一致 */
.infobox a { color: var(--link); text-decoration: none; }
.infobox a:hover { text-decoration: underline; }
.infobox a.wikilink.broken { color: var(--link-broken); }

article blockquote {
  margin: 1em 0;
  padding: .5em 1em;
  border-left: 3px solid var(--accent-dim);
  background: var(--bg-box);
  color: var(--fg-muted);
  border-radius: 0 4px 4px 0;
}
article blockquote p { margin: .3em 0; }

article code {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: .1em .4em;
  font-size: .88em;
  font-family: monospace;
  color: #d2a679;
}
article pre code {
  display: block;
  padding: 1em;
  overflow-x: auto;
  line-height: 1.5;
}

article table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
  font-size: .92em;
  font-family: var(--sans);
}
article th { background: var(--bg-box); color: var(--accent); padding: .5em .8em; border: 1px solid var(--border); text-align: left; }
article td { padding: .4em .8em; border: 1px solid var(--border); }
article tr:nth-child(even) td { background: #0f1419; }

article hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }

article img { max-width: 100%; border-radius: 4px; }

/* seealso block — 绿色左边框，与引用块/blockquote 区分 */
.seealso-block {
  margin: .8em 0;
  padding: .4em .8em;
  background: rgba(92, 138, 66, 0.06);
  border-left: 3px solid #5c8a42;
  border-radius: 0 3px 3px 0;
  font-size: .93em;
}
.seealso-label {
  font-weight: 600;
  color: var(--accent);
  margin: 0 .4em 0 0;
  display: inline;
}
p.seealso-block { margin: .8em 0; }
p.seealso-block .seealso-label { display: inline; }
.seealso-block ul { margin: .2em 0 0 0; padding-left: 1.4em; }
.seealso-block li { margin: .15em 0; }

/* Sidebar */
.sidebar {
  font-family: var(--sans);
  font-size: .93em;
}
.infobox {
  background: var(--bg-box);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1em;
  margin-bottom: 1.2em;
}
.infobox-title {
  font-weight: 700;
  font-size: 1.05em;
  text-align: center;
  margin-bottom: .6em;
  color: var(--accent);
  padding-bottom: .4em;
  border-bottom: 1px solid var(--border);
}
.infobox table { width: 100%; font-size: .88em; }
.infobox td { padding: .25em .3em; border: none; vertical-align: top; }
.infobox td:first-child { color: var(--fg-muted); white-space: nowrap; padding-right: .6em; }
.infobox .infobox-group th {
  font-weight: 600;
  font-size: .82em;
  padding-top: .8em;
  padding-bottom: .2em;
  color: var(--fg-muted);
  border-bottom: 1px solid var(--border);
  text-align: left;
  letter-spacing: .5px;
}
.sidebar-portrait { margin: 0 0 1em; }
.sidebar-portrait img { width: 100%; border-radius: 6px; border: 1px solid var(--border); }
.sidebar-portrait figcaption { font-size: .8em; color: var(--fg-muted); text-align: center; margin-top: .3em; }

/* Left TOC sidebar */
.toc-sidebar {
  font-family: var(--sans);
  font-size: 1em;
  position: sticky;
  top: 4rem;
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
  padding-right: .5em;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.toc-sidebar::-webkit-scrollbar { width: 4px; }
.toc-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.toc-section {
  border: none;
  margin: 0;
}
.toc-section[open] > summary::before { transform: rotate(90deg); }
.toc-sidebar a {
  color: var(--fg-muted);
  text-decoration: none;
  display: block;
  padding: .2em 0;
  line-height: 1.4;
  transition: color .1s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toc-sidebar a:hover,
.toc-sidebar a.active {
  color: var(--accent);
}
.toc-h2 {
  font-size: .9em;
  margin: .15em 0;
  padding-left: .2em;
  border-left: 2px solid transparent;
}
.toc-h2 a { font-weight: 500; }
.toc-h2:hover { border-left-color: var(--accent-dim); }
.toc-h2.toc-current { border-left-color: var(--accent); }
.toc-h2.toc-current > a { color: var(--accent); }
.toc-children { padding-left: .8em; }
.toc-h3 { font-size: .84em; margin: .1em 0; }
.toc-h3 a { font-weight: 400; }
.toc-h3.toc-current > a { color: var(--accent); }
.toc-sidebar summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .4em;
  user-select: none;
}
.toc-sidebar summary::-webkit-details-marker { display: none; }
.toc-sidebar summary::before {
  content: '▶';
  font-size: .65em;
  color: var(--fg-muted);
  transition: transform .15s;
  flex-shrink: 0;
}
.toc-sidebar details[open] > summary::before { transform: rotate(90deg); }
.toc-empty {
  color: var(--fg-muted);
  font-size: .85em;
  font-style: italic;
}

/* TOC toggle button (next to h1) */
.toc-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4em;
  height: 1.4em;
  font-size: .65em;
  cursor: pointer;
  user-select: none;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  transition: color .15s, border-color .15s;
  flex-shrink: 0;
  margin-right: .15em;
}
.toc-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}
body.toc-collapsed .toc-toggle {
  color: var(--accent);
  border-color: var(--accent);
}
/* Hide TOC sidebar when collapsed */
body.toc-collapsed .toc-sidebar {
  display: none;
}
@media (min-width: 1200px) {
  body.toc-collapsed .page { grid-template-columns: minmax(0, 1fr) 380px; }
  body.toc-collapsed .page > article { grid-column: 1; }
  body.toc-collapsed .page > aside.sidebar { grid-column: 2; }
}
/* Hide toggle on mobile (where TOC is always hidden) */
@media (max-width: 1199px) {
  .toc-toggle { display: none; }
}

/* Category / type badges */
.type-badge {
  display: inline-block;
  padding: .15em .5em;
  border-radius: 3px;
  font-size: .78em;
  font-family: var(--sans);
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
}

/* Special pages */
.special-page h1 { color: var(--accent); }
.page-list { list-style: none; padding: 0; columns: 2; }
.page-list li { padding: .2em 0; }
@media (max-width: 700px) { .page-list { columns: 1; } }

/* Category page */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .6em;
  margin-top: 1em;
}
.category-card {
  background: var(--bg-box);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .6em .8em;
}
.category-card a { color: var(--link); text-decoration: none; }
.category-card a:hover { text-decoration: underline; }
.category-card .card-type { font-size: .75em; color: var(--fg-muted); }

/* Recent */
.recent-list { list-style: none; padding: 0; }
.recent-list li { padding: .4em 0; border-bottom: 1px solid var(--border); font-family: var(--sans); font-size: .92em; }
.recent-ts { color: var(--fg-muted); font-size: .82em; }
.rc-size { font-family: var(--sans); font-size: .85em; text-align: right; white-space: nowrap; font-weight: 600; }
.rc-size-plus  { color: #2a7a2a; }
.rc-size-minus { color: #c0392b; }
.rc-size-zero  { color: var(--fg-muted); font-weight: 400; }
.rc-size-mixed { color: var(--fg); }
.rc-plus  { color: #2a7a2a; }
.rc-minus { color: #c0392b; }

/* Home page — space poster hero */
body.is-home .page { padding: 0; margin-top: 0; }
body.is-home .wiki-home { max-width: none; margin: 0; }

.home-hero {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #060811;
  line-height: 1;
}
.hero-cosmos {
  display: block;
  width: 100%;
  height: clamp(260px, 36vw, 460px);
  object-fit: cover;
}
.hero-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 clamp(1.2em, 7vw, 7em) clamp(2.5em, 7vw, 5em);
  pointer-events: none;
}
.hero-eyebrow {
  font-family: "Courier New", "Courier", monospace;
  font-size: clamp(.55em, 1.1vw, .78em);
  letter-spacing: .28em;
  color: #b8861a;
  text-transform: uppercase;
  margin-bottom: .7em;
  font-weight: 400;
}
.hero-title {
  display: block;
  font-family: var(--serif);
  font-size: clamp(2.6em, 6.5vw, 5em);
  font-weight: 900;
  color: #f0e0a0;
  text-shadow: 0 2px 24px rgba(180,100,0,.5), 0 0 60px rgba(240,180,50,.18);
  line-height: 1.05;
  margin: 0 0 .35em;
  border: none;
  letter-spacing: -.01em;
}
.hero-tagline {
  font-family: var(--sans);
  font-size: clamp(.78em, 1.4vw, 1em);
  color: #c8a870;
  letter-spacing: .06em;
  font-weight: 300;
}
.hero-count {
  color: #c89030;
  font-weight: 500;
}
.hero-search {
  position: relative;
  margin-top: 1.2em;
  width: clamp(240px, 36vw, 460px);
  pointer-events: all;
}
.hero-search input {
  width: 100%;
  padding: .65em 1.1em;
  border: 1px solid rgba(200,150,40,.45);
  border-radius: 4px;
  background: rgba(6,8,17,.72);
  color: #e8e0cc;
  font-size: clamp(.85em, 1.3vw, 1em);
  font-family: var(--sans);
  outline: none;
  backdrop-filter: blur(6px);
  transition: border-color .2s, background .2s;
}
.hero-search input::placeholder { color: rgba(160,140,100,.6); }
.hero-search input:focus {
  border-color: #c89030;
  background: rgba(6,8,17,.88);
}
.hero-search #search-results {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: rgba(14,18,28,.96);
  border: 1px solid rgba(200,150,40,.35);
  border-top: none;
  border-radius: 0 0 4px 4px;
  list-style: none;
  margin: 0; padding: 0;
  z-index: 30;
  backdrop-filter: blur(8px);
}

.seal-group .seal-tip { opacity: 0; transition: opacity .2s; pointer-events: none; }
.seal-group:hover .seal-tip { opacity: 1; }

.home-body {
  max-width: none;
  margin: 0;
  padding: 1.8em clamp(1.2em, 7vw, 7em) 0;
}

/* Redirect notice */
.redirect-notice {
  background: var(--bg-box);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .4em .8em;
  font-size: .9em;
  font-family: var(--sans);
  color: var(--fg-muted);
  margin-bottom: 1em;
}
.redirect-notice a { color: var(--link); }
.redirect-arrow { margin-right: .4em; color: var(--accent); }

/* Error */
.error { color: var(--link-broken); }
.loading { color: var(--fg-muted); font-style: italic; }

/* Footer */
footer {
  max-width: 1440px;
  margin: 3em auto 1.5em;
  padding: 0 1.2em;
  font-size: .83em;
  color: var(--fg-muted);
  font-family: var(--sans);
  border-top: 1px solid var(--border);
  padding-top: 1em;
  text-align: center;
}

.footer-license {
  display: block;
  margin-top: .5em;
  text-align: center;
}
.footer-license a { color: var(--link); }

/* Source view */
.src-pre {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1em;
  font-size: .88em;
  line-height: 1.6;
}
.source-view {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1em;
  white-space: pre-wrap;
  font-family: monospace;
  font-size: .88em;
  overflow-x: auto;
  color: #c9d1d9;
}

/* History */
.history-list { list-style: none; padding: 0; }
.history-list li { padding: .4em 0; border-bottom: 1px solid var(--border); font-family: var(--sans); font-size: .9em; }

/* Stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1em;
  margin: 1em 0;
}
.stat-box {
  background: var(--bg-box);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .8em 1em;
  text-align: center;
}
.stat-box .stat-num { font-size: 2em; font-weight: 700; color: var(--accent); display: block; }
.stat-box .stat-label { font-size: .82em; color: var(--fg-muted); font-family: var(--sans); }

/* PN Citation */
.pn-label {
  color: var(--fg-muted);
  font-size: .78em;
  font-family: var(--mono, monospace);
  user-select: none;
  margin-right: .25em;
}

a.pn-citation {
  color: var(--fg-muted);
  font-size: .82em;
  text-decoration: none;
  font-family: var(--mono, monospace);
  border-bottom: 1px dotted var(--fg-muted);
  scroll-margin-top: 60px;
}
a.pn-citation:hover { color: var(--accent); border-bottom-color: var(--accent); }

@keyframes pn-flash {
  0%   { background: color-mix(in srgb, var(--accent) 30%, transparent); }
  100% { background: transparent; }
}
.pn-highlight {
  animation: pn-flash 2s ease-out forwards;
  border-radius: 3px;
}

/* Backlinks */
.backlinks {
  margin-top: 2em; padding-top: .8em;
  border-top: 1px solid var(--border);
  font-family: var(--sans); font-size: 13px;
}
.bl-heading {
  font-size: 13px; font-weight: 600;
  color: var(--fg-muted); margin: 0 0 .5em;
  text-transform: none; letter-spacing: 0;
  border: none; padding: 0;
}
.bl-body {
  display: flex; flex-wrap: wrap; gap: .6em 0;
  line-height: 1.6;
}
.bl-group {
  display: inline-flex; align-items: baseline; gap: .4em; flex-wrap: wrap;
  margin-right: 1.2em;
}
.bl-group-label {
  font-size: 11px; color: var(--fg-muted);
  background: var(--bg-box); border: 1px solid var(--border);
  border-radius: 3px; padding: 1px 5px;
  white-space: nowrap; flex-shrink: 0;
}
.bl-link {
  color: var(--link); text-decoration: none; font-size: 13px;
}
.bl-link::after {
  content: '·';
  margin-left: .4em;
  color: var(--border);
}
.bl-link:last-of-type::after { content: ''; }
.bl-link:hover { text-decoration: underline; }

/* Book TOC (home page) */
.book-toc {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: .5em 0;
  background: var(--bg-box);
}
.book-toc-title {
  padding: .7em 1em;
  cursor: pointer;
  font-weight: 600;
  font-family: var(--sans);
  list-style: none;
  display: flex;
  align-items: center;
  gap: .6em;
}
.book-toc-title::-webkit-details-marker { display: none; }
.book-toc-title::before { content: '▶'; font-size: .7em; color: var(--fg-muted); transition: transform .15s; }
details[open] .book-toc-title::before { transform: rotate(90deg); }
.book-chap-count { font-size: .8em; color: var(--fg-muted); font-weight: 400; margin-left: auto; }
.book-chap-list {
  padding: .5em 1em .8em;
  display: flex;
  flex-wrap: wrap;
  gap: .3em .5em;
  border-top: 1px solid var(--border);
}
a.book-chap-link {
  font-size: .85em;
  color: var(--fg-muted);
  text-decoration: none;
  padding: .15em .4em;
  border-radius: 3px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
a.book-chap-link:hover { color: var(--accent); border-color: var(--accent); }

/* Chapter prev/next nav */
.chapnav {
  display: flex;
  align-items: center;
  gap: .5em;
  padding: .6em 0;
  margin: .8em 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-family: var(--sans);
  font-size: .88em;
}
.chapnav a, .chapnav span { text-decoration: none; padding: .3em .6em; border-radius: 4px; }
.chapnav-prev { margin-right: auto; }
.chapnav-next { margin-left: auto; }
.chapnav a { color: var(--accent); border: 1px solid var(--border); }
.chapnav a:hover { background: var(--bg-box); }
.chapnav-disabled { color: var(--fg-muted); }
.chapnav-toc { color: var(--fg-muted) !important; font-size: .85em; border: 1px solid var(--border); }
.chapnav-toc:hover { background: var(--bg-box); color: var(--fg) !important; }

/* ── 阅读进度条 ────────────────────────────────────── */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), #e8b840);
  z-index: 100;
  width: 0%;
  transition: width 0.1s linear;
}
body.is-home .reading-progress { display: none; }

/* ── 章节原文排版增强 ──────────────────────────────── */

/* 通用：段落间距加大 */
article[data-type="chapter"] p {
  margin: 1.1em 0;
}

/* Mobile (<1200px)：PN 编号保留在段首 */
@media (max-width: 1199px) {
  article[data-type="chapter"] .pn-label {
    color: var(--fg-muted);
    margin-right: 0.35em;
  }
}

/* Desktop (≥1200px)：PN 编号浮动到 article 左边 */
@media (min-width: 1200px) {
  article[data-type="chapter"] {
    padding-left: 6.5em;
  }
  article[data-type="chapter"] .pn-label {
    float: left;
    margin-left: -6.8em;
    width: 6em;
    text-align: right;
    clear: both;
    color: var(--fg-muted);
    font-size: 0.72em;
    font-family: var(--mono, monospace);
  }
}

/* 诗词检测 —— 短行连续段自动识别 */
article[data-type="chapter"] .chapter-poem {
  font-family: var(--serif);
  line-height: 2.1;
  font-size: 1.02em;
  color: #e8dcb8;
  margin: 0;
}
article[data-type="chapter"] .chapter-poem .pn-label {
  color: var(--fg-muted);
}
@media (min-width: 1200px) {
  article[data-type="chapter"] .chapter-poem-short {
    text-align: center;
  }
  article[data-type="chapter"] .chapter-poem-short .pn-label {
    width: 5.5em;
  }
}

/* 对话高亮——「」内文字 */
.dialog-text {
  background: rgba(210, 155, 40, 0.22);
  border-radius: 2px;
  padding: 0 2px;
}

/* 对话续段缩进：同一对话拆成多段后，第二段起缩进两个汉字 */
.dialogue-cont { padding-left: 2em; }

/* Quality badges */
.res-quality { border-radius: 3px; padding: 1px 5px; font-size: .82em; font-weight: 500; font-family: var(--sans); white-space: nowrap; }
.res-quality-premium  { background: #e9d8fd; color: #553c9a; }
.res-quality-featured { background: #bee3f8; color: #2b6cb0; }
.res-quality-standard { background: #c6f6d5; color: #276749; }
.res-quality-basic    { background: #fefcbf; color: #744210; }
.res-quality-stub     { background: #fed7d7; color: #822727; }

/* Page-level quality badge (在 crumb/面包屑中) */
.page-quality,
.page-quality-score {
  border-radius: 3px; padding: 0 5px; font-size: .82em; font-weight: 500;
  font-family: var(--sans); white-space: nowrap; vertical-align: middle;
}
.page-quality-premium  { background: #e9d8fd; color: #553c9a; }
.page-quality-featured { background: #bee3f8; color: #2b6cb0; }
.page-quality-standard { background: #c6f6d5; color: #276749; }
.page-quality-score    { background: #e2e8f0; color: #4a5568; margin-left: 3px; }

/* Home page wrapper */
.wiki-home {
  max-width: 960px;
  margin: 0 auto;
}
.wiki-home .home-body h1 {
  text-align: center;
  border-bottom: none;
  margin-bottom: .2em;
}
.wiki-home .tagline {
  text-align: center;
  color: var(--fg-muted);
  margin-top: 0;
  margin-bottom: 1.4em;
}
.wiki-home .search-box {
  max-width: 520px;
  margin: 0 auto 1.8em;
  position: relative;
}
.wiki-home .search-box #wiki-search {
  width: 100%;
  box-sizing: border-box;
  padding: .6em 1em;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-code);
  color: var(--fg);
  font-size: 1em;
  font-family: var(--sans);
  outline: none;
}
.wiki-home .search-box #wiki-search:focus { border-color: var(--accent); }
#search-results {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--bg-box);
  border: 1px solid var(--border);
  border-radius: 0 0 6px 6px;
  list-style: none;
  margin: 0; padding: 0;
  z-index: 20;
}
#search-results li { border-bottom: 1px solid var(--border); }
#search-results li:last-child { border-bottom: none; }
#search-results a {
  display: flex;
  align-items: center;
  gap: .5em;
  padding: .5em .9em;
  text-decoration: none;
  color: var(--fg);
  font-size: .9em;
}
#search-results a:hover { background: var(--bg-code); }
.match-label { font-weight: 500; }
.match-alt { color: var(--fg-muted); font-size: .85em; }
.match-meta { margin-left: auto; color: var(--fg-muted); font-size: .8em; }
.search-empty { padding: .5em .9em; color: var(--fg-muted); font-size: .9em; }
.wiki-home .home-links {
  display: flex;
  justify-content: center;
  gap: 1.5em;
  flex-wrap: wrap;
  margin: 1em 0;
}
.home-link {
  color: var(--accent);
  text-decoration: none;
  font-family: var(--sans);
  font-size: .9em;
}
.home-link:hover { text-decoration: underline; }
.wiki-home .home-disclaimer {
  text-align: center;
  font-size: .8em;
  color: var(--fg-muted);
  margin-top: 2em;
}

.wiki-home .home-epigraph {
  margin: 2.5em auto 0;
  max-width: 28em;
  text-align: center;
  border: none;
  padding: 0;
  font-family: var(--serif);
  color: var(--fg-muted);
}
.wiki-home .home-epigraph p {
  margin: 0;
  line-height: 2;
  letter-spacing: .05em;
  font-size: .95em;
}
.wiki-home .home-epigraph footer {
  margin-top: .8em;
  font-size: .8em;
  opacity: .6;
}

/* ── 卡片网格（古典悲剧美学 · 冷金清雅） ────────────────────── */
.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1em;
  margin: 1em 0 1.8em;
}

/* Entity cards */
.featured-card {
  background: #0f0c08;
  border: 1px solid rgba(160,140,100,.65);
  border-radius: 2px;
  overflow: hidden;
  text-decoration: none;
  color: var(--fg);
  display: flex;
  flex-direction: column;
  padding: 1.15em 1.15em .9em;
  position: relative;
  transition: border-color .25s, background .25s;
}
/* 书脑 — 左侧装订边 */
.featured-card::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: -1px;
  width: 5px;
  background: rgba(20,15,10,.75);
  border-left: 2px solid var(--card-accent, rgba(180,155,100,.7));
  border-radius: 1px 0 0 1px;
  pointer-events: none;
}
.featured-card:hover {
  background: #12100b;
  border-color: rgba(180,155,100,.85);
  text-decoration: none;
}
/* 标题行（标题 + 印章标签） */
/* 首页卡片缩略图 */
.card-thumb {
  width: calc(100% + 2.3em);
  height: 220px;
  overflow: hidden;
  background: var(--bg-box);
  flex-shrink: 0;
  margin: -1.15em -1.15em 1em;
}
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  transition: transform .2s;
}
.featured-card:hover .card-thumb img {
  transform: scale(1.04);
}

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5em;
  margin-bottom: .3em;
}
.card-header h3 {
  margin: 0;
  font-size: 1.08em;
  font-weight: 600;
  font-family: var(--serif);
  color: #c0a878;
  line-height: 1.3;
  letter-spacing: .03em;
  min-width: 0;
}
/* 印章式类型标签 */
.featured-card .card-eyebrow {
  font-size: .78em;
  font-family: var(--sans);
  letter-spacing: .06em;
  font-weight: 500;
  flex-shrink: 0;
  padding: .08em .5em;
  border-radius: 2px;
  color: #f0e8d0;
  background: var(--card-accent, #5a4a3a);
}
/* 人物用朱砂印泥红 */
.card-t-person .card-eyebrow {
  background: #c04a30;
}
.featured-card .card-desc {
  font-size: .8em;
  color: #7a6a5a;
  line-height: 1.5;
  margin-top: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Type accent palette — 红楼梦 */
.card-t-person       { --card-accent: #c89030; }
.card-t-family       { --card-accent: #b84040; }
.card-t-place        { --card-accent: #3a8870; }
.card-t-object       { --card-accent: #8a6020; }
.card-t-event        { --card-accent: #c87820; }
.card-t-poem         { --card-accent: #a060a8; }
.card-t-chapter      { --card-accent: #607080; }
.card-t-concept      { --card-accent: #4a78c0; }
.card-t-organization { --card-accent: #7050b8; }
.card-t-quote        { --card-accent: #b89050; }
.card-t-overview     { --card-accent: #507888; }
.card-t-list         { --card-accent: #607070; }

/* Article left-border accent per type */
article[data-type="person"]       { border-left-color: #c89030; }
article[data-type="family"]       { border-left-color: #b84040; }
article[data-type="place"]        { border-left-color: #3a8870; }
article[data-type="object"]       { border-left-color: #8a6020; }
article[data-type="music"]        { border-left-color: #8a6020; }
article[data-type="event"]        { border-left-color: #c87820; }
article[data-type="poem"]         { border-left-color: #a060a8; }
article[data-type="chapter"]      { border-left-color: #607080; }
article[data-type="concept"]      { border-left-color: #4a78c0; }
article[data-type="organization"] { border-left-color: #7050b8; }
article[data-type="quote"]        { border-left-color: #b89050; }
article[data-type="overview"]     { border-left-color: #507888; }
article[data-type="list"]         { border-left-color: #607070; }
article[data-type="book"]         { border-left-color: #607080; }
article[data-type="story"]        { border-left-color: #c87820; }
article[data-type="time"]         { border-left-color: #507888; }
article[data-type="food"]         { border-left-color: #8a6020; }
article[data-type="medicine"]     { border-left-color: #8a6020; }
article[data-type="game"]         { border-left-color: #607070; }
article[data-type="animal"]       { border-left-color: #3a8870; }
article[data-type="plant"]        { border-left-color: #3a8870; }
article[data-type="clothing"]     { border-left-color: #8a6020; }
article[data-type="painting"]     { border-left-color: #8a6020; }
article[data-type="mythology"]    { border-left-color: #4a78c0; }
article[data-type="ritual"]       { border-left-color: #7050b8; }
article[data-type="symbol"]       { border-left-color: #4a78c0; }
article[data-type="skill"]        { border-left-color: #4a78c0; }

/* Book cards — full-width horizontal strips */
.featured-card.book-card {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  gap: 0;
  padding: 0;
  background: #0a0806;
  border-radius: 4px;
  overflow: visible;
}
.featured-card.book-card:hover {
  background: #0e0b07;
}
.bc-numeral {
  font-size: 2.2em;
  font-weight: 400;
  font-family: 'ChongxiSeal', var(--serif);
  color: rgba(192,168,120,.45);
  line-height: 1;
  min-width: 2.6em;
  text-align: center;
  text-decoration: none;
  padding: .6em .1em .6em .5em;
  flex-shrink: 0;
  letter-spacing: 0;
  transition: color .2s;
}
.bc-numeral:hover { color: rgba(192,168,120,.75); }
.bc-body {
  flex: 1;
  padding: .65em 1.1em .65em .2em;
  min-width: 0;
}
.bc-head {
  display: flex;
  align-items: baseline;
  gap: .7em;
  margin-bottom: .4em;
}
.bc-title {
  font-size: 1em;
  font-weight: 600;
  font-family: var(--serif);
  color: #c0a878;
  text-decoration: none;
}
.bc-title:hover { color: #d0b888; }
.bc-sub {
  font-size: .72em;
  color: #6a5a4a;
  font-family: var(--sans);
  letter-spacing: .06em;
}
.bc-chapters {
  display: flex;
  flex-wrap: wrap;
  gap: .2em .35em;
}
.bc-chap {
  font-size: .73em;
  color: #5a6a5a;
  text-decoration: none;
  white-space: nowrap;
  transition: color .2s;
}
.bc-chap:hover { color: #c0a878; }
.bc-more {
  font-size: .73em;
  color: #5a4a3a;
}

/* ── Special:AllPages ─────────────────────────────────────────────── */
.allpages-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.5em;
  align-items: start;
}
@media (max-width: 700px) {
  .allpages-layout { grid-template-columns: 1fr; }
}
.allpages-mobile { padding: 0; }
.ap-mobile-filters {
  display: flex;
  flex-direction: column;
  gap: .5em;
  margin-bottom: 1em;
}
.ap-type-select {
  width: 100%;
  padding: .45em .7em;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: .95em;
  background: var(--bg-box);
  color: var(--fg);
  box-sizing: border-box;
}
.ap-type-select:focus { outline: none; border-color: var(--accent); }

/* 分面侧栏 */
.facet-panel {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .75em;
  font-size: .9em;
  font-family: var(--sans);
  position: sticky;
  top: 4rem;
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
  background: var(--bg-box);
}
.facet-reset-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .6em;
}
.facet-reset-btn {
  font-size: .8em;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: none;
  cursor: pointer;
  color: var(--fg-muted);
}
.facet-reset-btn:hover { color: var(--accent); border-color: var(--accent); }
.facet-group { margin-bottom: .5em; }
.facet-group-title {
  font-weight: 600;
  font-size: .82em;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--fg-muted);
  cursor: pointer;
  padding: .3em 0;
  list-style: none;
  user-select: none;
}
.facet-group-title::marker { display: none; }
.facet-group summary::-webkit-details-marker { display: none; }
.facet-items {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: .2em 0 .4em;
}
.facet-tags { max-height: 200px; overflow-y: auto; }
.facet-item {
  display: flex;
  align-items: center;
  gap: .4em;
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1.35;
}
.facet-item:hover { background: var(--bg); }
.facet-item.active { background: var(--bg); }
.facet-item input { accent-color: var(--accent); flex-shrink: 0; }
.facet-label { flex: 1; }
.facet-count { font-size: .8em; color: var(--fg-muted); font-variant-numeric: tabular-nums; }

/* 搜索栏 */
.allpages-search-row { margin-bottom: .8em; }
.allpages-search {
  width: 100%;
  padding: .45em .7em;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: .95em;
  background: var(--bg-box);
  color: var(--fg);
  box-sizing: border-box;
  font-family: var(--sans);
}
.allpages-search:focus { outline: none; border-color: var(--accent); }

/* 结果列表 */
.res-header { font-size: .88em; color: var(--fg-muted); margin-bottom: .6em; }
.res-header strong { color: var(--fg); }
.res-list { list-style: none; margin: 0; padding: 0; }
.res-item { padding: .5em 0; border-bottom: 1px solid var(--border); }
.res-title {
  font-weight: 500;
  text-decoration: none;
  color: var(--link);
  font-family: var(--sans);
}
.res-title:hover { text-decoration: underline; color: var(--accent); }
.res-desc { font-size: .85em; color: var(--fg-muted); margin: .15em 0 .2em; }
.res-meta {
  margin-top: .25em;
  font-size: .8em;
  color: var(--fg-muted);
  display: flex;
  flex-wrap: wrap;
  gap: .3em;
  align-items: center;
  font-family: var(--sans);
}
.res-type {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
}
.res-score { color: var(--fg-muted); }
.res-tag { background: var(--bg); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; }
.res-empty { color: var(--fg-muted); padding: 1.5em 0; font-style: italic; list-style: none; }

/* 分页 */
.pager { display: flex; gap: .3em; margin-top: 1em; flex-wrap: wrap; align-items: center; }
.pager-btn {
  display: inline-block;
  padding: .3em .65em;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-decoration: none;
  font-size: .88em;
  color: var(--link);
  background: var(--bg-box);
  font-family: var(--sans);
}
.pager-btn:hover { border-color: var(--accent); color: var(--accent); }
.pager-btn.active { background: var(--accent); color: #000; border-color: var(--accent); }
.pager-ellipsis { color: var(--fg-muted); padding: .3em .2em; }

/* ---------- 版本 diff 页 ---------- */
.diff-meta {
  background: var(--bg-box);
  padding: .8em 1em;
  border-radius: 4px;
  margin: 1em 0 1.5em;
  font-family: var(--sans);
  font-size: .9em;
  line-height: 1.6;
}
.diff-meta code { background: var(--bg); padding: 1px 4px; border-radius: 2px; font-size: .88em; }
.diff-meta .diff-summary { margin-top: .4em; color: var(--fg-muted); }
.diff-added   { color: #3fb950; font-weight: 600; }
.diff-removed { color: #f85149; font-weight: 600; }
.diff-body {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow-x: auto;
}
.diff-line {
  display: flex;
  padding: 1px 8px;
  white-space: pre-wrap;
  word-break: break-word;
}
.diff-sign {
  flex: 0 0 1.5em;
  color: var(--fg-muted);
  -webkit-user-select: none;
  user-select: none;
  text-align: center;
}
.diff-text { flex: 1; }
.diff-same { background: var(--bg); color: var(--fg); }
.diff-add  { background: #0f4429; color: #3fb950; }
.diff-add .diff-sign { color: #3fb950; font-weight: 600; }
.diff-del  { background: #4b1113; color: #f85149; }
.diff-del .diff-sign { color: #f85149; font-weight: 600; }
.sep { color: var(--border); margin: 0 .4em; }

/* ───── 全文检索 (FTS) ───── */
.search-mode-toggle {
  display: flex;
  align-items: center;
  gap: .4em;
  margin-top: .35em;
  font-size: .82em;
  font-family: var(--sans);
  pointer-events: all;
}
.mode-opt {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: .3em;
  color: rgba(160,140,100,.7);
  white-space: nowrap;
}
.mode-opt input[type="checkbox"] {
  accent-color: #c89030;
  cursor: pointer;
}

.fts-item a {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .3em .6em;
  padding: .5em .8em;
}
.fts-chap {
  color: #c89030;
  font-size: .82em;
  font-weight: 500;
  white-space: nowrap;
}
.fts-pn {
  color: rgba(160,140,100,.5);
  font-size: .75em;
  font-family: monospace;
}
.fts-snip {
  width: 100%;
  font-size: .88em;
  color: #c8c0b0;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fts-title {
  color: rgba(160,140,100,.45);
  font-size: .75em;
  margin-left: auto;
  white-space: nowrap;
}
.fts-hl {
  background: rgba(200,150,40,.25);
  color: #f0d890;
  padding: 0 1px;
  border-radius: 2px;
}
.fts-all a {
  display: block;
  padding: .5em .8em;
  text-align: center;
  font-size: .85em;
  color: #c89030;
  border-top: 1px solid #2a2010;
  transition: background .1s;
}
.fts-all a:hover { background: rgba(200,150,40,.08); }
