/* ============================================================
   神玺书 Wiki · 墨纸朱砂主题
   零依赖、响应式、明暗双主题
   ============================================================ */

:root {
  --font-serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", Georgia, "Times New Roman", serif;
  --font-sans: "Noto Sans SC", "Source Han Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;

  --paper: #f4efe4;
  --paper-2: #faf6ed;
  --surface: #fffdf7;
  --surface-2: #efe7d7;
  --surface-3: #e8dfcc;
  --ink: #211d17;
  --ink-2: #3d362b;
  --muted: #756b5b;
  --muted-2: #948874;
  --line: #dfd4bf;
  --line-strong: #c8b99c;
  --accent: #9c3a2b;
  --accent-2: #7a2a1f;
  --accent-soft: #f2e2da;
  --gold: #a27b38;
  --gold-soft: #f3ead4;
  --jade: #3f6f5c;
  --jade-soft: #e4efe9;
  --purple: #6d4f8a;
  --header-bg: rgba(244, 239, 228, 0.86);
  --shadow-sm: 0 1px 2px rgba(50, 40, 25, 0.06);
  --shadow-md: 0 10px 30px -18px rgba(50, 40, 25, 0.35);
  --shadow-lg: 0 24px 60px -28px rgba(50, 40, 25, 0.45);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --max: 1240px;
  --reading: 760px;
  --header-height: 70px;
  --spoiler-bg: #f3e7d5;
  --spoiler-line: #c99a4e;
  --code-bg: #ebe2d0;
  --selection: #e9d3a8;
}

[data-theme="dark"] {
  --paper: #14120e;
  --paper-2: #1a1712;
  --surface: #201c16;
  --surface-2: #2a251d;
  --surface-3: #332d23;
  --ink: #eee5d4;
  --ink-2: #d6cab5;
  --muted: #a1947e;
  --muted-2: #817663;
  --line: #3a3327;
  --line-strong: #514836;
  --accent: #d16b57;
  --accent-2: #e58d79;
  --accent-soft: #3a221c;
  --gold: #c8a35d;
  --gold-soft: #332a1a;
  --jade: #74ad95;
  --jade-soft: #1e2e27;
  --purple: #a889c2;
  --header-bg: rgba(20, 18, 14, 0.86);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 30px -18px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 24px 60px -28px rgba(0, 0, 0, 0.8);
  --spoiler-bg: #2b2218;
  --spoiler-line: #9c7331;
  --code-bg: #2a251d;
  --selection: #4a3a22;
}

@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --paper: #14120e;
    --paper-2: #1a1712;
    --surface: #201c16;
    --surface-2: #2a251d;
    --surface-3: #332d23;
    --ink: #eee5d4;
    --ink-2: #d6cab5;
    --muted: #a1947e;
    --muted-2: #817663;
    --line: #3a3327;
    --line-strong: #514836;
    --accent: #d16b57;
    --accent-2: #e58d79;
    --accent-soft: #3a221c;
    --gold: #c8a35d;
    --gold-soft: #332a1a;
    --jade: #74ad95;
    --jade-soft: #1e2e27;
    --purple: #a889c2;
    --header-bg: rgba(20, 18, 14, 0.86);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 30px -18px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 24px 60px -28px rgba(0, 0, 0, 0.8);
    --spoiler-bg: #2b2218;
    --spoiler-line: #9c7331;
    --code-bg: #2a251d;
    --selection: #4a3a22;
  }
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 24px);
}

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--gold) 7%, transparent), transparent 65%),
    radial-gradient(900px 500px at 90% 0%, color-mix(in srgb, var(--accent) 5%, transparent), transparent 60%),
    linear-gradient(180deg, var(--paper-2), var(--paper) 38%, var(--paper));
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--selection);
}

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

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

button {
  cursor: pointer;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2rem 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 0;
  left: 12px;
  z-index: 1000;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-120%);
}

.skip-link:focus {
  transform: translateY(10px);
}

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

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

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

.header-inner {
  max-width: var(--max);
  height: 100%;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  color: var(--ink);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-seal {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #f6ecd8;
  font-family: var(--font-serif);
  font-size: 22px;
  line-height: 1;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--gold) 55%, transparent), var(--shadow-sm);
}

.brand-seal.small {
  width: 32px;
  height: 32px;
  font-size: 17px;
  border-radius: 7px;
}

.brand-seal.large {
  width: 64px;
  height: 64px;
  font-size: 34px;
  border-radius: 12px;
}

.brand-logo {
  display: block;
  object-fit: contain;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.02em;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}

.nav-link {
  padding: 7px 11px;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 14px;
  white-space: nowrap;
}

.nav-link:hover,
.nav-link.is-active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  text-decoration: none;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-search {
  display: flex;
  align-items: center;
  height: 38px;
  padding: 0 6px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.header-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

.header-search input {
  width: 190px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 13px;
}

.header-search button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}

.header-search button:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.header-search svg,
.icon-button svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.icon-button:hover {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 18%, transparent);
}

.theme-toggle .icon-moon,
[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}

@media (prefers-color-scheme: dark) {
  [data-theme="auto"] .theme-toggle .icon-sun {
    display: none;
  }
  [data-theme="auto"] .theme-toggle .icon-moon {
    display: block;
  }
}

.nav-toggle {
  display: none;
}

/* ---------- Main / footer ---------- */

.site-main {
  min-height: 60vh;
}

