/* ============ 三国演义·时空互动地图 ============ */
:root {
  --paper: #efe7d3;
  --paper-2: #e7ddc4;
  --paper-deep: #e0d5b8;
  --ink: #2b2620;
  --ink-soft: #5c5346;
  --ink-faint: #71685a;
  --gold: #a8842c;
  --gold-soft: #c9a95c;
  --line: #c6b896;

  --wei: #3b5b7d;
  --shu: #b03a2e;
  --wu: #3d7a5c;
  --qun: #7a6f58;
  --han: #a8842c;
  --jin: #6b5b7a;

  --serif: "Noto Serif SC", "Songti SC", "STSong", "STZhongsong", "SimSun", serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--serif);
  color: var(--ink);
  background: var(--paper);
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  overflow: hidden;
}

/* ============ 顶栏 ============ */
#topbar {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
  padding: 10px 18px;
  background: linear-gradient(180deg, #443c30, #37312a);
  color: #efe7d3;
  border-bottom: 3px solid var(--gold);
  z-index: 1200;
}
.brand { display: flex; align-items: center; gap: 12px; }
.seal {
  width: 46px; height: 46px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--shu); color: #f5eeda;
  font-size: 19px; font-weight: 700; letter-spacing: 2px;
  border-radius: 6px; border: 2px solid #d4b06a;
  box-shadow: inset 0 0 10px rgba(0,0,0,.35);
  writing-mode: vertical-lr;
}
.brand-text h1 { font-size: 20px; font-weight: 700; letter-spacing: 2px; color: #f0e8d2; }
.brand-text .sub { font-size: 12px; color: #b5a884; letter-spacing: 1px; }
.controls { display: flex; align-items: center; gap: 10px; }
#searchBox {
  width: 240px; padding: 7px 12px;
  background: rgba(255,251,238,.94);
  border: 1px solid #6b614e; border-radius: 4px;
  font-family: var(--serif); font-size: 13px; color: var(--ink);
  outline: none;
}
#searchBox:focus { border-color: var(--gold-soft); box-shadow: 0 0 0 2px rgba(201,169,92,.35); }
.btn-gold {
  padding: 7px 16px; font-family: var(--serif); font-size: 14px; letter-spacing: 2px;
  background: linear-gradient(180deg, #b8923e, #96742c);
  color: #fdf6e0; border: 1px solid #7c5f22; border-radius: 4px; cursor: pointer;
}
.btn-gold:hover { filter: brightness(1.1); }
.btn-ghost {
  padding: 7px 12px; font-family: var(--serif); font-size: 13px; letter-spacing: 1px;
  background: transparent; color: #d8cdb0; border: 1px solid rgba(255,251,238,.35);
  border-radius: 4px; cursor: pointer;
}
.btn-ghost:hover { border-color: var(--gold-soft); color: #fdf6e0; }

/* 拆书笔记 */
.notes { border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 10px; }
.notes-head { font-size: 12px; color: var(--gold); letter-spacing: 2px; margin-bottom: 6px; }
.notes textarea {
  width: 100%; min-height: 88px; resize: vertical;
  background: rgba(255,251,238,.75); border: 1px solid var(--line); border-radius: 5px;
  padding: 8px 10px; font-family: var(--serif); font-size: 13px; line-height: 1.75;
  color: var(--ink); outline: none;
}
.notes textarea:focus { border-color: var(--gold-soft); box-shadow: 0 0 0 2px rgba(201,169,92,.25); }
.notes-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 5px; }
#noteDelete {
  font-size: 11px; background: none; border: 1px solid var(--line); border-radius: 3px;
  color: var(--ink-faint); cursor: pointer; padding: 2px 8px; font-family: var(--serif);
}
#noteDelete:hover { color: var(--shu); border-color: var(--shu); }
.nb {
  font-size: 10px; color: var(--gold); border: 1px solid var(--gold-soft);
  border-radius: 3px; padding: 0 4px; font-weight: 700;
}

/* 筛选 chips */
.chip-row { display: flex; gap: 5px; flex-wrap: wrap; }
.fchip {
  font-family: var(--serif); font-size: 13px; letter-spacing: 1px;
  padding: 4px 10px; border-radius: 3px; cursor: pointer; user-select: none;
  border: 1px solid rgba(255,251,238,.35);
  color: #d8cdb0; background: transparent;
  transition: all .15s;
}
.fchip.on { color: #fdf6e0; background: var(--fc, #6b614e); border-color: var(--fc, #6b614e); box-shadow: 0 0 0 1px rgba(0,0,0,.25) inset; }
.fchip:not(.on) { opacity: .55; }
.fchip:hover { opacity: .9; }

/* ============ 主区 ============ */
main { display: flex; min-height: 0; }

/* 侧栏 */
#sidebar {
  width: 320px; flex: none;
  background: var(--paper-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
  z-index: 900;
}
.sidebar-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 10px 14px 6px;
}
.sidebar-head h2 { font-size: 16px; letter-spacing: 3px; color: var(--ink); }
.muted { font-size: 12px; color: var(--ink-faint); }
#typeChips { padding: 0 14px 8px; border-bottom: 1px dashed var(--line); }
#typeChips .fchip { font-size: 12px; padding: 3px 8px; color: var(--ink-soft); border-color: var(--line); background: rgba(255,251,238,.5); }
#typeChips .fchip.on { color: #fdf6e0; background: var(--ink-soft); border-color: var(--ink-soft); }
#eventList { flex: 1; overflow-y: auto; padding: 6px 8px 20px; }
#eventList::-webkit-scrollbar { width: 8px; }
#eventList::-webkit-scrollbar-thumb { background: #c2b492; border-radius: 4px; }
.year-head {
  display: flex; align-items: baseline; gap: 8px;
  margin: 14px 6px 6px;
  font-size: 13px; color: var(--gold); font-weight: 700; letter-spacing: 1px;
}
.year-head::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.ev-item {
  padding: 8px 10px; margin: 3px 0; border-radius: 5px; cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s;
}
.ev-item:hover { background: rgba(255,251,238,.8); }
.ev-item.sel { background: #fbf4de; border-color: var(--gold-soft); box-shadow: 0 1px 4px rgba(122,95,32,.18); }
.ev-item.dim { opacity: .38; }
.ev-item .t { font-size: 14px; font-weight: 700; line-height: 1.4; }
.ev-item .m { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 12px; color: var(--ink-faint); flex-wrap: wrap; }
.ev-item .ch { display: inline-block; padding: 0 6px; font-size: 11px; border: 1px solid var(--line); border-radius: 3px; color: var(--ink-soft); background: rgba(255,251,238,.6); }
.fdot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ============ 地图 ============ */
#mapWrap { position: relative; flex: 1; min-width: 0; }
#map {
  position: absolute; inset: 0;
  /* 海：淡青灰渐变，与纸色陆地形成海陆之分 */
  background: linear-gradient(155deg, #e9eBdf 0%, #dfe4d7 45%, #d2dccb 100%);
}
.leaflet-container { background: transparent; font-family: var(--serif); }
.leaflet-control-zoom a { background: #fbf4de !important; color: var(--ink) !important; border-color: var(--line) !important; }
.leaflet-control-attribution { background: rgba(239,231,211,.85) !important; color: var(--ink-faint) !important; font-size: 10px !important; }
.leaflet-control-attribution a { color: var(--ink-soft) !important; }

/* 地图标记 */
.mk {
  position: relative; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid rgba(43,38,32,.55);
  color: #fdf6e0; font-size: 13px; font-weight: 700;
  box-shadow: 0 2px 5px rgba(43,38,32,.35);
  cursor: pointer;
  transition: transform .12s;
}
.mk:hover { transform: scale(1.18); z-index: 999; }
.mk .mk-count {
  position: absolute; top: -7px; right: -7px;
  min-width: 16px; height: 16px; padding: 0 3px;
  background: #fbf4de; color: var(--ink);
  border: 1px solid var(--ink-soft); border-radius: 8px;
  font-size: 10px; line-height: 14px; font-weight: 700;
}
.mk.pulse { animation: mkpulse 1.6s ease-out infinite; }
@keyframes mkpulse {
  0% { box-shadow: 0 0 0 0 rgba(201,169,92,.75), 0 2px 5px rgba(43,38,32,.35); }
  70% { box-shadow: 0 0 0 14px rgba(201,169,92,0), 0 2px 5px rgba(43,38,32,.35); }
  100% { box-shadow: 0 0 0 0 rgba(201,169,92,0), 0 2px 5px rgba(43,38,32,.35); }
}
.mk.selected { outline: 3px solid var(--gold-soft); outline-offset: 2px; }

/* Leaflet popup 样式（宣纸风） */
.leaflet-popup-content-wrapper {
  background: #fbf4de; color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 3px 12px rgba(43,38,32,.25);
}
.leaflet-popup-tip { background: #fbf4de; border: 1px solid var(--line); }
.leaflet-popup-content { margin: 10px 14px; font-family: var(--serif); }
.pop h4 { font-size: 14px; letter-spacing: 1px; margin-bottom: 4px; }
.pop .pm { font-size: 11px; color: var(--ink-faint); margin-bottom: 6px; }
.pop a { display: block; font-size: 12px; color: var(--ink-soft); text-decoration: none; padding: 3px 0; border-top: 1px dashed var(--line); cursor: pointer; }
.pop a:hover { color: var(--shu); }
.pop a .y { color: var(--gold); margin-right: 6px; font-weight: 700; }
.leaflet-tooltip.mk-tip {
  background: #37312a; color: #f0e8d2; border: none; border-radius: 3px;
  font-family: var(--serif); font-size: 12px; padding: 2px 8px; letter-spacing: 1px;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.leaflet-tooltip.mk-tip::before { display: none; }

/* 路线动画 */
.route-anim { animation: dashmove 1.1s linear infinite; }
@keyframes dashmove { to { stroke-dashoffset: -28; } }

/* 地点名称常显标签 */
.leaflet-tooltip.place-label {
  background: transparent; border: none; box-shadow: none;
  color: #6f6350; font-family: var(--serif); font-size: 11.5px; letter-spacing: 1.5px;
  text-shadow: 0 0 4px #efe7d3, 0 0 4px #efe7d3, 0 1px 0 rgba(239,231,211,.9);
  padding: 1px 2px; font-weight: 700;
}
.leaflet-tooltip.place-label::before { display: none; }
#map.labels-hidden .place-label { visibility: hidden; }

/* 东汉十三州名标签 */
.leaflet-tooltip.province-label {
  background: transparent; border: none; box-shadow: none;
  color: rgba(112,89,44,.75); font-family: var(--serif);
  font-size: 15px; font-weight: 700; letter-spacing: 8px; padding: 0 0 0 8px;
  text-shadow: 0 0 6px rgba(239,231,211,.9);
}
.leaflet-tooltip.province-label::before { display: none; }

/* 行踪轨迹年份标签 */
.leaflet-tooltip.traj-year {
  background: rgba(251,244,222,.85); border: 1px solid var(--line); border-radius: 3px;
  color: var(--ink-soft); font-family: var(--serif); font-size: 10px; font-weight: 700;
  padding: 0 4px; box-shadow: none;
}
.leaflet-tooltip.traj-year::before { display: none; }

/* 人物画像统一做旧处理（素材来源不一，统一为宣纸基调） */
.char-card img, .char-chip img, #charFilterChip img {
  filter: sepia(.22) saturate(.85) contrast(1.03) brightness(1.02);
}
.char-card .ph img { mix-blend-mode: multiply; }
.char-card .ph { background: #f3ecd8; }

/* 图例分隔线与图层开关 */
.lg-sep { border-top: 1px dashed var(--line); margin: 6px 0; }
.lg-chk {
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--ink-soft); cursor: pointer; line-height: 1.8;
}
.lg-chk input { accent-color: var(--gold); }

/* 年份徽章 */
#yearBadge {
  position: absolute; top: 14px; left: 60px; z-index: 800;
  background: rgba(55,49,42,.92); color: #f0e8d2;
  border: 1px solid var(--gold-soft); border-radius: 5px;
  padding: 8px 14px; text-align: center;
  box-shadow: 0 3px 10px rgba(43,38,32,.3);
  pointer-events: none;
}
#yearBadge .y1 { font-size: 19px; font-weight: 700; letter-spacing: 1px; }
#yearBadge .y2 { font-size: 11px; color: var(--gold-soft); letter-spacing: 1px; margin-top: 2px; }

/* 图例 */
#legend {
  position: absolute; right: 12px; bottom: 26px; z-index: 800;
  background: rgba(251,244,222,.94); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 12px; font-size: 11px; color: var(--ink-soft);
  box-shadow: 0 2px 8px rgba(43,38,32,.18);
  line-height: 1.9;
}
#legend .lg-row { display: flex; align-items: center; gap: 6px; }
#legend b { font-size: 11px; letter-spacing: 2px; color: var(--ink); display: block; margin-bottom: 2px; }

/* 人物筛选 chip */
#charFilterChip {
  position: absolute; top: 82px; left: 10px; z-index: 850;
  display: flex; align-items: center; gap: 8px;
  background: rgba(251,244,222,.96); border: 1px solid var(--gold-soft); border-radius: 20px;
  padding: 4px 6px 4px 4px; box-shadow: 0 2px 8px rgba(43,38,32,.2);
}
#charFilterChip img, #charFilterChip .avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; object-position: top; }
#charFilterChip .nm { font-size: 13px; font-weight: 700; }
#charFilterChip .traj-flag { font-size: 10.5px; color: var(--gold); letter-spacing: 1px; }
#charFilterChip .clr { cursor: pointer; border: none; background: var(--ink-soft); color: #fff; width: 18px; height: 18px; border-radius: 50%; font-size: 10px; line-height: 1; }

/* ============ 事件卡片 ============ */
#eventCard {
  position: absolute; top: 14px; right: 12px; z-index: 900;
  width: 372px; max-height: calc(100% - 90px);
  background: #fbf4de; border: 1px solid var(--gold-soft); border-radius: 8px;
  box-shadow: 0 6px 24px rgba(43,38,32,.3);
  display: flex; flex-direction: column;
  overflow: hidden;
}
#eventCard .card-head {
  background: linear-gradient(180deg, #443c30, #37312a);
  color: #f0e8d2; padding: 10px 14px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
}
#eventCard .card-head .ch-badge {
  font-size: 11px; letter-spacing: 1px; color: var(--gold-soft);
  display: block; margin-bottom: 4px;
}
#eventCard .card-head h3 { font-size: 17px; letter-spacing: 1px; line-height: 1.35; }
#eventCard .card-close { background: none; border: none; color: #c9bfa0; font-size: 16px; cursor: pointer; padding: 2px; }
#eventCard .card-close:hover { color: #fff; }
#eventCard .card-body { padding: 12px 14px; overflow-y: auto; }
#eventCard .card-body::-webkit-scrollbar { width: 8px; }
#eventCard .card-body::-webkit-scrollbar-thumb { background: #d3c5a1; border-radius: 4px; }
.meta-line { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 8px; line-height: 1.7; }
.meta-line b { color: var(--ink); }
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 10px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 3px; color: #fdf6e0; background: var(--tc, var(--ink-soft)); letter-spacing: 1px; }
.tag.type { background: transparent; color: var(--ink-soft); border: 1px solid var(--ink-faint); }
.char-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.char-chip {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 16px; padding: 2px 10px 2px 3px;
  background: rgba(255,251,238,.7); transition: border-color .12s;
}
.char-chip:hover { border-color: var(--gold); }
.char-chip img, .char-chip .avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; object-position: top; }
.char-chip .cn { font-size: 12.5px; font-weight: 700; }
blockquote.quote {
  margin: 4px 0 10px; padding: 8px 12px;
  background: rgba(168,132,44,.09); border-left: 3px solid var(--gold-soft);
  font-size: 13.5px; line-height: 1.8; color: var(--ink);
}
blockquote.quote::before { content: "「"; color: var(--gold); }
blockquote.quote::after { content: "」"; color: var(--gold); }
.summary { font-size: 13.5px; line-height: 1.95; text-align: justify; }
.card-foot {
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px dashed var(--line); padding: 8px 14px;
}
.nav-btns button {
  font-family: var(--serif); font-size: 12px; padding: 4px 12px; cursor: pointer;
  background: rgba(255,251,238,.8); border: 1px solid var(--line); border-radius: 4px; color: var(--ink-soft);
}
.nav-btns button:hover { border-color: var(--gold); color: var(--ink); }
.route-note { font-size: 11.5px; color: var(--gold); margin-top: 8px; }

