/* ==========================================================================
   西域 · 汉匈争霸 — 设计与验证工作台
   版式：暖黑底、单一琥珀强调色、细线分隔；标题用 Noto Serif SC，
   章节号与拉丁数字用 Newsreader，数据与编号用 IBM Plex Mono。
   ========================================================================== */

:root {
  color-scheme: dark;

  --bg: #0e0d0b;
  --bg-raised: #151411;
  --bg-sunken: #0a0908;
  --bg-hover: #1c1a16;
  --line: #26241f;
  --line-strong: #3a3731;
  --rule: #5a554b;
  --text: #ece6d8;
  --text-2: #b3ac9d;
  --text-3: #7d776c;

  --accent: #d9a046;
  --accent-strong: #f0b866;
  --accent-ink: #1a1205;
  --accent-wash: rgba(217, 160, 70, 0.12);

  --han: #c4513f;
  --han-wash: rgba(196, 81, 63, 0.14);
  --xn: #a8825f;
  --xn-wash: rgba(168, 130, 95, 0.16);
  --ok: #82b08c;
  --ok-wash: rgba(130, 176, 140, 0.12);
  --bad: #d4664f;
  --bad-wash: rgba(212, 102, 79, 0.12);

  --parchment: #e9dcc0;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-serif: "Noto Serif SC", "Songti SC", "Source Han Serif SC", "STSong", Georgia, serif;
  --font-latin: "Newsreader", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  --wrap: 1360px;
  --gutter: clamp(20px, 3.4vw, 44px);
  --header-h: 60px;
  --r-1: 2px;
  --r-2: 3px;
  --r-3: 4px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 24px);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* 胶片颗粒：让大面积暗色不显得像纯色块 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3, h4, p, ul, ol, figure, blockquote {
  margin: 0;
}

h1, h2, h3 {
  text-wrap: balance;
}

p, li, blockquote {
  text-wrap: pretty;
}

ul, ol {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

strong, b {
  font-weight: 600;
}

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

img, svg {
  display: block;
  max-width: 100%;
}

::selection {
  background: rgba(217, 160, 70, 0.32);
}

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

* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.mono, code {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

code {
  font-size: 0.9em;
  color: var(--text-2);
}

.num {
  font-family: var(--font-latin);
  font-variant-numeric: lining-nums tabular-nums;
}

.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.c-ok { color: var(--ok); }
.c-bad { color: var(--bad); }
.c-accent { color: var(--accent); }
.c-han { color: var(--han); }
.c-xn { color: var(--xn); }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-3);
}

kbd {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 17px;
  text-align: center;
  color: var(--text-3);
}

.icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.3) blur(14px);
  backdrop-filter: saturate(1.3) blur(14px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 100%;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-mark {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.brand-sub {
  padding-left: 10px;
  border-left: 1px solid var(--line-strong);
  font-size: 12px;
  line-height: 1;
  color: var(--text-3);
  white-space: nowrap;
}

.site-nav {
  display: flex;
  align-self: stretch;
  gap: 2px;
}

.site-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  font-size: 13.5px;
  color: var(--text-2);
  white-space: nowrap;
  transition: color 0.2s;
}

.nav-no {
  font-family: var(--font-latin);
  font-size: 12.5px;
  font-style: italic;
  color: var(--text-3);
  transition: color 0.2s;
}

.site-nav a:hover { color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--text); }
.site-nav a[aria-current="page"] .nav-no { color: var(--accent); }

.site-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -1px;
  height: 1px;
  background: var(--accent);
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.engine-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--bg-raised);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.engine-pill:hover {
  border-color: var(--line-strong);
  color: var(--text-2);
}

.engine-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
}

.engine-dot.loading {
  background: var(--accent);
  animation: blink 1.2s ease-in-out infinite;
}

@keyframes blink {
  50% { opacity: 0.3; }
}

@media (max-width: 1080px) {
  .brand-sub, .engine-pill { display: none; }
}

@media (max-width: 760px) {
  .site-header { height: auto; }
  .header-inner { flex-wrap: wrap; padding-top: 10px; padding-bottom: 0; gap: 8px 16px; }
  .site-nav { order: 3; width: 100%; height: 40px; overflow-x: auto; }
}

