:root {
  color-scheme: light;

  /* 宣纸 rice-paper grounds */
  --paper-bg: #f5efe1;
  --paper-2: #efe6d3;
  --paper-edge: #e4d8bf;
  --paper-shadow: rgba(60, 50, 35, 0.12);

  /* 墨分五色  焦 > 浓 > 重 > 淡 > 清 */
  --ink-jiao: #1a1714;
  --ink-nong: #2f2a25;
  --ink-zhong: #4a443c;
  --ink-dan: #7a7163;
  --ink-qing: #a89e8c;

  /* 点缀:朱砂 / 石青 / 赭石(克制使用) */
  --cinnabar: #9d2933;
  --cinnabar-bright: #c1352e;
  --stone-blue: #2c6b80;
  --ochre: #845a33;

  /* 字体 */
  --font-title: "Ma Shan Zheng", "ZCOOL XiaoWei", "KaiTi", "STKaiti", serif;
  --font-head: "ZCOOL XiaoWei", "Noto Serif SC", "KaiTi", "Songti SC", serif;
  --font-body: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;

  /* 语义别名:让既有 var() 用法零改动继承新皮肤 */
  --bg: var(--paper-bg);
  --panel: var(--paper-2);
  --panel-2: var(--paper-edge);
  --line: var(--paper-edge);
  --text: var(--ink-nong);
  --muted: var(--ink-dan);
  --soft: var(--ink-qing);
  --gold: var(--cinnabar);
  --jade: var(--stone-blue);
  --red: var(--cinnabar-bright);
  --blue: var(--stone-blue);
  --shadow: var(--paper-shadow);
  --paper: rgba(60, 50, 35, 0.04);

  /* 比例字阶(1.25 大三度)与间距尺标 —— 替代手感裸值 */
  --step--1: 13px;
  --step-0: 16px;
  --step-1: 20px;
  --step-2: 25px;
  --step-3: 31px;
  --step-4: 39px;
  --sp-1: 6px;
  --sp-2: 10px;
  --sp-3: 16px;
  --sp-4: 24px;
  --sp-5: 38px;
  --sp-6: 60px;

  /* 动效 token(克制、水墨气质) */
  --ease-ink: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur-1: 0.18s;
  --dur-2: 0.36s;

  /* 多层墨棕柔影:统一光源方向(替换全站单层大阴影,§4.9) */
  --shadow-1: 0 0.5px 1px hsl(30 25% 18% / 0.05), 0 1px 2px hsl(30 25% 18% / 0.05),
    0 2px 4px hsl(30 25% 18% / 0.05);
  --shadow-2: 0 1px 2px hsl(30 25% 18% / 0.055), 0 3px 6px hsl(30 25% 18% / 0.05),
    0 8px 16px hsl(30 25% 18% / 0.045);
  --shadow-3: 0 2px 4px hsl(30 25% 18% / 0.06), 0 8px 16px hsl(30 25% 18% / 0.05),
    0 18px 36px hsl(30 25% 18% / 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(60% 90% at 12% -10%, rgba(26, 23, 20, 0.06), transparent 60%),
    radial-gradient(50% 90% at 95% -20%, rgba(44, 107, 128, 0.05), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  letter-spacing: 0;
}

/* 宣纸噪点:一次性烘焙的静态噪点贴图(浏览器解码一次即缓存,不再每帧跑滤镜)。
   旧版用 filter:url(#paperGrain) 实时滤镜 + mix-blend-mode,滚动时整屏重栅格化 → 卡顿元凶,已弃。 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}

body > * {
  position: relative;
  z-index: 1;
}

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

button,
input {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 15px 14px;
  border-bottom: 1px solid rgba(157, 41, 51, 0.12);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--jade);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(34px, 5vw, 68px);
  line-height: 1.05;
  font-weight: 800;
}

.lead {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.action {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(74, 68, 60, 0.28);
  border-radius: 4px;
  background: rgba(157, 41, 51, 0.08);
  color: var(--cinnabar);
  font-size: 14px;
  transition:
    background var(--dur-1) var(--ease-ink),
    border-color var(--dur-1) var(--ease-ink),
    color var(--dur-1) var(--ease-ink);
}

.action.secondary {
  border-color: rgba(60, 50, 35, 0.16);
  background: rgba(60, 50, 35, 0.06);
  color: var(--text);
}

main {
  padding: 18px 15px 56px;
}

.poster {
  width: 100%;
  height: auto;
  aspect-ratio: 21 / 8;
  min-height: 180px;
  max-height: 260px;
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid rgba(60, 50, 35, 0.1);
  border-radius: 4px;
  background: var(--paper-2);
  box-shadow: var(--shadow-1);
}

.poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid rgba(157, 41, 51, 0.16);
  border-radius: 6px;
  background: rgba(157, 41, 51, 0.16);
}

.stat-panel,
.episode-card,
.episode-chapter,
.detail-panel,
.entity-detail,
.workflow,
.map-notes,
.map-canvas,
.dashboard-panel {
  border: 1px solid rgba(60, 50, 35, 0.1);
  border-radius: 4px;
  background: var(--paper-2);
  box-shadow: var(--shadow-2);
}

.stat-panel {
  padding: 13px 16px;
  border: 0;
  border-radius: 0;
  background: var(--paper-2);
  box-shadow: none;
}

.stat {
  display: block;
  color: var(--gold);
  font-size: 24px;
  font-weight: 800;
}

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

/* 两列工作区:左侧竖排视图 tab,右侧工具栏 + 各视图 */
.work-area {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: clamp(8px, 1vw, 12px);
  align-items: start;
}
.work-main {
  min-width: 0;
}
.view-tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  position: sticky;
  top: 12px;
  min-width: 0;
}
.view-tabs .tab {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 36px;
  padding: 0 9px;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-align: left;
}
.view-tabs .tab.active {
  border-color: rgba(157, 41, 51, 0.45);
  background: rgba(157, 41, 51, 0.1);
  color: var(--cinnabar);
  box-shadow: inset 3px 0 0 var(--cinnabar);
}

.tab,
.filter-chip,
.scene-button,
.memory-link,
.entity-item {
  border: 1px solid rgba(60, 50, 35, 0.12);
  border-radius: 4px;
  background: rgba(60, 50, 35, 0.05);
  color: var(--text);
  cursor: pointer;
  transition:
    background var(--dur-1) var(--ease-ink),
    border-color var(--dur-1) var(--ease-ink),
    color var(--dur-1) var(--ease-ink),
    box-shadow var(--dur-1) var(--ease-ink),
    transform var(--dur-1) var(--ease-ink);
}

.tab {
  min-height: 38px;
  padding: 0 14px;
  white-space: nowrap;
}

.tab.active,
.filter-chip.active {
  border-color: rgba(44, 107, 128, 0.72);
  background: rgba(44, 107, 128, 0.14);
  color: var(--stone-blue);
}

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

.search-wrap {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  width: min(420px, 100%);
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid rgba(60, 50, 35, 0.12);
  border-radius: 6px;
  background: rgba(60, 50, 35, 0.18);
}

.search-wrap span {
  color: var(--gold);
  font-size: 16px;
}

.search-wrap input {
  font-size: 14px;
}

.search-wrap input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

/* 篇章筛选:左右 chevron 箭头驱动横向滚动,隐藏原生滚动条 */
.filters-shell {
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  align-items: center;
  gap: 6px;
}
.filters {
  display: flex;
  flex: 1 1 0;
  flex-wrap: nowrap;
  min-width: 0;
  gap: 8px;
  justify-content: flex-start;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox 隐藏滚动条 */
}
.filters::-webkit-scrollbar {
  display: none; /* Chromium 隐藏滚动条 */
}
.filters-nav {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(157, 41, 51, 0.28);
  border-radius: 50%;
  background: rgba(157, 41, 51, 0.06);
  color: var(--cinnabar);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition:
    background var(--dur-1) var(--ease-ink),
    color var(--dur-1) var(--ease-ink),
    opacity var(--dur-1) var(--ease-ink);
}
.filters-nav:hover {
  background: rgba(157, 41, 51, 0.16);
}
.filters-nav:disabled {
  opacity: 0.28;
  cursor: default;
}

.filter-chip {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 0 11px;
  white-space: nowrap;
  color: var(--muted);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.dense-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr);
  gap: 16px;
  align-items: start;
}