/* ============ 时间轴 ============ */
#timelineBar {
  display: flex; align-items: stretch; gap: 12px;
  padding: 10px 18px 8px;
  background: var(--paper-2);
  border-top: 2px solid var(--gold);
  z-index: 1000;
}
#playBtn {
  flex: none; width: 52px; border-radius: 6px;
  background: linear-gradient(180deg, #b8923e, #96742c);
  color: #fdf6e0; border: 1px solid #7c5f22;
  font-size: 19px; cursor: pointer;
}
#playBtn:hover { filter: brightness(1.1); }
#timeline { position: relative; flex: 1; min-width: 0; height: 108px; user-select: none; }
#eraTrack { position: absolute; left: 0; right: 0; bottom: 22px; height: 22px; border-radius: 4px; overflow: hidden; display: flex; border: 1px solid var(--line); }
.era-seg { position: relative; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 10.5px; letter-spacing: 2px; color: rgba(253,246,224,.95); text-shadow: 0 1px 2px rgba(0,0,0,.25); overflow: hidden; white-space: nowrap; }
#dots { position: absolute; left: 0; right: 0; bottom: 44px; height: 60px; pointer-events: none; }
.dot {
  position: absolute; width: 7px; height: 7px; border-radius: 50%;
  background: var(--dc, var(--ink-faint)); opacity: .28;
  transform: translateX(-50%);
  cursor: pointer; pointer-events: auto;
  transition: opacity .15s, transform .15s;
}
.dot.lit { opacity: 1; }
.dot:hover { transform: translateX(-50%) scale(1.7); }
.dot.now { box-shadow: 0 0 0 3px rgba(201,169,92,.5); }
#cursorLine {
  position: absolute; bottom: 22px; top: -2px; width: 2px;
  background: var(--shu); transform: translateX(-50%);
  box-shadow: 0 0 6px rgba(176,58,46,.6); pointer-events: none;
}
#yearSlider {
  position: absolute; left: 0; right: 0; bottom: 22px; height: 34px; width: 100%;
  opacity: 0; cursor: pointer; margin: 0;
}
#yearLabels { position: absolute; left: 0; right: 0; bottom: 0; height: 16px; font-size: 10px; color: var(--ink-faint); }
#yearLabels span { position: absolute; transform: translateX(-50%); }
.follow { flex: none; display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink-soft); cursor: pointer; }