/* --------------------------------------------------------------------------
   Buttons & form controls
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s, color 0.2s, opacity 0.2s;
}

.btn:hover:not(:disabled) { background: var(--bg-hover); }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn .icon { transition: transform 0.3s var(--ease); }
.btn:hover:not(:disabled) .icon { transform: translateX(2px); }

.btn-solid {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

.btn-solid:hover:not(:disabled) {
  background: var(--text);
  opacity: 0.88;
}

.btn-accent {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 500;
}

.btn-accent:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn-quiet {
  padding: 0 4px;
  border-color: transparent;
  color: var(--text-2);
}

.btn-quiet:hover:not(:disabled) {
  background: none;
  color: var(--text);
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
}

.btn-lg {
  height: 42px;
  padding: 0 20px;
  font-size: 14px;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

select,
input[type="number"],
input[type="text"] {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--bg-raised);
  font-size: 13px;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 30px;
  background: var(--bg-raised)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238a867c' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E")
    no-repeat right 9px center / 13px;
  cursor: pointer;
}

select:hover,
input[type="number"]:hover,
input[type="text"]:hover {
  border-color: var(--line-strong);
}

select:focus,
input:focus {
  outline: none;
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

input::placeholder { color: var(--text-3); }

input[type="checkbox"] {
  accent-color: var(--accent);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field-label {
  font-size: 11.5px;
  color: var(--text-3);
}

.field-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-2);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.switch input {
  position: relative;
  width: 28px;
  height: 16px;
  margin: 0;
  border-radius: 999px;
  background: var(--line-strong);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: background 0.2s;
}

.switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f3f1ea;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.25s var(--ease);
}

.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(12px); }

/* 分段切换（命令分类、矩阵视图） */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--bg-raised);
}

.segmented button {
  height: 26px;
  padding: 0 10px;
  border-radius: 2px;
  font-size: 12.5px;
  color: var(--text-3);
  white-space: nowrap;
  transition: color 0.2s, background 0.2s;
}

.segmented button:hover { color: var(--text); }

.segmented button.active,
.segmented button[aria-pressed="true"] {
  background: var(--bg-hover);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

/* 小标签：只改字色，不填底色 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 7px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-1);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--text-2);
  white-space: nowrap;
  vertical-align: 1px;
}

.badge-gold { color: var(--accent); border-color: rgba(217, 160, 70, 0.4); }
.badge-green { color: var(--ok); border-color: rgba(130, 176, 140, 0.38); }
.badge-red { color: var(--han); border-color: rgba(196, 81, 63, 0.42); }
.badge-blue { color: var(--xn); border-color: rgba(168, 130, 95, 0.42); }

.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Views & page heads
   -------------------------------------------------------------------------- */

.tab-view { display: none; }
.tab-view.active { display: block; }

.page-head {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  align-items: end;
  gap: 20px 72px;
  padding-top: 56px;
  padding-bottom: 32px;
  margin-bottom: 32px;
  position: relative;
}

.page-head::after {
  content: "";
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: 0;
  height: 1px;
  background: var(--line);
}

.chapter-mark {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 13px;
  color: var(--text-2);
}

.chapter-mark .en {
  font-family: var(--font-latin);
  font-size: 14px;
  font-style: italic;
  color: var(--text-3);
}

.chapter-no {
  font-family: var(--font-latin);
  font-size: 15px;
  font-style: italic;
  color: var(--accent);
}

.page-title {
  margin-top: 16px;
  font-family: var(--font-serif);
  font-size: clamp(30px, 3.8vw, 46px);
  font-weight: 600;
  line-height: 1.18;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.page-lede {
  max-width: 34em;
  padding-bottom: 6px;
  font-size: 15px;
  line-height: 1.9;
  color: var(--text-2);
}

@media (max-width: 900px) {
  .page-head { grid-template-columns: 1fr; padding-top: 40px; }
}

.view-body {
  padding-bottom: 96px;
}

/* --------------------------------------------------------------------------
   Cover (home)
   -------------------------------------------------------------------------- */

.cover {
  --mx: 24%;
  --my: 70%;
  position: relative;
  overflow: hidden;
  padding: 28px 0 clamp(64px, 9vw, 128px);
  border-bottom: 1px solid var(--line);
  isolation: isolate;
}

.cover::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(circle 560px at var(--mx) var(--my), var(--accent-wash), transparent 70%);
  pointer-events: none;
}

/* 背景：一条由东向西的驼队商路 */
.cover-route {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  max-width: none;
  fill: none;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(circle 420px at var(--mx) var(--my), #000 0%, rgba(0, 0, 0, 0.35) 45%, rgba(0, 0, 0, 0.1) 100%);
  mask-image: radial-gradient(circle 420px at var(--mx) var(--my), #000 0%, rgba(0, 0, 0, 0.35) 45%, rgba(0, 0, 0, 0.1) 100%);
}

.cover-route .road {
  stroke: var(--text-3);
  stroke-width: 1.2;
  stroke-dasharray: 2 7;
  stroke-linecap: round;
}

.cover-route .dune {
  stroke: var(--line-strong);
  stroke-width: 1;
}

.cover-route .post {
  fill: var(--bg);
  stroke: var(--text-3);
  stroke-width: 1.2;
}

.cover-route .rider {
  fill: var(--bg);
  stroke: var(--accent);
  stroke-width: 1.3;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.dateline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text-3);
}

.dateline span:last-child {
  font-family: var(--font-latin);
  font-size: 14px;
  font-style: italic;
}

.cover-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr);
  gap: 72px;
  align-items: start;
  margin-top: 64px;
}

.display {
  font-family: var(--font-serif);
  font-size: clamp(48px, 6.6vw, 96px);
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -0.01em;
  word-break: keep-all;
}

