/* 奇幻北歐風格 UI：毛玻璃面板、盧恩符文裝飾、響應式。 */

:root {
  --bg: #04050d;
  --ink: #ece6d6;
  --ink-dim: #b2ad9f;
  --ink-faint: #7f7b72;
  --accent: #e8c872;
  --line: rgba(232, 200, 114, 0.22);
  --line-soft: rgba(255, 255, 255, 0.08);
  --glass: rgba(12, 15, 32, 0.62);
  --glass-strong: rgba(9, 11, 24, 0.86);
  --font-display: 'Cinzel', 'Noto Serif TC', 'Songti TC', 'PMingLiU', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
  --node-color: var(--accent);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none; /* 讓 OrbitControls 接管觸控手勢 */
  cursor: grab;
  outline: none;
}
#stage:active { cursor: grabbing; }

.glass {
  background: var(--glass);
  backdrop-filter: blur(12px) saturate(1.25);
  -webkit-backdrop-filter: blur(12px) saturate(1.25);
  border: 1px solid var(--line);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* ---------- 左上：品牌 ---------- */
.brand {
  position: fixed;
  top: calc(18px + var(--safe-t));
  left: calc(20px + var(--safe-l));
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.8);
}
.brand-rune { color: var(--accent); display: inline-flex; }
.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.14em;
}
.brand p {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--ink-dim);
}

/* ---------- 右上：音效與體系切換 ---------- */
.topright {
  position: fixed;
  top: calc(16px + var(--safe-t));
  right: calc(18px + var(--safe-r));
  z-index: 10;
  display: flex;
  gap: 10px;
  align-items: center;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  transition: color 0.25s, border-color 0.25s, background 0.25s;
}
.icon-btn:hover { color: var(--ink); border-color: rgba(232, 200, 114, 0.5); }
.icon-btn[aria-pressed='true'] { color: var(--accent); border-color: rgba(232, 200, 114, 0.55); }
.icon-btn .mute { display: block; }
.icon-btn .wave { display: none; }
.icon-btn[aria-pressed='true'] .mute { display: none; }
.icon-btn[aria-pressed='true'] .wave { display: block; }

.switcher[hidden] { display: none; }
.switcher { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.switcher button { border: 0; background: transparent; padding: 7px 14px; border-radius: 999px; font-size: 13px; color: var(--ink-dim); }
.switcher button[aria-current='true'] { background: rgba(232, 200, 114, 0.16); color: var(--accent); }

/* ---------- 左下：快速導覽 ---------- */
.dock {
  position: fixed;
  left: calc(18px + var(--safe-l));
  bottom: calc(18px + var(--safe-b));
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
.dock-row {
  display: flex;
  gap: 4px;
  padding: 5px;
  border-radius: 16px;
  background: var(--glass);
  backdrop-filter: blur(12px) saturate(1.25);
  -webkit-backdrop-filter: blur(12px) saturate(1.25);
  border: 1px solid var(--line);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
}
.dock-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  padding: 9px 14px;
  border-radius: 11px;
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
}
.dock-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--ink); }
.dock-btn[aria-current='true'] { background: rgba(255, 255, 255, 0.09); color: var(--ink); }
.dock-btn .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tier-color, var(--accent));
}
.dock-sep { width: 1px; margin: 6px 3px; background: var(--line-soft); }

.catalog {
  width: min(340px, calc(100vw - 36px));
  max-height: min(60vh, 520px);
  overflow-y: auto;
  padding: 10px;
  border-radius: 16px;
  background: var(--glass-strong);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.55);
  order: -1;
}
.catalog[hidden] { display: none; }
.cat-head { display: flex; align-items: center; justify-content: space-between; margin: 0 4px 2px 8px; font: 11px var(--font-display); letter-spacing: 0.22em; color: var(--ink-faint); }
.cat-pin { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 1px solid transparent; background: transparent; color: var(--ink-faint); transition: color 0.15s, background 0.15s, transform 0.2s; }
.cat-pin:hover { color: var(--ink); background: rgba(255, 255, 255, 0.08); }
.cat-pin[aria-pressed='true'] { color: var(--accent); border-color: var(--line); background: rgba(255, 255, 255, 0.06); transform: rotate(35deg); }
.catalog.pinned { max-height: calc(100vh - 190px); }
.catalog li button[aria-current='true'] { background: rgba(255, 255, 255, 0.09); color: var(--accent); }
.catalog h4 {
  margin: 10px 8px 4px;
  font-size: 12px;
  letter-spacing: 0.2em;
  font-weight: 500;
  color: var(--tier-color);
}
.catalog h4:first-child { margin-top: 2px; }
.catalog ul { list-style: none; margin: 0; padding: 0; }
.catalog li button {
  width: 100%;
  display: flex;
  align-items: baseline;
  gap: 8px;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px;
  border-radius: 9px;
  font-size: 14px;
}
.catalog li button:hover { background: rgba(255, 255, 255, 0.07); }
.catalog li small { color: var(--ink-faint); font-family: var(--font-display); font-size: 11px; flex: 1; }
.catalog li .kind { font-size: 11px; color: var(--ink-faint); border: 1px solid var(--line-soft); border-radius: 999px; padding: 1px 8px; }