/* ============ 人物志弹窗 ============ */
#charModal.hidden { display: none; }
#charModal { position: fixed; inset: 0; z-index: 2000; }
.modal-mask { position: absolute; inset: 0; background: rgba(43,38,32,.55); }
.modal-panel {
  position: absolute; top: 4vh; left: 50%; transform: translateX(-50%);
  width: min(1060px, 94vw); max-height: 92vh;
  background: var(--paper-2); border: 1px solid var(--gold-soft); border-radius: 10px;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.modal-head {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px; border-bottom: 2px solid var(--gold);
  background: linear-gradient(180deg, #443c30, #37312a); border-radius: 10px 10px 0 0;
}
.modal-head h2 { color: #f0e8d2; font-size: 18px; letter-spacing: 4px; margin-right: 6px; }
.modal-head .fchip { font-size: 12px; }
.modal-close { margin-left: auto; background: none; border: none; color: #c9bfa0; font-size: 17px; cursor: pointer; }
.modal-close:hover { color: #fff; }
#charGrid {
  flex: 1; overflow-y: auto; padding: 16px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 12px;
  align-content: start;
}
#charGrid::-webkit-scrollbar { width: 8px; }
#charGrid::-webkit-scrollbar-thumb { background: #c2b492; border-radius: 4px; }
.char-card {
  background: #fbf4de; border: 1px solid var(--line); border-radius: 7px;
  padding: 8px; cursor: pointer; text-align: center;
  transition: border-color .12s, transform .12s, box-shadow .12s;
}
.char-card:hover { border-color: var(--gold); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(43,38,32,.15); }
.char-card .ph { height: 150px; border-radius: 5px; overflow: hidden; background: var(--paper-deep); margin-bottom: 7px; }
.char-card img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.avatar {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--c, #7a6f58), rgba(0,0,0,.35)),
              radial-gradient(circle at 50% 30%, rgba(255,251,238,.22), transparent 60%);
  background-blend-mode: multiply;
  color: #f5eeda; font-size: 46px; font-weight: 700;
  text-shadow: 0 2px 4px rgba(0,0,0,.4);
}
.char-card .nm { font-size: 15px; font-weight: 700; letter-spacing: 1px; }
.char-card .zi { font-size: 11.5px; color: var(--ink-faint); margin-top: 1px; }
.char-card .ttl { font-size: 10.5px; color: var(--ink-soft); margin-top: 4px; line-height: 1.5; height: 32px; overflow: hidden; }
.modal-foot { padding: 8px 18px; border-top: 1px dashed var(--line); font-size: 11px; color: var(--ink-faint); }

.hidden { display: none !important; }

/* ============ 装饰罗盘 ============ */
#compass {
  position: absolute; top: 12px; right: 12px; width: 52px; height: 52px;
  z-index: 800; pointer-events: none; opacity: .92;
  filter: drop-shadow(0 2px 4px rgba(43,38,32,.25));
}

/* ============ 人物详情弹层 ============ */
#charDetail { position: fixed; inset: 0; z-index: 2500; display: flex; align-items: center; justify-content: center; }
#charDetail.hidden { display: none; }
.detail-card {
  position: relative; z-index: 1;
  background: var(--paper-2); border: 2px solid var(--gold-soft); border-radius: 10px;
  padding: 18px 20px; width: min(440px, 92vw); max-height: 86vh; overflow-y: auto;
  box-shadow: 0 24px 70px rgba(0,0,0,.45);
}
.detail-card .modal-close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none; color: var(--ink-faint); font-size: 16px; cursor: pointer;
}
.detail-card .modal-close:hover { color: var(--ink); }
.detail-top { display: flex; gap: 14px; margin-bottom: 10px; }
.detail-ph {
  width: 104px; height: 138px; flex: none;
  border-radius: 6px; overflow: hidden; background: #f3ecd8; border: 1px solid var(--line);
}
.detail-ph img {
  width: 100%; height: 100%; object-fit: cover; object-position: top;
  filter: sepia(.22) saturate(.85) contrast(1.03); mix-blend-mode: multiply;
}
.detail-ph .avatar { font-size: 40px; }
.detail-info { min-width: 0; padding-top: 4px; }
.detail-info h3 { font-size: 21px; letter-spacing: 2px; }
.detail-sub { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }
.detail-title { font-size: 12.5px; color: var(--ink-soft); margin-top: 8px; line-height: 1.6; }
.detail-bio { font-size: 13.5px; line-height: 1.95; text-align: justify; margin: 4px 0 12px; }
.detail-stats {
  display: flex; gap: 16px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--ink-soft);
  border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line);
  padding: 8px 0; margin-bottom: 14px;
}
.detail-stats b { color: var(--ink); }
.btn-detail {
  width: 100%; padding: 10px; letter-spacing: 2px;
  background: linear-gradient(180deg, #b8923e, #96742c);
  color: #fdf6e0; border: 1px solid #7c5f22; border-radius: 5px;
  font-family: var(--serif); font-size: 14px; cursor: pointer;
}
.btn-detail:hover { filter: brightness(1.08); }

/* ============ 笔记菜单 ============ */
#notesMenu {
  position: absolute; top: 52px; right: 12px; z-index: 1400;
  background: #fbf4de; border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 8px 24px rgba(43,38,32,.3);
  display: flex; flex-direction: column; min-width: 200px; overflow: hidden;
}
#notesMenu.hidden { display: none; }
#notesMenu button {
  font-family: var(--serif); font-size: 13px; text-align: left;
  padding: 9px 14px; background: none; border: none;
  border-bottom: 1px dashed var(--line); color: var(--ink-soft); cursor: pointer;
}
#notesMenu button:hover { background: rgba(201,169,92,.15); color: var(--ink); }
#notesMenu button:last-child { border-bottom: none; }