.display em {
  font-style: normal;
  color: var(--accent);
  text-shadow: 0 0 48px rgba(217, 160, 70, 0.26);
}

.hero-lede {
  max-width: 30em;
  margin-top: 36px;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.9;
  color: var(--text);
}

.hero-count {
  max-width: 34em;
  margin-top: 16px;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--text-3);
}

.hero-count b {
  font-family: var(--font-latin);
  font-size: 17px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: lining-nums;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin-top: 34px;
}

/* 插图：像书里的一幅图版 */
.plate {
  margin-top: 12px;
}

.plate-media {
  display: block;
  position: relative;
  aspect-ratio: 1000 / 620;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--parchment);
}

.plate-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: sepia(0.15) saturate(0.85) contrast(1.02);
  transition: transform 1.2s var(--ease);
}

.plate:hover .plate-media img {
  transform: scale(1.025);
}

.plate-media::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 80px rgba(20, 14, 6, 0.45);
  pointer-events: none;
}

.plate-caption {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--text-3);
}

.plate-caption .mono {
  font-size: 11.5px;
}

.plate-quote {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.plate-kicker {
  font-size: 12px;
  color: var(--accent);
}

.plate-quote blockquote {
  margin-top: 12px;
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 500;
  line-height: 1.75;
  color: var(--text);
}

.plate-quote .quote-src {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--text-3);
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  transition: color 0.2s;
}

.text-link:hover {
  color: var(--accent-strong);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

@media (max-width: 980px) {
  .cover-grid { grid-template-columns: 1fr; gap: 48px; margin-top: 44px; }
}

/* 目录条 */
.contents {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.contents a {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  padding: 22px 20px 22px 0;
  transition: background 0.2s;
}

.contents a + a {
  padding-left: 20px;
  border-left: 1px solid var(--line);
}

.contents a:hover { background: var(--bg-raised); }

.contents .no {
  grid-row: span 2;
  font-family: var(--font-latin);
  font-size: 16px;
  font-style: italic;
  color: var(--accent);
  line-height: 1.5;
}

.contents .t {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
}

.contents .d {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-3);
}

@media (max-width: 860px) {
  .contents { grid-template-columns: 1fr 1fr; }
  .contents a:nth-child(3) { padding-left: 0; border-left: 0; }
  .contents a:nth-child(n + 3) { border-top: 1px solid var(--line); }
}

/* 首页分节 */
.section {
  padding-top: 88px;
}

.chapter-head {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 0 8px;
  align-items: baseline;
  margin-bottom: 36px;
}

.chapter-head .chapter-no {
  font-size: 20px;
}

.section-title {
  font-family: var(--font-serif);
  font-size: clamp(24px, 2.6vw, 32px);
  font-weight: 600;
  line-height: 1.3;
  word-break: keep-all;
}

.section-note {
  margin-top: 8px;
  max-width: 40em;
  font-size: 14px;
  color: var(--text-2);
}

/* 剧本条目：像书目，不像卡片 */
.scenario-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--rule);
}

.scenario {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 26px 28px 30px 0;
  border-bottom: 1px solid var(--line);
  transition: background 0.2s;
}

.scenario + .scenario {
  padding-left: 28px;
  border-left: 1px solid var(--line);
}

.scenario:hover { background: var(--bg-raised); }

.scenario-year {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-3);
}

.scenario-name {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.scenario-desc {
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--text-2);
}

.scenario-meta {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-3);
}

.scenario:hover .scenario-meta .text-link { color: var(--accent-strong); }

@media (max-width: 900px) {
  .scenario-list { grid-template-columns: 1fr; }
  .scenario + .scenario { padding-left: 0; border-left: 0; }
}

/* 阵营对照 */
.factions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid var(--line);
}

.faction {
  padding: 32px 32px 34px;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 0 20px;
}

.faction + .faction { border-left: 1px solid var(--line); }

.faction-seal {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid currentColor;
  border-radius: var(--r-2);
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  color: var(--han);
}

.faction.xn .faction-seal { color: var(--xn); }

.faction-name {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
}

.faction-role {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-3);
}

.faction-desc {
  margin-top: 14px;
  font-size: 14px;
  line-height: 1.85;
  color: var(--text-2);
}

.faction-goal {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 13px;
}

.faction-goal .eyebrow { flex-shrink: 0; }

@media (max-width: 860px) {
  .factions { grid-template-columns: 1fr; }
  .faction + .faction { border-left: 0; border-top: 1px solid var(--line); }
}

/* 关键数字 */
.figures {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--rule);
}

.figure {
  padding: 22px 24px 4px 0;
}

.figure + .figure {
  padding-left: 24px;
  border-left: 1px solid var(--line);
}

.figure-v {
  font-family: var(--font-latin);
  font-size: 44px;
  font-weight: 400;
  line-height: 1.1;
  font-variant-numeric: lining-nums;
}

.figure-v small {
  font-size: 18px;
  color: var(--text-3);
  margin-left: 2px;
}