.site-footer {
  margin-top: 72px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper-2) 75%, transparent);
}

.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 36px 28px 44px;
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 32px;
  align-items: start;
}

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

.footer-brand strong {
  font-family: var(--font-serif);
}

.footer-brand p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.footer-disclaimer {
  margin: 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

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

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

/* ---------- Common ---------- */

.container {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 28px;
}

.narrow {
  max-width: var(--reading);
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.section-heading h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.section-action {
  flex: 0 0 auto;
}

.text-link {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.text-link:hover {
  color: var(--accent);
  text-decoration: none;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.button:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff8ec;
}

.button.primary:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
}

.button.ghost {
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  border-color: var(--line);
  color: var(--ink-2);
}

.button.ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.button.danger {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  color: var(--accent);
}

.button.danger:hover {
  background: var(--accent);
  color: #fff8ec;
}

.button.small {
  min-height: 32px;
  padding: 4px 12px;
  font-size: 12px;
}

.button.tiny {
  min-height: 28px;
  padding: 2px 9px;
  font-size: 11px;
  border-radius: 7px;
}

.button.full {
  width: 100%;
}

.button:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
  box-shadow: none;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
  white-space: nowrap;
}

.tag:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.tag.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.tag .tag-count {
  margin-left: 5px;
  color: var(--muted-2);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.tag.is-filtered-out {
  display: none;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px 2px 6px;
  border: 1px solid color-mix(in srgb, var(--type-color, var(--line-strong)) 35%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--type-color, var(--muted)) 10%, transparent);
  color: var(--type-color, var(--ink-2));
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
}

.type-badge .type-glyph {
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--type-color, var(--muted)) 18%, transparent);
  font-family: var(--font-serif);
  font-size: 10px;
  font-weight: 700;
}

.type-badge.is-small {
  padding: 1px 7px 1px 4px;
  font-size: 11px;
}

.type-badge.is-small .type-glyph {
  width: 15px;
  height: 15px;
  font-size: 9px;
}

.type-glyph {
  flex: 0 0 auto;
}

.type-glyph.small {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--type-color, var(--muted)) 12%, transparent);
  color: var(--type-color, var(--muted));
  font-family: var(--font-serif);
  font-size: 12px;
  font-weight: 700;
}

.type-glyph.large {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--type-color, var(--muted)) 12%, transparent);
  color: var(--type-color, var(--muted));
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
}

.type-work { --type-color: #8b3b2a; }
.type-character { --type-color: #9c3a2b; }
.type-faction { --type-color: #3f6f5c; }
.type-location { --type-color: #5f7d3d; }
.type-event { --type-color: #73508f; }
.type-item { --type-color: #a27b38; }
.type-concept { --type-color: #4d6f8e; }
.type-chapter { --type-color: #8a6949; }

.spoiler-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 10px;
  line-height: 1.7;
  white-space: nowrap;
}

.spoiler-badge.level-0 {
  color: var(--jade);
  background: var(--jade-soft);
  border-color: color-mix(in srgb, var(--jade) 22%, transparent);
}

.spoiler-badge.level-1 {
  color: var(--gold);
  background: var(--gold-soft);
  border-color: color-mix(in srgb, var(--gold) 28%, transparent);
}

.spoiler-badge.level-2 {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
}

.count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

/* ---------- Hero ---------- */

.page-hero {
  position: relative;
  overflow: hidden;
  padding: 76px 28px 60px;
  border-bottom: 1px solid var(--line);
}

.page-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(700px 340px at 50% 0%, color-mix(in srgb, var(--gold) 11%, transparent), transparent 70%),
    repeating-linear-gradient(115deg, transparent 0 18px, color-mix(in srgb, var(--ink) 1.4%, transparent) 18px 19px);
  pointer-events: none;
  opacity: 0.9;
}

.page-hero::after {
  content: "玺";
  position: absolute;
  right: max(4vw, 24px);
  top: 50%;
  transform: translateY(-50%) rotate(-8deg);
  color: color-mix(in srgb, var(--accent) 7%, transparent);
  font-family: var(--font-serif);
  font-size: clamp(120px, 20vw, 260px);
  line-height: 1;
  pointer-events: none;
}

.page-hero.is-compact {
  padding: 50px 28px 40px;
}

.page-hero.is-compact::after {
  font-size: clamp(90px, 13vw, 170px);
}

.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 920px;
  margin: 0 auto;
  text-align: center;
}

.hero-eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.hero-eyebrow::before,
.hero-eyebrow::after {
  content: "·";
  margin: 0 10px;
  color: var(--gold);
}

.page-hero h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.hero-title-main {
  display: block;
  font-size: clamp(52px, 9vw, 92px);
  line-height: 1.08;
  color: var(--ink);
  text-shadow: 0 2px 0 color-mix(in srgb, var(--paper) 80%, transparent);
}

.hero-title-sub {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: clamp(18px, 3.4vw, 30px);
  letter-spacing: 0.26em;
}

.hero-subtitle {
  margin: 12px 0 0;
  color: var(--ink-2);
  font-family: var(--font-serif);
  font-size: clamp(17px, 2.2vw, 22px);
}

.hero-description {
  max-width: 720px;
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.9;
}

.hero-search {
  display: flex;
  max-width: 620px;
  margin: 28px auto 0;
  padding: 6px 6px 6px 20px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  box-shadow: var(--shadow-md);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.hero-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 10%, transparent), var(--shadow-md);
}

.hero-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
}

.hero-search button {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 26px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff8ec;
  font-weight: 600;
  letter-spacing: 0.08em;
  transition: background 0.2s ease;
}

.hero-search button:hover {
  background: var(--accent-2);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 26px;
}

/* ---------- Home ---------- */

.stats-strip {
  max-width: var(--max);
  margin: -26px auto 0;
  padding: 0 28px;
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
  box-shadow: var(--shadow-md);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 18px 10px 16px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}

.stat strong {
  font-family: var(--font-serif);
  font-size: 26px;
  line-height: 1.1;
  color: var(--accent);
}

.stat span {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.home-section {
  max-width: var(--max);
  margin: 64px auto 0;
  padding: 0 28px;
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.type-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  color: var(--ink);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.type-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--type-color, var(--accent)) 45%, var(--line));
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

.type-card-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.type-card-text strong {
  font-family: var(--font-serif);
  font-size: 16px;
}

.type-card-text small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.type-count {
  margin-left: auto;
  align-self: flex-start;
  color: var(--type-color, var(--muted));
  font-family: var(--font-serif);
  font-size: 18px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.compact-grid {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

.entity-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 18px 18px 16px;
  border: 1px solid var(--line);
  border-top: 3px solid color-mix(in srgb, var(--type-color, var(--accent)) 62%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  color: var(--ink);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.entity-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--type-color, var(--accent)) 35%, var(--line));
  text-decoration: none;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.entity-card h3 {
  margin: 0 0 2px;
  font-family: var(--font-serif);
  font-size: 20px;
  line-height: 1.35;
}

.card-subtitle {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.card-summary {
  margin: 0;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.75;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 12px;
}

.card-tags .tag {
  padding: 1px 7px;
  font-size: 10px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.9fr);
  gap: 40px;
  align-items: start;
}

.update-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}

.update-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  transition: background 0.2s ease, padding 0.2s ease;
}

.update-row:hover {
  background: color-mix(in srgb, var(--accent) 4%, transparent);
  padding-left: 10px;
  padding-right: 10px;
  text-decoration: none;
}

.update-glyph {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--type-color, var(--muted)) 11%, transparent);
  color: var(--type-color, var(--muted));
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
}