/* ============ 诗词库 ============ */
#poemsModal { position: fixed; inset: 0; z-index: 2300; display: flex; align-items: center; justify-content: center; }
#poemsModal.hidden { display: none; }
.poems-panel { width: min(880px, 95vw); }
.poems-filter {
  font-family: var(--serif); font-size: 12px; padding: 4px 8px;
  background: rgba(255,251,238,.12); color: #f0e8d2;
  border: 1px solid rgba(255,251,238,.3); border-radius: 4px;
}
.poems-filter option { color: var(--ink); background: var(--paper-2); }
#poemsList { flex: 1; overflow-y: auto; padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; align-content: start; }
#poemsList::-webkit-scrollbar { width: 8px; }
#poemsList::-webkit-scrollbar-thumb { background: #c2b492; border-radius: 4px; }
.poems-empty { grid-column: 1/-1; text-align: center; padding: 50px 0; color: var(--ink-faint); }
.poem-card {
  background: #fbf4de; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; display: flex; flex-direction: column;
}
.poem-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.poem-kind {
  font-size: 10.5px; padding: 1px 7px; border-radius: 3px; letter-spacing: 1px;
  background: var(--gold); color: #fdf6e0;
}
.poem-ch { font-size: 11.5px; color: var(--ink-faint); flex: 1; }
.poem-open { font-size: 11px; color: var(--gold); cursor: pointer; text-decoration: none; }
.poem-open:hover { text-decoration: underline; }
.poem-lines { text-align: center; font-size: 14px; line-height: 2; color: var(--ink); letter-spacing: 1px; }