.figure-k {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-2);
}

.figure-d {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-3);
}

@media (max-width: 860px) {
  .figures { grid-template-columns: 1fr 1fr; }
  .figure:nth-child(3) { padding-left: 0; border-left: 0; }
}

/* --------------------------------------------------------------------------
   Panels（工具页的基础容器：细线框，不填色）
   -------------------------------------------------------------------------- */

.panel-box {
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--bg);
  margin-bottom: 20px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  min-height: 52px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.panel-title h3 {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.panel-title .eyebrow {
  white-space: nowrap;
}

.panel-hint {
  font-size: 12.5px;
  color: var(--text-3);
}

.panel-body {
  padding: 16px 18px;
}

/* --------------------------------------------------------------------------
   Sandbox
   -------------------------------------------------------------------------- */

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 28px;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 14px;
}

.toolbar-row .spacer { flex: 1; }

.toolbar .field select { min-width: 150px; }

/* 顶部指标条：账簿式四栏 */
.hud-banner {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.hud-card {
  padding: 16px 20px 18px;
  min-width: 0;
}

.hud-card + .hud-card { border-left: 1px solid var(--line); }
.hud-card.span-2 { grid-column: span 2; }

.hud-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-2);
}

.hud-head .eyebrow { margin-right: 6px; }

.hud-val {
  margin-top: 6px;
  font-family: var(--font-latin);
  font-size: 30px;
  line-height: 1.15;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-val small {
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--text-3);
  margin-left: 4px;
}

.hud-val .unit {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-2);
  margin-right: 6px;
}

.hud-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-3);
}

.hud-sub .warn { color: var(--bad); }
.hud-sub .hl { color: var(--accent); }

.progress-track {
  height: 2px;
  margin: 10px 0 2px;
  background: var(--line-strong);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--text-2);
  transition: width 0.35s var(--ease);
}

.progress-fill.han { background: var(--han); }
.progress-fill.xn { background: var(--xn); }
.progress-fill.accent { background: var(--accent); }
.progress-fill.ok { background: var(--ok); }

.tribe-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin-top: 10px;
}

.tribe {
  padding: 2px 12px 0 0;
}

.tribe + .tribe {
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.tribe-name { font-size: 12.5px; color: var(--text-2); }
.tribe-v { font-family: var(--font-latin); font-size: 22px; line-height: 1.3; }
.tribe-sub { font-size: 11.5px; color: var(--text-3); }
.tribe.at-risk .tribe-name, .tribe.at-risk .tribe-v { color: var(--bad); }

@media (max-width: 1100px) {
  .hud-banner { grid-template-columns: 1fr 1fr; }
  .hud-card:nth-child(3) { border-left: 0; }
  .hud-card:nth-child(n + 3) { border-top: 1px solid var(--line); }
}

#ending-banner-box { display: none; margin-bottom: 24px; }

.ending {
  padding: 22px 26px;
  border: 1px solid rgba(217, 160, 70, 0.4);
  border-radius: var(--r-2);
  background: var(--accent-wash);
}

.ending-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--accent-strong);
}

.ending-bio {
  margin-top: 10px;
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.9;
}

.ending-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 24px;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--text-2);
}

.playtest-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

@media (max-width: 1200px) {
  .playtest-grid { grid-template-columns: 1fr; }
}

/* 地图（绢本底） */
.map-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1000 / 620;
  overflow: hidden;
  background: var(--parchment);
  border-bottom: 1px solid var(--line);
}

.map-svg {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
}

.map-svg text { font-family: var(--font-serif); }

.map-legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 5px 10px;
  background: rgba(245, 235, 210, 0.92);
  border: 1px solid rgba(120, 90, 40, 0.35);
  border-radius: var(--r-1);
  font-size: 11px;
  color: #37291a;
  pointer-events: none;
}

.legend-item { display: inline-flex; align-items: center; gap: 5px; }

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(42, 29, 16, 0.8);
  display: inline-block;
}

/* 节点检视 */
.node-inspector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 28px;
  font-size: 13px;
}

@media (max-width: 680px) {
  .node-inspector { grid-template-columns: 1fr; }
}

.ins-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.ins-title h4 {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
}

.ins-subhead {
  margin: 14px 0 6px;
  font-size: 12px;
  color: var(--text-3);
}

.kv-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 16px;
  font-size: 13px;
}

.kv-list dt { color: var(--text-3); }
.kv-list dd { margin: 0; font-variant-numeric: tabular-nums; }

.army-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12.5px;
  border-bottom: 1px dashed var(--line);
}

.bar-row {
  display: grid;
  grid-template-columns: 76px 1fr 30px;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  margin-top: 6px;
}

.bar-row .k { color: var(--text-3); }
.bar-row .v { text-align: right; font-family: var(--font-mono); font-size: 12px; }
.bar-row .progress-track { margin: 0; }

.empty {
  padding: 18px 4px;
  font-size: 13px;
  color: var(--text-3);
}