/* ---------- 提示與懸停標籤 ---------- */
.hint {
  position: fixed;
  left: 50%;
  bottom: calc(26px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 9;
  margin: 0;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  background: rgba(8, 10, 22, 0.5);
  border: 1px solid var(--line-soft);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s;
  white-space: nowrap;
}
.hint.show { opacity: 1; }

.tooltip {
  position: fixed;
  z-index: 15;
  pointer-events: none;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transform: translate(14px, 14px);
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.tooltip[hidden] { display: none; }
.tooltip b { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.05em; }
.tooltip small { display: block; margin-top: 1px; color: var(--ink-faint); font-family: var(--font-display); font-size: 11px; letter-spacing: 0.08em; }

/* ---------- 右側：解說面板 ---------- */
.panel {
  position: fixed;
  z-index: 20;
  top: calc(16px + var(--safe-t));
  right: calc(16px + var(--safe-r));
  bottom: calc(16px + var(--safe-b));
  width: min(420px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  background: var(--glass);
  backdrop-filter: blur(12px) saturate(1.25);
  -webkit-backdrop-filter: blur(12px) saturate(1.25);
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  overflow: hidden;
  transform: translateX(calc(100% + 40px));
  opacity: 0;
  visibility: hidden;
  transition: transform 0.6s var(--ease), opacity 0.4s, visibility 0s 0.6s;
}
.panel.open {
  transform: none;
  opacity: 1;
  visibility: visible;
  transition: transform 0.6s var(--ease), opacity 0.4s, visibility 0s;
}
.panel::before { /* 依節點顏色染的頂部光暈 */
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 220px;
  background: radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--node-color) 30%, transparent), transparent 62%);
  pointer-events: none;
}
.panel-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink-dim);
}
.panel-close:hover { color: var(--ink); background: rgba(255, 255, 255, 0.1); }

.panel-head { position: relative; padding: 26px 26px 14px; }
.panel-rune {
  position: absolute;
  right: 18px;
  top: 52px;
  color: var(--node-color);
  opacity: 0.16;
  pointer-events: none;
}
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; padding-right: 40px; }
.tag {
  font-size: 12px;
  letter-spacing: 0.12em;
  padding: 3px 11px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  color: var(--ink-dim);
  background: rgba(255, 255, 255, 0.04);
}
.tag.tier { color: var(--tier-color); border-color: color-mix(in srgb, var(--tier-color) 45%, transparent); background: color-mix(in srgb, var(--tier-color) 12%, transparent); }
.panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 32px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.native {
  margin: 6px 0 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15px;
  letter-spacing: 0.1em;
  color: var(--node-color);
}
.native .epithet { font-style: normal; color: var(--ink-faint); font-family: var(--font-body); letter-spacing: 0.06em; margin-left: 8px; font-size: 13px; }

.panel-body {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 4px 26px 22px;
  scrollbar-width: thin;
  scrollbar-color: rgba(232, 200, 114, 0.3) transparent;
  outline: none;
}
.panel-body::-webkit-scrollbar { width: 6px; }
.panel-body::-webkit-scrollbar-thumb { background: rgba(232, 200, 114, 0.28); border-radius: 3px; }