.dashboard-panel {
  padding: 16px;
}

.dashboard-panel.wide {
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(60, 50, 35, 0.08);
  padding-bottom: 10px;
}

.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.panel-head span {
  color: var(--soft);
  font-size: 12px;
}

.episode-matrix,
.event-table,
.review-list,
#candidatePanel {
  display: grid;
  gap: 8px;
}

.matrix-row,
.event-row,
.review-list button,
.candidate-row {
  width: 100%;
  border: 1px solid rgba(60, 50, 35, 0.1);
  border-radius: 4px;
  background: rgba(60, 50, 35, 0.045);
  color: var(--text);
  transition:
    background var(--dur-1) var(--ease-ink),
    border-color var(--dur-1) var(--ease-ink);
}

.matrix-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 240px minmax(180px, 0.7fr);
  gap: 12px;
  padding: 12px;
  cursor: pointer;
  text-align: left;
}

.matrix-row p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.metric-stack span,
.mini-pill {
  min-height: 24px;
  border-radius: 999px;
  background: rgba(60, 50, 35, 0.07);
  color: var(--muted);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
}

.speaker-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: start;
}

.quality-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.quality-grid div {
  padding: 12px;
  border-radius: 4px;
  background: rgba(60, 50, 35, 0.055);
}

.quality-grid strong {
  display: block;
  color: var(--gold);
  font-size: 24px;
}

.quality-grid span,
.candidate-row span {
  color: var(--muted);
  font-size: 12px;
}

.review-list button {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  cursor: pointer;
  text-align: left;
}

.event-row {
  display: grid;
  grid-template-columns: 76px 160px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 9px 10px;
  cursor: pointer;
  text-align: left;
}

.event-row span {
  color: var(--soft);
  font-size: 12px;
}

.event-row strong {
  color: var(--text);
  font-size: 13px;
}

.event-row em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  line-height: 1.45;
}

.candidate-row {
  padding: 10px;
}

.candidate-row strong {
  display: block;
  margin-bottom: 4px;
}

/* 删去左侧卷栏后:时光回廊单列满宽,左右边缘与上面的标签/工具栏对齐(同走 main 的左右 padding) */
#corridorView.active {
  display: block;
}

/* —— 纪览折叠:默认收起海报/统计/引言,核心展示(时间轴)顶进视口;功能不删,一键展开 —— */
#masthead {
  overflow: hidden;
  transition: max-height var(--dur-2) var(--ease-ink), opacity var(--dur-2) var(--ease-ink), margin var(--dur-2) var(--ease-ink);
  max-height: 600px;
}
body.intro-collapsed #masthead {
  max-height: 0;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}
body.intro-collapsed .lead {
  display: none;
}
body.intro-collapsed .app-header {
  align-items: center;
  padding-top: 8px;
  padding-bottom: 6px;
}
body.intro-collapsed h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 3vw, 34px);
}
/* 折叠态再收紧上方间距,把时间轴整体上移约 80px(装饰性 eyebrow 收起) */
body.intro-collapsed .eyebrow {
  display: none;
}
body.intro-collapsed main {
  padding-top: 8px;
  padding-bottom: 20px; /* 折叠态收紧底距,整页落在一屏内,消除右侧竖滚动条 */
}
body.intro-collapsed .toolbar {
  margin-bottom: 10px;
}
/* 视图 tab 移到左侧后顶部腾出约 50px,叠加再上移 ~30px:时间轴顶边升、底边仍填到视口底。
   顶部时序 ribbon 占约 40px,故再相应下调,保持整页一屏内不出竖滚动条。 */
body.intro-collapsed #timeline-embed {
  height: calc(100vh - 158px);
}
/* 人物与地点:折叠态同款一屏定高,左右各自滚 */
body.intro-collapsed .entity-layout {
  height: calc(100vh - 118px);
}

.episode-rail {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 4px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 4px 8px 4px 0;
  border-right: 1px solid rgba(157, 41, 51, 0.14);
}

.rail-item {
  padding: 10px 8px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.rail-item.active {
  border-left-color: rgba(157, 41, 51, 0.9);
  background: rgba(157, 41, 51, 0.08);
}

.rail-item strong {
  display: block;
  margin-bottom: 6px;
}

.rail-item span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.corridor {
  position: relative;
  display: grid;
  gap: 42px;
  padding-left: 0;
}

.episode-card,
.episode-chapter {
  position: relative;
}

.episode-chapter {
  padding: 0;
  overflow: clip;
  background:
    linear-gradient(180deg, rgba(239, 225, 197, 0.035), var(--paper-2) 34%),
    var(--paper-2);
}

.episode-art {
  width: 100%;
  aspect-ratio: 4 / 3;
  margin: 0;
  overflow: hidden;
  background: rgba(60, 50, 35, 0.06);
  align-self: start;
}

.episode-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.episode-banner {
  display: grid;
  grid-template-columns: minmax(240px, 0.38fr) minmax(0, 1fr);
  gap: 0;
  min-height: 260px;
  border-bottom: 1px solid rgba(157, 41, 51, 0.13);
}

.episode-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(24px, 4vw, 44px);
  background:
    linear-gradient(90deg, rgba(60, 50, 35, 0.14), transparent),
    var(--paper);
}

.episode-card::before,
.memory-node::before {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: var(--bg);
}

.episode-card::before {
  top: 28px;
  left: -22px;
  width: 12px;
  height: 12px;
  border: 2px solid var(--gold);
}

.episode-head,
.scene-meta,
.entity-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--soft);
  font-size: 12px;
}

.episode-no,
.episode-tone,
.tag,
.entity-kind {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(60, 50, 35, 0.06);
}

.episode-card h2,
.episode-chapter h2 {
  margin-bottom: 12px;
  font-size: clamp(25px, 3vw, 38px);
  line-height: 1.15;
}

.episode-card p,
.episode-chapter p,
.detail-panel p,
.entity-detail p,
.workflow p,
.map-notes p {
  color: var(--muted);
  line-height: 1.75;
}

.episode-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.highlight {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(157, 41, 51, 0.28);
  border-radius: 999px;
  background: rgba(157, 41, 51, 0.08);
  color: var(--ink-nong);
  font-size: 13px;
  line-height: 1.35;
}

