:root {
  --fg: #1a1a1a;
  --fg-muted: #666;
  --bg: #fafaf7;
  --bg-box: #f0ece0;
  --accent: #7a1f1f;
  --accent-deep: #4a1212;
  --xuanqing: #1b3a4b;
  --gold: #e8d5a3;
  --gold-soft: #dcc090;
  --link: #1a5490;
  --link-broken: #c44;
  --border: #d8d2bf;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  --sans: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--serif);
  color: var(--fg);
  background: var(--bg);
  line-height: 1.75;
  font-size: 17px;
}

a { color: var(--link); }

/* ---------- Topnav ---------- */
.topnav {
  background: #fff;
  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;
  flex-wrap: wrap;
}
.topnav .brand {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .04em;
}
.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: #fff;
  color: var(--fg);
}
.topnav-search input:focus {
  border-color: var(--accent);
  width: 220px;
  transition: width .2s;
}
body.is-home .topnav-search { display: none; }
.topnav-link {
  color: var(--xuanqing);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}
.topnav-link:hover { color: var(--accent); text-decoration: underline; }
.topnav .status {
  color: var(--fg-muted);
  font-style: italic;
  font-size: 12px;
}

/* ---------- Page layout ---------- */
.page {
  max-width: 1440px;
  margin: 2em auto;
  padding: 0 1.2em;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2em;
}
@media (min-width: 1200px) {
  .page:not(.is-home-layout) {
    grid-template-columns: minmax(0, 1fr) 340px;
  }
  .page:not(.is-home-layout) > article { grid-column: 1; grid-row: 1; }
  .page:not(.is-home-layout) > aside.sidebar { grid-column: 2; grid-row: 1; }
}

body.is-home .page {
  grid-template-columns: 1fr;
  padding: 0;
  margin-top: 0;
  max-width: none;
}

/* ---------- Article typography ---------- */
article h1 {
  font-size: 2em;
  margin-top: 0;
  padding-bottom: .3em;
  border-bottom: 2px solid var(--accent);
  color: var(--accent);
}
article h2 {
  font-size: 1.35em;
  margin-top: 1.8em;
  padding-bottom: .2em;
  border-bottom: 1px solid var(--border);
}
article h3 {
  font-size: 1.1em;
  margin-top: 1.4em;
  color: var(--accent);
}
article p { margin: .5em 0; }
article ul, article ol { padding-left: 1.4em; }
article li { margin: .3em 0; }
article blockquote {
  margin: .8em 0;
  padding: .6em 1em;
  border-left: 3px solid var(--accent);
  background: var(--bg-box);
  color: var(--fg-muted);
  font-size: .95em;
}
article table {
  border-collapse: collapse;
  margin: 1em 0;
  font-size: .93em;
  width: 100%;
}
article th, article td {
  padding: .35em .8em;
  border: 1px solid var(--border);
  text-align: left;
}
article th { background: var(--bg-box); font-weight: 600; }
article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}
article code {
  background: var(--bg-box);
  padding: .1em .35em;
  border-radius: 3px;
  font-size: .9em;
}

/* ---------- Sidebar / infobox ---------- */
aside.sidebar {
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: .8em;
}
.infobox {
  background: var(--bg-box);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1em;
  font-size: .9em;
}
.infobox h2 {
  margin: 0 0 .6em 0;
  font-size: 1.1em;
  padding-bottom: .3em;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
}
.infobox table { width: 100%; border: none; margin: 0; }
.infobox th, .infobox td {
  border: none;
  padding: .25em .3em;
  vertical-align: top;
  background: transparent;
}
.infobox th {
  color: var(--fg-muted);
  font-weight: 500;
  width: 4.8em;
  white-space: nowrap;
}
/* ---------- Infobox figure（图示管线阶段 A） ---------- */
.infobox-figure { margin: 0 0 .8em 0; }
.infobox-figure img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 28em;
  object-fit: contain;
  background: #fff;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.infobox-figure figcaption {
  margin-top: .45em;
  font-size: .78em;
  line-height: 1.55;
  color: var(--fg-muted);
  overflow-wrap: break-word;
}
.infobox-figure .fig-title { font-weight: 600; }
.infobox-figure .fig-credit a { color: var(--link); }
.infobox-figure .fig-note { margin-top: .2em; }
@media (max-width: 700px) {
  .infobox-figure img { max-height: 60vh; object-fit: contain; }
}

/* ---------- Wikilinks ---------- */
.wikilink.resolved {
  color: var(--link);
  text-decoration: none;
}
.wikilink.resolved:hover { text-decoration: underline; }
/* 站点自动链类型（scripts/link_chapter_entities.py 生成 data-type）：可区分但不花哨 */
.wikilink-person {
  color: #7a1f1f;
  text-decoration: underline;
  text-decoration-color: rgba(122, 31, 31, .45);
  text-underline-offset: 2px;
}
.wikilink-person:hover { color: var(--accent-deep); }
.wikilink-concept {
  color: var(--link);
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}
.wikilink-place {
  color: var(--xuanqing);
  text-decoration: underline dashed;
  text-underline-offset: 2px;
}
.wikilink-institution {
  color: #6b4a1e;
  background: rgba(232, 213, 163, .22);
  border-radius: 2px;
  padding: 0 1px;
  text-decoration: underline dashed;
  text-underline-offset: 2px;
}
.wikilink-office {
  color: #4b3a6b;
  background: rgba(192, 132, 252, .12);
  border-radius: 2px;
  padding: 0 1px;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}