.summary {
  margin: 8px 0 20px;
  padding: 0 0 0 14px;
  border-left: 2px solid var(--node-color);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.75;
  color: var(--ink);
}
.sec { margin: 0 0 20px; }
.sec h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.24em;
  color: var(--ink-faint);
}
.sec h3::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 0; padding: 0; list-style: none; }
.chips li {
  font-size: 13.5px;
  padding: 4px 12px;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line-soft);
}
.story p { margin: 0 0 14px; font-size: 15px; line-height: 1.95; color: #d8d3c5; text-align: justify; }
.source { margin: 4px 0 0; font-size: 12.5px; line-height: 1.7; color: var(--ink-faint); }
.source b { font-weight: 500; letter-spacing: 0.1em; color: var(--ink-dim); }

.more { margin-top: 18px; }
.more summary {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  letter-spacing: 0.24em;
  color: var(--ink-faint);
  cursor: pointer;
  list-style: none;
}
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: '＋'; font-size: 11px; color: var(--accent); }
.more[open] summary::before { content: '－'; }
.more summary::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }
.more summary:hover { color: var(--ink-dim); }
.more .source { margin: 12px 0 0; }
.more .cites { margin: 8px 0 0; padding: 0; list-style: none; font-size: 12.5px; line-height: 1.75; color: var(--ink-faint); }
.more .cites b { font-weight: 500; letter-spacing: 0.08em; color: var(--ink-dim); }
.more .note { margin: 10px 0 0; font-size: 12.5px; line-height: 1.75; color: var(--ink-faint); }
.links { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0 0; padding: 0; list-style: none; }
.links a {
  display: inline-block;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 999px;
  color: var(--ink-dim);
  text-decoration: none;
  border: 1px solid var(--line-soft);
}
.links a:hover, .links a:focus-visible { color: var(--ink); border-color: var(--line); background: rgba(255, 255, 255, 0.06); }
.links small { margin-left: 6px; font-size: 10px; letter-spacing: 0.08em; opacity: 0.7; }