.scene-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.scene-button {
  min-height: 116px;
  padding: 13px;
  text-align: left;
}

.scene-button:hover,
.entity-item:hover {
  border-color: rgba(44, 107, 128, 0.5);
}

.scene-button strong {
  display: block;
  margin-bottom: 7px;
  color: var(--text);
}

.scene-button span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.memory-list {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(16px, 2vw, 22px);
  padding: clamp(22px, 3.2vw, 34px) clamp(18px, 3vw, 32px) clamp(22px, 3.2vw, 34px) clamp(48px, 5vw, 60px);
}

.memory-list::before {
  content: "";
  position: absolute;
  left: clamp(22px, 3vw, 30px);
  top: 28px;
  bottom: 28px;
  display: block;
  width: 1px;
  background: linear-gradient(180deg, rgba(157, 41, 51, 0.72), rgba(44, 107, 128, 0.16));
}

.memory-node {
  position: relative;
}

.memory-node::before {
  top: 30px;
  left: clamp(-32px, -3.2vw, -24px);
  display: block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(157, 41, 51, 0.8);
}

.memory-node.active::before {
  border-color: var(--jade);
  box-shadow: 0 0 0 5px rgba(44, 107, 128, 0.16);
}

.memory-link {
  display: grid;
  grid-template-columns: minmax(180px, 34%) minmax(0, 1fr);
  gap: 0;
  width: 100%;
  height: 100%;
  min-height: 210px;
  padding: 0;
  overflow: hidden;
  text-align: left;
  background:
    linear-gradient(180deg, rgba(60, 50, 35, 0.055), rgba(60, 50, 35, 0.028)),
    var(--paper-2);
  border-color: rgba(239, 225, 197, 0.12);
  box-shadow: var(--shadow-2);
}

.memory-link:hover,
.memory-node.active .memory-link {
  border-color: rgba(44, 107, 128, 0.58);
  background: rgba(44, 107, 128, 0.08);
  box-shadow: var(--shadow-3);
}

.memory-media {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 0;
  background: var(--paper-2);
  aspect-ratio: 4 / 3;
  height: 100%;
}

.memory-media img,
.detail-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.memory-media::after {
  content: "";
  position: absolute;
  inset: 45% 0 0;
  background: linear-gradient(180deg, transparent, rgba(60, 50, 35, 0.42));
  pointer-events: none;
}

.memory-index {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(60, 50, 35, 0.58);
  color: var(--cinnabar);
  font-size: 12px;
}

.memory-copy {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-width: 0;
  padding: 16px 18px 17px;
}

.memory-meta,
.memory-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.memory-meta {
  margin-bottom: 10px;
}

.memory-meta span,
.memory-foot span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(60, 50, 35, 0.07);
  color: var(--soft);
  font-size: 12px;
}

.memory-link strong {
  margin-bottom: 10px;
  color: var(--text);
  font-size: 19px;
  line-height: 1.35;
}

.memory-summary {
  color: var(--ink-zhong);
  font-size: var(--step-0);
  line-height: 1.85;
  max-width: 34em;
}

.memory-foot {
  margin-top: auto;
  padding-top: 14px;
}

.memory-foot span {
  color: var(--stone-blue);
}

.memory-foot .entity-chip {
  border-color: rgba(44, 107, 128, 0.2);
  cursor: pointer;
}

.memory-foot .entity-chip:hover,
.memory-foot .entity-chip:focus-visible {
  background: rgba(44, 107, 128, 0.16);
  color: var(--stone-blue);
  outline: none;
}

.detail-panel {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 90;
  width: min(500px, calc(100vw - 48px));
  padding: 0 0 18px;
  max-height: calc(100vh - 48px);
  overflow: auto;
  border-color: rgba(248, 223, 155, 0.28);
  box-shadow: var(--shadow-3);
  transform: translateX(calc(100% + 32px));
  opacity: 0;
  pointer-events: none;
  transition:
    transform var(--dur-2) var(--ease-ink),
    opacity var(--dur-2) var(--ease-ink);
}

.detail-panel.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.detail-close {
  position: sticky;
  top: 10px;
  z-index: 2;
  float: right;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 10px 10px -44px auto;
  border-radius: 50%;
  border: 1px solid rgba(60, 50, 35, 0.18);
  background: var(--paper-2);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: block;
  background: rgba(60, 50, 35, 0.34);
  backdrop-filter: blur(2px);
}

.detail-backdrop[hidden] {
  display: none;
}

.detail-visual {
  width: 100%;
  aspect-ratio: 16 / 10;
  margin-bottom: 16px;
  overflow: hidden;
  border-radius: 4px 4px 0 0;
  background: var(--paper-2);
}

/* 有真实配图时:完整展示整页连环画(多格拼版页接近竖版),
   不再用 16/10 cover 把下半截分格裁掉。空图位占位仍保留 16/10。 */
.detail-visual:has(img) {
  aspect-ratio: auto;
}
.detail-visual:has(img) img {
  height: auto;
  object-fit: contain;
}

.detail-panel > :not(.detail-visual) {
  margin-left: 20px;
  margin-right: 20px;
}

.detail-panel h2 {
  font-size: 24px;
  line-height: 1.25;
}

.detail-panel p {
  max-width: 58ch;
  font-size: 15px;
  line-height: 1.86;
}

.detail-panel blockquote {
  margin: 14px 0 0;
  padding: 12px;
  border-left: 3px solid var(--jade);
  background: rgba(44, 107, 128, 0.08);
  color: var(--ink-nong);
  line-height: 1.7;
}

.evidence-drawer {
  margin-top: 18px;
  border-top: 1px solid rgba(60, 50, 35, 0.08);
  padding-top: 12px;
  opacity: 0.78;
}

.evidence-drawer summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  list-style-position: inside;
}

.evidence-drawer[open] summary {
  color: var(--gold);
}

.evidence-drawer blockquote {
  max-height: 220px;
  overflow: auto;
  font-size: 13px;
}

.review-warning {
  margin: 10px 0 0;
  padding: 9px 10px;
  border: 1px solid rgba(216, 111, 98, 0.34);
  border-radius: 4px;
  background: rgba(216, 111, 98, 0.1);
  color: #7a2620;
  font-size: 13px;
}

/* 主从布局:整块定高一屏内,左列表与右详情各自独立纵向滚动(翻左边时右边详情不动) */
.entity-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  height: clamp(440px, calc(100vh - 248px), 900px);
  align-items: stretch;
}

.entity-list {
  display: grid;
  gap: 8px;
  align-content: start;
  overflow-y: auto;
  min-height: 0;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(122, 113, 99, 0.4) transparent;
}

.entity-item {
  padding: 13px;
  text-align: left;
}

.entity-item.active {
  border-color: rgba(157, 41, 51, 0.45);
  background: rgba(157, 41, 51, 0.08);
  box-shadow: inset 3px 0 0 var(--cinnabar);
}

.entity-empty {
  padding: 16px 13px;
  color: var(--ink-dan);
  font-family: var(--font-head);
}