/* ============ 阅读器排版/笔记面板 ============ */
#typoPanel {
  position: absolute; top: 54px; left: 50%; transform: translateX(-50%);
  z-index: 20; background: #fbf4de; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(43,38,32,.3); padding: 12px 16px;
  display: flex; flex-direction: column; gap: 8px; min-width: 280px;
}
#typoPanel.hidden { display: none; }
.typo-row { display: flex; align-items: center; gap: 6px; }
.typo-label { width: 36px; font-size: 11.5px; color: var(--ink-faint); letter-spacing: 2px; }
.typo-row button {
  font-family: var(--serif); font-size: 12.5px; padding: 4px 12px;
  background: rgba(255,251,238,.8); border: 1px solid var(--line); border-radius: 4px;
  color: var(--ink-soft); cursor: pointer;
}
.typo-row button:hover { border-color: var(--gold); }
.typo-row button.on { background: var(--gold); color: #fdf6e0; border-color: #7c5f22; }
#readerNotePanel {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 18px; z-index: 20; width: min(640px, 92%);
  background: #fbf4de; border: 1px solid var(--gold-soft); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(43,38,32,.3); padding: 12px 14px;
}
#readerNotePanel.hidden { display: none; }
#readerNotePanel { max-height: 62vh; overflow-y: auto; }
#readerNotePanel::-webkit-scrollbar { width: 8px; }
#readerNotePanel::-webkit-scrollbar-thumb { background: #c2b492; border-radius: 4px; }
.rnote-hl-head {
  font-size: 12px; letter-spacing: 2px; color: var(--gold); font-weight: 700;
  border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 10px; margin-bottom: 6px;
}
.hl-item {
  border: 1px dashed var(--line); border-radius: 6px;
  padding: 7px 9px; margin-bottom: 7px; background: rgba(255,251,238,.6);
}
.hl-item .hl-text {
  font-size: 12px; color: var(--ink-soft); line-height: 1.7; margin-bottom: 5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.hl-item .hl-text::before { content: "❝ "; color: var(--gold); }
.hl-item input {
  width: 100%; box-sizing: border-box; font-family: var(--serif); font-size: 12px;
  padding: 4px 7px; border: 1px solid var(--line); border-radius: 4px;
  background: rgba(255,251,238,.85); color: var(--ink); outline: none;
}
.hl-item input:focus { border-color: var(--gold-soft); }
.hl-item button {
  margin-top: 4px; font-size: 10.5px; background: none; border: none;
  color: var(--ink-faint); cursor: pointer; padding: 0; font-family: var(--serif);
}
.hl-item button:hover { color: var(--shu); }
.rnote-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; letter-spacing: 2px; color: var(--gold); font-weight: 700; margin-bottom: 6px;
}
#rnoteDelete {
  font-size: 11px; background: none; border: 1px solid var(--line); border-radius: 3px;
  color: var(--ink-faint); cursor: pointer; padding: 2px 8px; font-family: var(--serif);
}
#rnoteDelete:hover { color: var(--shu); border-color: var(--shu); }
#rnoteArea {
  width: 100%; min-height: 84px; resize: vertical;
  background: rgba(255,251,238,.85); border: 1px solid var(--line); border-radius: 5px;
  padding: 8px 10px; font-family: var(--serif); font-size: 13px; line-height: 1.75;
  color: var(--ink); outline: none;
}
#rnoteArea:focus { border-color: var(--gold-soft); }
.rnote-status { margin-top: 4px; font-size: 11px; }