.update-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.update-text strong {
  font-size: 14px;
}

.update-text small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.update-row time {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--muted-2);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.mini-timeline {
  position: relative;
  padding-left: 18px;
}

.mini-timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 4px;
  bottom: 4px;
  width: 1px;
  background: var(--line-strong);
}

.mini-timeline-item {
  position: relative;
  margin-bottom: 18px;
}

.mini-dot {
  position: absolute;
  left: -17px;
  top: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 16%, transparent);
}

.mini-timeline-item small {
  display: block;
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.mini-timeline-item strong {
  display: block;
  margin: 1px 0 2px;
  font-size: 14px;
}

.mini-timeline-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.notice-card {
  display: flex;
  gap: 12px;
  margin-top: 26px;
  padding: 16px;
  border: 1px dashed color-mix(in srgb, var(--gold) 45%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--gold) 7%, transparent);
}

.notice-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gold);
  color: #fff8ec;
  font-family: var(--font-serif);
  font-weight: 700;
}

.notice-card strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 14px;
}

.notice-card p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.notice-card a {
  font-size: 12px;
}

.work-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.work-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  color: var(--ink);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.work-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

.work-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 46px;
  height: 56px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-serif);
  font-size: 20px;
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--accent) 22%, transparent);
}

.work-card strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 18px;
}

.work-card small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.work-card p {
  margin: 8px 0 0;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.7;
}

.work-arrow {
  margin-left: auto;
  align-self: center;
  color: var(--muted);
  font-size: 20px;
}

.work-card.is-placeholder {
  border-style: dashed;
  background: transparent;
}

.disclaimer-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 56px;
  padding: 22px 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 58%, transparent);
}

.disclaimer-strip strong {
  font-family: var(--font-serif);
}

.disclaimer-strip p {
  max-width: 860px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

/* ---------- Explore / search ---------- */

.explore-section,
.search-section,
.timeline-section,
.graph-section,
.about-section,
.admin-section,
.error-section,
.admin-login-section {
  max-width: var(--max);
  margin: 0 auto;
  padding: 44px 28px 0;
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 18px;
}

.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 13px;
  transition: all 0.2s ease;
}

.filter-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.filter-tab.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff8ec;
}

.filter-tab span {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  font-size: 10px;
  line-height: 1;
}

.filter-tab.is-active span {
  background: rgba(255, 255, 255, 0.2);
}

.tag-panel {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 62%, transparent);
}

.tag-panel summary {
  padding: 12px 16px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  list-style: none;
}

.tag-panel summary::before {
  content: "＋";
  margin-right: 8px;
  color: var(--accent);
}

.tag-panel[open] summary::before {
  content: "－";
}

.tag-panel summary span {
  color: var(--muted-2);
  font-size: 11px;
}

.tag-panel-body {
  padding: 0 16px 16px;
}

.tag-filter-input {
  width: 100%;
  margin: 0 0 12px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
}

.tag-filter-input:focus {
  border-color: var(--accent);
  outline: none;
}

.tag-panel .tag-cloud {
  max-height: min(48vh, 380px);
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
}