.entity-item strong {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.entity-item span {
  color: var(--muted);
  font-size: 13px;
}

.entity-detail {
  min-height: 0;
  overflow-y: auto;
  padding: 22px;
  scrollbar-width: thin;
  scrollbar-color: rgba(122, 113, 99, 0.4) transparent;
}
.entity-list::-webkit-scrollbar,
.entity-detail::-webkit-scrollbar {
  width: 8px;
}
.entity-list::-webkit-scrollbar-thumb,
.entity-detail::-webkit-scrollbar-thumb {
  background: rgba(122, 113, 99, 0.4);
  border-radius: 6px;
}
.entity-list::-webkit-scrollbar-thumb:hover,
.entity-detail::-webkit-scrollbar-thumb:hover {
  background: rgba(157, 41, 51, 0.5);
}

.link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(60, 50, 35, 0.12);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
}

.map-canvas,
.map-notes,
.workflow {
  padding: 22px;
}

.map-canvas {
  min-height: 560px;
  overflow: auto;
}

.calendar-item {
  padding: 12px 0;
  border-top: 1px solid rgba(60, 50, 35, 0.08);
}

.calendar-item strong {
  display: block;
  margin-bottom: 5px;
}

.calendar-when {
  margin: 0 6px;
  padding: 1px 7px;
  border-radius: 3px;
  background: rgba(157, 41, 51, 0.08);
  color: var(--cinnabar);
  font-family: var(--font-head);
  font-size: 12px;
  font-style: normal;
  font-weight: 600;
}

.calendar-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.workflow {
  max-width: 920px;
}

.workflow ol {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
  padding-left: 22px;
  color: var(--muted);
  line-height: 1.75;
}

code {
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(60, 50, 35, 0.08);
  color: var(--cinnabar);
}


@media (max-width: 1280px) and (min-width: 861px) {
  .memory-link {
    grid-template-columns: minmax(180px, 34%) minmax(0, 1fr);
  }

  .memory-media {
    min-height: auto;
    aspect-ratio: 4 / 3;
  }

  .memory-copy {
    padding: 14px;
  }
}

@media (max-width: 860px) {
  body {
    background-size: 40px 40px, 40px 40px, auto, auto, auto;
  }

  .app-header,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .app-header {
    padding: 22px 16px 12px;
    gap: 12px;
  }

  h1 {
    margin-bottom: 8px;
    font-size: 34px;
  }

  .lead {
    font-size: 14px;
    line-height: 1.55;
  }

  .obsidian-link {
    display: none;
  }

  main {
    padding: 12px 12px 36px;
  }

  .header-actions,
  .filters {
    justify-content: flex-start;
  }

  .overview-grid,
  #corridorView.active,
  .dense-dashboard,
  .matrix-row,
  .entity-layout,
  .map-layout {
    grid-template-columns: 1fr;
  }

  /* 窄屏:主从布局回到自然高度,整页滚动(不锁内部双滚) */
  .entity-layout,
  body.intro-collapsed .entity-layout {
    height: auto;
  }
  .entity-list,
  .entity-detail {
    overflow-y: visible;
  }

  .poster {
    min-height: 0;
    margin-bottom: 10px;
    aspect-ratio: 21 / 8;
    max-height: 150px;
    border-radius: 6px;
  }

  .overview-grid {
    display: none;
  }

  /* 窄屏:工作区回单列,视图 tab 回到横排可滚 */
  .work-area {
    grid-template-columns: 1fr;
  }
  .view-tabs {
    flex-direction: row;
    position: static;
    min-width: 0;
    margin: 10px 0 8px;
    padding-bottom: 2px;
    overflow-x: auto;
  }
  .view-tabs .tab {
    width: auto;
    min-height: 34px;
    padding: 0 11px;
    font-size: 13px;
  }
  .view-tabs .tab.active {
    box-shadow: inset 0 -3px 0 var(--cinnabar);
  }

  .toolbar {
    gap: 8px;
    margin-bottom: 12px;
  }

  .search-wrap {
    min-height: 38px;
    padding: 0 10px;
  }

  .filters {
    flex-wrap: nowrap;
    justify-content: flex-start;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .filter-chip {
    flex: 0 0 auto;
    min-height: 31px;
    padding: 0 10px;
    font-size: 12px;
  }

  .event-row {
    grid-template-columns: 1fr;
  }

  .episode-rail {
    display: none;
  }

  .corridor {
    gap: 18px;
    padding-left: 0;
  }

  .corridor::before,
  .episode-card::before {
    display: none;
  }

  .episode-banner,
  .memory-link {
    grid-template-columns: 1fr;
  }

  .episode-banner {
    min-height: 0;
  }

  .episode-art {
    aspect-ratio: 16 / 7;
  }

  .memory-media,
  .detail-visual {
    min-height: auto;
    aspect-ratio: 16 / 9;
  }

  body.detail-open {
    overflow: hidden;
  }

  .detail-panel {
    left: 10px;
    right: 10px;
    bottom: 10px;
    top: auto;
    width: auto;
    max-height: min(82vh, 720px);
    padding-bottom: 18px;
    transform: translateY(calc(100% + 24px));
  }

  .detail-panel.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .episode-copy {
    padding: 16px;
  }

  .episode-copy .episode-tone:nth-of-type(n + 2) {
    display: none;
  }

  .episode-chapter h2 {
    margin-bottom: 8px;
    font-size: 24px;
  }

  .episode-summary {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }

  .memory-list {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }

  .memory-list::before {
    left: 16px;
  }

  .memory-node::before {
    left: -22px;
  }

  .memory-copy {
    padding: 14px;
  }
}

/* ============================================================
   水墨 / 古风 皮肤增补(只增色与纹理,不改布局)
   ============================================================ */

/* —— 字体 —— */
body {
  line-height: 1.75;
}
h1 {
  font-family: var(--font-title);
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--ink-jiao);
}
.panel-head h2,
.tab,
.episode-chapter h2,
.episode-card h2,
.detail-panel h2,
.entity-detail h2,
.stat {
  font-family: var(--font-head);
}
.lead,
.memory-summary,
.detail-panel p,
.episode-summary,
.episode-chapter p,
.entity-detail p,
.calendar-item span {
  font-family: var(--font-body);
  line-height: 1.95;
}
.eyebrow {
  color: var(--ochre);
}

/* —— 顶部水墨横幅(替代旧死图)—— */
.poster {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--paper-edge);
  background:
    radial-gradient(70% 130% at 18% -25%, rgba(26, 23, 20, 0.14), transparent 60%),
    radial-gradient(60% 130% at 88% -10%, rgba(44, 107, 128, 0.08), transparent 55%),
    var(--paper-2);
}
.poster-seal {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 6px;
  background: var(--cinnabar);
  color: #fbf3e6;
  font-family: var(--font-title);
  font-size: 22px;
  box-shadow: 0 3px 10px rgba(157, 41, 51, 0.38);
}
.poster-title {
  font-family: var(--font-title);
  font-size: clamp(30px, 5vw, 54px);
  color: var(--ink-jiao);
  letter-spacing: 0.12em;
}
.poster-sub {
  font-family: var(--font-head);
  color: var(--ink-dan);
  font-size: 13px;
  letter-spacing: 0.34em;
}