/* 纪事 */
.chronicle-box {
  padding: 4px 0 16px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.chronicle-text {
  font-family: var(--font-serif);
  font-size: 15.5px;
  line-height: 2;
  color: var(--text);
  text-indent: 2em;
}

.todo-list {
  display: flex;
  flex-direction: column;
}

.todo-item {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 0 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.todo-item:last-child { border-bottom: 0; }
.todo-item .dot { margin-top: 8px; color: var(--accent); }
.todo-item.urgent .dot { color: var(--bad); }
.todo-title { font-weight: 600; }
.todo-item.urgent .todo-title { color: var(--bad); }
.todo-detail { color: var(--text-2); font-size: 12.5px; }

/* 命令列表 */
.cmd-filter-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.cmd-list {
  max-height: 460px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
  margin: 0 -18px -16px;
}

.cmd-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s;
}

.cmd-item:hover { background: var(--bg-raised); }

.cmd-item.selected {
  background: rgba(217, 160, 70, 0.05);
  box-shadow: inset 2px 0 0 var(--accent);
}

.cmd-item input[type="checkbox"] {
  margin: 3px 0 0;
  width: 14px;
  height: 14px;
}

.cmd-title {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
}

.cmd-title .idx {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-3);
  margin-right: 6px;
}

.cmd-title .rec {
  margin-left: 6px;
  font-size: 12px;
  color: var(--accent);
  white-space: nowrap;
}

.cmd-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-3);
}

.cmd-meta .cost { font-family: var(--font-mono); font-size: 11.5px; }

/* 战报 */
.log-stream {
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.turn-log-card {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.turn-log-card:first-child { padding-top: 0; }

.turn-log-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.turn-log-head h5 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
}

.turn-log-mine {
  margin: 4px 0 6px;
  font-size: 12px;
  color: var(--text-3);
}

.event-line {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  padding: 3px 0;
  color: var(--text-2);
}

.event-line .when {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-3);
  padding-top: 1px;
}

.rating-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.rating-bar select { height: 28px; font-size: 12px; }
.rating-bar input[type="text"] { height: 28px; font-size: 12px; width: 200px; }

details.raw {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

details.raw summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-3);
}

details.raw summary:hover { color: var(--text-2); }

.pre-briefing {
  margin-top: 10px;
  padding: 12px 14px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--bg-sunken);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  color: var(--text-2);
}

/* --------------------------------------------------------------------------
   Validation
   -------------------------------------------------------------------------- */

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
}

@media (max-width: 1024px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.gate-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  margin-bottom: 0;
  border-top: 1px solid var(--rule);
  font-size: 13px;
  color: var(--text-2);
}

.gate-banner .verdict {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ok);
}

.gates {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
}

.gate {
  padding: 18px 20px 20px 0;
}

.gate + .gate {
  padding-left: 20px;
  border-left: 1px solid var(--line);
}

.gate-k {
  font-size: 12.5px;
  color: var(--text-2);
}

.gate-v {
  margin-top: 6px;
  font-family: var(--font-latin);
  font-size: 34px;
  line-height: 1.1;
  font-variant-numeric: lining-nums;
}

.gate-v small {
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--text-3);
  margin-left: 6px;
}

.gate-d {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-3);
}

.gate-target {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ok);
}

@media (max-width: 1100px) {
  .gates { grid-template-columns: 1fr 1fr; }
  .gate:nth-child(3) { padding-left: 0; border-left: 0; }
  .gate:nth-child(n + 3) { border-top: 1px solid var(--line); }
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.data-table th {
  position: sticky;
  top: 0;
  background: var(--bg);
  font-weight: 400;
  font-size: 12px;
  color: var(--text-3);
  border-bottom-color: var(--line-strong);
  white-space: nowrap;
}

.data-table td:first-child,
.data-table th:first-child { padding-left: 0; }

.data-table tbody tr:hover { background: var(--bg-raised); }

.data-table .was-bad { color: var(--bad); }
.data-table .v-new { color: var(--text); font-weight: 500; }
.data-table .rank { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-3); }
.data-table code { font-size: 11.5px; word-break: break-all; }

.status-ok {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ok);
  white-space: nowrap;
  font-size: 12.5px;
}

.matrix-table td.cell {
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: right;
}

.matrix-table th { text-align: right; }
.matrix-table th:first-child { text-align: left; }
.matrix-table td.cell.han-lean { background: var(--han-wash); color: #e8a597; }
.matrix-table td.cell.xn-lean { background: var(--xn-wash); color: #d8bea3; }
.matrix-table tr.total td { border-top: 1px solid var(--line-strong); }

.matrix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-3);
}

.matrix-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  vertical-align: -1px;
}

.batch-result {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--bg-raised);
  font-size: 13px;
  color: var(--text-2);
}

.batch-result .stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin-top: 6px;
  color: var(--text);
}

/* --------------------------------------------------------------------------
   Formula lab
   -------------------------------------------------------------------------- */