.wikilink.self {
  color: var(--fg);
  font-weight: 600;
  text-decoration: none;
  cursor: default;
}
.wikilink.broken {
  color: var(--link-broken);
  text-decoration: underline dashed;
  cursor: help;
}

/* ---------- Hero ---------- */
.home-hero {
  position: relative;
  width: 100%;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 20% 30%, rgba(27, 58, 75, .35), transparent 50%),
    radial-gradient(ellipse at 80% 60%, rgba(232, 213, 163, .12), transparent 45%),
    linear-gradient(160deg, var(--accent-deep) 0%, var(--accent) 45%, #5c1818 100%);
  min-height: clamp(280px, 42vw, 420px);
  display: flex;
  align-items: flex-end;
}
.home-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .18;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cpath fill='none' stroke='%23e8d5a3' stroke-width='1' d='M10 60c20-30 40-30 60 0s40 30 60 0M10 30c20-20 40-20 60 0s40 20 60 0M10 90c20-20 40-20 60 0s40 20 60 0'/%3E%3C/svg%3E");
  background-size: 160px 160px;
  pointer-events: none;
}
.hero-overlay {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 0 0 clamp(2em, 6vw, 3.5em);
}
.hero-overlay-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 1.2em;
}
.hero-eyebrow {
  font-family: var(--sans);
  font-size: clamp(.7em, 1.2vw, .85em);
  letter-spacing: .28em;
  color: var(--gold);
  margin-bottom: .7em;
}
.hero-title {
  font-family: var(--serif);
  font-size: clamp(2.4em, 6vw, 4.4em);
  font-weight: 900;
  color: var(--gold);
  line-height: 1.05;
  margin: 0 0 .35em;
  border: none;
  text-shadow: 0 2px 24px rgba(0,0,0,.35);
}
.hero-tagline {
  font-family: var(--sans);
  font-size: clamp(.85em, 1.4vw, 1em);
  color: var(--gold-soft);
  letter-spacing: .04em;
  font-weight: 300;
  margin: 0;
}
.hero-count {
  color: #c89030;
  font-weight: 600;
}
.hero-seal {
  position: absolute;
  bottom: clamp(1em, 3vw, 2em);
  right: clamp(1em, 4vw, 3em);
  z-index: 2;
  width: clamp(56px, 8vw, 84px);
  height: clamp(56px, 8vw, 84px);
  border: 2px solid var(--gold);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-family: var(--serif);
  font-size: clamp(1.6em, 3vw, 2.4em);
  font-weight: 900;
  background: rgba(27, 58, 75, .55);
  box-shadow: 0 0 0 4px rgba(232, 213, 163, .15);
  cursor: default;
  user-select: none;
}
.hero-search {
  margin-top: 1.2em;
  max-width: 480px;
  position: relative;
}
.hero-search input {
  width: 100%;
  padding: .55em 1em;
  font-size: 1em;
  border: 1px solid rgba(232, 213, 163, .35);
  border-radius: 6px;
  background: rgba(20, 12, 8, .55);
  color: #f5eab5;
  font-family: var(--serif);
  outline: none;
}
.hero-search input::placeholder { color: #a09070; }
.hero-search input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(232, 213, 163, .15);
}

#search-results {
  list-style: none;
  margin: .4em 0 0;
  padding: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 360px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  position: absolute;
  left: 0;
  right: 0;
  z-index: 5;
}
.search-result-item { border-bottom: 1px solid var(--border); }
.search-result-item:last-child { border-bottom: none; }
.search-result-item a {
  display: flex;
  align-items: center;
  gap: .6em;
  padding: .55em .8em;
  text-decoration: none;
  color: inherit;
}
.search-result-item a:hover { background: var(--bg-box); }
.match-label { font-weight: 600; color: var(--accent); }
.match-alt { color: var(--fg-muted); font-size: .9em; }
.match-meta { margin-left: auto; color: var(--fg-muted); font-size: .85em; }
.search-empty {
  padding: .6em .8em;
  color: var(--fg-muted);
  font-style: italic;
}

/* ---------- Home body ---------- */
.home-body {
  max-width: 1440px;
  margin: 0 auto;
  padding: 2em 1.2em 3em;
}
.home-disclaimer {
  font-size: .88em;
  color: var(--fg-muted);
  background: #f8f6f0;
  border-left: 3px solid var(--xuanqing);
  padding: .55em .85em;
  margin: 1.2em 0;
  border-radius: 0 4px 4px 0;
}

.home-featured-intro {
  margin: .2em 0 1.4em;
  padding-bottom: .9em;
  border-bottom: 1px solid var(--border);
}
.home-featured-title {
  margin: 0 0 .25em;
  font-size: 1.45em;
  color: var(--accent-deep);
  letter-spacing: .12em;
  border: none;
  padding: 0;
}
.home-featured-lead {
  margin: 0;
  font-family: var(--sans);
  font-size: .95em;
  color: var(--fg-muted);
  letter-spacing: .04em;
}