/* —— 配图框:墨色统一(将来出图自动套用)—— */
.memory-media img,
.detail-visual img,
.episode-art img {
  filter: grayscale(1) sepia(0.14) brightness(1.02) contrast(1.04);
  transition: filter 0.4s ease;
}
.memory-link:hover .memory-media img {
  filter: grayscale(0.35) sepia(0.16) contrast(1.06);
}
.memory-media::after {
  display: none;
}
.memory-index {
  background: rgba(245, 239, 225, 0.86);
  color: var(--ink-nong);
  border: 1px solid var(--paper-edge);
}

/* —— 空图位:水墨素描占位「山水未绘」(出图前也像成品)—— */
.memory-media:not(:has(img)),
.detail-visual:not(:has(img)),
.episode-art:not(:has(img)) {
  display: grid;
  place-items: center;
  background:
    radial-gradient(64% 52% at 50% 72%, rgba(74, 68, 60, 0.12), transparent 70%),
    var(--paper-2);
}
.memory-media:not(:has(img))::before,
.detail-visual:not(:has(img))::before,
.episode-art:not(:has(img))::before {
  content: attr(data-empty-label);
  font-family: var(--font-head);
  color: var(--ink-qing);
  font-size: 14px;
  letter-spacing: 0.34em;
}

/* —— 笔触式分隔线 —— */
.panel-head {
  border-bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='8'%3E%3Cpath d='M2 5 Q100 1 200 4 T398 3' stroke='%234a443c' stroke-width='1.4' fill='none' stroke-linecap='round' opacity='.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: bottom;
  background-size: 100% 8px;
  padding-bottom: 14px;
}

/* —— 时间线长卷:墨色竖轴 + 朱砂印点 —— */
.memory-list::before {
  background: linear-gradient(180deg, var(--ink-dan), var(--ink-qing));
}
.memory-node::before {
  background: var(--paper-bg);
  border-color: var(--cinnabar);
}
.memory-node.active::before {
  border-color: var(--cinnabar);
  box-shadow: 0 0 0 5px rgba(157, 41, 51, 0.16);
}

/* —— 印章式当前页签 —— */
.tab.active {
  border-color: var(--cinnabar);
  background: rgba(157, 41, 51, 0.1);
  color: var(--cinnabar);
}

/* —— 实体立绘:列表缩略 + 详情大图(锚定一致性的定妆照)—— */
.entity-item {
  display: flex;
  align-items: center;
  gap: 12px;
}
.entity-item-text {
  flex: 1;
  min-width: 0;
}
.entity-thumb {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 1px solid var(--paper-edge);
  background: var(--paper-2);
}
.entity-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) sepia(0.14) brightness(1.02) contrast(1.04);
}
.entity-thumb.empty::before {
  content: attr(data-empty-label);
  font-family: var(--font-head);
  color: var(--ink-qing);
  font-size: 11px;
  letter-spacing: 0.18em;
}
.entity-portrait {
  margin: 0 0 14px;
  width: 100%;
  max-height: 320px;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 1px solid var(--paper-edge);
  background:
    radial-gradient(64% 52% at 50% 72%, rgba(74, 68, 60, 0.12), transparent 70%),
    var(--paper-2);
}
.entity-portrait img {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  filter: grayscale(1) sepia(0.14) brightness(1.02) contrast(1.04);
  transition: filter 0.4s ease;
}
.entity-detail:hover .entity-portrait img {
  filter: grayscale(0.3) sepia(0.14) contrast(1.06);
}
.entity-portrait.empty {
  min-height: 160px;
}
.entity-portrait.empty::before {
  content: attr(data-empty-label);
  font-family: var(--font-head);
  color: var(--ink-qing);
  font-size: 15px;
  letter-spacing: 0.34em;
}