/* 目录内笔记圆点 */
.reader-toc-item.has-note .toc-n::after { content: "记"; color: var(--gold); font-size: 9px; margin-left: 3px; }

/* ============ 同地事件链接 ============ */
.same-place { margin-top: 10px; font-size: 12px; line-height: 1.9; }
.same-place .sp-label { color: var(--gold); margin-right: 6px; font-weight: 700; letter-spacing: 1px; }
.sp-link {
  display: inline-block; margin: 2px 6px 2px 0; padding: 2px 9px;
  border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink-soft); text-decoration: none; cursor: pointer;
  font-size: 11.5px; background: rgba(255,251,238,.7);
}
.sp-link:hover { border-color: var(--gold); color: var(--ink); }
.sp-more { font-size: 11px; color: var(--ink-faint); }

/* 轨迹未到达节点年份标签淡化 */
.leaflet-tooltip.traj-year.dim-tip { opacity: .32; }

/* ============ 演义×正史对照 ============ */
.history-box {
  margin-top: 10px; border: 1px dashed var(--gold-soft); border-radius: 6px;
  background: rgba(168,132,44,.07); overflow: hidden;
}
.history-box summary {
  cursor: pointer; list-style: none; padding: 7px 12px;
  font-size: 12px; font-weight: 700; letter-spacing: 2px; color: var(--gold);
  user-select: none;
}
.history-box summary::-webkit-details-marker { display: none; }
.history-box summary::before { content: "◈ "; }
.history-box summary::after { content: "（点击展开）"; font-weight: 400; font-size: 10.5px; color: var(--ink-faint); margin-left: 6px; }
.history-box[open] summary::after { content: "（点击收起）"; }
.history-box p { padding: 2px 13px 11px; font-size: 12.5px; line-height: 1.9; color: var(--ink-soft); text-align: justify; }

/* ============ 关系图谱弹窗 ============ */
#graphModal { position: fixed; inset: 0; z-index: 2200; display: flex; align-items: center; justify-content: center; }
#graphModal.hidden { display: none; }
.graph-panel { width: min(1200px, 96vw); }
#graphBody { display: flex; min-height: 0; flex: 1; }
#graphChart { flex: 1; min-width: 0; height: min(66vh, 640px); }
#graphSide {
  width: 250px; flex: none; border-left: 1px dashed var(--line);
  padding: 14px; overflow-y: auto; background: rgba(251,244,222,.5);
}
#graphSide::-webkit-scrollbar { width: 8px; }
#graphSide::-webkit-scrollbar-thumb { background: #c2b492; border-radius: 4px; }
#graphSideEmpty { text-align: center; padding: 40px 10px; font-size: 12.5px; line-height: 2; }
.gs-head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.gs-head img { width: 46px; height: 58px; border-radius: 5px; object-fit: cover; object-position: top; border: 1px solid var(--line); filter: sepia(.22) saturate(.85); }
.gs-head .avatar { width: 46px; height: 58px; border-radius: 5px; font-size: 22px; }
.gs-name { font-size: 17px; font-weight: 700; }
.gs-sub { font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }
.gs-sec { font-size: 11.5px; letter-spacing: 2px; color: var(--gold); font-weight: 700; margin: 6px 0; }
.gs-rel {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 8px; border-radius: 4px; cursor: pointer; font-size: 12.5px;
}
.gs-rel:hover { background: rgba(201,169,92,.18); }
.gs-rel-nm { flex: 1; }
.gs-rel-w { font-size: 11px; color: var(--ink-faint); }
#gsGo { margin-top: 14px; }