.slider-row {
  padding: 10px 0 8px;
  border-bottom: 1px dashed var(--line);
}

.slider-row:last-of-type { border-bottom: 0; }

.slider-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-2);
}

.slider-head strong {
  font-family: var(--font-latin);
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: lining-nums tabular-nums;
}

.slider-head label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.calc-result {
  margin-top: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--bg-raised);
}

.calc-big {
  font-family: var(--font-latin);
  font-size: 34px;
  line-height: 1.15;
  font-variant-numeric: lining-nums;
}

.calc-big small {
  font-size: 16px;
  color: var(--text-3);
}

.calc-verdict {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 13px;
}

.calc-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-3);
}

.calc-breakdown b {
  font-family: var(--font-mono);
  font-weight: 400;
  color: var(--text-2);
}

.share-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
}

.share-strip > div + div {
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.share-strip .k { font-size: 12px; color: var(--text-3); }
.share-strip .v { font-family: var(--font-latin); font-size: 26px; line-height: 1.2; }

.food-chart {
  width: 100%;
  height: 190px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--bg-sunken);
}

.food-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--text-3);
}

.food-summary b {
  font-family: var(--font-mono);
  font-weight: 400;
  color: var(--text);
}

/* --------------------------------------------------------------------------
   Docs reader
   -------------------------------------------------------------------------- */

.docs-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

@media (max-width: 960px) {
  .docs-layout { grid-template-columns: 1fr; gap: 24px; }
}

.docs-nav {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
  padding-right: 8px;
}

.doc-nav-group + .doc-nav-group { margin-top: 22px; }

.doc-nav-group-title {
  padding-bottom: 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-3);
}

.doc-nav-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0 6px 12px;
  margin-left: -1px;
  border-left: 1px solid transparent;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-2);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.doc-nav-item:hover { color: var(--text); }

.doc-nav-item.active {
  color: var(--text);
  border-left-color: var(--accent);
}

.doc-nav-item .lines {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-3);
}

.doc-viewer {
  min-width: 0;
  max-width: 820px;
  font-size: 14.5px;
  line-height: 1.85;
  color: var(--text-2);
}

.doc-viewer-header {
  padding-bottom: 16px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.doc-viewer-header h2 {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
}

.doc-viewer-header .eyebrow { display: block; margin-top: 6px; }

.doc-viewer h1,
.doc-viewer h2,
.doc-viewer h3 {
  font-family: var(--font-serif);
  color: var(--text);
  font-weight: 600;
  line-height: 1.4;
}

.doc-viewer #doc-viewer-body h1 { font-size: 24px; margin: 32px 0 12px; }
.doc-viewer #doc-viewer-body h2 { font-size: 19px; margin: 32px 0 10px; padding-top: 20px; border-top: 1px solid var(--line); }
.doc-viewer #doc-viewer-body h3 { font-size: 16px; margin: 22px 0 8px; }
.doc-viewer #doc-viewer-body h1:first-child { margin-top: 0; }
.doc-viewer li { padding-left: 1.1em; text-indent: -1.1em; }
.doc-viewer li::before { content: "·"; display: inline-block; width: 1.1em; text-indent: 0; color: var(--text-3); }
.doc-viewer hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

.doc-viewer pre {
  margin: 12px 0;
  padding: 14px 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--bg-sunken);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-2);
}

.doc-viewer code {
  font-size: 0.88em;
  color: var(--accent);
}

.doc-viewer pre code { color: inherit; font-size: inherit; }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.site-footer {
  margin-top: 40px;
  padding: 56px 0 28px;
  border-top: 1px solid var(--line);
  overflow: hidden;
}

.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr));
  gap: 40px;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.footer-note {
  margin-top: 14px;
  max-width: 30em;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-3);
}

.footer-h {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 12px;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
  color: var(--text-2);
}

.footer-links a:hover { color: var(--text); }

.colophon {
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--text-3);
}

.footer-wordmark {
  margin: 56px 0 0;
  font-family: var(--font-serif);
  font-size: clamp(72px, 16vw, 220px);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: 0.08em;
  color: transparent;
  -webkit-text-stroke: 1px var(--line-strong);
  user-select: none;
  white-space: nowrap;
}

.footer-base {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-3);
}