/* —— 历程立绘:多形态角色(魔化/白狐/壮年→白发等)的各版样子,点击换主图 —— */
.looks-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 14px;
}
.look-thumb {
  flex: none;
  width: 64px;
  padding: 0;
  border: 1px solid var(--paper-edge);
  border-radius: 8px;
  background: var(--paper-2);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: border-color 0.25s ease, transform 0.2s ease;
}
.look-thumb:hover {
  transform: translateY(-2px);
}
.look-thumb img {
  width: 100%;
  height: 56px;
  object-fit: cover;
  object-position: top center;
  filter: grayscale(1) sepia(0.14) brightness(1.02) contrast(1.04);
}
.look-thumb span {
  display: block;
  width: 100%;
  text-align: center;
  font-family: var(--font-head);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-dan);
  padding: 3px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.look-thumb.active {
  border-color: var(--ink-zhu, #9d2933);
  box-shadow: 0 0 0 1px var(--ink-zhu, #9d2933) inset;
}
.look-thumb.active img {
  filter: grayscale(0.2) sepia(0.12) contrast(1.06);
}
.look-thumb.active span {
  color: var(--ink-zhu, #9d2933);
}

/* —— 实体别名:此前 aliases 完全未展示 —— */
.entity-aliases {
  margin: -2px 0 var(--sp-3);
  color: var(--ink-dan);
  font-size: var(--step--1);
  letter-spacing: 0.04em;
}

/* —— 可达性:统一焦点环 + 尊重减弱动效偏好 —— */
:focus-visible {
  outline: 2px solid var(--stone-blue);
  outline-offset: 2px;
  border-radius: 3px;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   成熟组件接入(PhotoSwipe / Cytoscape / Lenis)的皮肤与容器
   ============================================================ */

/* —— Lenis 惯性滚动必需样式(官方建议)—— */
html.lenis,
html.lenis body {
  height: auto;
}
.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}
.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}
.lenis.lenis-stopped {
  overflow: hidden;
}

/* —— 场景配图锚点:点开 PhotoSwipe 的可点提示 —— */
a.memory-media {
  cursor: zoom-in;
}
.pswp-caption-content {
  display: none;
}

/* —— PhotoSwipe 宣纸化外观(§4.2)—— */
.pswp {
  --pswp-bg: #1a1714;
}
.pswp__icn {
  fill: var(--paper-bg);
}
.pswp__dynamic-caption {
  font-family: var(--font-body);
  color: var(--ink-nong);
  background: var(--paper-bg);
  border-left: 3px solid var(--cinnabar);
  padding: 18px 20px;
  overflow: auto;
  max-height: 40vh; /* 超长散文兜底滚动 */
}
.pswp__dynamic-caption strong {
  display: block;
  margin-bottom: 10px;
  font-family: var(--font-head);
  font-size: var(--step-1);
  color: var(--ink-jiao);
}
.pswp__dynamic-caption p {
  margin: 0 0 12px;
  line-height: 1.9;
}
.pswp__dynamic-caption blockquote {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 2px solid var(--ink-qing);
  background: rgba(60, 50, 35, 0.05);
  color: var(--ink-zhong);
  font-size: var(--step--1);
  line-height: 1.75;
}

/* —— Cytoscape 关系图容器 —— */
#relationGraph {
  width: 100%;
  height: 560px;
}

/* ============================================================
   时光回廊 = 成熟竖向时间轴(中央墨线 + 朱砂节点 + 滚动揭示)
   ============================================================ */

/* 无配图的篇章:卷首横幅不再撑空图框,单列排版 */
.episode-chapter.no-art .episode-banner {
  grid-template-columns: 1fr;
  min-height: 0;
}

/* 时间轴轨道:左侧一条墨线 */
.memory-list {
  grid-template-columns: 1fr;
  gap: clamp(16px, 2.2vw, 26px);
  padding: clamp(10px, 2vw, 18px) 0 clamp(12px, 2vw, 20px) 48px;
}
.memory-list::before {
  left: 16px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: linear-gradient(180deg, rgba(157, 41, 51, 0.5), var(--ink-qing) 78%, transparent);
}

/* 节点圆点:落在墨线上,纸色描边盖住穿过的线 */
.memory-node::before {
  top: 22px;
  left: -38px;
  width: 14px;
  height: 14px;
  border: 2px solid var(--cinnabar);
  background: var(--paper-bg);
  box-shadow: 0 0 0 4px var(--paper-bg);
  z-index: 1;
}
.memory-node.has-img::before,
.memory-node.active::before {
  background: var(--cinnabar);
  box-shadow: 0 0 0 4px var(--paper-bg), 0 0 0 5px rgba(157, 41, 51, 0.18);
}

/* 有配图节点:保留 图|文 两栏卡片 */
.memory-node.has-img .memory-link {
  min-height: 200px;
}

/* 无配图节点:细条文字行(消灭"山水未绘"图墙),散文截两行便于扫读 */
.memory-node.text-only .memory-link {
  grid-template-columns: 1fr;
  min-height: 0;
  padding: 13px 16px;
  background: linear-gradient(180deg, rgba(60, 50, 35, 0.04), transparent), var(--paper-2);
}
.memory-node.text-only .memory-copy {
  padding: 0;
}
.memory-node.text-only .memory-summary {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.7;
}
.memory-node.text-only strong {
  font-size: var(--step-0);
}

/* 滚动揭示:仅在允许动效时先藏后淡入,减弱动效用户直接可见(不致卡隐藏态) */
@media (prefers-reduced-motion: no-preference) {
  .memory-node {
    opacity: 0;
    transform: translateY(14px);
    transition:
      opacity 0.6s var(--ease-ink),
      transform 0.6s var(--ease-ink);
  }
  .memory-node.in-view {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 860px) {
  .memory-list {
    padding-left: 34px;
  }
  .memory-list::before {
    left: 10px;
  }
  .memory-node::before {
    left: -30px;
  }
}

/* ============================================================
   左侧篇目卷栏:古风目录 + 墨色滚动条(替换违和的现代侧栏)
   ============================================================ */
.episode-rail {
  gap: 2px;
  align-content: start;
  padding: 14px 10px 16px;
  border-right: 0;
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(60, 50, 35, 0.06), transparent 38%), var(--paper-2);
  box-shadow: var(--shadow-1);
  scrollbar-width: thin;
  scrollbar-color: rgba(122, 113, 99, 0.5) transparent;
}
.rail-title {
  margin: 2px 0 10px;
  padding-bottom: 9px;
  font-family: var(--font-title);
  font-size: 19px;
  letter-spacing: 0.32em;
  text-align: center;
  color: var(--ink-jiao);
  border-bottom: 1px solid var(--paper-edge);
}
.rail-item {
  position: relative;
  display: grid;
  gap: 3px;
  padding: 8px 10px 8px 14px;
  border: 0;
  border-left: 0;
  border-radius: 4px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease-ink);
}
/* 左侧朱砂笔触:默认收起,激活时拉满 */
.rail-item::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  width: 3px;
  height: 0;
  transform: translateY(-50%);
  border-radius: 2px;
  background: var(--cinnabar);
  transition: height var(--dur-2) var(--ease-ink);
}
.rail-item:hover {
  background: rgba(157, 41, 51, 0.06);
}
.rail-item.active {
  background: rgba(157, 41, 51, 0.1);
}
.rail-item.active::before {
  height: calc(100% - 14px);
}
.rail-ord {
  font-family: var(--font-head);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--ink-dan);
}
.rail-all .rail-ord {
  color: var(--stone-blue);
}
.rail-item.active .rail-ord {
  color: var(--cinnabar);
}
.rail-name {
  font-family: var(--font-head);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-nong);
}
.rail-item.active .rail-name {
  color: var(--cinnabar);
}

/* —— 墨色细滚动条:卷栏 / 关系图 / 全局 —— */
.episode-rail::-webkit-scrollbar,
.map-canvas::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.episode-rail::-webkit-scrollbar-track,
.map-canvas::-webkit-scrollbar-track {
  background: transparent;
}
.episode-rail::-webkit-scrollbar-thumb,
.map-canvas::-webkit-scrollbar-thumb {
  background: rgba(122, 113, 99, 0.45);
  border-radius: 6px;
  border: 2px solid var(--paper-2);
}
.episode-rail::-webkit-scrollbar-thumb:hover,
.map-canvas::-webkit-scrollbar-thumb:hover {
  background: rgba(157, 41, 51, 0.5);
}
html {
  scrollbar-width: thin;
  scrollbar-color: rgba(122, 113, 99, 0.45) transparent;
}
body::-webkit-scrollbar {
  width: 12px;
}
body::-webkit-scrollbar-track {
  background: var(--paper-2);
}
body::-webkit-scrollbar-thumb {
  background: rgba(122, 113, 99, 0.4);
  border-radius: 6px;
  border: 3px solid var(--paper-bg);
}
body::-webkit-scrollbar-thumb:hover {
  background: rgba(157, 41, 51, 0.45);
}

/* ════════════════════════════════════════════════════════════
   TimelineJS3(Knight Lab)水墨重皮 —— 整套成熟图文展陈骨架,
   只覆盖其皮:字体→宣纸字体,蓝色强调→朱砂,白底→宣纸。
   ════════════════════════════════════════════════════════════ */
/* 世设时序 ribbon:环景二年季节弧,高亮当前回所在阶段 */
.time-ribbon {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 8px;
  padding: 6px 12px;
  border: 1px solid var(--paper-edge);
  border-radius: 4px;
  background: var(--paper-2);
  box-shadow: var(--shadow-1);
  font-family: var(--font-head);
  font-size: 13px;
  overflow-x: auto;
  scrollbar-width: none;
}
.time-ribbon::-webkit-scrollbar {
  display: none;
}
.tr-era {
  flex: 0 0 auto;
  font-family: var(--font-title);
  color: var(--cinnabar);
  letter-spacing: 0.1em;
  padding-right: 10px;
  border-right: 1px solid var(--paper-edge);
}
.tr-track {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.tr-node {
  color: var(--ink-dan);
  padding: 1px 3px;
}
.tr-node.active {
  color: var(--cinnabar);
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--cinnabar);
}
.tr-node.frozen {
  color: var(--stone-blue);
}
.tr-node.frozen.active {
  box-shadow: inset 0 -2px 0 var(--stone-blue);
}
.tr-arrow {
  color: var(--ink-qing);
}

#timeline-embed {
  width: 100%;
  /* 折叠纪览后,核心展示直接填满视口剩余高度,无需向下滚动即可看全 */
  height: clamp(440px, calc(100vh - 248px), 900px);
  border-radius: 4px;
  overflow: hidden;
  background: var(--paper-bg);
  box-shadow: var(--shadow-2);
}