@media (max-width: 768px) {
  #graphBody { flex-direction: column; }
  #graphChart { height: 46vh; }
  #graphSide { width: 100%; border-left: none; border-top: 1px dashed var(--line); max-height: 30vh; }
}

/* ============ 首次使用引导 ============ */
#introOverlay { position: fixed; inset: 0; z-index: 3000; display: flex; align-items: center; justify-content: center; }
#introOverlay.hidden { display: none; }
.intro-card {
  position: relative; z-index: 1;
  background: var(--paper-2); border: 2px solid var(--gold-soft); border-radius: 10px;
  padding: 24px 28px; width: min(430px, 92vw);
  box-shadow: 0 24px 70px rgba(0,0,0,.45);
}
.intro-card h3 { font-size: 19px; letter-spacing: 3px; margin-bottom: 12px; }
.intro-card ol { margin: 0 0 18px 20px; }
.intro-card li { font-size: 13.5px; line-height: 2.1; color: var(--ink-soft); }
.intro-card li b { color: var(--ink); }
#introStart {
  width: 100%; padding: 10px; letter-spacing: 2px;
  background: linear-gradient(180deg, #b8923e, #96742c);
  color: #fdf6e0; border: 1px solid #7c5f22; border-radius: 5px;
  font-family: var(--serif); font-size: 14px; cursor: pointer;
}
#introStart:hover { filter: brightness(1.08); }
.intro-skip {
  display: block; margin: 10px auto 0;
  background: none; border: none; color: var(--ink-faint);
  font-size: 12px; cursor: pointer; text-decoration: underline; font-family: var(--serif);
}

/* ============ 全文阅读器 ============ */
#reader { position: fixed; inset: 0; z-index: 2800; display: flex; flex-direction: column; background: linear-gradient(180deg, #f4edda, #ede4cd); }
#reader.hidden { display: none; }
.reader-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 18px;
  background: linear-gradient(180deg, #443c30, #37312a);
  color: #f0e8d2; border-bottom: 3px solid var(--gold);
}
.reader-title { flex: 1; min-width: 220px; font-size: 15px; letter-spacing: 1px; }
#readerCh { color: var(--gold-soft); margin-right: 8px; font-weight: 700; }
#readerTitle { opacity: .95; }
.reader-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.reader-tools button, .reader-tools select {
  font-family: var(--serif); font-size: 13px; padding: 4px 10px;
  background: rgba(255,251,238,.12); color: #f0e8d2;
  border: 1px solid rgba(255,251,238,.3); border-radius: 4px; cursor: pointer;
}
.reader-tools button:hover:not(:disabled) { border-color: var(--gold-soft); }
#readerTocBtn { display: none; }
.reader-tools button:disabled { opacity: .35; cursor: default; }
#readerJump { max-width: 250px; color: #f0e8d2; }
#readerJump option { color: var(--ink); background: var(--paper-2); }
.reader-main { flex: 1; display: flex; min-height: 0; }
#readerToc {
  width: 232px; flex: none; overflow-y: auto;
  border-right: 1px solid var(--line); background: rgba(231,223,196,.55);
  padding: 10px 0 20px;
}
#readerToc::-webkit-scrollbar { width: 8px; }
#readerToc::-webkit-scrollbar-thumb { background: #c2b492; border-radius: 4px; }
.reader-toc-hint {
  font-size: 11px; letter-spacing: 4px; color: var(--gold);
  padding: 4px 14px 8px; font-weight: 700;
}
.reader-toc-item {
  display: flex; gap: 8px; align-items: baseline;
  padding: 6px 14px; cursor: pointer; font-size: 12.5px; color: var(--ink-soft);
  border-left: 3px solid transparent; line-height: 1.5;
}
.reader-toc-item:hover { background: rgba(201,169,92,.14); }
.reader-toc-item.cur { border-left-color: var(--shu); background: rgba(176,58,46,.08); color: var(--ink); font-weight: 700; }
.reader-toc-item .toc-n { flex: none; width: 26px; color: var(--ink-faint); font-size: 11px; }
.reader-toc-item.cur .toc-n { color: var(--shu); }
.reader-toc-item .toc-t {
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 1; -webkit-box-orient: vertical;
}
.reader-body { flex: 1; min-width: 0; overflow-y: auto; padding: 28px 16px 90px; }
.reader-events {
  max-width: 700px; margin: 0 auto 18px; padding: 10px 14px;
  background: rgba(168,132,44,.08); border: 1px dashed var(--gold-soft); border-radius: 6px;
  font-size: 12.5px; line-height: 2;
}
.reader-events.hidden { display: none; }
.reader-events .re-label { color: var(--gold); font-weight: 700; letter-spacing: 1px; margin-right: 8px; }
.re-chip {
  display: inline-block; margin: 2px 6px 2px 0; padding: 2px 9px;
  border: 1px solid var(--gold-soft); border-radius: 10px;
  color: var(--ink-soft); cursor: pointer; font-size: 11.5px; background: rgba(251,244,222,.8);
}
.re-chip:hover { background: rgba(201,169,92,.25); color: var(--ink); }
.reader-text { max-width: 700px; margin: 0 auto; }
.reader-text { font-size: 17px; line-height: 2.05; }
.reader-text p {
  font-size: inherit; line-height: inherit; text-align: justify;
  margin: 0 0 14px; text-indent: 2em; color: var(--ink);
}
.reader-text p.anchored { background: rgba(201,169,92,.16); border-radius: 4px; }
.reader-text mark { background: rgba(176,58,46,.16); color: inherit; padding: 1px 2px; border-radius: 2px; }
.reader-loading { text-align: center; color: var(--ink-faint); padding: 70px 0; font-size: 14px; letter-spacing: 2px; }

