/* 猫庵 · 原稿纸版面
   设计主张：明治稿纸 + 朱印。纸底、墨字、朱线、靛青点缀；
   正文走明体衬线，界面控件走黑体，两套字形明确分工。 */

:root {
  --paper: #f1e9d9;
  --paper-2: #fbf6ea;
  --paper-3: #e8dec8;
  --ink: #221f1a;
  --ink-2: #4b443a;
  --muted: #7c7260;
  --shu: #a8392a;
  --shu-soft: rgba(168, 57, 42, 0.12);
  --ai: #2d4b64;
  --ai-soft: rgba(45, 75, 100, 0.12);
  --rule: #d6c9b0;
  --grid: rgba(168, 57, 42, 0.16);
  --serif: "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC", "STSong", SimSun, "Hiragino Mincho ProN", serif;
  --gothic: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Heiti SC", sans-serif;
  --shadow: 0 1px 0 var(--rule), 0 10px 24px -18px rgba(34, 31, 26, 0.55);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.95;
  letter-spacing: 0.012em;
}

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

a { color: var(--ai); text-underline-offset: 3px; }
a:hover { color: var(--shu); }

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

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── 页眉 ───────────────────────────────────── */
.topbar {
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(180deg, var(--paper-2), var(--paper));
}
.topbar .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
  padding-top: 14px;
  padding-bottom: 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.brand .mark { width: 34px; height: 34px; flex: 0 0 auto; }
.brand .sub {
  font-family: var(--gothic);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.22em;
  color: var(--muted);
}
.topnav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-left: auto;
  font-family: var(--gothic);
  font-size: 13.5px;
}
.topnav a { color: var(--ink-2); text-decoration: none; }
.topnav a:hover { color: var(--shu); text-decoration: underline; }

/* ── 首屏 ───────────────────────────────────── */
.hero {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--rule);
  background-color: var(--paper-2);
  background-image:
    repeating-linear-gradient(0deg, transparent 0 39px, var(--grid) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, var(--grid) 39px 40px);
  background-position: center;
}
.hero .wrap {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 32px;
  align-items: center;
  padding-top: 46px;
  padding-bottom: 46px;
}
.eyebrow {
  font-family: var(--gothic);
  font-size: 12px;
  letter-spacing: 0.26em;
  color: var(--shu);
  margin: 0 0 14px;
}
h1 {
  margin: 0 0 18px;
  font-size: clamp(27px, 5.4vw, 46px);
  line-height: 1.34;
  letter-spacing: 0.02em;
  font-weight: 700;
}
h1 .kw {
  white-space: nowrap;
  background: linear-gradient(180deg, transparent 68%, var(--shu-soft) 68%);
  padding: 0 2px;
}
.lede {
  margin: 0 0 22px;
  font-size: clamp(15px, 2.4vw, 17.5px);
  color: var(--ink-2);
}
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}
.facts div {
  background: var(--paper-2);
  padding: 11px 13px;
}
.facts dt {
  font-family: var(--gothic);
  font-size: 11.5px;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin: 0 0 3px;
}
.facts dd {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.5;
  font-weight: 700;
}
.nw { white-space: nowrap; }
.hero-art { justify-self: center; width: 100%; max-width: 330px; }

/* ── 区块 ───────────────────────────────────── */
section { padding: 52px 0; border-bottom: 1px solid var(--rule); }
section:nth-of-type(even) { background: rgba(251, 246, 234, 0.6); }

.shead { margin-bottom: 26px; }
.shead .no {
  display: inline-block;
  font-family: var(--gothic);
  font-size: 11px;
  letter-spacing: 0.28em;
  color: #fff;
  background: var(--shu);
  padding: 3px 10px 3px 12px;
  margin-bottom: 12px;
}
h2 {
  margin: 0;
  font-size: clamp(21px, 3.6vw, 29px);
  line-height: 1.45;
  letter-spacing: 0.02em;
  border-left: 5px solid var(--shu);
  padding-left: 14px;
}
.shead p {
  margin: 12px 0 0;
  padding-left: 19px;
  color: var(--ink-2);
  max-width: 62em;
}
h3 {
  font-size: 18.5px;
  margin: 28px 0 8px;
  letter-spacing: 0.02em;
}
p { margin: 0 0 15px; max-width: 64em; }
.note {
  font-family: var(--gothic);
  font-size: 13px;
  line-height: 1.85;
  color: var(--muted);
}