@media (max-width: 860px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Markdown 正文 */
.doc-viewer p { margin: 0 0 14px; }
.doc-viewer strong { color: var(--text); }
.doc-viewer blockquote {
  margin: 0;
  padding: 2px 0 2px 16px;
  border-left: 2px solid var(--line-strong);
  color: var(--text-3);
  font-size: 13.5px;
}
.doc-viewer blockquote + :not(blockquote) { margin-top: 16px; }
.doc-viewer ul, .doc-viewer ol { margin: 0 0 14px; }
.doc-viewer ol { counter-reset: md; }
.doc-viewer ol > li { counter-increment: md; }
.doc-viewer ol > li::before { content: counter(md) "."; font-family: var(--font-mono); font-size: 12px; }
.doc-viewer .md-link { color: var(--accent); }
.doc-viewer .md-table { overflow-x: auto; margin: 4px 0 18px; }
.doc-viewer .md-table .data-table { font-size: 12.5px; }
.doc-viewer .md-table .data-table td,
.doc-viewer .md-table .data-table th { padding: 8px 10px; }
.doc-viewer .md-table .data-table th { position: static; color: var(--text-2); }

/* ==========================================================================
   书简主题（覆盖层）
   取意汉代简牍与漆器：漆黑底、竹简缃色、墨色字、朱砂点睛。
   标题用江西拙楷（毛笔意趣），正文与按键用霞鹜文楷。
   ========================================================================== */

:root {
  --bg: #100e0b;
  --bg-raised: #16130f;
  --bg-sunken: #0b0a08;
  --bg-hover: #1c1813;
  --line: #29241c;
  --line-strong: #3d362b;
  --rule: #5b5141;
  --text: #e9dfc8;
  --text-2: #b4a88f;
  --text-3: #7e7463;

  /* 竹简缃色 / 朱砂 / 墨 */
  --slip: #cdb98e;
  --slip-light: #ddcca4;
  --slip-line: rgba(205, 185, 142, 0.26);
  --slip-line-strong: rgba(205, 185, 142, 0.46);
  --slip-wash: rgba(205, 185, 142, 0.07);
  --ink: #2a2015;
  --cinnabar: #b0523b;
  --cinnabar-soft: #d39a86;

  --accent: #c2a26c;
  --accent-strong: #d8bb86;
  --accent-ink: #2a2015;
  --accent-wash: rgba(194, 162, 108, 0.1);
  --han: #b0523b;
  --han-wash: rgba(176, 82, 59, 0.13);
  --xn: #9c8064;
  --ok: #8fa98a;
  --bad: #c0644f;

  --font-brush: "jiangxizhuokai", "LXGW WenKai", "Kaiti SC", "STKaiti", "KaiTi", serif;
  --font-kai: "LXGW WenKai", "Kaiti SC", "STKaiti", "KaiTi", serif;
  --font-serif: var(--font-kai);
  --font-sans: "LXGW WenKai", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

body {
  font-family: var(--font-sans);
  font-size: 14.5px;
  letter-spacing: 0.01em;
}

/* 标题：毛笔字 */
.display,
.page-title,
.section-title,
.scenario-name,
.faction-name,
.faction-seal,
.brand-name,
.footer-wordmark,
.ending-title,
.doc-viewer-header h2 {
  font-family: var(--font-brush);
  font-weight: 400;
}

.display { letter-spacing: 0.02em; line-height: 1.12; }
.display em { color: var(--cinnabar-soft); text-shadow: none; }
.page-title { letter-spacing: 0.04em; }
.section-title { letter-spacing: 0.04em; }
.brand-name { letter-spacing: 0.18em; font-size: 20px; }
.scenario-name { letter-spacing: 0.1em; font-size: 28px; }

.panel-title h3,
.turn-log-head h5,
.ins-title h4,
.contents .t,
.plate-quote blockquote,
.hero-lede,
.chronicle-text,
.ending-bio {
  font-family: var(--font-kai);
  font-weight: 400;
}

.panel-title h3 { font-size: 17px; letter-spacing: 0.08em; }
.hero-lede { font-size: 17.5px; }
.plate-quote blockquote { font-size: 21px; }

/* 章节号：汉字数码 */
.nav-no,
.chapter-no,
.contents .no {
  font-family: var(--font-kai);
  font-style: normal;
}

.nav-no { font-size: 12px; color: var(--text-3); }
.chapter-no { font-size: 15px; color: var(--cinnabar-soft); }
.contents .no { font-size: 15px; color: var(--cinnabar-soft); }
.site-nav a[aria-current="page"] .nav-no { color: var(--cinnabar-soft); }
.site-nav a[aria-current="page"]::after { background: var(--slip); }

/* 封面：竖向简条纹理 + 两道编绳 */
.cover {
  background:
    linear-gradient(180deg, transparent 0 22%, rgba(205, 185, 142, 0.05) 22% calc(22% + 1px), transparent calc(22% + 1px) 78%, rgba(205, 185, 142, 0.05) 78% calc(78% + 1px), transparent calc(78% + 1px)),
    repeating-linear-gradient(90deg, rgba(205, 185, 142, 0.028) 0 1px, transparent 1px 36px);
}

.cover::before {
  background: radial-gradient(circle 560px at var(--mx) var(--my), rgba(205, 185, 142, 0.08), transparent 70%);
}

.cover-route .rider { stroke: var(--cinnabar-soft); }

.plate-media img { filter: sepia(0.28) saturate(0.7) contrast(0.98) brightness(0.96); }

/* --------------------------------------------------------------------------
   按键：一枚竹简 / 一道细线
   -------------------------------------------------------------------------- */

.btn {
  height: 34px;
  padding: 0 16px;
  border: 1px solid var(--slip-line);
  border-radius: 1px;
  background: transparent;
  font-family: var(--font-kai);
  font-size: 14px;
  letter-spacing: 0.12em;
  color: var(--slip-light);
  transition: background 0.25s, border-color 0.25s, color 0.25s;
}

.btn:hover:not(:disabled) {
  background: var(--slip-wash);
  border-color: var(--slip-line-strong);
  color: var(--text);
}

.btn .icon { width: 13px; height: 13px; stroke-width: 1.3; }

/* 主操作：竹简色底、墨字、细竹纹与两道编绳 */
.btn-solid,
.btn-accent {
  border: 1px solid #b8a274;
  color: var(--ink);
  background:
    linear-gradient(180deg, transparent 5px, rgba(60, 40, 18, 0.22) 5px 6px, transparent 6px calc(100% - 6px), rgba(60, 40, 18, 0.22) calc(100% - 6px) calc(100% - 5px), transparent calc(100% - 5px)),
    repeating-linear-gradient(90deg, rgba(90, 64, 30, 0.07) 0 1px, transparent 1px 5px),
    linear-gradient(180deg, #cfc09b, #bba982);
  font-weight: 400;
  box-shadow: inset 0 1px 0 rgba(255, 248, 228, 0.35);
}

.btn-solid:hover:not(:disabled),
.btn-accent:hover:not(:disabled) {
  opacity: 1;
  color: #1a130b;
  border-color: #cdb98e;
  background:
    linear-gradient(180deg, transparent 5px, rgba(60, 40, 18, 0.22) 5px 6px, transparent 6px calc(100% - 6px), rgba(60, 40, 18, 0.22) calc(100% - 6px) calc(100% - 5px), transparent calc(100% - 5px)),
    repeating-linear-gradient(90deg, rgba(90, 64, 30, 0.07) 0 1px, transparent 1px 5px),
    linear-gradient(180deg, #dacca8, #c7b58d);
}

.btn-quiet {
  border-color: transparent;
  color: var(--text-2);
  padding: 0 4px;
}

.btn-quiet:hover:not(:disabled) {
  background: none;
  border-color: transparent;
  color: var(--slip-light);
}

.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 44px; padding: 0 24px; font-size: 15.5px; letter-spacing: 0.2em; }

.engine-pill {
  border-color: var(--slip-line);
  border-radius: 1px;
  background: transparent;
}

/* 分段与开关 */
.segmented {
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  gap: 4px;
}

.segmented button {
  height: 30px;
  padding: 0 10px;
  border-radius: 0;
  font-family: var(--font-kai);
  font-size: 13.5px;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: -1px;
  border-bottom: 1px solid transparent;
}

.segmented button.active,
.segmented button[aria-pressed="true"] {
  background: transparent;
  box-shadow: none;
  color: var(--slip-light);
  border-bottom-color: var(--slip);
}

.switch input:checked { background: var(--slip); }

/* 表单 */
select,
input[type="number"],
input[type="text"] {
  border-color: var(--line-strong);
  border-radius: 1px;
  background-color: transparent;
  font-family: var(--font-kai);
  font-size: 13.5px;
}

select option { background: #16130f; color: var(--text); }

input[type="range"],
input[type="checkbox"] { accent-color: #b9a274; }

/* 小标签：像简端的朱笔批注 */
.badge {
  border-radius: 1px;
  font-family: var(--font-kai);
  font-size: 12px;
  border-color: var(--line-strong);
}

.badge-gold { color: var(--accent); border-color: rgba(194, 162, 108, 0.38); }
.badge-red { color: var(--cinnabar-soft); border-color: rgba(176, 82, 59, 0.45); }

/* 面板与表格 */
.panel-box { border-radius: 1px; }
.progress-fill.accent { background: var(--accent); }
.progress-fill.han { background: var(--cinnabar); }
.cmd-item.selected { background: rgba(205, 185, 142, 0.045); box-shadow: inset 2px 0 0 var(--slip); }
.cmd-title .rec { color: var(--cinnabar-soft); }
.todo-item .dot { color: var(--slip); }
.text-link { color: var(--accent); }
.text-link:hover { color: var(--accent-strong); }
.plate-kicker { color: var(--cinnabar-soft); }
.doc-nav-item.active { border-left-color: var(--slip); }
.doc-viewer code, .doc-viewer .md-link { color: var(--accent); }

/* 阵营印：朱文方印 */
.faction-seal {
  border-width: 2px;
  border-radius: 2px;
  font-size: 28px;
}

.figure-v, .gate-v, .hud-val, .calc-big { font-weight: 400; }

.chapter-mark .en { font-family: var(--font-kai); font-style: normal; font-size: 13px; letter-spacing: 0.2em; }
.chapter-head .chapter-no {
  font-size: 0;
  width: 10px;
  height: 10px;
  margin-top: 14px;
  background: var(--cinnabar);
  opacity: 0.85;
}
.chapter-head .chapter-no { align-self: start; }