.tl-empty {
  display: grid;
  place-content: center;
  height: 100%;
  font-family: var(--font-head);
  color: var(--ink-dan);
  letter-spacing: 0.1em;
}

/* —— 整体字体与底色 —— */
.tl-timeline,
.tl-timeline * {
  font-family: var(--font-body);
}
.tl-timeline {
  background: var(--paper-bg);
  color: var(--ink-zhong);
}
.tl-storyslider,
.tl-slider-container-mask,
.tl-slider-container,
.tl-slide,
.tl-slide-scrollable-container,
.tl-slide-content {
  background: var(--paper-bg) !important;
}

/* —— 标题幻灯 / 日期 —— */
.tl-headline,
.tl-text .tl-headline a {
  font-family: var(--font-head) !important;
  color: var(--ink-jiao) !important;
  font-weight: 600;
}
.tl-slide-titleslide .tl-headline {
  font-family: var(--font-title) !important;
  letter-spacing: 0.06em;
}
.tl-headline-date {
  font-family: var(--font-head) !important;
  color: var(--cinnabar) !important;
  letter-spacing: 0.14em;
}

/* —— 正文与原文片段 —— */
.tl-text .tl-text-content {
  font-family: var(--font-body) !important;
  color: var(--ink-zhong) !important;
  font-size: 16px;
  line-height: 1.95;
}
.tl-text-content blockquote,
.tl-ink-excerpt {
  margin: 14px 0 0;
  padding: 6px 0 6px 14px;
  border-left: 3px solid var(--cinnabar);
  color: var(--ink-dan);
  font-style: normal;
}
/* 逐幕时序小注:据真实转写推得的相对时点,淡墨小字,不抢正文 */
.tl-text-content .tl-ink-when {
  margin: 0 0 8px !important;
  font-family: var(--font-head) !important;
  font-size: 12px !important;
  line-height: 1.5 !important;
  letter-spacing: 0.02em;
  color: var(--ink-qing) !important;
}

/* —— 媒体图:水墨柔影 —— */
.tl-media img {
  border-radius: 4px;
  box-shadow: var(--shadow-2);
}
.tl-media .tl-caption,
.tl-media .tl-credit {
  font-family: var(--font-body) !important;
  color: var(--ink-dan) !important;
}

/* —— 底部时间导航 —— */
.tl-timenav,
.tl-timenav .tl-timeaxis-background,
.tl-menubar {
  background: var(--paper-2) !important;
}
.tl-timenav {
  border-top: 1px solid var(--paper-edge);
}
/* 底栏(slider 及各层)压到约 1/3 高,并贴在挂载区最底;上方幻灯由 JS(fitTimenav)补满 */
.tl-timenav,
.tl-timenav .tl-timenav-slider,
.tl-timenav .tl-timenav-slider-background,
.tl-timenav .tl-timenav-container-mask,
.tl-timenav .tl-timenav-container,
.tl-timenav .tl-timenav-item-container {
  height: 55px !important;
}
.tl-timenav {
  top: auto !important;
  bottom: 0 !important;
}
.tl-timeaxis-tick .tl-timeaxis-tick-text,
.tl-timegroup-message {
  color: var(--ink-dan) !important;
  font-family: var(--font-body) !important;
}

/* —— 时间标记(每一景的小卡)—— */
.tl-timemarker .tl-timemarker-content-container {
  background: var(--paper-bg) !important;
  border: 1px solid var(--paper-edge) !important;
  border-radius: 4px !important;
  box-shadow: var(--shadow-1) !important;
}
.tl-timemarker .tl-timemarker-content-container .tl-headline {
  color: var(--ink-zhong) !important;
  font-size: 12px;
}

/* 底部 marker 压缩:文字已由 JS 换成「第X景/第X回」,缩小字号、收紧内距、不占地方 */
.tl-timenav .tl-timemarker .tl-headline,
.tl-timenav .tl-timemarker .tl-timemarker-text .tl-headline {
  font-family: var(--font-body) !important;
  font-size: 11px !important;
  line-height: 1.2 !important;
  font-weight: 400 !important;
  white-space: nowrap;
}
.tl-timenav .tl-timemarker .tl-timemarker-content,
.tl-timenav .tl-timemarker .tl-timemarker-content-small {
  padding: 1px 6px !important;
}
/* 标记卡高度刚好容下文字 */
.tl-timenav .tl-timemarker .tl-timemarker-content-container {
  min-height: 0 !important;
  height: auto !important;
}
/* 概览(每回一张)媒体缩略图在 marker 里太占位 → 隐藏,只留短标签 */
.tl-timenav .tl-timemarker .tl-timemarker-media-container {
  display: none !important;
}
.tl-timemarker.tl-timemarker-active .tl-timemarker-content-container {
  background: var(--cinnabar) !important;
  border-color: var(--cinnabar) !important;
}
.tl-timemarker.tl-timemarker-active .tl-timemarker-content-container .tl-headline {
  color: var(--paper-bg) !important;
}
.tl-timemarker .tl-timemarker-line-left,
.tl-timemarker .tl-timemarker-line-right,
.tl-timemarker .tl-timemarker-content-container:after {
  background: var(--cinnabar) !important;
  border-color: var(--cinnabar) !important;
}

/* —— 当前进度线 —— */
.tl-timenav-line,
.tl-timenav-line .tl-timenav-line-marker {
  background: var(--cinnabar) !important;
}

/* —— 左右翻页箭头 —— */
.tl-slidenav-next .tl-slidenav-icon,
.tl-slidenav-previous .tl-slidenav-icon {
  color: var(--cinnabar) !important;
}
.tl-slidenav-title {
  font-family: var(--font-head) !important;
  color: var(--ink-jiao) !important;
}
.tl-slidenav-description {
  color: var(--ink-dan) !important;
}

/* —— 缩放菜单条:这里用不到(初始缩放已适配,标记可直接点),整条隐去 —— */
.tl-menubar {
  display: none !important;
}

/* —— 归属链接低调化 —— */
.tl-attribution {
  opacity: 0.5;
}
.tl-attribution a {
  color: var(--ink-dan) !important;
}

/* —— 幻灯内部纵向滚动条:染墨色细条,消掉默认灰「上下滚动框」 —— */
.tl-text-content-container,
.tl-slide-scrollable-container,
.tl-slide {
  scrollbar-width: thin;
  scrollbar-color: rgba(122, 113, 99, 0.4) transparent;
}
.tl-text-content-container::-webkit-scrollbar,
.tl-slide-scrollable-container::-webkit-scrollbar,
.tl-slide::-webkit-scrollbar {
  width: 8px;
}
.tl-text-content-container::-webkit-scrollbar-track,
.tl-slide-scrollable-container::-webkit-scrollbar-track,
.tl-slide::-webkit-scrollbar-track {
  background: transparent;
}
.tl-text-content-container::-webkit-scrollbar-thumb,
.tl-slide-scrollable-container::-webkit-scrollbar-thumb,
.tl-slide::-webkit-scrollbar-thumb {
  background: rgba(122, 113, 99, 0.4);
  border-radius: 6px;
}
.tl-text-content-container::-webkit-scrollbar-thumb:hover,
.tl-slide-scrollable-container::-webkit-scrollbar-thumb:hover,
.tl-slide::-webkit-scrollbar-thumb:hover {
  background: rgba(157, 41, 51, 0.5);
}