.tag-filter-empty {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.active-filter {
  margin: 0 0 16px;
  padding: 8px 14px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--ink-2);
  font-size: 13px;
}

.active-filter a {
  margin-left: 8px;
  font-size: 12px;
}

.explore-grid {
  margin-top: 6px;
}

.empty-state {
  padding: 48px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
  color: var(--muted);
}

.search-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 26px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
}

.search-controls input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search-controls select {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-result {
  display: block;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  color: var(--ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.search-result:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  text-decoration: none;
}

.search-result-top {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
}

.search-result h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 21px;
}

.search-subtitle {
  margin: 1px 0 6px;
  color: var(--muted);
  font-size: 12px;
}

.search-snippet {
  margin: 0;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.75;
}

mark {
  padding: 0 2px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--gold) 35%, transparent);
  color: inherit;
}

.search-suggestions {
  margin-top: 46px;
}

/* ---------- Entity page ---------- */

.entity-page {
  background: transparent;
}

.entity-container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 26px 28px 0;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.breadcrumbs a {
  color: var(--muted);
}

.breadcrumbs a:hover {
  color: var(--accent);
}

.breadcrumbs .current {
  color: var(--ink-2);
}

.entity-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  align-items: end;
  margin: 22px 0 30px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.entity-header-main {
  min-width: 0;
}

.entity-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 12px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.7;
}

.meta-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.entity-header h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(38px, 6vw, 62px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: 0.015em;
}

.entity-aliases {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.entity-subtitle {
  margin: 8px 0 0;
  color: var(--accent);
  font-family: var(--font-serif);
  font-size: 17px;
}

.entity-summary {
  max-width: 760px;
  margin-top: 16px;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.9;
}

.entity-summary p {
  margin: 0;
}

.entity-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}

.admin-inline {
  margin-top: 18px;
}

.entity-image {
  width: 100%;
  margin: 0 0 34px;
}

.entity-image a {
  display: block;
}

.entity-image img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.imagegen-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}

.imagegen-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.imagegen-card {
  padding: 24px;
  overflow-y: auto;
}

.imagegen-card h2 {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 22px;
}

.imagegen-note {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.imagegen-current {
  display: flex;
  justify-content: center;
  margin: 0 0 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-2);
}

.imagegen-current img {
  max-width: 100%;
  max-height: 220px;
  border-radius: var(--radius-sm);
}

.imagegen-card label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}

.imagegen-prompt {
  width: 100%;
  min-height: 150px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper-2);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.7;
  resize: vertical;
}

.imagegen-prompt:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 1px;
}

.imagegen-model-row {
  margin-top: 14px;
}

.imagegen-model {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper-2);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13px;
}

.imagegen-model:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 1px;
}

.imagegen-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.imagegen-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.imagegen-status {
  min-height: 1.5em;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.imagegen-status.is-error {
  color: var(--accent);
}

.imagegen-status.is-success {
  color: var(--jade);
}

.imagegen-status.is-warning {
  color: var(--gold);
}

.entity-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 44px;
  align-items: start;
}

.entity-article {
  max-width: var(--reading);
  min-width: 0;
}

.article-section {
  margin: 0 0 42px;
  scroll-margin-top: calc(var(--header-height) + 24px);
}

.article-section h2 {
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-serif);
  font-size: clamp(22px, 2.4vw, 28px);
  line-height: 1.35;
  letter-spacing: 0.01em;
}

.section-note {
  margin: -8px 0 16px;
  color: var(--muted);
  font-size: 12px;
}

.markdown {
  color: var(--ink-2);
  font-size: 16px;
  line-height: 1.95;
}

.markdown p {
  margin: 0 0 1.15em;
}

.markdown h3,
.markdown h4 {
  margin: 1.8em 0 0.65em;
  color: var(--ink);
  font-family: var(--font-serif);
  line-height: 1.4;
}

.markdown h3 {
  font-size: 20px;
}

.markdown h4 {
  font-size: 17px;
}

.markdown ul,
.markdown ol {
  margin: 0 0 1.2em;
  padding-left: 1.4em;
}

.markdown li {
  margin: 0.3em 0;
}

.markdown blockquote {
  margin: 1.4em 0;
  padding: 10px 18px;
  border-left: 3px solid var(--gold);
  background: color-mix(in srgb, var(--gold) 7%, transparent);
  color: var(--ink-2);
  font-style: normal;
}

.markdown code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--code-bg);
  color: var(--ink);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
}

.markdown pre.md-code {
  overflow-x: auto;
  margin: 1.4em 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  font-size: 13px;
  line-height: 1.7;
}

.markdown pre.md-code code {
  padding: 0;
  background: transparent;
}

.markdown .table-wrap {
  overflow-x: auto;
  margin: 1.5em 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.markdown table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

.markdown th {
  background: var(--surface-2);
  font-weight: 600;
}

.markdown tr:last-child td {
  border-bottom: 0;
}

.markdown img.md-image {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.markdown a,
.entity-summary a,
.wiki-link {
  color: var(--accent);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.markdown a:hover,
.entity-summary a:hover,
.wiki-link:hover {
  border-bottom-color: var(--accent);
  text-decoration: none;
}

.wiki-link.is-missing {
  color: var(--muted);
  border-bottom: 1px dashed var(--line-strong);
  cursor: help;
}

/* Spoilers */

.spoiler-block {
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--spoiler-line) 32%, var(--line));
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--spoiler-bg) 65%, transparent), transparent 60%),
    color-mix(in srgb, var(--surface) 72%, transparent);
  overflow: hidden;
}