.featured-sections {
  display: flex;
  flex-direction: column;
  gap: 1.75em;
  margin: 0 0 2em;
}
.featured-section {
  position: relative;
  padding: 1.05em 1.1em 1.15em;
  background: linear-gradient(180deg, #fffcf5 0%, #f7f3e8 100%);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 1px 0 rgba(232, 213, 163, .55) inset;
}
.featured-section-head {
  display: flex;
  align-items: center;
  gap: .85em;
  margin: 0 0 1em;
  padding-bottom: .75em;
  border-bottom: 1px solid rgba(216, 210, 191, .9);
}
.featured-section-mark {
  flex: 0 0 auto;
  width: 2.1em;
  height: 2.1em;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-weight: 900;
  font-size: 1.05em;
  color: var(--gold);
  background: var(--accent-deep);
  border: 1px solid var(--gold-soft);
  border-radius: 4px;
  letter-spacing: 0;
  box-shadow: 0 1px 3px rgba(74, 18, 18, .25);
}
.featured-section-titles {
  flex: 1;
  min-width: 0;
}
.featured-section-titles h2 {
  margin: 0;
  font-size: 1.28em;
  color: var(--accent);
  border: none;
  padding: 0;
  letter-spacing: .18em;
}
.featured-section-note {
  margin: .15em 0 0;
  font-family: var(--sans);
  font-size: .82em;
  color: var(--fg-muted);
  letter-spacing: .06em;
}
.featured-section-more {
  flex: 0 0 auto;
  font-family: var(--sans);
  font-size: .86em;
  color: var(--xuanqing);
  text-decoration: none;
  border: 1px solid rgba(27, 58, 75, .28);
  border-radius: 999px;
  padding: .28em .85em;
  background: rgba(255, 255, 255, .7);
  white-space: nowrap;
}
.featured-section-more:hover {
  color: #fff;
  background: var(--xuanqing);
  border-color: var(--xuanqing);
}
.featured-section-emperors {
  border-top: 3px solid var(--accent);
}
.featured-section-generals {
  border-top: 3px solid var(--xuanqing);
}
.featured-section-events {
  border-top: 3px solid #6b4a1e;
}

.featured-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: .85em;
  margin: 0;
  align-items: stretch;
}
@media (max-width: 1100px) {
  .featured-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .featured-section { padding: .9em; }
}
@media (max-width: 700px) {
  .featured-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .featured-section-head { flex-wrap: wrap; }
  .featured-section-more { margin-left: auto; }
}
.featured-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.featured-card:hover {
  border-color: var(--accent);
  box-shadow: 0 3px 12px rgba(122, 31, 31, .12);
  transform: translateY(-2px);
}
.card-thumb {
  height: auto;
  aspect-ratio: 3 / 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .35em;
  color: var(--gold);
  font-family: var(--serif);
  letter-spacing: .05em;
  position: relative;
  overflow: hidden;
  background: #f3ead4;
}
.card-thumb::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .22;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cpath fill='none' stroke='%23e8d5a3' stroke-width='1' d='M0 40c14-18 26-18 40 0s26 18 40 0'/%3E%3C/svg%3E");
  background-size: 80px 80px;
  pointer-events: none;
}
.card-thumb.thumb-entity {
  background: linear-gradient(145deg, #4a1212 0%, #7a1f1f 55%, #1b3a4b 120%);
}
.card-thumb.thumb-concept {
  background: linear-gradient(145deg, #122633 0%, #1b3a4b 50%, #7a1f1f 120%);
}
.card-thumb.thumb-source {
  background: linear-gradient(145deg, #3d2a12 0%, #6b4a1e 50%, #1b3a4b 120%);
}
.thumb-glyph {
  position: relative;
  z-index: 1;
  font-size: 2.8em;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 12px rgba(0,0,0,.35);
}
.thumb-type {
  position: relative;
  z-index: 1;
  font-family: var(--sans);
  font-size: .72em;
  letter-spacing: .18em;
  color: rgba(232, 213, 163, .85);
  border: 1px solid rgba(232, 213, 163, .35);
  border-radius: 999px;
  padding: .15em .7em;
  background: rgba(0,0,0,.18);
}
.card-thumb img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
}
.card-thumb.thumb-map img {
  object-position: center center;
}
.card-thumb.thumb-portrait::after,
.card-thumb.thumb-map::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(232, 213, 163, .55);
  box-shadow: inset 0 0 0 1px rgba(74, 18, 18, .12);
  pointer-events: none;
  z-index: 2;
}
.card-thumb:has(img)::before {
  display: none;
}
.card-body {
  padding: .85em 1em 1em;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.featured-card h3 {
  margin: 0 0 .3em;
  font-size: 1.08em;
  line-height: 1.3;
  height: 2.6em;
  color: var(--accent);
  border: none;
  padding: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-life {
  font-size: .85em;
  line-height: 1.35;
  height: 1.35em;
  overflow: hidden;
  color: var(--fg-muted);
  margin-bottom: .3em;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.card-meta {
  font-size: .88em;
  line-height: 1.35;
  height: 1.35em;
  overflow: hidden;
  margin-bottom: .25em;
  white-space: nowrap;
}
.card-meta strong {
  color: var(--accent);
  font-weight: 600;
}
.card-aliases {
  font-size: .82em;
  line-height: 1.4;
  color: var(--fg-muted);
  margin-top: auto;
  padding-top: .4em;
  border-top: 1px dashed var(--border);
  height: 3.2em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.home-links {
  margin-top: 1.5em;
  padding-top: 1em;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: .8em;
  font-family: var(--sans);
}
.home-link {
  color: var(--accent);
  text-decoration: none;
  font-size: .95em;
  padding: .3em .7em;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: all .15s;
}
.home-link:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.k-panel {
  margin-top: 2.2em;
  padding: 1.1em 1.3em;
  border-top: 2px solid var(--xuanqing);
  background: #fbfaf5;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.7;
}
.k-panel h3 {
  margin: 0 0 .6em;
  font-size: 15px;
  font-weight: 600;
  color: var(--fg-muted);
  border: none;
}
.k-stats {
  display: flex;
  flex-wrap: wrap;
  gap: .55em 1.3em;
  margin-bottom: .65em;
}
.k-top {
  padding-top: .55em;
  border-top: 1px dashed var(--border);
  color: var(--fg);
}
.k-top a { color: var(--link); text-decoration: none; }
.k-top a:hover { text-decoration: underline; }
.k-stat-num {
  color: var(--accent);
  font-weight: 700;
  font-family: ui-monospace, monospace;
}

/* ---------- All pages ---------- */
.all-toolbar {
  display: flex;
  gap: .8em;
  margin: 1em 0 1.5em;
  flex-wrap: wrap;
}
.all-toolbar input {
  flex: 1;
  min-width: 200px;
  padding: .45em .7em;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-family: var(--serif);
  font-size: .95em;
}
.all-group {
  margin: 1.6em 0;
}
.all-group h2 {
  font-size: 1.2em;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: .2em;
  margin: 0 0 .6em;
}
.all-group h2 small {
  color: var(--fg-muted);
  font-weight: 400;
  font-size: .8em;
  margin-left: .4em;
}
.all-list {
  list-style: none;
  padding: 0;
  margin: 0;
  columns: 2;
  column-gap: 2em;
}
.all-list li {
  padding: .25em 0;
  break-inside: avoid;
}
.all-list a {
  color: var(--link);
  text-decoration: none;
  font-weight: 500;
}
.all-list a:hover {
  color: var(--accent);
  text-decoration: underline;
}
.all-list .list-meta {
  color: var(--fg-muted);
  font-size: .85em;
  margin-left: .45em;
}
@media (max-width: 700px) {
  .all-list { columns: 1; }
}

/* ---------- Entity index ---------- */
.ent-group {
  margin: 1.2em 0;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: .6em .9em .8em;
}
.ent-group > summary {
  cursor: pointer;
  font-size: 1.15em;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--serif);
}
.ent-group > summary small {
  color: var(--fg-muted);
  font-weight: 400;
  font-size: .8em;
  margin-left: .4em;
  font-family: var(--sans);
}
.ent-group > summary:hover { color: var(--accent-deep); }
.ent-group .all-list { margin-top: .6em; }

/* ---------- Entity tags ---------- */
.entity-tags {
  margin-top: 2.5em;
  padding-top: 1em;
  border-top: 1px solid var(--border);
  font-family: var(--sans);
  display: flex;
  flex-wrap: wrap;
  gap: .5em;
  align-items: center;
}
.entity-tags .tag-label {
  color: var(--fg-muted);
  font-size: .85em;
}
.entity-tags .tag {
  display: inline-block;
  padding: .25em .75em;
  background: var(--bg-box);
  color: var(--fg);
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: .85em;
  text-decoration: none;
}
.entity-tags .tag:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.entity-tags .tag.tag-type {
  background: #fff;
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

/* ---------- Backlinks / related ---------- */
.backlinks {
  margin-top: 2em;
  padding-top: .9em;
  border-top: 1px solid var(--border);
  font-family: var(--sans);
  font-size: 14px;
}
.bl-heading {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-muted);
  margin: 0 0 .6em;
  border: none;
  padding: 0;
}
.bl-body {
  display: flex;
  flex-direction: column;
  gap: .55em;
}
.bl-group {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35em .65em;
}
.bl-group-label {
  font-size: 11px;
  color: var(--xuanqing);
  background: var(--bg-box);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 6px;
  white-space: nowrap;
}
.bl-link {
  color: var(--link);
  text-decoration: none;
  font-size: 13px;
}
.bl-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.loading { color: var(--fg-muted); font-style: italic; }
.error { color: var(--link-broken); }

footer {
  max-width: 1440px;
  margin: 3em auto 2em;
  padding: 1em 1.2em;
  color: var(--fg-muted);
  font-family: var(--sans);
  font-size: 12px;
  border-top: 1px solid var(--border);
}
footer code {
  background: var(--bg-box);
  padding: 1px 4px;
  border-radius: 2px;
  color: var(--link-broken);
  margin-right: 4px;
}

.about-block {
  max-width: 720px;
}
.about-block ul { padding-left: 1.2em; }

.section-note {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 400;
  color: var(--fg-muted);
  margin-left: .4em;
}

.quality-badge {
  display: inline-block;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  vertical-align: middle;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: .25em;
  letter-spacing: .02em;
}
.quality-badge.q-premium { background: #4a1212; color: #e8d5a3; }
.quality-badge.q-featured { background: #7a1f1f; color: #fff; }
.quality-badge.q-standard { background: #1b3a4b; color: #e8d5a3; }
.quality-badge.q-basic { background: #d8d2bf; color: #333; }
.quality-badge.q-stub { background: #eee; color: #888; }

.recent-list {
  list-style: none;
  padding: 0;
  margin: 1em 0 2em;
  font-family: var(--sans);
  font-size: 14px;
}
.recent-item {
  display: grid;
  grid-template-columns: 9.5em 7em 7em 1fr;
  gap: .6em 1em;
  padding: .55em 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
.recent-item time { color: var(--fg-muted); white-space: nowrap; }
.recent-action { color: var(--accent); font-weight: 600; }
.recent-sum { color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 800px) {
  .recent-item {
    grid-template-columns: 1fr;
    gap: .2em;
  }
}

/* ---------- Chapter reader ---------- */
.ch-home { margin-top: 1em; }
.ch-home-filter-wrap { margin: .6em 0 0; }
.ch-home-filter {
  width: min(100%, 28em);
  font-family: var(--sans);
  font-size: 14px;
  padding: .4em .7em;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
.ch-home-filter:focus {
  outline: 2px solid #c084fc;
  border-color: #7c3aed;
}
.ch-cat { margin: 1.6em 0 2em; scroll-margin-top: 4.5em; }

/* Chapter side TOC (书籍 / 本籍目录) */
.ch-toc {
  position: sticky;
  top: 4.2em;
  align-self: start;
  background: var(--bg-box);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75em .8em .9em;
  font-family: var(--sans);
  font-size: 13px;
  max-height: calc(100vh - 5.2em);
  display: flex;
  flex-direction: column;
  gap: .5em;
}
.ch-toc-head h2 {
  margin: 0;
  font-size: 1.05em;
  color: var(--accent);
  border: none;
  padding: 0;
}
.ch-toc-sub {
  margin: .15em 0 .35em;
  color: var(--fg-muted);
  font-size: 12px;
}
.ch-toc-filter {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  padding: .3em .5em;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
}
.ch-toc-filter:focus {
  outline: 2px solid #c084fc;
  border-color: #7c3aed;
}
.ch-toc-list {
  overflow: auto;
  flex: 1 1 auto;
  max-height: calc(100vh - 11em);
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0 -.2em;
  padding: 0 .2em;
}
.ch-toc-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .4em;
  text-decoration: none;
  color: var(--xuanqing);
  padding: .28em .4em;
  border-radius: 4px;
  line-height: 1.35;
}
.ch-toc-item:hover {
  background: #fff;
  color: var(--accent);
}
.ch-toc-item.is-current {
  background: #fdf3d8;
  color: var(--accent);
  font-weight: 700;
  box-shadow: inset 3px 0 0 #7c3aed;
}
.ch-toc-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.ch-toc-meta {
  flex: 0 0 auto;
  color: var(--fg-muted);
  font-size: 11px;
  white-space: nowrap;
}
@media (max-width: 1199px) {
  .ch-toc {
    position: static;
    max-height: none;
  }
  .ch-toc-list {
    max-height: 16em;
  }
}
.ch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: .8em;
}
.ch-card {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: .75em .9em;
}
.ch-card-title {
  font-weight: 700;
  text-decoration: none;
  color: var(--accent);
}
.ch-card-meta {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--fg-muted);
  margin: .25em 0 .4em;
}
.ch-card-secs {
  display: flex;
  flex-wrap: wrap;
  gap: .3em;
}
.ch-sec {
  font-family: var(--sans);
  font-size: 11px;
  background: var(--bg-box);
  color: var(--fg-muted);
  padding: 1px 6px;
  border-radius: 999px;
}
.ch-outline {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: .8em 1em;
  margin: 1em 0 1.4em;
}
.ch-outline h2 {
  margin: 0 0 .4em;
  font-size: 1.05em;
}
.ch-outline ul {
  margin: 0;
  padding-left: 1.2em;
}
.ch-outline .pn-inline {
  color: #6b21a8;
  font-family: var(--sans);
  font-size: 12px;
}
.ch-body {
  max-width: 48em;
  --reader-font-size: 17px;
  font-size: var(--reader-font-size);
}
.ch-para {
  margin: 0 0 1em;
  line-height: 1.9;
}
/* 超长段显示层分行（.ch-sent） */
.ch-sent {
  display: block;
  margin: 0 0 0.55em;
}
.ch-sent:last-child {
  margin-bottom: 0;
}
/* 阅读设置条（章节 header） */
.reader-settings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35em 1em;
  margin: 0.65em 0 0;
  padding: 0.45em 0.7em;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(245, 240, 230, 0.55);
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--fg-muted);
}
.reader-set-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.reader-set-item input[type="checkbox"] {
  margin: 0;
  accent-color: var(--accent-deep);
}
.reader-set-font input[type="range"] {
  width: 7em;
  vertical-align: middle;
  accent-color: var(--accent-deep);
}
.reader-fs-val {
  min-width: 1.6em;
  font-variant-numeric: tabular-nums;
  color: var(--xuanqing);
  font-weight: 600;
}
@media (max-width: 700px) {
  .reader-settings {
    gap: 0.4em 0.75em;
    padding: 0.5em 0.6em;
    font-size: 12px;
  }
  .reader-set-font input[type="range"] {
    width: 5.5em;
  }
}
/* 实体高亮关：章节正文内链外观随正文，仍可点击 */
body.ch-hl-off .ch-body a.wikilink,
body.ch-hl-off .ch-body a.wikilink.resolved,
body.ch-hl-off .ch-body a.wikilink-person,
body.ch-hl-off .ch-body a.wikilink-concept,
body.ch-hl-off .ch-body a.wikilink-place,
body.ch-hl-off .ch-body a.wikilink-institution,
body.ch-hl-off .ch-body a.wikilink-office,
body.ch-hl-off .ch-body a.wikilink.broken,
body.ch-hl-off .ch-body a.wikilink:hover,
body.ch-hl-off .ch-body a.wikilink-person:hover,
body.ch-hl-off .ch-body a.wikilink-concept:hover,
body.ch-hl-off .ch-body a.wikilink-place:hover,
body.ch-hl-off .ch-body a.wikilink-institution:hover,
body.ch-hl-off .ch-body a.wikilink-office:hover {
  color: var(--fg) !important;
  background: none !important;
  text-decoration: none;
  padding: 0;
  border-radius: 0;
  font-weight: inherit;
}
body.ch-hl-off .ch-body a.wikilink:hover {
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-underline-offset: 2px;
}
.ch-para-section .ch-text {
  font-weight: 700;
  color: var(--accent-deep);
}
.ch-para .pn {
  color: #6b21a8;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  margin-right: .35em;
  white-space: nowrap;
}
.ch-para .pn:hover { text-decoration: underline; }
.ch-para-target {
  background: #fdf3d8;
  border-left: 4px solid #7c3aed;
  outline: 2px solid #c084fc;
  outline-offset: 1px;
  border-radius: 0 4px 4px 0;
  padding: .25em .4em .25em .55em;
  box-shadow: 0 1px 6px rgba(124, 58, 237, .18);
}
@media (max-width: 700px) {
  .ch-para-target {
    background: #fdf3d8;
    border-left-width: 5px;
    padding: .3em .35em .3em .5em;
  }
}
/* 章间导航 */
.ch-nav {
  display: flex;
  align-items: center;
  gap: .6em;
  flex-wrap: wrap;
  font-family: var(--sans);
  font-size: 13px;
  margin: .8em 0;
}
.ch-nav-top {
  padding-bottom: .7em;
  border-bottom: 1px solid var(--border);
}
.ch-nav-bottom {
  margin-top: 1.6em;
  padding-top: .9em;
  border-top: 2px solid var(--xuanqing);
}
.ch-nav-prev, .ch-nav-next, .ch-nav-home {
  text-decoration: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: .25em .8em;
  color: var(--xuanqing);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ch-nav-prev:hover, .ch-nav-next:hover, .ch-nav-home:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.ch-nav .is-disabled {
  color: var(--fg-muted);
  border: 1px dashed var(--border);
  border-radius: 999px;
  padding: .25em .8em;
}
@media (max-width: 700px) {
  .ch-nav { font-size: 12px; gap: .45em; }
  .ch-nav-prev, .ch-nav-next {
    max-width: 100%;
    white-space: normal;
  }
}
/* 类型图例 */
.ch-legend {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--fg-muted);
  margin: .5em 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: .15em .7em;
  align-items: baseline;
}
.ch-legend-item .wikilink { font-size: 12px; cursor: default; }
/* 段号复制 toast */
.ch-toast {
  position: fixed;
  left: 50%;
  bottom: 2em;
  transform: translateX(-50%) translateY(8px);
  background: rgba(27, 58, 75, .94);
  color: #f5eab5;
  font-family: var(--sans);
  font-size: 13px;
  padding: .45em 1em;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 50;
}
.ch-toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
a.pn-cite {
  color: #6b21a8;
  text-decoration: none;
  border-bottom: 1px dotted #c084fc;
}
a.pn-cite:hover { border-bottom-style: solid; }

/* ---------- Events index ---------- */
.ev-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .4em;
  margin: 1em 0 1.2em;
  font-family: var(--sans);
  font-size: 13px;
}
.ev-tab {
  text-decoration: none;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: .2em .7em;
}
.ev-tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.ev-tab small { opacity: .75; }
.ev-era { margin: 1.4em 0 1.8em; }
.ev-era h2 { font-size: 1.15em; }
.ev-more {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  margin-left: .6em;
}
.ev-card {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: .7em .9em;
  margin: .55em 0;
}
.ev-meta {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--fg-muted);
  display: flex;
  flex-wrap: wrap;
  gap: .55em;
  margin-bottom: .35em;
}
.ev-kind {
  background: var(--bg-box);
  padding: 0 6px;
  border-radius: 4px;
}
.ev-pn { color: #6b21a8; text-decoration: none; }
.ev-pn:hover { text-decoration: underline; }
.ev-text { margin: 0; line-height: 1.75; }
.ev-links {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--fg-muted);
  margin-top: .35em;
}
.ev-summary {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--fg-muted);
  margin: .3em 0 0;
}
.ev-filter {
  display: flex;
  flex-wrap: wrap;
  gap: .5em;
  align-items: center;
  margin: .9em 0 .2em;
}
.ev-filter input[type="search"] {
  flex: 1 1 220px;
  min-width: 0;
  font-size: 14px;
  padding: .45em .7em;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: inherit;
}
.ev-filter button {
  font-size: 13px;
  padding: .45em 1em;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.ev-clear {
  font-size: 13px;
}
.ev-count {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--fg-muted);
  margin: .4em 0 0;
}
@media (max-width: 480px) {
  .ev-filter input[type="search"] { flex-basis: 100%; }
  .ev-card { padding: .6em .7em; }
}

/* ---------- EventGraph ---------- */
#evg {
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  touch-action: none;
}
.evg-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .6em;
  align-items: center;
  justify-content: space-between;
  margin: .9em 0 .6em;
  font-family: var(--sans);
  font-size: 13px;
}
.evg-filters { display: flex; flex-wrap: wrap; gap: .8em; }
.evg-type { display: inline-flex; align-items: center; gap: .3em; cursor: pointer; }
.evg-type::before {
  content: "";
  width: .7em;
  height: .7em;
  border-radius: 50%;
  background: var(--evg, #666);
}
.evg-node { cursor: pointer; }
.evg-node rect {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 1.4;
}
.evg-node text { font-size: 12px; fill: #111; }
.evg-node:hover rect { fill: var(--bg-box); }
.evg-dot {
  display: inline-block;
  width: .6em;
  height: .6em;
  border-radius: 50%;
  margin-right: .3em;
}
.evg-rel { color: var(--fg-muted); }
.evg-edges {
  list-style: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.9;
}
.evg-edges small { color: var(--fg-muted); }

/* ---------- Metro ---------- */
.metro-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  margin: .4em 0 1em;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.metro-wrap svg {
  display: block;
  min-width: 720px;
  width: 100%;
  height: auto;
}
.metro-hint {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--fg-muted);
  margin: .15em 0 .5em;
}
.metro-leg {
  display: inline-flex;
  align-items: center;
  gap: .35em;
}
.metro-leg i {
  display: inline-block;
  width: 1.4em;
  height: 0;
  border-top: 4px solid var(--accent);
}
.metro-leg-dash { border-top-style: dashed !important; border-top-width: 2px !important; }
.metro-station { cursor: pointer; }
.metro-station:focus { outline: none; }
.metro-station:hover .metro-disk,
.metro-station:focus .metro-disk { fill: var(--gold); }
.metro-idx {
  font-size: 11px;
  fill: var(--fg-muted);
  font-family: var(--sans);
}
.metro-name {
  font-size: 14px;
  fill: #111;
  font-family: var(--serif);
}
.metro-edge-lab {
  font-size: 12px;
  font-family: var(--sans);
}

/* ---------- Full-text search (Special:Search) ---------- */
.ft-form {
  display: flex;
  gap: .5em;
  max-width: 720px;
  margin: .2em 0 0.6em;
}
#ft-q {
  flex: 1;
  box-sizing: border-box;
  padding: .65em .9em .65em 2.4em;
  font-size: 16px;
  font-family: var(--sans);
  color: var(--fg);
  background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a1f1f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>") no-repeat 12px center;
  background-size: 16px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
}
#ft-q:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(122, 31, 31, .12);
}
.ft-go {
  font-family: var(--sans);
  font-size: 14px;
  padding: .55em 1.1em;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.ft-go:hover { background: var(--accent-deep); }
.ft-options {
  display: flex;
  align-items: center;
  gap: .6em;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--accent);
  margin-bottom: .6em;
}
.ft-fuzzy { cursor: pointer; user-select: none; }
.ft-fuzzy input { accent-color: var(--accent); }
.ft-hint { color: var(--fg-muted); font-size: 12px; }
.ft-corpora {
  display: flex;
  flex-wrap: wrap;
  gap: .35em;
  margin: 0 0 1em;
}
.ft-chip {
  font-family: var(--sans);
  font-size: 12px;
  padding: .25em .65em;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--xuanqing);
  border-radius: 999px;
  cursor: pointer;
}
.ft-chip small { color: var(--fg-muted); margin-left: .15em; }
.ft-chip:hover { border-color: var(--accent); color: var(--accent); }
.ft-chip.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.ft-chip.is-on small { color: var(--gold); }
.ft-wiki h2 { font-size: 1.15em; margin-top: .4em; }
.ft-wiki-list { list-style: none; padding: 0; margin: 0 0 1em; }
.ft-wiki-list li { padding: .25em 0; }
.ft-blurb { display: block; color: var(--fg-muted); font-size: 13px; }
.ft-expanded {
  font-size: 13px;
  color: var(--fg-muted);
  background: var(--bg-box);
  border-left: 3px solid var(--gold-soft);
  padding: .4em .8em;
  margin: .4em 0 .8em;
  border-radius: 3px;
}
.ft-expanded code {
  background: #fff3b0;
  color: var(--accent-deep);
  padding: 0 4px;
  border-radius: 2px;
  font-family: inherit;
}
.ft-summary {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--fg-muted);
  margin: .4em 0 .8em;
}
.ft-summary strong { color: var(--accent); }
.ft-hit {
  display: block;
  padding: .75em 1em;
  margin-bottom: .65em;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold-soft);
  border-radius: 4px;
  text-decoration: none;
  color: var(--fg);
}
.ft-hit:hover {
  border-left-color: var(--accent);
  box-shadow: 0 2px 8px rgba(122, 31, 31, .08);
}
.ft-ch {
  display: block;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--accent);
  margin-bottom: .25em;
}
.ft-snip { display: block; font-size: 15px; line-height: 1.7; }
.ft-hit mark, .shiji-search-results mark {
  background: #fff3b0;
  color: var(--accent-deep);
  padding: 0 2px;
  border-radius: 2px;
}
.ft-pager {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 1.4em 0 2em;
}
.ft-page {
  display: inline-block;
  min-width: 28px;
  padding: 4px 10px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--accent);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
}
.ft-page:hover { background: var(--bg-box); }
.ft-page.is-on {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
  cursor: default;
}
.ft-page.is-off { color: #ccc; cursor: default; background: #fff; }
.search-more a { color: var(--accent); font-family: var(--sans); font-size: 13px; }

/* ---------- 战争馆 (Special:Wars) ---------- */
.wars-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: .2em 0 2em;
}
.wars-hero {
  background: #fff;
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: 6px;
  padding: 1.4em 1.6em 1.2em;
  margin-bottom: 2em;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .03);
}
.wars-hero-top {
  margin-bottom: 1.2em;
}
.wars-hero-title {
  display: flex;
  align-items: center;
  gap: .6em;
  margin-bottom: .4em;
}
.wars-hero-title h1 {
  margin: 0;
  font-size: 1.85em;
  color: var(--accent);
  letter-spacing: .02em;
}
.wars-hero-badge {
  font-family: var(--sans);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-box);
  color: var(--accent);
  border: 1px solid var(--border);
  font-weight: 600;
}
.wars-hero-desc {
  font-size: 15px;
  color: var(--fg-muted);
  line-height: 1.7;
  margin: 0;
}
.wars-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .8em;
  justify-content: space-between;
  align-items: center;
  padding-top: 1em;
  border-top: 1px dashed var(--border);
}
.wars-era-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .45em;
}
.wars-era-btn {
  font-family: var(--sans);
  font-size: 13px;
  padding: .35em .85em;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--fg);
  cursor: pointer;
  transition: all .15s ease;
  line-height: 1.3;
}
.wars-era-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-box);
}
.wars-filter-box {
  display: flex;
  align-items: center;
  gap: .6em;
}
.wars-filter-input {
  font-family: var(--sans);
  font-size: 13px;
  padding: .4em .85em;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 220px;
  background: #fff;
  color: var(--fg);
  transition: border-color .15s ease;
}
.wars-filter-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(122, 31, 31, .15);
}
.wars-count {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--fg-muted);
  white-space: nowrap;
}
.wars-group {
  margin-bottom: 2.5em;
}
.wars-group-header {
  margin-bottom: 1.1em;
  padding-bottom: .6em;
  border-bottom: 2px solid var(--gold-soft);
}
.wars-group-title {
  margin: 0 0 .35em;
  font-size: 1.35em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: .6em;
  flex-wrap: wrap;
}
.wars-group-period {
  font-family: var(--sans);
  font-size: .7em;
  font-weight: 500;
  color: var(--xuanqing);
  background: var(--bg-box);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.wars-group-blurb {
  margin: 0;
  font-size: 14.5px;
  color: var(--fg-muted);
  line-height: 1.65;
}
.wars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 1.2em;
}
.wars-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  text-decoration: none;
  color: var(--fg);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.wars-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(122, 31, 31, .12);
}
.wars-card-thumb {
  position: relative;
  width: 100%;
  height: 180px;
  background: var(--bg-box);
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.wars-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  transition: transform .35s ease;
}
.wars-card:hover .wars-card-thumb img {
  transform: scale(1.03);
}
.wars-card-glyph {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .3em;
  background: linear-gradient(135deg, var(--bg-box), #e8d5a3);
}
.wars-card-glyph .thumb-glyph {
  font-size: 2.6em;
}
.wars-card-glyph .thumb-type {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: .08em;
}
.wars-card-body {
  padding: .9em 1.1em 1em;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.wars-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .4em;
  margin-bottom: .35em;
  flex-wrap: wrap;
}
.wars-card-title {
  margin: 0;
  font-size: 1.18em;
  color: var(--accent);
  font-weight: 700;
  line-height: 1.35;
}
.wars-card-badges {
  display: flex;
  align-items: center;
  gap: .35em;
}
.wars-badge {
  font-family: var(--sans);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg-box);
  color: var(--accent-deep);
  border: 1px solid var(--border);
}
.wars-card-year {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--fg-muted);
  margin-bottom: .55em;
}
.wars-card-blurb {
  margin: 0 0 .8em;
  font-size: 14px;
  line-height: 1.6;
  color: var(--fg);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}