/* ===========================================================================
   编辑层(口令解锁后出现);水墨同源,不引新视觉语言。
   =========================================================================== */
.edit-lock {
  font-family: var(--font-head);
  cursor: pointer;
}
.edit-lock.active {
  background: var(--cinnabar);
  color: var(--paper-bg);
  border-color: var(--cinnabar);
}

/* 通用编辑按钮 */
.edit-btn {
  font-family: var(--font-head);
  font-size: var(--step--1);
  padding: 6px 12px;
  border: 1px solid var(--paper-edge);
  border-radius: 4px;
  background: var(--paper-2);
  color: var(--ink-zhong);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.edit-btn:hover { border-color: var(--cinnabar); color: var(--cinnabar); }
.edit-btn.primary { background: var(--cinnabar); color: var(--paper-bg); border-color: var(--cinnabar); }
.edit-btn.primary:hover { background: var(--cinnabar-bright); color: var(--paper-bg); }
.edit-btn.ghost { background: transparent; }
.edit-btn:disabled { opacity: 0.5; cursor: progress; }
.edit-entry { margin: 0 0 10px; }

/* 回廊编辑条(随当前幻灯切换) */
.corridor-edit-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 12px;
  margin-bottom: 8px;
  background: var(--paper-2);
  border: 1px solid var(--paper-edge);
  border-left: 3px solid var(--cinnabar);
  border-radius: 4px;
}
.corridor-edit-bar .ceb-label {
  font-family: var(--font-head);
  font-size: var(--step--1);
  color: var(--ink-dan);
}

/* 遮罩 + 右侧抽屉 */
.edit-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 23, 20, 0.34);
  z-index: 60;
}
.edit-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(440px, 94vw);
  height: 100vh;
  background: var(--paper-bg);
  border-left: 1px solid var(--paper-edge);
  box-shadow: -10px 0 36px var(--paper-shadow);
  z-index: 61;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.edit-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--paper-edge);
  background: var(--paper-2);
}
.edit-drawer-head h3 {
  margin: 0;
  font-family: var(--font-head);
  font-size: var(--step-1);
  color: var(--ink-jiao);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.edit-close {
  border: none;
  background: none;
  font-size: 26px;
  line-height: 1;
  color: var(--ink-dan);
  cursor: pointer;
}
.edit-close:hover { color: var(--cinnabar); }
.edit-drawer-body {
  padding: 16px 18px 40px;
  overflow-y: auto;
  flex: 1;
}
.edit-section {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px dashed var(--paper-edge);
}
.edit-section:last-child { border-bottom: none; }
.edit-section h4 {
  margin: 0 0 12px;
  font-family: var(--font-head);
  font-size: var(--step-0);
  color: var(--cinnabar);
}
.ef {
  display: block;
  margin-bottom: 12px;
}
.ef > span {
  display: block;
  font-size: var(--step--1);
  color: var(--ink-dan);
  margin-bottom: 4px;
}
.ef input,
.ef select,
.ef textarea {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-body);
  font-size: var(--step-0);
  color: var(--ink-nong);
  background: var(--paper-bg);
  border: 1px solid var(--paper-edge);
  border-radius: 4px;
  padding: 8px 10px;
}
.ef textarea { resize: vertical; line-height: 1.7; }
.ef input:focus,
.ef select:focus,
.ef textarea:focus {
  outline: none;
  border-color: var(--cinnabar);
}
.edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

/* 图片评价 */
.image-review .ir-thumb {
  max-width: 160px;
  margin-bottom: 10px;
  border: 1px solid var(--paper-edge);
  border-radius: 4px;
  overflow: hidden;
}
.image-review .ir-thumb img { display: block; width: 100%; }
.ir-stars { display: flex; align-items: center; gap: 2px; margin-bottom: 10px; }
.ir-stars .star {
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: var(--paper-edge);
  cursor: pointer;
  padding: 0 1px;
}
.ir-stars .star.on { color: var(--cinnabar); }
.ir-stars .star-clear {
  margin-left: 8px;
  border: none;
  background: none;
  font-size: var(--step--1);
  color: var(--ink-qing);
  cursor: pointer;
}
.ir-redo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--step--1);
  color: var(--ink-zhong);
  margin-bottom: 10px;
}

/* 图片评价淡角标 */
.entity-portrait { position: relative; }
.review-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-family: var(--font-head);
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 3px;
  background: rgba(245, 239, 225, 0.9);
  color: var(--ink-zhong);
  border: 1px solid var(--paper-edge);
}
.review-badge.redo { color: var(--paper-bg); background: var(--cinnabar); border-color: var(--cinnabar); }

/* 改动历史 */
.rev-list { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.rev-empty { color: var(--ink-qing); font-size: var(--step--1); }
.rev-row {
  padding: 10px;
  background: var(--paper-2);
  border: 1px solid var(--paper-edge);
  border-radius: 4px;
}
.rev-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.rev-field { font-family: var(--font-head); color: var(--cinnabar); font-size: var(--step--1); }
.rev-when { font-size: 12px; color: var(--ink-qing); }
.rev-diff { font-size: var(--step--1); line-height: 1.6; word-break: break-word; }
.rev-before { color: var(--ink-dan); text-decoration: line-through; }
.rev-after { color: var(--ink-nong); }
.rev-arrow { color: var(--cinnabar); margin: 0 4px; }
.rev-revert { margin-top: 8px; }

/* 鉴权弹层 */
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 23, 20, 0.4);
}
.auth-card {
  width: min(360px, 92vw);
  background: var(--paper-bg);
  border: 1px solid var(--paper-edge);
  border-top: 3px solid var(--cinnabar);
  border-radius: 6px;
  box-shadow: 0 18px 50px var(--paper-shadow);
  padding: 22px 22px 18px;
}
.auth-card h3 {
  margin: 0 0 6px;
  font-family: var(--font-title);
  font-size: var(--step-2);
  color: var(--ink-jiao);
}
.auth-hint { margin: 0 0 16px; font-size: var(--step--1); color: var(--ink-dan); }
.auth-card label {
  display: block;
  font-size: var(--step--1);
  color: var(--ink-dan);
  margin-bottom: 12px;
}
.auth-card label input {
  width: 100%;
  box-sizing: border-box;
  margin-top: 4px;
  font-family: var(--font-body);
  font-size: var(--step-0);
  padding: 8px 10px;
  border: 1px solid var(--paper-edge);
  border-radius: 4px;
  background: var(--paper-bg);
  color: var(--ink-nong);
}
.auth-card label input:focus { outline: none; border-color: var(--cinnabar); }
.auth-error { margin: 0 0 12px; color: var(--cinnabar-bright); font-size: var(--step--1); }
.auth-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* toast */
.edit-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  font-family: var(--font-head);
  font-size: var(--step--1);
  padding: 10px 18px;
  border-radius: 4px;
  background: var(--ink-jiao);
  color: var(--paper-bg);
  box-shadow: 0 8px 24px var(--paper-shadow);
}
.edit-toast.err { background: var(--cinnabar); }

/* 只读态彻底隐藏编辑专属元素(双保险) */
body:not(.edit-mode) .corridor-edit-bar { display: none; }