.spoiler-block > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.spoiler-block > summary::-webkit-details-marker {
  display: none;
}

.spoiler-block > summary::after {
  content: "＋";
  margin-left: auto;
  color: var(--accent);
  font-family: var(--font-serif);
  font-size: 16px;
}

.spoiler-block[open] > summary::after {
  content: "－";
}

.spoiler-block > summary h2 {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: clamp(19px, 2vw, 23px);
}

.spoiler-hint {
  color: var(--muted);
  font-size: 11px;
}

/* 文章章节的“展开阅读”贴右，与加号组成一组 */
.article-section.spoiler-block > summary .spoiler-hint {
  margin-left: auto;
}

.article-section.spoiler-block > summary::after {
  margin-left: 8px;
}

.spoiler-block .spoiler-content,
.spoiler-block > .markdown {
  padding: 4px 22px 20px;
}

.spoiler-block > .markdown {
  border-top: 1px solid color-mix(in srgb, var(--spoiler-line) 20%, transparent);
}

.spoiler-inline {
  display: inline;
  padding: 0 3px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--spoiler-bg) 85%, transparent);
  filter: blur(5px);
  cursor: pointer;
  user-select: none;
  transition: filter 0.25s ease, background 0.25s ease;
}

.spoiler-inline:focus,
.spoiler-inline.is-revealed {
  filter: none;
}

.spoiler-inline:focus-visible {
  outline: 2px solid var(--accent);
}

/* 原文引用上标 */

.cite-ref {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15em;
  height: 1.15em;
  padding: 0 0.22em;
  margin: 0 0.08em 0 0.15em;
  border: 0;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 0.64em;
  font-weight: 700;
  line-height: 1;
  vertical-align: super;
  transform: translateY(-0.12em);
  cursor: help;
  position: relative;
}

.cite-ref:hover,
.cite-ref:focus,
.cite-ref.is-open {
  background: var(--accent);
  color: #fff;
  outline: none;
}

.cite-ref:focus-visible {
  box-shadow: 0 0 0 2px var(--accent);
}

.cite-ref.is-missing {
  background: transparent;
  color: var(--accent);
  cursor: help;
}

.cite-tooltip {
  position: fixed;
  z-index: 2147483647;
  max-width: min(24rem, calc(100vw - 16px));
  padding: 8px 10px;
  border-radius: 6px;
  background: #1f2328;
  color: #f5f1e8;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.6;
  text-align: left;
  white-space: normal;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease;
}

.cite-tooltip.is-open {
  opacity: 1;
  visibility: visible;
}

/* Relations */

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

.relation-group h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.relation-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dot, var(--muted));
}

.relation-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface) 62%, transparent);
  overflow: hidden;
}

.relation-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
}

.relation-item:last-child {
  border-bottom: 0;
}

.relation-item:hover {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  text-decoration: none;
}

.relation-target {
  font-weight: 600;
}

.relation-type {
  color: var(--muted);
  font-size: 10px;
}

.relation-label {
  color: var(--muted);
  font-size: 11px;
}

.relation-item.is-missing {
  color: var(--muted);
  cursor: default;
}

/* Backlinks / related / appearances */

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

.backlink-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}

.backlink-item:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.backlink-item span:last-child {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.backlink-item strong {
  font-size: 13px;
}

.backlink-item small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chapter-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 62%, transparent);
  color: var(--ink-2);
  font-size: 12px;
}

.chapter-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.chapter-chip span {
  color: var(--muted-2);
  font-size: 10px;
}

.article-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 48px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.copy-link {
  margin-left: auto;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.copy-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Aside */

.entity-aside {
  position: static;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.infobox {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  box-shadow: var(--shadow-sm);
}

.view-count {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  box-shadow: var(--shadow-sm);
  color: var(--muted);
  font-size: 12px;
}

.view-count strong {
  color: var(--accent);
  font-family: var(--font-serif);
  font-size: 22px;
  line-height: 1;
}

.view-count-label {
  color: var(--muted);
}

.view-count-unit {
  color: var(--muted-2);
}

.infobox-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--type-color, var(--accent)) 7%, transparent);
  font-family: var(--font-serif);
  font-size: 16px;
}

.infobox-glyph {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--type-color, var(--muted)) 14%, transparent);
  color: var(--type-color, var(--muted));
  font-size: 13px;
  font-weight: 700;
}

.infobox dl {
  margin: 0;
  padding: 4px 0;
}

.info-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 8px;
  padding: 7px 16px;
  font-size: 12px;
  line-height: 1.65;
}

.info-row dt {
  color: var(--muted);
}

.info-row dd {
  margin: 0;
  color: var(--ink-2);
}

.info-row dd a {
  color: var(--accent);
}

.infobox-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 9px 16px 12px;
  border-top: 1px solid var(--line);
  color: var(--muted-2);
  font-size: 10px;
}

.toc {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 58%, transparent);
}

.toc strong {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.1em;
}

.toc ol {
  margin: 0;
  padding-left: 1.1em;
  color: var(--muted);
  font-size: 12px;
}

.toc li {
  margin: 4px 0;
  line-height: 1.55;
}

.toc a {
  color: var(--ink-2);
}