.wars-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--fg-muted);
  padding-top: .55em;
  border-top: 1px dashed var(--border);
  margin-top: auto;
}
.wars-inbound {
  color: var(--xuanqing);
  background: var(--bg-box);
  padding: 1px 6px;
  border-radius: 3px;
}
.wars-goto {
  color: var(--accent);
  font-weight: 600;
  transition: transform .15s ease;
}
.wars-card:hover .wars-goto {
  transform: translateX(2px);
}
.wars-unmounted {
  margin-top: 2em;
}
.wars-unmounted-box {
  padding: 1.1em 1.4em;
  border-radius: 6px;
  border: 1px dashed var(--border);
  background: #fff;
  font-family: var(--sans);
}
.wars-unmounted-box.is-complete {
  border-color: #86efac;
  background: #f0fdf4;
}
.wars-unmounted-box.is-complete h4 {
  color: #166534;
}
.wars-unmounted-box.is-complete p {
  color: #15803d;
}
.wars-unmounted-box.is-warn {
  border-color: #fca5a5;
  background: #fef2f2;
}
.wars-unmounted-box.is-warn h4 {
  color: #991b1b;
}
.wars-unmounted-box.is-warn p {
  color: #b91c1c;
}
.wars-unmounted-box h4 {
  margin: 0 0 .35em;
  font-size: 14px;
}
.wars-unmounted-box p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