.cols2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 10px 36px;
}

.card {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

/* ── 控件 ───────────────────────────────────── */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 0 0 18px;
  list-style: none;
}
.chip {
  font-family: var(--gothic);
  font-size: 13px;
  line-height: 1.4;
  padding: 7px 13px;
  border: 1px solid var(--rule);
  background: var(--paper-2);
  color: var(--ink-2);
  cursor: pointer;
  border-radius: 2px;
}
.chip:hover { border-color: var(--shu); color: var(--shu); }
.chip[aria-pressed="true"] {
  background: var(--shu);
  border-color: var(--shu);
  color: #fff;
}
.chip.ai[aria-pressed="true"] { background: var(--ai); border-color: var(--ai); }

.searchrow {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.searchrow label {
  font-family: var(--gothic);
  font-size: 13px;
  color: var(--muted);
}
.searchrow input {
  flex: 1 1 220px;
  min-width: 0;
  font-family: var(--gothic);
  font-size: 14.5px;
  padding: 9px 12px;
  border: 1px solid var(--rule);
  background: #fff;
  color: var(--ink);
  border-radius: 2px;
}
.searchrow input:focus { border-color: var(--shu); outline: none; box-shadow: 0 0 0 2px var(--shu-soft); }
.tally {
  font-family: var(--gothic);
  font-size: 13px;
  color: var(--muted);
}

/* ── 人物图谱 ───────────────────────────────── */
.maplayout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.mapbox {
  border: 1px solid var(--rule);
  background: var(--paper-2);
  padding: 8px;
}
.mapbox svg { display: block; width: 100%; height: auto; }

.node { cursor: pointer; }
.node circle {
  fill: var(--paper-2);
  stroke: var(--ink-2);
  stroke-width: 1.4;
  transition: fill .15s, stroke .15s;
}
.node text {
  font-family: var(--gothic);
  font-size: 13px;
  fill: var(--ink);
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}
.node.g-cat circle { stroke: var(--shu); }
.node.g-home circle { stroke: var(--ink); }
.node.g-idler circle { stroke: var(--ai); }
.node.g-kaneda circle { stroke: #7a5c18; }
.node:hover circle { fill: #fff; }
.node.on circle { fill: var(--shu); stroke: var(--shu); }
.node.on text { fill: #fff; }
.node.dim { opacity: .28; }
.edge { stroke: var(--rule); stroke-width: 1.4; fill: none; }
.edge.on { stroke: var(--shu); stroke-width: 2.2; }
.edge.dim { opacity: .25; }

.roster {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  margin: 14px 0 0;
  list-style: none;
}
.roster button {
  font-family: var(--gothic);
  font-size: 13px;
  padding: 6px 11px;
  border: 1px solid var(--rule);
  background: var(--paper-2);
  color: var(--ink-2);
  cursor: pointer;
  border-radius: 2px;
}
.roster button:hover { border-color: var(--shu); color: var(--shu); }
.roster button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper-2); }

.panel {
  border: 1px solid var(--rule);
  background: var(--paper-2);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.panel h3 { margin: 0 0 4px; font-size: 22px; }
.panel .tag {
  font-family: var(--gothic);
  font-size: 11.5px;
  letter-spacing: 0.14em;
  color: var(--shu);
  margin-bottom: 14px;
}
.panel dl { margin: 0; }
.panel dt {
  font-family: var(--gothic);
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-top: 13px;
}
.panel dd { margin: 3px 0 0; font-size: 15.5px; line-height: 1.85; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-family: var(--gothic);
  font-size: 12.5px;
  color: var(--muted);
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
.legend span {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid currentColor;
  margin-right: 6px;
  vertical-align: -1px;
}
.lg-cat { color: var(--shu); }
.lg-home { color: var(--ink); }
.lg-idler { color: var(--ai); }
.lg-kaneda { color: #7a5c18; }

/* ── 回次卡片 ───────────────────────────────── */
.chapters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 16px;
}
.ch {
  border: 1px solid var(--rule);
  background: var(--paper-2);
  padding: 18px 20px 16px;
  box-shadow: var(--shadow);
}
.ch[hidden] { display: none; }
.ch .num {
  font-family: var(--gothic);
  font-size: 11.5px;
  letter-spacing: 0.2em;
  color: var(--shu);
}
.ch h3 { margin: 4px 0 10px; font-size: 19px; }
.ch p { font-size: 15.5px; line-height: 1.85; margin: 0 0 10px; }
.ch .sat {
  border-top: 1px dashed var(--rule);
  padding-top: 10px;
  font-size: 14.5px;
  color: var(--ink-2);
}
.ch .sat b { color: var(--shu); font-weight: 700; }
.ch ul.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
}
.ch ul.tags li {
  font-family: var(--gothic);
  font-size: 11.5px;
  padding: 3px 8px;
  border: 1px solid var(--ai-soft);
  background: var(--ai-soft);
  color: var(--ai);
  border-radius: 2px;
}
.empty {
  font-family: var(--gothic);
  font-size: 14px;
  color: var(--muted);
  border: 1px dashed var(--rule);
  padding: 22px;
  text-align: center;
}

/* ── 名句 ───────────────────────────────────── */
.quotes { display: grid; gap: 18px; }
.q {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  border: 1px solid var(--rule);
  background: var(--paper-2);
  box-shadow: var(--shadow);
}
.q .jp {
  font-size: 17px;
  line-height: 2;
  padding: 20px 22px 6px;
  margin: 0;
  overflow-wrap: anywhere;
}
.q .zh {
  padding: 0 22px 6px;
  margin: 0;
  color: var(--ink-2);
  font-size: 16px;
}
.q .zh b {
  font-family: var(--gothic);
  font-size: 11.5px;
  letter-spacing: 0.14em;
  color: var(--shu);
  display: block;
  font-weight: 400;
}
.q .src {
  padding: 0 22px 14px;
  margin: 0;
  font-family: var(--gothic);
  font-size: 12.5px;
  color: var(--muted);
}
.q .read {
  border-top: 1px solid var(--rule);
  padding: 16px 22px 18px;
  margin: 0;
  background: rgba(214, 201, 176, 0.18);
  font-size: 15.5px;
}

/* ── 脚注 / 404 ─────────────────────────────── */
footer {
  padding: 34px 0 44px;
  background: var(--paper-3);
}
footer .wrap { display: grid; gap: 12px; }
footer p { margin: 0; font-size: 14px; color: var(--ink-2); max-width: 70em; }
footer .seal {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--gothic);
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.nf { padding: 60px 0 70px; }
.nf .wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 220px);
  gap: 30px;
  align-items: center;
}
.nf h1 { font-size: clamp(25px, 5vw, 40px); }
.nf .back {
  display: inline-block;
  font-family: var(--gothic);
  font-size: 14px;
  padding: 10px 20px;
  background: var(--shu);
  color: #fff;
  text-decoration: none;
  border-radius: 2px;
}
.nf .back:hover { background: var(--ink); color: #fff; }
.nf ul { padding-left: 1.1em; margin: 0 0 20px; }
.nf li { margin-bottom: 4px; }

/* 窄屏：图谱整体缩小后字会看不清，放大节点与连线 */
@media (max-width: 700px) {
  .node circle { r: 46px; }
  .node text { font-size: 22px; }
  .edge { stroke-width: 2.4; }
}

@media (max-width: 860px) {
  .hero .wrap { grid-template-columns: minmax(0, 1fr); }
  .hero-art { order: -1; max-width: 230px; }
  .maplayout { grid-template-columns: minmax(0, 1fr); }
  .nf .wrap { grid-template-columns: minmax(0, 1fr); }
  .nf .art { max-width: 180px; }
}

@media (max-width: 480px) {
  body { font-size: 16px; line-height: 1.9; }
  .wrap { padding: 0 15px; }
  section { padding: 40px 0; }
  .topnav { font-size: 12.5px; gap: 4px 12px; }
  .q .jp, .q .zh, .q .src, .q .read { padding-left: 16px; padding-right: 16px; }
  .ch, .panel, .card { padding-left: 15px; padding-right: 15px; }
}
