/* ==========================================================================
   世界树 WorldTree —— 暗色羊皮纸 + 铜绿金，长时阅读友好
   ========================================================================== */
:root {
  --bg: #0b1014;
  --bg2: #10181e;
  --panel: #131d24;
  --panel2: #17232c;
  --line: #24333d;
  --ink: #dfe6e3;
  --ink-dim: #96a6a8;
  --ink-faint: #6a7b80;
  --gold: #d9b96b;
  --gold-dim: #8f7538;
  --green: #6fb08a;
  --red: #cf6a52;
  --violet: #9d82d1;
  --blue: #5b9bc4;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Noto Sans Mono", monospace;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", Georgia, serif;
  --sans: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: radial-gradient(1200px 700px at 60% -10%, #16222a 0%, var(--bg) 60%);
  color: var(--ink); font-family: var(--sans); font-size: 13.5px; line-height: 1.55;
  overflow: hidden;
}
#app { display: flex; flex-direction: column; height: 100vh; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #263640; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
select, input[type=text], textarea { font: inherit; }
a { color: var(--gold); }

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 0 14px; height: 56px; flex: 0 0 56px;
  background: linear-gradient(180deg, #16222a, #101a20); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand .glyph { color: var(--gold); font-size: 22px; text-shadow: 0 0 14px rgba(217,185,107,.45); }
.brand-text b { display: block; font-family: var(--serif); letter-spacing: 3px; font-size: 16px; }
.brand-text small { display: block; color: var(--ink-faint); font-size: 10.5px; letter-spacing: .6px; }
.worldtag { display: flex; flex-direction: column; padding-left: 14px; border-left: 1px solid var(--line); min-width: 130px; }
.worldtag .wname { font-family: var(--serif); font-size: 14.5px; color: var(--gold); }
.worldtag .wseed { font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint); }
.timebar { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 240px; }
.timebar input[type=range] { flex: 1 1 auto; }
.epoch-read { display: flex; flex-direction: column; width: 96px; }
.epoch-read b { font-size: 12.5px; }
.epoch-read small { color: var(--ink-faint); font-size: 10.5px; }
.topact { display: flex; align-items: center; gap: 10px; }
.mini-label { display: flex; flex-direction: column; font-size: 10.5px; color: var(--ink-faint); gap: 2px; }
.icon { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; width: 30px; height: 28px; }
.icon:hover { border-color: var(--gold-dim); color: var(--gold); }
.ghost { background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 6px 11px; }
.ghost:hover { border-color: var(--gold-dim); color: var(--gold); }
.primary {
  background: linear-gradient(180deg, #2c4a3a, #23392f); border: 1px solid #3d6b52; color: #e9f4ec;
  border-radius: 8px; padding: 9px 12px; font-family: var(--serif); letter-spacing: 2px; width: 100%;
}
.primary:hover { border-color: var(--gold); color: #fff6dd; }
.dropdown { position: relative; }
.menu {
  position: absolute; right: 0; top: 38px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 2px; min-width: 190px;
  box-shadow: 0 18px 40px rgba(0,0,0,.5); z-index: 50;
}
.menu button { text-align: left; background: none; border: 0; padding: 7px 9px; border-radius: 6px; font-size: 12.5px; }
.menu button:hover { background: var(--panel2); color: var(--gold); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* ---------------- 舞台 ---------------- */
.stage { flex: 1 1 auto; display: grid; grid-template-columns: 268px minmax(0,1fr) 322px; min-height: 0; }
.rail { overflow-y: auto; padding: 12px; background: linear-gradient(180deg, #0f171d, #0c1318); border-right: 1px solid var(--line); }
.rail.right { border-right: 0; border-left: 1px solid var(--line); }
.rail-title {
  font-family: var(--serif); font-size: 12px; letter-spacing: 3px; color: var(--gold-dim);
  margin: 14px 0 9px; padding-bottom: 5px; border-bottom: 1px dashed var(--line);
  display: flex; justify-content: space-between; align-items: baseline;
}
.rail-title:first-child { margin-top: 0; }
.cnt { font-family: var(--mono); color: var(--ink-faint); letter-spacing: 0; }
.field { margin: 0 0 11px; }
.field > label { display: block; font-size: 12px; color: var(--ink-dim); margin-bottom: 4px; }
.field output { float: right; font-family: var(--mono); color: var(--gold); font-size: 11.5px; }
.hint { display: block; color: var(--ink-faint); font-size: 10.5px; font-weight: 400; }
.seedrow { display: flex; gap: 6px; }
.seedrow input { flex: 1; }
input[type=text], select, textarea {
  width: 100%; background: #0c1418; border: 1px solid var(--line); color: var(--ink);
  border-radius: 6px; padding: 6px 8px;
}
input[type=text]:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold-dim); }
input[type=range] { width: 100%; accent-color: var(--gold); }
.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg button { flex: 1; background: #0c1418; border: 1px solid var(--line); border-radius: 6px; padding: 5px 4px; font-size: 11.5px; }
.seg button.on { border-color: var(--gold); color: var(--gold); background: #16222a; }
.note-line { color: var(--ink-faint); font-size: 11px; margin: 9px 0 0; }
.saves { display: flex; flex-direction: column; gap: 6px; }
.save {
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
  background: #0c1418; border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; font-size: 12px;
}
.save:hover { border-color: var(--gold-dim); }
.save b { font-family: var(--serif); font-weight: 600; }
.save small { display: block; color: var(--ink-faint); font-family: var(--mono); font-size: 10px; }
.save .del { background: none; border: 0; color: var(--ink-faint); }
.save .del:hover { color: var(--red); }
.empty { color: var(--ink-faint); font-size: 12px; }

/* ---------------- 视图 ---------------- */
.view { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tabs { display: flex; gap: 2px; padding: 8px 10px 0; background: #0d151a; border-bottom: 1px solid var(--line); }
.tabs button {
  background: transparent; border: 1px solid transparent; border-bottom: 0; border-radius: 7px 7px 0 0;
  padding: 7px 14px; font-family: var(--serif); letter-spacing: 1.5px; color: var(--ink-dim); font-size: 13px;
}
.tabs button:hover { color: var(--ink); }
.tabs button.on { background: var(--panel); border-color: var(--line); color: var(--gold); }
.subbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 7px 12px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 38px; }
.subbar .chip {
  background: #0c1418; border: 1px solid var(--line); border-radius: 20px; padding: 3px 11px; font-size: 11.5px; color: var(--ink-dim);
}
.subbar .chip.on { border-color: var(--gold); color: var(--gold); }
.subbar .sep { width: 1px; height: 18px; background: var(--line); }
.sb-title { font-family: var(--serif); font-size: 13px; color: var(--gold); letter-spacing: .14em; margin-right: 4px; }
.sb-note { color: var(--ink-faint); font-size: 11.5px; margin-right: 4px; transition: color var(--d1) var(--out); }
.card-group-h {
  grid-column: 1 / -1; font-family: var(--serif); font-size: 12px; letter-spacing: .22em; color: var(--gold-dim);
  margin: 12px 0 2px; display: flex; align-items: center; gap: 10px;
}
.card-group-h::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }
#cards { display: block; padding: 0 4px 6px; }
#cards > .cards { margin-bottom: 2px; }
.subbar label.t { font-size: 11.5px; color: var(--ink-faint); }
.subbar select { width: auto; padding: 3px 6px; }
.panels { flex: 1 1 auto; position: relative; min-height: 0; background: var(--panel); }
.panel { position: absolute; inset: 0; overflow: auto; }

/* 地图 */
#panel-map { overflow: hidden; }
#map { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
#map.grabbing { cursor: grabbing; }
.maplegend {
  position: absolute; left: 10px; bottom: 10px; background: rgba(9,15,19,.86); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 11px; max-width: 320px; line-height: 1.5;
}
.maplegend .row { display: flex; gap: 6px; flex-wrap: wrap; }
.maplegend .sw { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 3px; }
.tip {
  position: absolute; pointer-events: none; background: rgba(9,15,19,.94); border: 1px solid var(--gold-dim);
  color: var(--ink); border-radius: 7px; padding: 6px 9px; font-size: 11.5px; max-width: 280px; z-index: 20;
}
.tip b { color: var(--gold); font-family: var(--serif); }

/* 世界树 */
.treehost { position: absolute; inset: 0; overflow: hidden; background: radial-gradient(900px 600px at 50% 45%, #16232b, #0d151a 70%); }
.tree-svg { width: 100%; height: 100%; display: block; }
.tlabel { font-family: var(--serif); font-size: 8.5px; pointer-events: none; paint-order: stroke; stroke: rgba(6,10,13,.85); stroke-width: 2.4px; }
.tnode { cursor: pointer; transition: r .35s ease; }
.treekey {
  position: absolute; left: 10px; bottom: 10px; display: flex; gap: 10px; flex-wrap: wrap; max-width: 70%;
  background: rgba(9,15,19,.86); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 11px;
}
.treekey i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; }

/* 编年史 */
.chron { padding: 16px 22px 60px; max-width: 980px; }
.chron .era { margin: 0 0 4px; font-family: var(--serif); font-size: 15px; color: var(--gold); letter-spacing: 2px; }
.chron .erastat { color: var(--ink-faint); font-size: 11px; margin-bottom: 10px; }
.chron .ev {
  display: grid; grid-template-columns: 66px 1fr; gap: 10px; padding: 5px 8px; border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0; cursor: pointer;
}
.chron .ev:hover { background: #17232c; }
.chron .ev.big { border-left-color: var(--gold); background: rgba(217,185,107,.06); }
.chron .ev time { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); padding-top: 2px; }
.chron .ev .txt { font-family: var(--serif); font-size: 14px; }
.chron .ev .tag { font-size: 10.5px; padding: 0 5px; border-radius: 3px; margin-right: 6px; font-family: var(--sans); }
.chron .ev .cause { color: var(--ink-faint); font-size: 11.5px; font-family: var(--sans); margin-top: 2px; }

/* 因果链 */
.causalhost { padding: 12px; height: 100%; overflow: auto; }
.causal text { font-family: var(--serif); font-size: 11px; fill: var(--ink); }
.causal text.axis { font-family: var(--mono); font-size: 9px; fill: var(--ink-faint); }
.causal .cev { cursor: pointer; }
.causal .cev:hover circle { stroke: var(--gold); stroke-width: 2; }
.causal text.cevt { font-size: 10.5px; }
.tl text { font-family: var(--serif); font-size: 10px; fill: var(--ink-dim); }
.tl text.tlab { font-size: 9.5px; fill: var(--gold); }
.tl text.tlab2 { font-size: 10px; fill: var(--gold); font-family: var(--mono); }
.tl .tlhit { cursor: pointer; }

/* 设定总览 */
.codex { padding: 18px 24px 70px; max-width: 1060px; }
.codex h1 { font-family: var(--serif); font-size: 22px; color: var(--gold); letter-spacing: 3px; margin: 0 0 4px; }
.codex h2 { font-family: var(--serif); font-size: 15px; color: var(--green); letter-spacing: 2px; border-bottom: 1px solid var(--line); padding-bottom: 4px; margin: 26px 0 10px; }
.codex h3 { font-family: var(--serif); font-size: 13.5px; color: var(--gold-dim); margin: 18px 0 6px; letter-spacing: 1.5px; }
.codex p, .codex li { color: var(--ink-dim); }
.codex blockquote { margin: 8px 0; padding: 8px 14px; border-left: 2px solid var(--gold-dim); background: rgba(217,185,107,.05); color: var(--ink); font-family: var(--serif); }
.codex table { border-collapse: collapse; width: 100%; font-size: 12px; margin: 8px 0 14px; }
.codex th, .codex td { border: 1px solid var(--line); padding: 5px 7px; text-align: left; vertical-align: top; }
.codex th { background: #12202a; color: var(--gold); font-weight: 600; }
.codex tr:hover td { background: #16232b; }
.codex .clickable { color: var(--blue); cursor: pointer; text-decoration: underline dotted; }
.codex ul { padding-left: 20px; }

/* 写作台 */
.writing { padding: 16px 22px 70px; max-width: 1000px; }
.hook {
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; margin-bottom: 10px; background: #121d24;
}
.hook .h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hook .type { font-family: var(--serif); color: var(--gold); letter-spacing: 1px; }
.hook .strength { font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint); }
.hook .line { font-family: var(--serif); font-size: 13.5px; margin: 5px 0; }
.hook .meta { font-size: 11.5px; color: var(--ink-faint); }
.hook .acts { display: flex; gap: 6px; margin-top: 7px; }
.hook .acts button { background: #0c1418; border: 1px solid var(--line); border-radius: 5px; padding: 3px 8px; font-size: 11px; }
.hook .acts button:hover { border-color: var(--gold-dim); color: var(--gold); }
.smeter { height: 4px; background: #0c1418; border-radius: 2px; overflow: hidden; margin-top: 6px; }
.smeter i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--gold)); }

/* 档案卡 */
.dossier .d-title { font-family: var(--serif); font-size: 16px; color: var(--gold); margin: 0 0 1px; }
.dossier .d-kind { font-size: 11px; color: var(--ink-faint); font-family: var(--mono); margin-bottom: 8px; }
.dossier dl { margin: 0; }
.dossier dt { color: var(--ink-faint); font-size: 10.5px; margin-top: 7px; }
.dossier dd { margin: 0; font-size: 12.5px; }
.dossier .chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.dossier .chip { background: #0c1418; border: 1px solid var(--line); border-radius: 4px; padding: 2px 7px; font-size: 11px; cursor: pointer; }
.dossier .chip:hover { border-color: var(--gold-dim); color: var(--gold); }
.dossier .mem { font-family: var(--serif); font-size: 12px; padding: 3px 0; border-bottom: 1px dotted var(--line); cursor: pointer; }
.dossier .mem:hover { color: var(--gold); }
.dossier .mem time { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); margin-right: 5px; }
.d-actions { display: flex; gap: 6px; margin: 10px 0 4px; }
.d-actions button { flex: 1; background: #0c1418; border: 1px solid var(--line); border-radius: 6px; padding: 5px; font-size: 11.5px; }
.d-actions button:hover { border-color: var(--gold-dim); color: var(--gold); }
.basket { display: flex; flex-direction: column; gap: 5px; }
.basket .b { display: flex; justify-content: space-between; gap: 6px; align-items: center; font-size: 12px; background: #0c1418; border: 1px solid var(--line); border-radius: 6px; padding: 4px 7px; cursor: pointer; }
.basket .b:hover { border-color: var(--gold-dim); }
.basket .b .x { color: var(--ink-faint); background: none; border: 0; }
.basket .b .x:hover { color: var(--red); }
textarea.note { min-height: 74px; font-family: var(--serif); font-size: 12.5px; line-height: 1.6; }

/* 遮罩 */
.veil { position: fixed; inset: 0; background: rgba(6,10,13,.78); display: flex; align-items: center; justify-content: center; z-index: 100; }
.veil-box { text-align: center; font-family: var(--serif); letter-spacing: 2px; color: var(--gold); }
.veil-box .spin { font-size: 30px; animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { width: 220px; height: 3px; background: #1b2831; border-radius: 2px; overflow: hidden; margin: 10px auto 0; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--gold)); transition: width .2s; }

/* ---------------- 模型扩写（可选层） ---------------- */
.tag-opt { font-family: var(--sans); font-size: 10px; color: var(--ink-faint); letter-spacing: 0; }
.llm-panel { background: #0d161b; border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; }
.llm-row { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.llm-sw { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--gold); cursor: pointer; }
.llm-sw input { width: auto; accent-color: var(--gold); }
.llm-field { margin-bottom: 7px; }
.llm-field label { display: block; font-size: 10.5px; color: var(--ink-faint); margin-bottom: 3px; }
.llm-actions { display: flex; gap: 6px; margin-top: 4px; }
.llm-actions button, .llm-btn, .llm-mini button {
  background: #0c1418; border: 1px solid var(--line); border-radius: 6px; padding: 4px 9px; font-size: 11.5px; color: var(--ink-dim);
}
.llm-actions button:hover, .llm-btn:hover, .llm-mini button:hover { border-color: var(--gold-dim); color: var(--gold); }
.llm-btn { width: 100%; margin-bottom: 6px; }
.llm-stat, .llm-note { font-size: 10.5px; color: var(--ink-faint); margin: 7px 0 0; line-height: 1.5; }
.llm-wrap { margin: 10px 0 2px; }
.llm-out { border-left: 2px solid var(--gold-dim); padding-left: 9px; }
.llm-head { font-size: 10.5px; color: var(--gold-dim); letter-spacing: 1px; }
.llm-text { font-family: var(--serif); font-size: 13px; line-height: 1.75; color: var(--ink); white-space: pre-wrap; margin: 4px 0 6px; }
.llm-wait, .llm-err { font-size: 11.5px; color: var(--ink-faint); }
.llm-err { color: var(--red); }
.llm-mini { display: flex; gap: 6px; }
.chron .ev .llm-inline { margin-top: 4px; }
.chron .ev .llm-inline button { background: none; border: 1px dashed var(--line); border-radius: 5px; color: var(--ink-faint); font-size: 10.5px; padding: 1px 6px; }
.chron .ev .llm-inline button:hover { color: var(--gold); border-color: var(--gold-dim); }

/* 响应式 */
@media (max-width: 1180px) {
  .stage { grid-template-columns: 240px minmax(0,1fr); }
  .rail.right { position: absolute; right: 0; top: 56px; bottom: 0; width: 320px; z-index: 40; box-shadow: -14px 0 30px rgba(0,0,0,.5); display: none; }
  .rail.right.open { display: block; }
}
@media (max-width: 820px) {
  body { font-size: 13px; }
  .stage { grid-template-columns: minmax(0,1fr); }
  .rail.left { position: absolute; left: 0; top: 56px; bottom: 0; width: 268px; z-index: 41; display: none; }
  .rail.left.open { display: block; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 10px; }
}

/* ==========================================================================
   世界工作台 LoreWork —— 条目 / 时间线 / 关系图 / 树 / 来源 / 检查
   ========================================================================== */
.searchbox { flex: 1 1 260px; max-width: 460px; position: relative; }
.searchbox input { width: 100%; }
.qhint { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); font-size: 11px; pointer-events: none; }
.badge { display: inline-block; min-width: 16px; padding: 0 4px; margin-left: 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 15px; text-align: center; vertical-align: 1px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 6px; background: var(--green); opacity: .55; vertical-align: 2px; }
.dot.dirty { background: var(--gold); opacity: 1; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.world-card { font-size: 12px; color: var(--ink-dim); }
.world-card .wc-name { color: var(--gold); font-size: 13.5px; font-weight: 600; margin-bottom: 3px; }
.world-card .wc-row { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 6px 0 2px; }
.world-card .wc-row b { color: var(--ink); font-weight: 600; }
.wc-mount { margin-top: 6px; font-size: 11px; color: var(--ink-faint); word-break: break-all; }
.cov { margin-top: 7px; }
.cov-bar { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.cov-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--gold)); }
.cov small { display: block; margin-top: 3px; color: var(--ink-faint); }

.filters { display: flex; flex-direction: column; gap: 8px; font-size: 12px; }
.fgroup > label { display: block; color: var(--ink-faint); font-size: 11px; letter-spacing: .06em; margin-bottom: 4px; }
.kchips { display: flex; flex-wrap: wrap; gap: 4px; }
.kchip { padding: 2px 7px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg2); color: var(--ink-dim); cursor: pointer; font-size: 11.5px; line-height: 1.5; user-select: none; }
.kchip.on { border-color: var(--gold-dim); color: var(--gold); background: #1b2530; }
.kchip i { font-style: normal; margin-right: 3px; }
.frow { display: flex; gap: 6px; align-items: center; }
.frow select, .frow input { flex: 1; min-width: 0; }

.quicknew { display: flex; flex-wrap: wrap; gap: 5px; }
.quicknew button { padding: 3px 8px; font-size: 11.5px; background: var(--panel2); border: 1px solid var(--line); color: var(--ink-dim); border-radius: 4px; cursor: pointer; }
.quicknew button:hover { border-color: var(--gold-dim); color: var(--gold); }

.ai-panel { font-size: 12px; display: flex; flex-direction: column; gap: 6px; }
.ai-panel .ai-row { display: flex; gap: 5px; align-items: center; }
.ai-panel .ai-row input { flex: 1; min-width: 0; }
.ai-log { color: var(--ink-faint); font-size: 10.5px; font-family: var(--mono); max-height: 66px; overflow: auto; }

/* 档案卡片区 */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 10px; padding: 2px; align-content: start; }
.card { content-visibility: auto; contain-intrinsic-size: auto 104px; scroll-margin: 46px 8px; }   /* 屏幕外的卡不排版不绘制：长档案滚动依旧顺 */
.card { position: relative; text-align: left; padding: 9px 11px 10px; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: 5px; cursor: pointer; color: inherit; }
.card:hover { background: var(--panel2); border-color: var(--gold-dim); }
.card.sel { background: #1a2530; box-shadow: 0 0 0 1px var(--gold-dim) inset; }
.card .c-head { display: flex; align-items: center; gap: 6px; }
.card .c-glyph { font-size: 13px; }
.card .c-name { font-weight: 600; font-size: 13.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .c-kind { font-size: 10.5px; color: var(--ink-faint); border: 1px solid var(--line); border-radius: 9px; padding: 0 6px; }
.card .c-tag { margin: 5px 0 0; font-size: 12px; color: var(--ink-dim); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .c-meta { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 10.5px; color: var(--ink-faint); }
.card .c-meta em { font-style: normal; color: var(--ink-dim); }
.card .st { position: absolute; right: -1px; top: -1px; font-size: 9.5px; padding: 1px 6px; border-radius: 0 5px 0 6px; }
.card.pending { border-style: dashed; }
/* 状态色只作用于徽标本身（.st）：以前裸写 .st-canon 会连带染到层级树的行 */
.st.st-canon { background: #17301f; color: var(--green); }
.st.st-draft { background: #2b2416; color: var(--gold); }
.st.st-disputed { background: #2d2013; color: #d1a85a; }
.st.st-retired { background: #22201f; color: #8f7f7f; }
.st.st-extracted { background: #2b1722; color: #c96f8f; }

/* 时间线 */
.tl-wrap { display: flex; flex-direction: column; gap: 14px; padding-bottom: 30px; }
.tl-era { border-top: 1px solid var(--line); padding-top: 8px; }
.tl-head {
  display: flex; align-items: baseline; gap: 8px; position: sticky; top: 0; z-index: 2;
  background: linear-gradient(var(--bg2) 62%, rgba(16, 24, 30, .72) 88%, rgba(16, 24, 30, 0));
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); padding: 8px 0 6px;
}
.tl-head b { color: var(--gold); font-size: 14px; }
.tl-head small { color: var(--ink-faint); }
.tl-items { position: relative; margin-left: 6px; padding-left: 16px; border-left: 1px dashed var(--line); }
.tl-item { position: relative; display: flex; gap: 9px; align-items: baseline; padding: 4px 6px 4px 0; border-radius: 4px; cursor: pointer; }
.tl-item:hover { background: var(--panel); }
.tl-item.sel { background: #1a2530; }
.tl-item::before { content: ''; position: absolute; left: -21px; top: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--panel); border: 2px solid var(--gold-dim); }
.tl-when { flex: 0 0 108px; font-family: var(--mono); font-size: 11px; color: var(--ink-faint); text-align: right; }
.tl-name { font-size: 13px; font-weight: 600; }
.tl-tag { font-size: 12px; color: var(--ink-dim); flex: 1; min-width: 0; }
.tl-who { font-size: 10.5px; color: var(--ink-faint); }
.tl-chain { margin-top: 3px; font-size: 11px; color: #c98f4f; }

/* 关系图 */
.graph-host { position: absolute; inset: 0; }
.graph-host .lg-svg { width: 100%; height: 100%; display: block; cursor: grab; background: radial-gradient(circle at 50% 45%, #14202a 0%, var(--bg2) 62%); }
.lg-node { cursor: pointer; }
.lg-node .lg-dot { stroke: #0b1014; stroke-width: 1.4; }
.lg-node:hover .lg-dot { stroke: var(--gold); stroke-width: 2; }
.lg-node.sel .lg-dot { stroke: var(--gold); stroke-width: 2.4; }
.lg-glyph { text-anchor: middle; fill: #10181e; font-size: 8px; pointer-events: none; }
.lg-label { text-anchor: middle; fill: var(--ink-dim); font-size: 10.5px; pointer-events: none; paint-order: stroke; stroke: #0b1014; stroke-width: 3px; }
.lg-link { stroke-width: 1.1; opacity: .5; }
.lg-link.derived { stroke-dasharray: 3 4; opacity: .28; }
.lg-halo { fill: none; stroke: #c96f8f; stroke-width: 1; stroke-dasharray: 2 3; }
.graph-hint { position: absolute; left: 10px; bottom: 8px; font-size: 11px; color: var(--ink-faint); pointer-events: none; }

/* 层级树 */
.tree-host { padding-bottom: 40px; }
.ltree { font-size: 12.5px; }
.ltgroup { margin: 14px 0 4px; padding-bottom: 3px; border-bottom: 1px solid var(--line); display: flex; align-items: baseline; gap: 8px; }
.ltgroup b { color: var(--gold); font-size: 12.5px; }
.ltgroup small { color: var(--ink-faint); font-size: 11px; }
.ltnode { display: flex; align-items: baseline; gap: 6px; padding: 2px 6px 2px 0; border-radius: 4px; cursor: pointer; white-space: nowrap; }
.ltnode:hover { background: var(--panel); }
.ltnode.sel { background: #1a2530; box-shadow: 0 0 0 1px var(--gold-dim) inset; }
.ltnode .ltri { width: 12px; color: var(--ink-faint); flex: none; text-align: center; }
.ltnode .ltri.leaf { opacity: .35; }
.ltnode .ltglyph { flex: none; width: 14px; text-align: center; }
.ltnode .ltname { font-weight: 600; }
.ltnode .lttag { color: var(--ink-faint); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; }
.ltnode .ltkind { color: var(--ink-faint); font-size: 10.5px; border: 1px solid var(--line); border-radius: 8px; padding: 0 5px; flex: none; }
.ltnode .ltcnt { color: var(--ink-dim); font-size: 10.5px; flex: none; }
.ltnode .ltaib { color: #c96f8f; font-size: 9.5px; border: 1px solid #4a2733; border-radius: 3px; padding: 0 3px; flex: none; }
.ltnode.st-retired { opacity: .45; }
.ltempty { color: var(--ink-faint); font-size: 11.5px; padding-left: 18px; }

/* 来源 */
.src-wrap { display: grid; grid-template-columns: 232px minmax(0,1fr); gap: 12px; align-items: start; }
.src-list { display: flex; flex-direction: column; gap: 5px; }
.src-item { text-align: left; padding: 6px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; font-size: 12px; }
.src-item.sel { border-color: var(--gold-dim); background: var(--panel2); }
.src-item b { display: block; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-item small { color: var(--ink-faint); }
.src-doc { min-width: 0; }
.src-doc h3 { margin: 0 0 4px; font-size: 14px; color: var(--gold); }
.src-doc .sd-meta { color: var(--ink-faint); font-size: 11.5px; margin-bottom: 8px; }
.src-text { white-space: pre-wrap; font-size: 12.5px; line-height: 1.85; background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 10px 12px; max-height: 44vh; overflow: auto; }
.src-text mark { background: #2f3a24; color: var(--green); border-radius: 2px; }
.sd-bar { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 12px; align-items: center; }
.drafts { display: flex; flex-direction: column; gap: 6px; }
.draft { border: 1px solid var(--line); border-left: 3px solid #c96f8f; border-radius: 4px; padding: 7px 9px; background: var(--panel); font-size: 12px; }
.draft.adopted { opacity: .45; border-left-color: var(--green); }
.draft .d-head { display: flex; gap: 6px; align-items: baseline; }
.draft .d-head b { font-size: 13px; }
.draft .d-quote { color: var(--ink-faint); font-size: 11.5px; margin-top: 4px; font-style: italic; }
.draft .d-quote.bad { color: var(--red); }
.draft .d-rels { color: var(--ink-dim); font-size: 11px; margin-top: 3px; }
.draft .d-act { display: flex; gap: 5px; margin-top: 6px; }

/* 检查 */
.lint-wrap { display: flex; flex-direction: column; gap: 12px; padding-bottom: 30px; }
.lint-sum { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--ink-dim); }
.sev { padding: 0 7px; border-radius: 9px; font-size: 10.5px; font-weight: 700; }
.sev.error { background: #3a1a15; color: #ef8f76; }
.sev.warning { background: #34290f; color: var(--gold); }
.sev.info { background: #17262b; color: #7fb6c9; }
.lint-rule { border-top: 1px solid var(--line); padding-top: 6px; }
.lint-rule > h4 { margin: 0 0 6px; font-size: 12.5px; color: var(--ink); display: flex; gap: 7px; align-items: baseline; }
.lint-rule > h4 small { color: var(--ink-faint); font-weight: 400; }
.issue { display: flex; gap: 8px; align-items: flex-start; padding: 5px 7px; border-radius: 4px; background: var(--panel); border: 1px solid var(--line); margin-bottom: 5px; font-size: 12px; }
.issue.resolved { opacity: .42; }
.issue .i-body { flex: 1; min-width: 0; }
.issue .i-desc { color: var(--ink-dim); }
.issue .i-fix { color: var(--ink-faint); font-size: 11px; margin-top: 2px; }
.issue .i-act { display: flex; gap: 4px; flex: none; }
.issue a { color: var(--blue); cursor: pointer; text-decoration: none; }
.issue a:hover { text-decoration: underline; }

/* 总览 */
.ovw { display: grid; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); gap: 10px; padding-bottom: 30px; }
.ovw-card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; font-size: 12.5px; }
.ovw-card h3 { margin: 0 0 7px; font-size: 12.5px; color: var(--gold); letter-spacing: .04em; }
.ovw-card.wide { grid-column: 1 / -1; }
.ovw-card ul { margin: 0; padding-left: 17px; color: var(--ink-dim); }
.ovw-card li { margin: 2px 0; }
.ovw-num { font-size: 20px; color: var(--ink); font-weight: 600; }
.ovw-bar { display: flex; gap: 2px; height: 7px; margin: 7px 0 4px; border-radius: 4px; overflow: hidden; }
.ovw-bar i { display: block; }
.kv { display: grid; grid-template-columns: 88px 1fr; gap: 2px 8px; color: var(--ink-dim); }
.kv dt { color: var(--ink-faint); }
.kv dd { margin: 0; }

/* 档案卡（编辑） */
.dos { font-size: 12.5px; }
.dos-head { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.dos-head .dg { font-size: 15px; }
.dos-title { width: 100%; font-size: 15px !important; font-weight: 600; }
.dos-path { color: var(--ink-faint); font-size: 11px; margin: 3px 0 7px; }
.dos-path a { color: var(--blue); cursor: pointer; }
.dos-sec { border-top: 1px solid var(--line); margin-top: 9px; padding-top: 7px; }
.dos-sec > h4 { margin: 0 0 6px; font-size: 11px; letter-spacing: .1em; color: var(--ink-faint); display: flex; gap: 6px; align-items: center; }
.dos-sec > h4 b { color: var(--gold); font-weight: 600; }
.fld { display: grid; grid-template-columns: 1fr 1.35fr; gap: 4px; margin-bottom: 4px; align-items: start; }
.fld input, .fld select, .dos input, .dos select, .dos textarea { background: var(--bg2); border: 1px solid var(--line); color: var(--ink); border-radius: 4px; padding: 3px 6px; font-size: 12px; font-family: inherit; }
.fld input:focus, .dos textarea:focus { border-color: var(--gold-dim); outline: none; }
.rel-row { border: 1px solid var(--line); border-radius: 4px; padding: 4px 6px; margin-bottom: 5px; background: var(--bg2); font-size: 11.5px; }
.rel-row .rr-top { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.rel-row .rr-ev { color: var(--ink-faint); font-size: 11px; margin-top: 3px; font-style: italic; }
.rel-row select { font-size: 11px; padding: 2px 4px; }
.rel-row input { font-size: 11px; padding: 2px 4px; }
.dos textarea.body { width: 100%; min-height: 168px; resize: vertical; line-height: 1.75; font-family: var(--serif); font-size: 13px; }
.dos .evid { color: var(--ink-faint); font-size: 11px; }
.dos .evid b { color: var(--green); }
.dos .warnline { color: var(--red); font-size: 11.5px; }
.hintline { color: var(--ink-faint); font-size: 11px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chips span { background: #1b2530; border: 1px solid var(--line); border-radius: 9px; padding: 0 7px; font-size: 11px; cursor: pointer; }
.chips span:hover { border-color: var(--red); color: #ef8f76; }
.btn-sm { padding: 2px 8px; font-size: 11px; border-radius: 4px; border: 1px solid var(--line); background: var(--panel2); color: var(--ink-dim); cursor: pointer; }
.btn-sm:hover { color: var(--gold); border-color: var(--gold-dim); }
.btn-sm.on { color: var(--gold); border-color: var(--gold-dim); }
.btn-x { border: 0; background: none; color: var(--ink-faint); cursor: pointer; font-size: 12px; padding: 0 2px; }
.btn-x:hover { color: var(--red); }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: #1b2530; border: 1px solid var(--gold-dim); color: var(--ink); padding: 7px 14px; border-radius: 5px; font-size: 12.5px; z-index: 90; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.toast.bad { border-color: #7a3327; color: #ef8f76; }
.sheet { position: fixed; inset: 0; background: rgba(6,9,12,.72); display: flex; align-items: center; justify-content: center; z-index: 80; }
.sheet-box { width: min(680px, 92vw); max-height: 84vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px; }
.sheet-box h3 { margin: 0 0 10px; color: var(--gold); font-size: 15px; }
.sheet-box .row { display: flex; gap: 7px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.sheet-box .row > label { flex: 0 0 92px; color: var(--ink-faint); font-size: 12px; }
.sheet-box input, .sheet-box select, .sheet-box textarea { flex: 1; min-width: 0; background: var(--bg2); border: 1px solid var(--line); color: var(--ink); border-radius: 4px; padding: 5px 7px; font-size: 12.5px; font-family: inherit; }
.wlist { display: flex; flex-direction: column; gap: 5px; }
.wlist .wl { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg2); cursor: pointer; font-size: 12.5px; }
.wlist .wl:hover { border-color: var(--gold-dim); }
.wlist .wl b { flex: 1; }
@media (max-width: 1180px) { .src-wrap { grid-template-columns: 1fr; } }


/* ==========================================================================
   流畅层 (motion) —— 工作台与工厂共用
   目标：切换有过渡、悬停有反馈、按下有回弹、滚动不串场、重排不闪烁。
   只做合成器友好的动画（transform / opacity），并且尊重 prefers-reduced-motion。
   ========================================================================== */
:root {
  --d1: 110ms; --d2: 190ms; --d3: 300ms; --d4: 460ms;
  --out: cubic-bezier(.22, .61, .36, 1);
  --out-back: cubic-bezier(.34, 1.32, .5, 1);
  --in-out: cubic-bezier(.4, 0, .2, 1);
}

/* ---- 1. 交互元素的基础过渡：颜色/阴影/位移都跟手 ---- */
button, .kchip, .chip, .btn-sm, .btn-x, .card, .tl-item, .ltnode, .issue, .draft,
.src-item, .src-text, .save, .wl, .hook, .basket .b, .mem, .d-actions button,
.quicknew button, .seg button, .menu button, .ghost, .icon, .primary, .tabs button,
input, select, textarea, .cov-bar i, .smeter i, .bar i, .lg-dot, .lg-link, .lg-label, .tnode {
  transition: background-color var(--d1) var(--out), border-color var(--d1) var(--out),
    color var(--d1) var(--out), box-shadow var(--d2) var(--out), opacity var(--d2) var(--out),
    transform var(--d2) var(--out-back);
}
@media (prefers-reduced-motion: no-preference) {
  .tnode { transition: transform var(--d4) var(--out), opacity var(--d3) var(--out); }
}
input[type=range] { transition: accent-color var(--d1) var(--out); }

/* 按下即回弹：所有小控件都要有物理反馈 */
.btn-sm:active, .ghost:active, .icon:active, .kchip:active, .chip:active, .seg button:active,
.quicknew button:active, .menu button:active, .tabs button:active, .primary:active,
.d-actions button:active, .hook .acts button:active, .btn-x:active { transform: translateY(1px) scale(.985); }
.primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
.ghost:hover, .icon:hover, .btn-sm:hover, .quicknew button:hover, .seg button:hover,
.chip:hover, .kchip:hover, .hook .acts button:hover, .d-actions button:hover { transform: translateY(-1px); }

/* ---- 2. 滚动容器：平滑 + 不串场 + 不留抖动位 ---- */
.rail, .panel, .src-text, .ai-log, .causalhost, .tree-host, .dossier, .sheet-box {
  scroll-behavior: smooth; overscroll-behavior: contain; scroll-padding-top: 8px;
}
.panel, .rail { scrollbar-gutter: stable; }
.rail { contain: paint; }
.panel { contain: layout paint; }
::selection { background: rgba(217, 185, 107, .28); color: #fff; }

/* ---- 3. 视图切换：面板进入用淡入+微位移（display 切换天然重播动画） ---- */
@keyframes panelIn { from { opacity: 0; transform: translateY(8px) scale(.995); } to { opacity: 1; transform: none; } }
.panel:not([hidden]) { animation: panelIn var(--d3) var(--out) both; }
@keyframes panelOut { to { opacity: 0; transform: translateY(-6px) scale(.995); } }

/* 卡片区/时间线/树：只在「换视图 / 换世界 / 换排序」时错峰入场，逐字搜索时绝不重播 */
@keyframes itemIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.stagger > * { animation: itemIn var(--d3) var(--out) both; }
.stagger > :nth-child(1) { animation-delay: 0ms; } .stagger > :nth-child(2) { animation-delay: 22ms; }
.stagger > :nth-child(3) { animation-delay: 44ms; } .stagger > :nth-child(4) { animation-delay: 66ms; }
.stagger > :nth-child(5) { animation-delay: 88ms; } .stagger > :nth-child(6) { animation-delay: 110ms; }
.stagger > :nth-child(7) { animation-delay: 132ms; } .stagger > :nth-child(8) { animation-delay: 154ms; }
.stagger > :nth-child(9) { animation-delay: 176ms; } .stagger > :nth-child(10) { animation-delay: 198ms; }
.stagger > :nth-child(n+11) { animation-delay: 220ms; }
@keyframes cardIn { from { opacity: 0; transform: translateY(9px) scale(.985); } to { opacity: 1; transform: none; } }
.cards.stagger .card { animation: cardIn var(--d3) var(--out) both; animation-delay: calc(var(--i, 0) * 16ms); }

/* ---- 4. 选中态：不要整屏重建，只换类；描边用 inset 阴影，不产生布局抖动 ---- */
.card.sel, .ltnode.sel { box-shadow: inset 0 0 0 1px var(--gold-dim), 0 4px 14px rgba(0, 0, 0, .3); }
.tl-item.sel::before, .tl-item:hover::before { transform: scale(1.35); box-shadow: 0 0 0 3px rgba(217, 185, 107, .16); }
.tl-item::before { transition: transform var(--d2) var(--out-back), box-shadow var(--d2) var(--out); }
.tl-item:hover, .ltnode:hover, .src-item:hover, .issue:hover, .save:hover, .wl:hover,
.basket .b:hover, .draft:hover, .chron .ev:hover, .mem:hover { transform: translateX(2px); }
.src-item.sel { transform: translateX(2px); box-shadow: 0 3px 10px rgba(0, 0, 0, .3); }
.card:hover { transform: translateY(-2px); }
.card.sel:hover, .card.sel { transform: translateY(-1px); }
@keyframes flashRing { 0% { box-shadow: inset 0 0 0 1px var(--gold), 0 0 0 0 rgba(217, 185, 107, .42); }
  100% { box-shadow: inset 0 0 0 1px var(--gold-dim), 0 0 0 13px rgba(217, 185, 107, 0); } }
.flash { animation: flashRing .62s var(--out) both; }
.stagger > .ltnode, .stagger > .tl-era { animation-delay: calc(var(--i, 0) * 9ms); }

/* ---- 5. 档案卡换条目时才「翻页」，同一条目内部改字段不重播 ---- */
@keyframes dosIn { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.dos.swap { animation: dosIn var(--d3) var(--out) both; }
.dos-sec { transition: background-color var(--d2) var(--out); }
.dos-sec:focus-within { background: rgba(217, 185, 107, .04); }

/* ---- 6. 顶栏 / 标签：下划线滑动指示，切换不闪 ---- */
.tabs { position: relative; }
.tabs button { position: relative; }
.tabs button::after {
  content: ''; position: absolute; left: 11px; right: 11px; bottom: 0; height: 2px; border-radius: 2px 2px 0 0;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold)); transform: scaleX(0); transform-origin: 50% 100%;
  transition: transform var(--d3) var(--out);
}
.tabs button.on::after { transform: scaleX(1); }
.tabs button:hover { transform: translateY(-1px); }
.badge { animation: popIn var(--d3) var(--out-back) both; }
@keyframes popIn { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }

/* ---- 7. 下拉菜单 / 模态 / toast / 遮罩：进出都有过渡 ---- */
@keyframes menuIn { from { opacity: 0; transform: translateY(-8px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes menuOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-6px) scale(.98); } }
.menu { transform-origin: top right; animation: menuIn var(--d2) var(--out) both; }
.menu.out { animation: menuOut var(--d1) var(--out) both; }
.menu button:hover { transform: translateX(2px); }
@keyframes sheetIn { from { opacity: 0; } to { opacity: 1; } }
.sheet { animation: sheetIn var(--d2) var(--out) both; backdrop-filter: blur(2px); }
@keyframes sheetBoxIn { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.sheet-box { animation: sheetBoxIn var(--d3) var(--out-back) both; }
.toast { opacity: 0; pointer-events: none; transform: translate(-50%, 14px); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toastOut { to { opacity: 0; transform: translate(-50%, 10px); } }
.toast:not([hidden]) { animation: toastIn var(--d2) var(--out) forwards; }
.toast.hide { animation: toastOut var(--d2) var(--out) forwards; }
.veil { opacity: 0; pointer-events: none; transition: opacity var(--d2) var(--out); }
.veil.on { opacity: 1; pointer-events: auto; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.veil-box { transform: translateY(10px) scale(.97); opacity: .0; transition: transform var(--d3) var(--out-back), opacity var(--d3) var(--out); }
.veil.on .veil-box { transform: none; opacity: 1; }
.bar i { transition: width var(--d4) var(--out); }
@keyframes shimmer { to { background-position: 200% 0; } }
.bar i { background-image: linear-gradient(90deg, var(--green), var(--gold), var(--green)); background-size: 200% 100%; animation: shimmer 1.6s linear infinite; }

/* ---- 8. 关系图：缩放/拖拽的光标与高亮，节点呼吸 ---- */
.lg-svg { cursor: grab; }
.lg-svg.grabbing { cursor: grabbing; }
.lg-svg.hovering .lg-node { opacity: .22; }
.lg-svg.hovering .lg-node.hi, .lg-svg.hovering .lg-node.sel { opacity: 1; }
.lg-svg.hovering .lg-link { opacity: .1; }
.lg-svg.hovering .lg-link.hi { opacity: .95; stroke-width: 2; }
.lg-node .lg-dot { transition: stroke-width var(--d1) var(--out), filter var(--d2) var(--out); }
.lg-node:hover .lg-dot, .lg-node.sel .lg-dot { filter: drop-shadow(0 0 6px rgba(217, 185, 107, .75)); }
.lg-halo { animation: haloSpin 9s linear infinite; transform-origin: center; }
@keyframes haloSpin { to { stroke-dashoffset: -30; } }
@keyframes linkIn { from { opacity: 0; } }
.lg-links > line { animation: linkIn var(--d4) var(--out) both; }
.lg-nodes > g { animation: linkIn var(--d3) var(--out) both; }
@keyframes treeFade { from { opacity: .55; } }
.treehost .tree-root { animation: treeFade .3s var(--out) both; }
.treehost { cursor: default; }
.treehost.grabbing { cursor: grabbing; }
.tree-svg { cursor: grab; touch-action: none; }

/* ---- 9. 工厂：画布提示框用 transform 定位（不触发重排），图例淡入 ---- */
.tip { opacity: 0; transition: opacity var(--d1) var(--out); will-change: transform; }
.tip:not([hidden]) { opacity: 1; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }
.maplegend, .treekey { animation: fadeUp var(--d3) var(--out) both; }
.causal .cev circle { transition: r var(--d2) var(--out-back), stroke-width var(--d1) var(--out); }
.causal .cev:hover circle { r: 7.5; }
.wlist .wl:hover, .save:hover { transform: translateX(2px); }

/* ---- 10. 侧栏抽屉：小屏用位移滑出，不再 display 硬切 ---- */
@media (max-width: 1180px) {
  .rail.right { display: block; transform: translateX(103%); opacity: 0; pointer-events: none;
    transition: transform var(--d3) var(--out), opacity var(--d3) var(--out); }
  .rail.right.open { transform: none; opacity: 1; pointer-events: auto; }
}
@media (max-width: 820px) {
  .rail.left { display: block; transform: translateX(-103%); opacity: 0; pointer-events: none;
    transition: transform var(--d3) var(--out), opacity var(--d3) var(--out); }
  .rail.left.open { transform: none; opacity: 1; pointer-events: auto; }
}

/* ---- 11. 滑块：自己画轨与柄，拖动有握感（工厂控制台 / 时间轴都靠它） ---- */
input[type=range] {
  -webkit-appearance: none; appearance: none; height: 20px; background: transparent; cursor: ew-resize;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--gold-dim), var(--line) 65%);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px; margin-top: -4.5px; border-radius: 50%;
  background: var(--gold); border: 1px solid #0b1014; box-shadow: 0 0 0 0 rgba(217, 185, 107, .3);
  transition: box-shadow var(--d1) var(--out), transform var(--d1) var(--out-back);
}
input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.18); }
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.06); box-shadow: 0 0 0 6px rgba(217, 185, 107, .2); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: #24333d; }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--gold-dim); }
input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%; background: var(--gold); border: 1px solid #0b1014;
  transition: box-shadow var(--d1) var(--out);
}
input[type=range]:active::-moz-range-thumb { box-shadow: 0 0 0 6px rgba(217, 185, 107, .2); }
.field output { transition: color var(--d1) var(--out); }
.field:has(input[type=range]:active) output { color: #f4dc9f; }

/* ---- 12. 工厂顶栏时间轴：纪元读数随拖动微动，「时间在走」看得见 ---- */
.epoch-read b { display: inline-block; }
.epoch-read.tick b { animation: epochTick var(--d2) var(--out-back); }
@keyframes epochTick { 0% { transform: translateY(-3px); opacity: .3; } 100% { transform: none; opacity: 1; } }
#btn-play.playing { color: var(--gold); border-color: var(--gold-dim); animation: playing 1.8s var(--out) infinite; }
@keyframes playing { 50% { box-shadow: 0 0 0 5px rgba(217, 185, 107, .14); } }

/* ---- 13. 窄屏抽屉：侧栏滑出画面时，给个把手和背景遮罩 ---- */
.drawers { display: none; position: fixed; right: 14px; bottom: 14px; z-index: 62; gap: 8px; }
.drawer-btn {
  background: var(--panel2); border: 1px solid var(--line); color: var(--ink-dim); border-radius: 20px;
  padding: 8px 13px; font-size: 12px; box-shadow: 0 10px 26px rgba(0, 0, 0, .5);
}
.drawer-btn:hover { color: var(--gold); border-color: var(--gold-dim); }
.drawer-scrim { position: fixed; inset: 0; background: rgba(6, 10, 13, .55); opacity: 0; pointer-events: none;
  transition: opacity var(--d3) var(--out); z-index: 39; }
body.drawer-open .drawer-scrim { opacity: 1; pointer-events: auto; }
@media (max-width: 1180px) { .drawers { display: flex; } }
@media (max-width: 820px) { .rail.right { top: 56px; } }

/* ---- 14. 空态/提示：不要一片空白地硬跳出来 ---- */
@keyframes fadeUp2 { from { opacity: 0; transform: translateY(5px); } }
.empty, .note-line { animation: fadeUp2 var(--d3) var(--out) both; }
/* ---- 11. 无障碍：系统要求减少动效时全部关掉 ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important; animation-iteration-count: 1 !important;
    transition-duration: 1ms !important; scroll-behavior: auto !important;
  }
}