.panel-foot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line-soft);
  background: rgba(6, 8, 18, 0.5);
}
.step {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 0;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
}
.step.next { justify-content: flex-end; text-align: right; }
.step:hover { background: rgba(255, 255, 255, 0.07); }
.step .arrow { font-size: 26px; line-height: 1; color: var(--node-color); }
.step-label { display: flex; flex-direction: column; min-width: 0; }
.step small { font-size: 11px; letter-spacing: 0.14em; color: var(--ink-faint); }
.step b { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.counter { font-family: var(--font-display); font-size: 12px; letter-spacing: 0.14em; color: var(--ink-faint); white-space: nowrap; }

/* ---------- 載入 / 進場畫面 ---------- */
.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(90% 70% at 50% 40%, #0d1230 0%, #04050d 70%);
  transition: opacity 1.1s ease, visibility 0s 1.1s;
}
.gate.done { opacity: 0; visibility: hidden; pointer-events: none; }
.gate-card { width: min(520px, 100%); text-align: center; }
.rune-ring { position: relative; width: 168px; height: 168px; margin: 0 auto 22px; animation: spin 60s linear infinite; }
.rune-ring span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  color: rgba(232, 200, 114, 0.18);
  transition: color 0.8s;
}
.rune-ring span.lit { color: var(--accent); }
.gate h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(38px, 8vw, 58px);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
}
.gate-native { margin: 6px 0 0; font-family: var(--font-display); font-style: italic; letter-spacing: 0.3em; color: var(--accent); }
.gate-text { margin: 22px auto 26px; max-width: 460px; font-size: 14.5px; line-height: 1.95; color: var(--ink-dim); text-align: left; }
.bar { height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #a8761e, var(--accent), #fff3c4); transition: width 0.35s ease; }
.gate-status { margin: 12px 0 0; font-size: 12.5px; letter-spacing: 0.2em; color: var(--ink-faint); min-height: 1.4em; }
.gate-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.gate-actions[hidden], .gate-error[hidden] { display: none; }
.btn {
  padding: 12px 26px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  letter-spacing: 0.1em;
  font-size: 15px;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.btn:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(232, 200, 114, 0.5); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(180deg, rgba(232, 200, 114, 0.3), rgba(232, 200, 114, 0.12)); border-color: rgba(232, 200, 114, 0.6); color: #fff3cf; }
.gate-note { margin: 24px auto 0; max-width: 440px; font-size: 12px; line-height: 1.8; color: var(--ink-faint); }
.gate-error { margin: 18px 0 0; color: #ff9d8a; font-size: 14px; line-height: 1.8; }
.noscript { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; margin: 0; background: var(--bg); }

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

/* ---------- 手機 / 窄螢幕 ---------- */
@media (max-width: 720px) {
  .brand { top: calc(14px + var(--safe-t)); left: calc(16px + var(--safe-l)); }
  .brand h1 { font-size: 18px; }
  .brand p { font-size: 11px; letter-spacing: 0.2em; }
  .topright { top: calc(12px + var(--safe-t)); right: calc(14px + var(--safe-r)); }

  .dock { left: calc(12px + var(--safe-l)); right: calc(12px + var(--safe-r)); bottom: calc(12px + var(--safe-b)); align-items: stretch; }
  .dock-row { overflow-x: auto; scrollbar-width: none; justify-content: flex-start; }
  .dock-row::-webkit-scrollbar { display: none; }
  .dock-row { gap: 2px; padding: 4px; }
  .dock-btn { padding: 9px 9px; gap: 6px; font-size: 13px; letter-spacing: 0; }
  .dock-sep { margin: 6px 1px; }
  .catalog { width: 100%; max-height: 52vh; }
  .cat-pin { display: none; }
  .hint { display: none; }

  .panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: min(60vh, 540px);
    border-radius: 22px 22px 0 0;
    padding-bottom: var(--safe-b);
    background: rgba(9, 11, 24, 0.84); /* 手機抽屜底色加深，明亮的場景才不會干擾閱讀 */
    transform: translateY(105%);
  }
  .panel.open { transform: none; }
  .panel-head { padding: 20px 20px 10px; }
  .panel h2 { font-size: 26px; }
  .panel-body { padding: 2px 20px 18px; }
  .panel-rune { top: 42px; }
  body.panel-open .dock { display: none; }
  body.panel-open .brand { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .panel, .panel.open, .gate, .hint, .bar i { transition-duration: 0.01s; }
  .rune-ring { animation: none; }
}

/* ---------- 人物：關係圖、人物資料、傳記導覽 ---------- */
.people {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: rgba(4, 5, 13, 0.95);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.people[hidden] { display: none; }
.people-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + var(--safe-t)) calc(16px + var(--safe-r)) 12px calc(16px + var(--safe-l));
  border-bottom: 1px solid var(--line-soft);
}
.people-bar h2 { margin: 0; font: 600 18px var(--font-display); letter-spacing: 0.12em; white-space: nowrap; }
.people-back, .people-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}
.people-back:disabled { opacity: 0.3; }
.people-back:not(:disabled):hover, .people-close:hover { background: rgba(255, 255, 255, 0.12); }
.people-search { position: relative; flex: 1; max-width: 460px; margin-left: auto; margin-right: auto; }
.people-search input {
  width: 100%;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.people-search input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.people-results {
  position: absolute;
  z-index: 3;
  top: 100%;
  left: 0;
  right: 0;
  margin: 6px 0 0;
  padding: 6px;
  list-style: none;
  max-height: 50vh;
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(12, 16, 34, 0.97);
  backdrop-filter: blur(12px);
}
.people-results button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  text-align: left;
}
.people-results.idle { max-height: min(76vh, 680px); }
.people-results.idle button { flex-direction: row; align-items: baseline; gap: 12px; padding: 5px 12px; }
.people-results.idle small { margin-left: auto; text-align: right; }
.people-results button:hover, .people-results button.sel { background: rgba(255, 255, 255, 0.09); }
.people-results b { font-weight: 500; font-size: 15px; }
.people-results small, .people-results .none { font-size: 12px; color: var(--ink-faint); }
.people-results .none { padding: 8px 12px; }
.people-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) min(430px, 40vw); }
.people-graph { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.people-graph svg { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.people-graph svg:active { cursor: grabbing; }
.graph-ctl { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.graph-ctl button {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
  background: var(--glass-strong);
  color: var(--ink);
  font-size: 16px;
}
.graph-ctl button:hover { background: rgba(255, 255, 255, 0.12); }
.graph-legend { position: absolute; left: 14px; bottom: 12px; right: 64px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--ink-faint); pointer-events: none; }
.graph-legend .lg::before { content: ''; display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 3px; border: 1.5px solid var(--c); vertical-align: -1px; }
.graph-legend .e { display: inline-block; width: 18px; height: 0; margin: 0 4px 0 8px; border-top: 2px solid; vertical-align: 3px; }
.graph-legend .e.spouse { border-color: #ffd36a; }
.graph-legend .e.lover { border-color: #ff9ac8; border-top-style: dashed; }
.graph-legend .e.foe { border-color: #ff8a7a; border-top-style: dotted; }

.pnode { cursor: pointer; outline: none; }
.pnode .box { fill: rgba(14, 18, 38, 0.88); stroke: var(--c); stroke-width: 1.4; transition: fill 0.15s; }
.pnode.layer-legend .box { stroke-dasharray: 5 3; }
.pnode .inner { fill: none; stroke: var(--c); stroke-width: 1; opacity: 0.8; }
.pnode:hover .box { fill: rgba(36, 44, 86, 0.95); }
.pnode:focus-visible .box { stroke: #fff; stroke-width: 2.4; }
.pnode.focus { cursor: default; }
.pnode.focus .box { fill: rgba(34, 40, 82, 0.97); stroke-width: 2.8; filter: drop-shadow(0 0 9px var(--c)); }
.pnode text { pointer-events: none; }
.pnode .nm { fill: var(--ink); font: 500 13px var(--font-body); }
.pnode .nm.small { font-size: 11px; }
.pnode .nt { fill: var(--ink-faint); font: 9px var(--font-body); }
.pmore rect { fill: none; stroke: var(--line); stroke-dasharray: 3 3; }
.pmore text { fill: var(--ink-faint); font: 11px var(--font-body); }
.edge { fill: none; stroke: rgba(180, 188, 216, 0.34); stroke-width: 1.2; }
.edge.spouse { stroke: #ffd36a; stroke-width: 2.4; }
.edge.lover { stroke: #ff9ac8; stroke-width: 1.6; stroke-dasharray: 5 4; }
.edge.foe { stroke: #ff8a7a; stroke-width: 1.6; stroke-dasharray: 2 4; }
.edge.friend { stroke: #8ae0a0; stroke-width: 1.6; stroke-dasharray: 2 4; }
.edge.origin { stroke-dasharray: 2 4; }
.edge.claim { stroke: #b48aff; stroke-dasharray: 6 4; }
.edge-label { fill: var(--ink-faint); font: 10px var(--font-body); text-anchor: middle; }

.people-side { overflow: auto; padding: 20px 22px 32px; border-left: 1px solid var(--line-soft); background: rgba(9, 11, 24, 0.55); }
.people-side:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.people-side h3 { margin: 8px 0 2px; font: 700 26px var(--font-display); letter-spacing: 0.02em; }
.pnative { margin: 0 0 10px; font-size: 14px; color: var(--ink-dim); font-style: italic; }
.psummary { margin: 0 0 14px; font-size: 15px; line-height: 1.8; color: #d8d3c5; }
.ptags { display: flex; flex-wrap: wrap; gap: 6px; }
.ptag { padding: 2px 10px; border-radius: 999px; font-size: 11.5px; letter-spacing: 0.08em; color: var(--c, var(--ink-dim)); border: 1px solid var(--c, var(--line-soft)); }
.ptag.layer-myth { --c: #b2ad9f; }
.ptag.layer-legend { --c: #6ac8ff; border-style: dashed; }
.ptag.layer-history { --c: #ffd36a; }
.ptag.outer { --c: #ff9ac0; border-style: dotted; }
.pouter { margin: 10px 0 0; padding: 9px 12px; border: 1px solid rgba(255, 154, 192, 0.28); border-radius: 10px; background: rgba(255, 154, 192, 0.07); font-size: 13px; line-height: 1.8; color: var(--ink-dim); }
.pouter b { font-weight: 500; letter-spacing: 0.1em; color: #ff9ac0; }
.pnode.outer .box { stroke: #ff9ac0; }
.pnode.outer .inner { stroke: #ff9ac0; }
.pnode .tag-outer { font-size: 9px; letter-spacing: 0.08em; fill: #ff9ac0; }
.people-chips li.outer button { border-style: dashed; border-color: rgba(255, 154, 192, 0.55); }
.pacts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.pbtn {
  display: inline-block;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}
.pbtn:hover { background: rgba(255, 255, 255, 0.13); }
.pbtn.primary { background: var(--accent); border-color: var(--accent); color: #1a1408; font-weight: 600; }
.pbtn.primary:hover { filter: brightness(1.1); }
.pbtn.ghost { border-color: var(--line-soft); color: var(--ink-dim); }
.pgroup { margin: 0 0 18px; }
.pgroup h4 { display: flex; align-items: center; gap: 10px; margin: 0 0 9px; font-size: 12px; font-weight: 500; letter-spacing: 0.22em; color: var(--ink-faint); }
.pgroup h4::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }
.pchips { display: flex; flex-wrap: wrap; gap: 7px; }
.pchip {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--c, var(--line-soft));
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}
.pchip:hover { background: rgba(255, 255, 255, 0.14); }
.psame { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0 0 8px; }
.psame small { font-size: 12px; color: var(--ink-faint); }
.psame .pnote { flex-basis: 100%; line-height: 1.6; }
.psame .pverb { color: #ff9a8a; min-width: 3.2em; }
.pnote { margin: 0; font-size: 12.5px; line-height: 1.7; color: var(--ink-faint); }
.plife { margin: 8px 0 0; padding: 0; list-style: none; counter-reset: life; }
.plife li { counter-increment: life; }
.plife button {
  display: flex;
  gap: 10px;
  width: 100%;
  padding: 7px 4px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.plife button::before { content: counter(life, decimal-leading-zero); flex: none; width: 1.8em; font: 12px var(--font-display); color: var(--accent); padding-top: 2px; }
.plife button:hover { background: rgba(255, 255, 255, 0.06); }

/* 節點解說面板裡的「人物關係」按鈕 */
.people-chips button {
  font: inherit;
  font-size: 13.5px;
  padding: 4px 12px;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line-soft);
  cursor: pointer;
}
.people-chips button:hover { border-color: var(--line); background: rgba(255, 255, 255, 0.12); }

/* 傳記導覽卡片：位置與節點解說面板相同（手機是底部抽屜） */
.life {
  position: fixed;
  z-index: 21;
  top: calc(16px + var(--safe-t));
  right: calc(16px + var(--safe-r));
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 32px - var(--safe-t) - var(--safe-b));
  display: flex;
  flex-direction: column;
  padding: 18px 22px 12px;
  overflow: auto;
  border-radius: 22px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px) saturate(1.25);
  backdrop-filter: blur(12px) saturate(1.25);
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
.life[hidden] { display: none; }
.life-top { display: flex; align-items: center; gap: 12px; }
.life-who { font-size: 12px; letter-spacing: 0.2em; color: var(--accent); }
.life-count { margin-left: auto; font: 12px var(--font-display); letter-spacing: 0.14em; color: var(--ink-faint); }
.life-close { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line-soft); background: rgba(255, 255, 255, 0.05); color: var(--ink); }
.life-close:hover { background: rgba(255, 255, 255, 0.14); }
.life-title { margin: 12px 0 10px; font: 700 24px var(--font-display); letter-spacing: 0.02em; }
.life-body p { margin: 0 0 10px; font-size: 15px; line-height: 1.95; color: #d8d3c5; text-align: justify; }
.life-body .more { margin-top: 8px; }
.life-body .more .source { margin: 10px 0 0; font-size: 12.5px; line-height: 1.75; color: var(--ink-faint); text-align: left; }
.life-with { margin: 6px 0 4px; }
.life-with small { display: block; margin-bottom: 7px; font-size: 11.5px; letter-spacing: 0.18em; color: var(--ink-faint); }
.life-with .pbtn { margin-top: 10px; }
.life-nav { display: flex; gap: 4px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line-soft); }
.life .step .arrow { color: var(--accent); }

@media (max-width: 720px) {
  .people-bar { gap: 8px; padding-left: calc(10px + var(--safe-l)); padding-right: calc(10px + var(--safe-r)); }
  .people-bar h2 { display: none; }
  .people-main { grid-template-columns: 1fr; grid-template-rows: minmax(210px, 42vh) minmax(0, 1fr); }
  .people-side { border-left: 0; border-top: 1px solid var(--line-soft); padding: 16px 16px calc(24px + var(--safe-b)); }
  .people-side h3 { font-size: 22px; }
  .graph-legend { display: none; }
  .life {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 58vh;
    border-radius: 22px 22px 0 0;
    padding: 16px 18px calc(10px + var(--safe-b));
    background: rgba(9, 11, 24, 0.9);
  }
  .life-title { font-size: 21px; }
  body.life-open .dock { display: none; }
  body.life-open .brand { opacity: 0; }
}