.toc a:hover {
  color: var(--accent);
}

.toc-spoiler {
  color: var(--accent);
  font-size: 9px;
}

.toc-spoiler-toggle {
  width: 100%;
  margin-top: 10px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.toc-spoiler-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Timeline ---------- */

.timeline-section {
  max-width: 1000px;
}

.timeline {
  position: relative;
  padding-left: 52px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: linear-gradient(180deg, transparent, var(--line-strong) 8%, var(--line-strong) 92%, transparent);
}

.timeline-item {
  position: relative;
  display: block;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.timeline-item:hover {
  border-color: color-mix(in srgb, var(--gold) 45%, var(--line));
  box-shadow: var(--shadow-sm);
}

.timeline > .timeline-item:not(details) {
  padding: 20px 22px;
}

.timeline-marker {
  position: absolute;
  left: -52px;
  top: 18px;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: var(--accent);
  color: #fff8ec;
  font-family: var(--font-serif);
  font-size: 11px;
  box-shadow: 0 0 0 1px var(--line-strong);
  z-index: 1;
}

.timeline-item > details,
.timeline-item summary {
  list-style: none;
}

.timeline-item.spoiler-block {
  overflow: visible;
  padding: 0;
}

.timeline-item.spoiler-block > summary {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
}

.timeline-item.spoiler-block > summary::after {
  content: "＋";
  flex-shrink: 0;
  line-height: 1;
}

.timeline-item.spoiler-block[open] > summary::after {
  content: "－";
}

.timeline-summary {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.timeline-summary .timeline-period {
  margin-bottom: 0;
}

.timeline-summary h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 19px;
}

.timeline-content {
  padding: 0 22px 20px;
}

.timeline-period {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.timeline-content h3 {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 21px;
}

.timeline-content p {
  margin: 0 0 12px;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.85;
}

.timeline-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.timeline-chip {
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  color: var(--muted);
  font-size: 11px;
}

.timeline-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.timeline-item.spoiler-block > summary .timeline-marker {
  top: 50%;
  transform: translateY(-50%);
}

.timeline-item.spoiler-block > summary .spoiler-hint {
  flex-shrink: 0;
  margin-left: 4px;
  line-height: 1;
}

.timeline-item.spoiler-block .timeline-content {
  margin: 0 20px;
  padding: 14px 2px 18px;
  border-top: 1px dashed color-mix(in srgb, var(--line) 80%, transparent);
}

/* ---------- Graph ---------- */

.graph-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}

.graph-search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 190px;
  flex: 0 1 240px;
}

.graph-search input {
  width: 100%;
  padding: 8px 30px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
}

.graph-types {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.graph-type-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.graph-type-toggle.is-active {
  border-color: var(--type-color, var(--accent));
  background: color-mix(in srgb, var(--type-color, var(--accent)) 12%, transparent);
  color: var(--type-color, var(--accent));
}

.graph-type-toggle .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--type-color, var(--muted));
}

.graph-actions {
  display: flex;
  gap: 7px;
  margin-left: auto;
}

.graph-stage {
  position: relative;
  height: min(72vh, 720px);
  min-height: 480px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--surface-2) 40%, transparent), transparent 70%),
    color-mix(in srgb, var(--paper-2) 80%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line) 30%, transparent);
}

#graph-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#graph-canvas.is-dragging {
  cursor: grabbing;
}

.graph-tooltip {
  position: absolute;
  z-index: 6;
  max-width: 260px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  font-size: 12px;
  line-height: 1.5;
}

.graph-tooltip strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 14px;
}

.graph-tooltip small {
  color: var(--muted);
}

.graph-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  background: color-mix(in srgb, var(--paper) 55%, transparent);
  backdrop-filter: blur(3px);
}

.graph-loading[hidden],
.graph-tooltip[hidden],
.graph-side[hidden] {
  display: none !important;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.graph-legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  max-width: calc(100% - 24px);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(6px);
  font-size: 10px;
  color: var(--muted);
}

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

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--type-color, var(--muted));
}

.graph-side {
  position: absolute;
  top: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 7;
  width: min(300px, calc(100% - 24px));
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
}

.graph-side-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
}

.graph-side-close:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.graph-side h3 {
  margin: 0 0 4px;
  padding-right: 22px;
  font-family: var(--font-serif);
  font-size: 21px;
}

.graph-side .side-type {
  margin-bottom: 10px;
}

.graph-side p {
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.75;
}

.graph-side .side-links {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 12px;
}

.graph-side .side-links a {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink-2);
}

.graph-side .side-links a:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.graph-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
}

/* ---------- About ---------- */

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 44px;
  align-items: start;
}

.about-figure {
  margin: 0 0 36px;
  padding: 0;
}

.about-figure a {
  display: block;
}

.about-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.about-figure figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.about-figure.is-compact {
  max-width: 240px;
  margin-right: auto;
  margin-left: auto;
}

.about-main h2 {
  margin: 0 0 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-serif);
  font-size: 26px;
}

.about-main h2:not(:first-child) {
  margin-top: 42px;
}

.about-main p {
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.9;
}

.feature-list {
  margin: 0;
  padding-left: 1.2em;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.9;
}

.feature-list li {
  margin: 6px 0;
}

.model-table {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 13px;
}

.model-table div {
  display: contents;
}

.model-table strong,
.model-table span {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}

.model-table strong {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 500;
}