/* 响应式支持：针对 ~390px 移动屏及平板 */
@media (max-width: 768px) {
  .wars-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}
@media (max-width: 480px) {
  .wars-hero {
    padding: 1.1em 1em;
  }
  .wars-hero-title h1 {
    font-size: 1.55em;
  }
  .wars-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: .7em;
  }
  .wars-filter-box {
    width: 100%;
  }
  .wars-filter-input {
    width: 100%;
    flex: 1;
  }
  .wars-grid {
    grid-template-columns: 1fr;
    gap: 1em;
  }
  .wars-card-thumb {
    height: 160px;
  }
}

/* ---------- Mentions (章节出现频次榜) ---------- */
.mentions-list {
  list-style: none;
  margin: 1.2em 0;
  padding: 0;
  border-top: 1px solid var(--border);
}
.mentions-item {
  display: flex;
  align-items: baseline;
  gap: .7em;
  padding: .45em .2em;
  border-bottom: 1px solid var(--border);
  font-family: var(--sans);
}
.mentions-rank {
  flex: 0 0 2.4em;
  text-align: right;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  font-size: .85em;
}
.mentions-name {
  flex: 1;
  color: var(--link);
  text-decoration: none;
}
.mentions-name:hover {
  text-decoration: underline;
}
.mentions-count {
  flex: 0 0 auto;
  min-width: 4.5em;
  text-align: right;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.mentions-chapters {
  flex: 0 0 5em;
  text-align: right;
  color: var(--fg-muted);
  font-size: .85em;
}
@media (max-width: 480px) {
  .mentions-item {
    flex-wrap: wrap;
    gap: .3em .6em;
  }
  .mentions-name {
    flex: 1 1 100%;
  }
  .mentions-rank {
    flex-basis: 1.8em;
  }
}