/* 事件卡「读原文」按钮 */
.btn-read {
  margin-top: 9px; font-family: var(--serif); font-size: 12.5px;
  padding: 6px 12px; letter-spacing: 1px;
  background: rgba(168,132,44,.1); color: var(--gold);
  border: 1px solid var(--gold-soft); border-radius: 4px; cursor: pointer;
}
.btn-read:hover { background: rgba(168,132,44,.22); }

/* ============ 响应式 ============ */
@media (max-width: 1080px) {
  #sidebar { width: 260px; }
  .brand-text .sub { display: none; }
  #searchBox { width: 140px; }
  .era-seg { font-size: 9px; letter-spacing: 1px; }
}

/* 手机/窄屏：上下堆叠布局 */
@media (max-width: 768px) {
  body { grid-template-rows: auto 1fr auto; }
  #topbar { flex-direction: column; align-items: stretch; gap: 6px; padding: 8px 10px; }
  .brand { justify-content: center; }
  .brand-text h1 { font-size: 16px; text-align: center; }
  .brand-text .sub { display: none; }
  .controls { flex-wrap: wrap; justify-content: center; max-width: 100%; gap: 6px; }
  .chip-row { justify-content: center; }
  .fchip { font-size: 11px; padding: 3px 7px; }
  #searchBox { flex: 1 1 150px; width: auto; min-width: 0; }
  .btn-gold, .btn-ghost { padding: 6px 10px; font-size: 12px; }

  main { flex-direction: column; min-height: 0; }
  #mapWrap { order: 1; flex: none; height: 42vh; }
  #sidebar { order: 2; width: 100%; flex: 1; min-height: 0; border-right: none; border-top: 1px solid var(--line); }
  .sidebar-head { padding: 8px 12px 4px; }

  #timelineBar { gap: 8px; padding: 6px 10px; }
  #playBtn { width: 40px; font-size: 16px; }
  #timeline { height: 96px; }
  #dots { bottom: 40px; height: 54px; }
  .era-seg { font-size: 0; letter-spacing: 0; }        /* 窄屏隐藏年代段文字，保留色带 */
  #cursorLine { bottom: 40px; }
  #yearLabels span:nth-child(2),
  #yearLabels span:nth-child(4),
  #yearLabels span:nth-child(5) { display: none; }      /* 只留 184/220/280 */
  #readerTocBtn { display: inline-block; position: relative; z-index: 6; }
  #readerToc {
    position: absolute; top: 0; bottom: 0; left: 0; z-index: 5;
    width: min(300px, 80vw); background: var(--paper-2);
    box-shadow: 6px 0 24px rgba(43,38,32,.3); display: none;
  }
  #readerToc.show { display: block; }
  .reader-events { font-size: 12px; }
  .follow { font-size: 11px; }

  #yearBadge { top: 8px; left: 8px; padding: 5px 10px; }
  #yearBadge .y1 { font-size: 14px; }
  #legend { right: 6px; bottom: 20px; padding: 5px 8px; font-size: 10px; line-height: 1.6; }
  #legend .lg-chk { font-size: 10px; }
  #charFilterChip { top: 6px; left: 6px; }

  /* 事件卡改为底部抽屉 */
  #eventCard {
    position: fixed; left: 8px; right: 8px; bottom: 8px; top: auto;
    width: auto; max-height: 55vh; z-index: 1600;
  }
}

/* ============ 划线与高亮 ============ */
mark.hl-mark {
  background: linear-gradient(transparent 42%, rgba(240,200,90,.6) 42%);
  color: inherit; cursor: pointer; padding: 0 1px;
}
mark.hl-mark:hover { background: rgba(240,200,90,.45); }
#selBubble {
  position: absolute; z-index: 40; display: flex; gap: 2px;
  background: #37312a; border-radius: 6px; padding: 4px;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
}
#selBubble.hidden { display: none; }
#selBubble button {
  font-family: var(--serif); font-size: 12.5px; padding: 4px 11px;
  background: none; border: none; color: #f0e8d2; cursor: pointer; border-radius: 4px;
  letter-spacing: 1px;
}
#selBubble button:hover { background: rgba(255,251,238,.15); }
#hlPop {
  position: absolute; z-index: 45; width: min(300px, 86%);
  background: #fbf4de; border: 1px solid var(--gold-soft); border-radius: 8px;
  box-shadow: 0 12px 34px rgba(43,38,32,.35); padding: 10px 12px;
}
#hlPop.hidden { display: none; }
#hlPop .hl-pop-text {
  font-size: 12.5px; line-height: 1.8; color: var(--ink-soft); margin-bottom: 8px;
  border-left: 3px solid var(--gold-soft); padding-left: 8px;
}
#hlPop textarea {
  width: 100%; min-height: 56px; resize: vertical; box-sizing: border-box;
  background: rgba(255,251,238,.85); border: 1px solid var(--line); border-radius: 5px;
  padding: 6px 8px; font-family: var(--serif); font-size: 12.5px; line-height: 1.7;
  color: var(--ink); outline: none;
}
#hlPop .hl-pop-btns { display: flex; gap: 6px; margin-top: 8px; justify-content: flex-end; }
#hlPop .hl-pop-btns button {
  font-family: var(--serif); font-size: 11.5px; padding: 3px 10px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 4px; background: rgba(255,251,238,.8); color: var(--ink-soft);
}
#hlPop .hl-pop-btns button.del:hover { color: var(--shu); border-color: var(--shu); }
#hlPop .hl-pop-btns button.save { background: var(--gold); color: #fdf6e0; border-color: #7c5f22; }