.model-table span {
  color: var(--ink-2);
}

.model-table > div:last-child strong,
.model-table > div:last-child span {
  border-bottom: 0;
}

.spoiler-explainer {
  display: grid;
  gap: 10px;
}

.spoiler-explainer > div {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}

.spoiler-explainer p {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.7;
}

.about-aside {
  position: sticky;
  top: calc(var(--header-height) + 20px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.about-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 68%, transparent);
}

.about-card h3 {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: 15px;
}

.about-card dl {
  margin: 0;
}

.about-card dl div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.about-card dl div:last-child {
  border-bottom: 0;
}

.about-card dt {
  color: var(--muted);
}

.about-card dd {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--accent);
}

.about-card > a {
  display: block;
  padding: 5px 0;
  font-size: 12px;
  color: var(--ink-2);
}

.about-card > a:hover {
  color: var(--accent);
}

.about-card .notice-card {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

/* ---------- Error ---------- */

.error-section {
  display: grid;
  place-items: center;
  min-height: 56vh;
  padding-top: 60px;
}

.error-card {
  max-width: 560px;
  text-align: center;
}

.error-code {
  display: block;
  color: var(--accent);
  font-family: var(--font-serif);
  font-size: clamp(64px, 12vw, 120px);
  line-height: 1;
  opacity: 0.8;
}

.error-card h1 {
  margin: 10px 0;
  font-family: var(--font-serif);
  font-size: 30px;
}

.error-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  margin-top: 22px;
}

/* ---------- Admin ---------- */

.admin-page .site-main {
  padding-bottom: 40px;
}

.admin-login-section {
  display: grid;
  place-items: center;
  min-height: 70vh;
}

.admin-login-card {
  width: min(440px, 100%);
  padding: 34px 30px 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.admin-login-card .brand-seal.large {
  margin: 0 auto 18px;
}

.admin-login-card h1 {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 28px;
}

.admin-login-card > p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.admin-form {
  margin-top: 22px;
  text-align: left;
}

.admin-form label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.admin-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 14px;
}

.admin-form input:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent);
}

.admin-form .button {
  margin-top: 14px;
}

.form-hint {
  margin: 10px 0 0;
  color: var(--muted-2);
  font-size: 11px;
  line-height: 1.6;
}

.form-error {
  margin: 14px 0;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  text-align: left;
}

.admin-back {
  margin: 20px 0 0;
  font-size: 12px;
}

.admin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.admin-head h1 {
  margin: 0 0 4px;
  font-family: var(--font-serif);
  font-size: 34px;
}

.admin-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.admin-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
}

.admin-stats > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}

.admin-stats strong {
  color: var(--accent);
  font-family: var(--font-serif);
  font-size: 24px;
}

.admin-stats span {
  color: var(--muted);
  font-size: 11px;
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 66%, transparent);
}

.admin-toolbar input {
  flex: 1;
  min-width: 200px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-toolbar select {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-toolbar span {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 76%, transparent);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.admin-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.admin-sort:hover,
.admin-sort:focus-visible {
  color: var(--accent);
}

.admin-sort::after {
  content: "↕";
  color: var(--muted-2);
  font-size: 10px;
}

.admin-table th[aria-sort="ascending"] .admin-sort::after {
  content: "↑";
  color: var(--accent);
}

.admin-table th[aria-sort="descending"] .admin-sort::after {
  content: "↓";
  color: var(--accent);
}

.admin-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.admin-views {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.admin-name {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 220px;
}

.admin-name strong {
  display: block;
  font-size: 13px;
}

.admin-name small {
  color: var(--muted-2);
  font-size: 10px;
  font-family: "SFMono-Regular", Consolas, monospace;
}

.admin-row-actions {
  display: flex;
  gap: 5px;
  white-space: nowrap;
}

.admin-note {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px dashed color-mix(in srgb, var(--gold) 35%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--gold) 6%, transparent);
}

.admin-note strong {
  font-family: var(--font-serif);
  font-size: 13px;
}

.admin-note p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

/* Editor */

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

.editor-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.form-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
}

.form-card h2 {
  margin: 0 0 14px;
  font-family: var(--font-serif);
  font-size: 20px;
}

.form-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.form-card-head h2 {
  margin: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.field .required {
  color: var(--accent);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13px;
}

.field textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.7;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent);
}

.field small {
  color: var(--muted-2);
  font-size: 10px;
  line-height: 1.5;
}

.field-row {
  display: grid;
  gap: 12px;
}

.field-row.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-row.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.repeat-rows {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.repeat-row {
  position: relative;
  padding: 12px 40px 4px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-2) 40%, transparent);
}

.repeat-row .remove-row {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
}

.repeat-row .remove-row:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.repeat-row .field-row {
  margin-bottom: 6px;
}

.section-editor .field-row {
  grid-template-columns: minmax(0, 1fr) 150px;
}

.section-editor textarea.markdown-input {
  min-height: 150px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.65;
}

.section-editor .section-tools {
  display: flex;
  gap: 6px;
  margin: 2px 0 8px;
}

.preview-panel {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.preview-head strong {
  font-family: var(--font-serif);
  color: var(--ink);
}

#preview-content {
  max-height: 420px;
  overflow-y: auto;
  padding: 14px 16px;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.suggestion-chip {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
}

.suggestion-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 20px;
}

.save-status {
  color: var(--muted);
  font-size: 12px;
}

.save-status.is-error {
  color: var(--accent);
}

.save-status.is-success {
  color: var(--jade);
}

.editor-aside {
  position: sticky;
  top: calc(var(--header-height) + 18px);
}

.sticky-card {
  font-size: 12px;
}

.sticky-card h3 {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 15px;
}

.sticky-card h3:not(:first-child) {
  margin-top: 20px;
}

.sticky-card ul {
  margin: 0;
  padding-left: 1.15em;
  color: var(--muted);
  line-height: 1.75;
}

.editor-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
}

.editor-meta code {
  color: var(--ink-2);
  font-size: 10px;
}

.import-dialog {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
}

.import-dialog-card {
  width: min(620px, 100%);
  max-height: 80vh;
  overflow-y: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.import-dialog-card h2 {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 22px;
}

.import-dialog-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.import-dialog-card textarea {
  width: 100%;
  min-height: 220px;
  margin: 10px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-2);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
}

.import-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .main-nav {
    gap: 0;
  }
  .nav-link {
    padding: 7px 8px;
    font-size: 13px;
  }
  .header-search input {
    width: 140px;
  }
  .type-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .entity-layout {
    grid-template-columns: minmax(0, 1fr) 270px;
    gap: 30px;
  }
}

@media (max-width: 900px) {
  .header-search {
    display: none;
  }
  .main-nav {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    max-height: calc(100vh - var(--header-height));
    overflow-y: auto;
    padding: 14px 22px 22px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
  }
  .main-nav.is-open {
    display: flex;
  }
  .nav-toggle {
    display: inline-grid;
  }
  .split-layout,
  .about-grid,
  .entity-layout {
    grid-template-columns: 1fr;
  }
  .entity-layout {
    gap: 28px;
  }
  .entity-aside {
    position: static;
    order: -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .toc {
    grid-column: 1 / -1;
  }
  .footer-inner {
    grid-template-columns: 1fr;
    gap: 18px;
  }
  .footer-links {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 14px;
  }
  .editor-grid {
    grid-template-columns: 1fr;
  }
  .editor-aside {
    position: static;
  }
  .about-aside {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  :root {
    --header-height: 62px;
  }
  .header-inner,
  .container,
  .home-section,
  .explore-section,
  .search-section,
  .timeline-section,
  .graph-section,
  .about-section,
  .admin-section,
  .error-section,
  .admin-login-section,
  .entity-container {
    padding-left: 18px;
    padding-right: 18px;
  }
  .brand-subtitle {
    display: none;
  }
  .type-grid,
  .work-grid,
  .relations-grid,
  .backlink-list {
    grid-template-columns: 1fr 1fr;
  }
  .stats-strip {
    grid-template-columns: repeat(3, 1fr);
    margin-left: 18px;
    margin-right: 18px;
  }
  .stats-strip .stat:nth-child(4),
  .stats-strip .stat:nth-child(5) {
    grid-column: span 1;
  }
  .entity-header {
    grid-template-columns: 1fr;
  }
  .entity-aside {
    grid-template-columns: 1fr;
  }
  .field-row.two,
  .field-row.three {
    grid-template-columns: 1fr;
  }
  .section-editor .field-row {
    grid-template-columns: 1fr;
  }
  .admin-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .admin-table th:nth-child(3),
  .admin-table td:nth-child(3) {
    display: none;
  }
  .timeline {
    padding-left: 42px;
  }
  .timeline-marker {
    left: -42px;
    width: 30px;
    height: 30px;
    font-size: 10px;
  }
  .timeline::before {
    left: 14px;
  }
  .graph-toolbar {
    align-items: stretch;
  }
  .graph-actions {
    margin-left: 0;
  }
  .graph-stage {
    min-height: 420px;
    height: 62vh;
  }
}

@media (max-width: 520px) {
  .type-grid,
  .work-grid,
  .card-grid,
  .compact-grid,
  .relations-grid,
  .backlink-list {
    grid-template-columns: 1fr;
  }
  .page-hero {
    padding: 54px 18px 42px;
  }
  .hero-title-main {
    font-size: 46px;
  }
  .hero-title-sub {
    font-size: 16px;
    letter-spacing: 0.18em;
  }
  .hero-search {
    flex-direction: column;
    padding: 8px;
    border-radius: var(--radius);
  }
  .hero-search button {
    width: 100%;
    min-height: 40px;
  }
  .stats-strip {
    grid-template-columns: repeat(2, 1fr);
  }
  .stat:nth-child(5) {
    grid-column: span 2;
  }
  .disclaimer-strip {
    flex-direction: column;
    align-items: flex-start;
  }
  .search-controls {
    flex-direction: column;
  }
  .admin-head-actions .button {
    flex: 1 1 auto;
  }
  .info-row {
    grid-template-columns: 68px minmax(0, 1fr);
  }
  .timeline-item.spoiler-block > summary .spoiler-hint {
    display: none;
  }
  .article-footer {
    font-size: 10px;
  }
  .copy-link {
    margin-left: 0;
  }
}

@media print {
  .site-header,
  .site-footer,
  .entity-aside,
  .admin-inline,
  .copy-link,
  .graph-toolbar,
  .graph-stage {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .entity-layout {
    display: block;
  }
  .article-section h2 {
    break-after: avoid;
  }
  .spoiler-block,
  .spoiler-inline {
    filter: none;
    background: transparent;
  }
}
