/* ============================================================
 * 故事讲述者 —— 西幻架空风格
 * 羊皮纸 · 钴蓝 · 古金 · 锻铁 · 鸢尾花
 * ============================================================ */
:root {
  --bg: #d7d1c1;
  --paper: #e7e2d2;
  --card: rgba(236, 232, 221, 0.92);
  --text: #2e3347;
  --muted: #87816f;
  --border: #b2ab95;
  --primary: #46527a;        /* 灰钴蓝 */
  --primary-dark: #323c5d;
  --primary-darker: #262e4b;
  --accent: #9d895b;         /* 哑光古金 */
  --gold: #ab9663;
  --gold-light: #ccbc8d;
  --danger: #7d4b4b;         /* 灰酒红 */
  --ink: #1f2436;            /* 深夜蓝墨 */
  --stage-bg: #e3dece;
  --radius: 6px;
  --shadow: 0 2px 6px rgba(30, 35, 60, 0.16), 0 12px 32px rgba(30, 35, 60, 0.12);
  --soft-shadow: 0 3px 14px rgba(60, 50, 25, 0.20);
  --font-serif: "Cinzel", "Trajan Pro", "Times New Roman",
    "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font-serif);
  color: var(--text);
  overflow: hidden;
  position: relative;
  background-color: #d2ccbb;
  /* 羊皮纸纤维与旧渍 */
  background-image:
    radial-gradient(ellipse at 18% 8%, rgba(255,250,232,0.55), transparent 52%),
    radial-gradient(ellipse at 86% 92%, rgba(110, 92, 52, 0.20), transparent 55%),
    radial-gradient(circle at 70% 18%, rgba(96, 78, 40, 0.08), transparent 38%),
    repeating-linear-gradient(0deg, rgba(90, 75, 40, 0.022) 0 2px, transparent 2px 5px),
    repeating-linear-gradient(90deg, rgba(90, 75, 40, 0.018) 0 2px, transparent 2px 5px);
}

/* 旧纸晕渍（墨蓝 + 古金） */
body::before,
body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(78px);
  pointer-events: none;
  z-index: 0;
}
body::before {
  top: -20%; left: -14%;
  width: 52%; height: 52%;
  background: radial-gradient(circle, rgba(70, 82, 122, 0.14), transparent 70%);
}
body::after {
  bottom: -22%; right: -14%;
  width: 52%; height: 52%;
  background: radial-gradient(circle, rgba(157, 137, 91, 0.20), transparent 70%);
}

/* ---------- 顶栏 ---------- */
.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background:linear-gradient(180deg, #2c3352 0%, #212744 55%, #1b2038 100%);
  color: var(--gold-light);
  position: relative;
  z-index: 10;
  border-bottom: 2px solid var(--gold);
  box-shadow:0 2px 18px rgba(10, 14, 32, 0.45),
              inset 0 -1px 0 rgba(204, 188, 141, 0.35);
}

.brand { display: flex; align-items: center; gap: 11px; }
.brand svg { color: var(--gold-light); filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.brand h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--gold-light);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.55);
}

.actions { display: flex; gap: 8px; }

/* ---------- 按钮 ---------- */
.btn {
  font: inherit;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .2s ease;
  white-space: nowrap;
  letter-spacing: 1px;
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  background:linear-gradient(180deg, #465584, #33406a);
  color: var(--gold-light);
  border-color: var(--gold);
  box-shadow:0 2px 8px rgba(15, 20, 45, 0.35),
              inset 0 1px 0 rgba(204, 188, 141, 0.25);
}
.btn.primary:hover {
  background:linear-gradient(180deg, #546294, #3c4a78);
  box-shadow:0 3px 12px rgba(15, 20, 45, 0.45);
}
.btn.block { width: 100%; margin-top: 4px; }
.btn.ghost {
  background:rgba(204, 188, 141, 0.08);
  color: var(--gold-light);
  border-color:rgba(171, 150, 99, 0.55);
}
.btn.ghost:hover { background:rgba(204, 188, 141, 0.2); border-color: var(--gold-light); }
.btn.danger {
  background: transparent;
  color:#b98585;
  border-color:rgba(150, 100, 100, 0.5);
}
.btn.danger:hover { background:rgba(125, 75, 75, 0.22); color:#cf9595; }
.btn.light-danger {
  background:rgba(125, 75, 75, 0.1);
  color: var(--danger);
  border-color:rgba(125, 75, 75, 0.35);
}
.btn.light-danger:hover { background:rgba(125, 75, 75, 0.2); }

/* ---------- 布局 ---------- */
.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: calc(100vh - 60px);
  position: relative;
  z-index: 1;
}

.sidebar {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-track { background: rgba(60, 50, 25, 0.08); }
.sidebar::-webkit-scrollbar-thumb {
  background:linear-gradient(var(--gold), #8a7c54);
  border-radius: 2px;
  border: 1px solid rgba(40, 30, 10, 0.25);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--soft-shadow);
  position: relative;
}
/* 卡片顶部金色饰线 */
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 2px;
  background: linear-gradient(to right, transparent, var(--gold), transparent);
}
.card h2 {
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary-dark);
  letter-spacing: 2px;
  font-weight: 700;
  margin-bottom: 14px;
}
/* 标题两侧装饰短划 */
.card h2::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--gold), transparent);
}
.card h2 em {
  font-style: normal;
  font-size: 11px;
  background:rgba(70, 82, 122, 0.12);
  color: var(--primary-dark);
  border:1px solid rgba(70, 82, 122, 0.3);
  padding: 1px 10px;
  border-radius: 3px;
  letter-spacing: 1px;
}

/* ---------- 表单 ---------- */
.field { display: block; margin-bottom: 12px; }
.field > span {
  display: block;
  font-size: 12px;
  color:#6f6854;
  margin-bottom: 5px;
  letter-spacing: 1px;
  font-weight: 600;
}

input[type="text"], input[type="number"], input[type="date"], textarea, select {
  width: 100%;
  font: inherit;
  font-size: 13px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background:rgba(253, 248, 234, 0.75);
  color: var(--text);
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--gold);
  background:rgba(255, 252, 242, 0.95);
  box-shadow:0 0 0 2px rgba(171, 150, 99, 0.25);
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color:#aaa188; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
/* RGB 自定义取色滑条（配合 .swatches） */
.rgb-picker {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 8px;
}
.rgb-picker .rgb-bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.rgb-picker .rgb-slider input[type="range"] { width: 150px; }
.rgb-picker .rgb-preview {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  border: 2px solid var(--gold);
}
.swatch {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform .15s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--primary-dark), 0 2px 6px rgba(40, 30, 10, 0.3);
}

/* ---------- 头像上传 ---------- */
.avatar-upload {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 10px;
  border: 1.5px dashed #a3997d;
  border-radius: 6px;
  background:rgba(253, 248, 234, 0.5);
  transition: border-color .2s, background .2s;
}
.avatar-upload:hover { border-color: var(--gold); background:rgba(171, 150, 99, 0.08); }

.avatar-preview {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background:#d3ccb8;
  color:#a49a83;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background-size: cover;
  background-position: center;
  border: 2.5px solid var(--gold);
  box-shadow: 0 2px 8px rgba(60, 50, 25, 0.25);
}
.avatar-preview.has-image { color: transparent; }

.avatar-hint { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.avatar-btn {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
}
.avatar-hint small { font-size: 11px; color: var(--muted); }
.avatar-remove {
  font: inherit;
  font-size: 12px;
  color: var(--danger);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.avatar-remove:hover { text-decoration: underline; }

/* ---------- 双列表单行 ---------- */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.field-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.field-row .field { margin-bottom: 12px; }

/* ---------- 详情面板字段网格 ---------- */
.detail-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  margin-bottom: 4px;
}
.detail-fields .field { margin-bottom: 0; }
.detail-fields .field > span { font-size: 11px; margin-bottom: 3px; }
.detail-fields .field-full { grid-column: 1 / -1; }
.detail-fields input, .detail-fields select { font-size: 12px; padding: 6px 8px; }

/* ---------- 人物列表 ---------- */
.person-list { list-style: none; display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.person-list::-webkit-scrollbar { width: 6px; }
.person-list::-webkit-scrollbar-thumb { background:rgba(131, 115, 74, 0.4); border-radius: 2px; }

.person-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  transition: background .2s, border-color .2s, box-shadow .2s;
  background:rgba(253, 248, 234, 0.5);
}
.person-item:hover {
  background:rgba(255, 252, 242, 0.85);
  border-color: var(--gold);
  box-shadow: 0 2px 10px rgba(60, 50, 25, 0.14);
}
.person-item.active {
  background:rgba(70, 82, 122, 0.1);
  border-color: var(--primary);
  box-shadow: inset 2px 0 0 var(--primary);
}
.person-item .thumb {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex: none;
  background:#d3ccb8;
  background-size: cover;
  background-position: center;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--gold);
  box-shadow: 0 2px 6px rgba(60, 50, 25, 0.2);
}
.person-item .meta { flex: 1; min-width: 0; }
.person-item .name { font-size: 13px; font-weight: 700; color: var(--primary-dark); }
.person-item .desc {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.person-item .tag-box {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}
.person-item .tag-chip {
  font-size: 10px;
  line-height: 1;
  color: var(--primary-dark);
  background:rgba(171, 150, 99, 0.14);
  border:1px solid rgba(131, 115, 74, 0.4);
  border-radius: 3px;
  padding: 3px 7px;
  white-space: nowrap;
}

/* ---------- #标签输入组件 ---------- */
.tag-input-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 8px;
  background:rgba(253, 248, 234, 0.7);
  cursor: text;
  transition: border-color .2s, box-shadow .2s;
}
.tag-input-box:focus-within {
  border-color: var(--gold);
  box-shadow:0 0 0 2px rgba(171, 150, 99, 0.22);
}
.tag-input-box .tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tag-input-box .tag-chips:empty { display: none; }
.tag-input-box .tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  line-height: 1;
  color: var(--primary-dark);
  background:rgba(171, 150, 99, 0.16);
  border:1px solid rgba(131, 115, 74, 0.45);
  border-radius: 3px;
  padding: 4px 6px 4px 9px;
  white-space: nowrap;
}
.tag-x {
  border: none;
  background: transparent;
  color: var(--primary-dark);
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity .15s, transform .15s;
}
.tag-x:hover { opacity: 1; transform: scale(1.15); }
.tag-input {
  flex: 1;
  min-width: 120px;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  padding: 2px;
}
.field-hint {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  color: var(--muted);
}
.person-item .del {
  border: none;
  background: none;
  color:#aaa085;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 3px;
}
.person-item .del:hover { color: var(--danger); background:rgba(125, 75, 75, 0.1); }

.empty-tip { font-size: 12px; color: var(--muted); text-align: center; padding: 14px 0; }

/* ---------- 关系图舞台 ---------- */
.stage {
  position: relative;
  background:radial-gradient(ellipse at 50% 40%, rgba(255, 250, 232, 0.5), transparent 70%),
    var(--stage-bg);
  overflow: hidden;
}
/* 舞台光晕（古金 + 钴蓝） */
.stage::before,
.stage::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(85px);
  pointer-events: none;
  z-index: 0;
}
.stage::before {
  top: -12%; right: -6%;
  width: 44%; height: 48%;
  background: radial-gradient(circle, rgba(157, 137, 91, 0.16), transparent 70%);
}
.stage::after {
  bottom: -12%; left: -6%;
  width: 44%; height: 48%;
  background:radial-gradient(circle, rgba(70, 82, 122, 0.12), transparent 70%);
}

#graph { display: block; width: 100%; height: 100%; cursor: grab; position: relative; z-index: 1; }

/* 关系网舞台：深蓝星穹底色（Canvas 未渲染时的兜底） */
body[data-view="network"] .stage {
  background: radial-gradient(ellipse at 82% 106%, #24406e 0%, #162c52 35%, #0c1a33 70%, #060d1c 100%);
}
body[data-view="network"] .stage::before,
body[data-view="network"] .stage::after {
  display: none;
}

.hint {
  position: absolute;
  left: 16px;
  bottom: 14px;
  font-size: 12px;
  color: var(--primary-dark);
  background: rgba(239, 230, 204, 0.85);
  padding: 6px 14px;
  border-radius: 3px;
  border: 1px solid var(--gold);
  pointer-events: none;
  z-index: 2;
}

.toast {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background:linear-gradient(180deg, #2c3352, #212744);
  color: var(--gold-light);
  font-size: 13px;
  padding: 8px 22px;
  border-radius: 3px;
  border: 1px solid var(--gold);
  box-shadow: 0 4px 16px rgba(10, 14, 32, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 20;
  letter-spacing: 1px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 详情面板 ---------- */
.detail {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 280px;
  max-height: calc(100% - 32px);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  box-shadow:0 10px 36px rgba(20, 25, 50, 0.28);
  padding: 18px;
  color: var(--text);
  z-index: 5;
}
.detail::before {
  content: '';
  position: absolute;
  top: 0; left: 12%; right: 12%;
  height: 2px;
  background: linear-gradient(to right, transparent, var(--gold-light), transparent);
}
.detail::-webkit-scrollbar { width: 6px; }
.detail::-webkit-scrollbar-thumb { background:rgba(131, 115, 74, 0.45); border-radius: 2px; }

.detail.hidden { display: none; }
.detail-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: none;
  background: none;
  font-size: 18px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  z-index: 2;
}
.detail-close:hover { color: var(--danger); }

.detail h3 {
  font-size: 13px;
  margin: 14px 0 8px;
  color:#6f6854;
  letter-spacing: 2px;
}

.detail-actions { display: flex; gap: 8px; margin-top: 12px; }
.detail-actions .btn { flex: 1; }

.rel-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.rel-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 7px 10px;
  background:rgba(253, 248, 234, 0.55);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.rel-row .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; border: 1px solid rgba(60,50,25,.3); }
.rel-row .other { flex: 1; font-weight: 700; color: var(--primary-dark); }
.rel-row .tag {
  background:rgba(171, 150, 99, 0.16);
  color: var(--primary-dark);
  border:1px solid rgba(131, 115, 74, 0.35);
  padding: 1px 10px;
  border-radius: 3px;
  font-size: 11px;
}
.rel-row .del-edge {
  border: none;
  background: none;
  color:#aaa085;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}
.rel-row .del-edge:hover { color: var(--danger); }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  body { overflow: auto; }
  .layout, .map-layout, .timeline-layout, .stories-layout, .chat-layout { grid-template-columns: 1fr; height: auto; }
  .stage { height: 62vh; }
  .topbar { padding: 0 12px; flex-wrap: wrap; gap: 8px; height: auto; min-height: 60px; }
  .brand h1 { font-size: 16px; }
  .actions .btn { padding: 6px 12px; font-size: 12px; }
  .tabs { order: 3; width: 100%; justify-content: center; }
}

/* ============================================================
 * 视图切换
 * ============================================================ */
body[data-view="network"] .map-layout,
body[data-view="network"] .timeline-layout,
body[data-view="network"] .stories-layout,
body[data-view="network"] .chat-layout { display: none; }
body[data-view="map"] .layout,
body[data-view="map"] .timeline-layout,
body[data-view="map"] .stories-layout,
body[data-view="map"] .chat-layout { display: none; }
body[data-view="timeline"] .layout,
body[data-view="timeline"] .map-layout,
body[data-view="timeline"] .stories-layout,
body[data-view="timeline"] .chat-layout { display: none; }
body[data-view="stories"] .layout,
body[data-view="stories"] .map-layout,
body[data-view="stories"] .timeline-layout,
body[data-view="stories"] .chat-layout { display: none; }
body[data-view="chat"] .layout,
body[data-view="chat"] .map-layout,
body[data-view="chat"] .timeline-layout,
body[data-view="chat"] .stories-layout { display: none; }

/* ---------- 顶栏标签（锻铁勋章风） ---------- */
.tabs {
  display: flex;
  gap: 2px;
  background:linear-gradient(180deg, #2b314e, #202540);
  border:1px solid rgba(171, 150, 99, 0.55);
  border-radius: 4px;
  padding: 3px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}
.tab-btn {
  font: inherit;
  font-size: 13px;
  padding: 6px 18px;
  border: 1px solid transparent;
  background: transparent;
  color:#aea68c;
  border-radius: 3px;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
  letter-spacing: 2px;
}
.tab-btn:hover { color: var(--gold-light); }
.tab-btn.active {
  background:linear-gradient(180deg, #4f5f8f, #37446b);
  color: var(--gold-light);
  border-color: var(--gold);
  box-shadow:0 1px 6px rgba(0, 0, 0, 0.4),
              inset 0 1px 0 rgba(204, 188, 141, 0.25);
}

/* ---------- 地图布局 ---------- */
.map-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: calc(100vh - 60px);
  position: relative;
  z-index: 1;
}

/* ---------- SVG 地图形状 ---------- */
.map-stage {
  background:radial-gradient(ellipse at 50% 40%, rgba(255, 250, 232, 0.5), transparent 70%),
    var(--stage-bg);
}
.map-stage svg { display: block; width: 100%; height: 100%; position: relative; z-index: 1; }

.map-region { cursor: grab; transition: opacity .2s; }
.map-region:active { cursor: grabbing; }
.map-region .map-shape { transition: fill-opacity .2s; }
.map-region:hover .map-shape { fill-opacity: 0.72; }
.map-region.selected .map-shape {
  fill-opacity: 0.62;
  stroke-width: 3;
  filter: drop-shadow(0 2px 8px rgba(120, 95, 35, 0.3));
}
.map-region-label {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  fill: var(--primary-dark);
  letter-spacing: 1px;
  pointer-events: none;
  user-select: none;
}
.map-resize-handle {
  fill: var(--gold);
  stroke: var(--primary-dark);
  stroke-width: 1.5;
  cursor: nwse-resize;
}

/* 旋转手柄 + 连杆 */
.map-rotate-handle {
  fill: var(--gold-light);
  stroke: var(--primary-dark);
  stroke-width: 1.5;
  cursor: grab;
}
.map-rotate-handle:active { cursor: grabbing; }
.map-rotate-link {
  stroke: var(--gold);
  stroke-width: 1.3;
  stroke-dasharray: 3 3;
  pointer-events: none;
}

/* ---------- 地区列表 ---------- */
.region-list { list-style: none; display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; }
.region-list::-webkit-scrollbar { width: 6px; }
.region-list::-webkit-scrollbar-thumb { background:rgba(131, 115, 74, 0.4); border-radius: 2px; }

.region-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  background:rgba(253, 248, 234, 0.5);
  transition: background .2s, border-color .2s, box-shadow .2s;
}
.region-item:hover {
  background:rgba(255, 252, 242, 0.85);
  border-color: var(--gold);
  box-shadow: 0 2px 8px rgba(60, 50, 25, 0.12);
}
.region-item.active {
  background:rgba(70, 82, 122, 0.1);
  border-color: var(--primary);
  box-shadow: inset 2px 0 0 var(--primary);
}
.region-dot { width: 14px; height: 14px; border-radius: 3px; flex: none; border: 2px solid var(--gold); box-shadow: 0 1px 3px rgba(60, 50, 25, 0.2); }
.region-name { flex: 1; font-size: 13px; font-weight: 700; color: var(--primary-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.region-type { font-size: 11px; color: var(--muted); flex: none; }
.region-del {
  border: none;
  background: none;
  color:#aaa085;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 3px;
  flex: none;
}
.region-del:hover { color: var(--danger); background:rgba(125, 75, 75, 0.1); }

/* ---------- 地图详情面板 ---------- */
.map-detail {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 280px;
  max-height: calc(100% - 32px);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  box-shadow:0 10px 36px rgba(20, 25, 50, 0.28);
  padding: 18px;
  color: var(--text);
  z-index: 5;
}
.map-detail::before {
  content: '';
  position: absolute;
  top: 0; left: 12%; right: 12%;
  height: 2px;
  background: linear-gradient(to right, transparent, var(--gold-light), transparent);
}
.map-detail::-webkit-scrollbar { width: 6px; }
.map-detail::-webkit-scrollbar-thumb { background:rgba(131, 115, 74, 0.45); border-radius: 2px; }
.map-detail.hidden { display: none; }
.map-detail-close {
  position: absolute;
  top: 10px;
  right: 10px;
  border: none;
  background: none;
  font-size: 18px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  z-index: 2;
}
.map-detail-close:hover { color: var(--danger); }
.map-detail .field > span { font-size: 12px; }

/* ============================================================
 * 时间线视图
 * ============================================================ */
.timeline-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: calc(100vh - 60px);
  position: relative;
  z-index: 1;
}

.tl-stage {
  overflow-y: auto;
  padding: 40px 24px 80px;
  position: relative;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255, 250, 232, 0.45), transparent 70%),
    var(--stage-bg);
}
.tl-stage::-webkit-scrollbar { width: 8px; }
.tl-stage::-webkit-scrollbar-thumb {
  background:linear-gradient(var(--gold), #8a7c54);
  border-radius: 2px;
}
/* toast 在滚动容器内用 sticky */
.tl-stage .toast { position: sticky; top: 0; }

/* ---------- 竖向时间轴轨道 ---------- */
.tl-track {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 0 20px;
}
/* 中央藤蔓（JS 生成 SVG，随内容高度自适应） */
.tl-vine {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* ---------- 事件项 ---------- */
.tl-item {
  position: relative;
  width: 50%;
  padding: 10px 34px;
  margin-bottom: 28px;
}
.tl-item.left { left: 0; text-align: right; }
.tl-item.right { left: 50%; }

/* 轴上节点（藤上长出的叶芽） */
.tl-dot {
  position: absolute;
  top: 22px;
  width: 16px;
  height: 16px;
  border-radius: 0 70% 0 70%;
  background: linear-gradient(135deg, #a3b674, #6e8448);
  border: 1.5px solid #5c7040;
  box-shadow: 0 1px 4px rgba(50, 60, 30, 0.35),
              inset 0 1px 2px rgba(255, 255, 240, 0.5);
  z-index: 1;
  transform: rotate(-45deg);
}
.tl-item.left .tl-dot { right: -8px; }
.tl-item.right .tl-dot { left: -8px; }
/* 藤蔓末梢嫩芽 */
.tl-end-dot {
  position: relative !important;
  left: 50%;
  top: 0;
  width: 14px;
  height: 14px;
  border-radius: 0 70% 0 70%;
  background: linear-gradient(135deg, #a3b674, #6e8448);
  border: 1.5px solid #5c7040;
  box-shadow: 0 2px 6px rgba(50, 60, 30, 0.3);
  transform: translateX(-50%) rotate(-45deg);
  margin: 12px 0 0;
}

/* ---------- 事件卡片（叶片） ---------- */
.tl-card {
  display: inline-block;
  max-width: 100%;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(150deg, rgba(255, 255, 244, 0.5), rgba(255, 255, 244, 0) 50%),
    linear-gradient(135deg, rgba(214, 227, 183, 0.55), rgba(186, 206, 152, 0.45));
  border: 1px solid rgba(118, 136, 80, 0.6);
  border-radius: 4px 26px 4px 26px;
  padding: 14px 18px;
  box-shadow: 0 3px 14px rgba(70, 80, 45, 0.18),
              inset 0 1px 0 rgba(255, 255, 250, 0.4);
  text-align: left;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
/* 叶片卡片保持素净，不加叶脉 */
.tl-card:hover {
  border-color: rgba(96, 116, 62, 0.9);
  box-shadow: 0 5px 22px rgba(70, 85, 45, 0.28);
  transform: translateY(-1px);
}
.tl-card.editing {
  border-color: var(--primary);
  box-shadow:0 0 0 2px rgba(70, 82, 122, 0.2);
}
.tl-item.right .tl-card {
  display: block;
  border-radius: 26px 4px 26px 4px;
}

.tl-year {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: #46582f;
  background: rgba(141, 166, 100, 0.28);
  border: 1px solid rgba(110, 132, 72, 0.55);
  padding: 2px 12px;
  border-radius: 3px;
  margin-bottom: 8px;
  letter-spacing: 0;
}
.tl-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 6px;
  letter-spacing: 0;
}
.tl-desc {
  font-size: 13px;
  line-height: 1.7;
  color:#6f6854;
  margin: 0;
  letter-spacing: 0;
}
.tl-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.tl-card-actions .btn { padding: 4px 12px; font-size: 12px; }

.tl-empty {
  text-align: center;
  color: var(--muted);
  padding: 80px 0;
  font-size: 14px;
}

.tl-form-actions { display: flex; gap: 8px; }

/* ---------- 响应式（窄屏单列） ---------- */
@media (max-width: 860px) {
  .tl-item { width: 100%; left: 0; padding: 10px 10px 10px 44px; text-align: left; }
  .tl-item.left { text-align: left; }
  .tl-item.left .tl-dot,
  .tl-item.right .tl-dot { left: 11px; right: auto; }
  .tl-item.right { left: 0; }
  .tl-item.right .tl-card { display: inline-block; border-radius: 4px 26px 4px 26px; }
  .tl-item.left .tl-card { border-radius: 4px 26px 4px 26px; }
}

/* ============================================================
 * 故事一角视图 —— 书架与阅读
 * ============================================================ */
.stories-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: calc(100vh - 60px);
  position: relative;
  z-index: 1;
}

.stories-stage {
  overflow-y: auto;
  padding: 28px 24px;
  position: relative;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255, 250, 232, 0.45), transparent 70%),
    var(--stage-bg);
}
.stories-stage::-webkit-scrollbar { width: 8px; }
.stories-stage::-webkit-scrollbar-thumb {
  background:linear-gradient(var(--gold), #8a7c54);
  border-radius: 2px;
}

/* ---------- 书架 ---------- */
.bookshelf {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.shelf-row {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 5px;
  padding: 0 16px;
  min-height: 210px;
  position: relative;
  flex-wrap: wrap;
}
/* 深色橡木板 */
.shelf-row::after {
  content: '';
  display: block;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 14px;
  background: linear-gradient(to bottom,
    #65543a 0%, #504230 35%, #3d3224 70%, #2e261b 100%);
  border-radius: 2px 2px 3px 3px;
  border-top:1px solid rgba(204, 188, 141, 0.35);
  box-shadow:0 5px 16px rgba(20, 12, 4, 0.4),
              inset 0 1px 0 rgba(204, 188, 141, 0.2);
}
/* 木板下方阴影 */
.shelf-row::before {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 8%;
  right: 8%;
  height: 7px;
  background: radial-gradient(ellipse, rgba(20, 12, 4, 0.3), transparent 70%);
  z-index: -1;
}

.shelf-empty {
  text-align: center;
  color: var(--muted);
  padding: 100px 0;
  font-size: 14px;
}

/* ---------- 书本 ---------- */
.book {
  width: var(--bw, 42px);
  height: var(--bh, 180px);
  background: var(--bc, #4d5c87);
  border-radius: 2px 2px 1px 1px;
  margin-bottom: 14px;
  position: relative;
  cursor: grab;
  transition: transform .3s cubic-bezier(.4, 0, .2, 1), box-shadow .3s;
  box-shadow:
    -2px 0 4px rgba(0, 0, 0, 0.25),
    inset 3px 0 6px rgba(255, 255, 255, 0.12),
    inset -3px 0 6px rgba(0, 0, 0, 0.3);
  z-index: 1;
}
.book:hover {
  transform: translateY(-14px) rotate(-2deg);
  box-shadow:
    -3px 5px 14px rgba(0, 0, 0, 0.35),
    inset 3px 0 6px rgba(255, 255, 255, 0.16),
    inset -3px 0 6px rgba(0, 0, 0, 0.32);
  z-index: 2;
}

/* 拖拽中：抓取手势、半透明、不再悬停抬起 */
.book:active { cursor: grabbing; }
.book.dragging,
.book.dragging:hover {
  opacity: .45;
  transform: none;
  z-index: 3;
  box-shadow:
    -2px 0 4px rgba(0, 0, 0, 0.25),
    inset 3px 0 6px rgba(255, 255, 255, 0.12),
    inset -3px 0 6px rgba(0, 0, 0, 0.3);
}
/* 拖拽悬停目标：金色描边提示 */
.book.drag-over {
  outline: 2px solid var(--gold-light);
  outline-offset: -2px;
}

/* 书脊纹理 */
.book-spine {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 2px;
  border-radius: 2px 2px 1px 1px;
  background: linear-gradient(to right,
    rgba(255, 255, 255, 0.12) 0%,
    transparent 12%, transparent 88%,
    rgba(0, 0, 0, 0.22) 100%);
}
/* 顶部装饰条（金线） */
.book-top {
  width: 78%;
  height: 2.5px;
  background: var(--gold-light);
  border-radius: 1px;
  margin-bottom: 6px;
  flex: none;
  opacity: 0.85;
}
/* 底部装饰条（金线） */
.book-bottom {
  width: 78%;
  height: 2.5px;
  background: var(--gold);
  border-radius: 1px;
  margin-top: auto;
  margin-bottom: 4px;
  flex: none;
  opacity: 0.7;
}
/* 书名（竖排） */
.book-title {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 246, 220, 0.94);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 130px;
  letter-spacing: 2px;
}

/* ---------- 阅读面板 ---------- */
.story-reader {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: 36px 48px 24px;
  background:radial-gradient(ellipse at 50% 0%, rgba(255, 250, 232, 0.7), transparent 60%),
    rgba(238, 228, 199, 0.97);
  overflow-y: auto;
  animation: storyOpen .35s ease;
}
@keyframes storyOpen {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}
.story-reader.hidden { display: none; }
.story-reader::-webkit-scrollbar { width: 8px; }
.story-reader::-webkit-scrollbar-thumb {
  background:linear-gradient(var(--gold), #8a7c54);
  border-radius: 2px;
}

.story-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--gold);
  border-radius: 4px;
  background:linear-gradient(180deg, #465584, #33406a);
  font-size: 20px;
  color: var(--gold-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
  z-index: 1;
}
.story-close:hover { background:linear-gradient(180deg, #546294, #3c4a78); }

.story-title {
  font-size: 25px;
  font-weight: 700;
  color: var(--primary-dark);
  text-align: center;
  margin-bottom: 8px;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--gold);
  letter-spacing: 3px;
  position: relative;
}

.story-content {
  flex: 1;
  font-family: var(--font-serif);
  line-height: 2;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 20px 8px;
  min-height: 200px;
}

.story-editor {
  flex: 1;
  font-family: var(--font-serif);
  line-height: 2;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 20px;
  min-height: 200px;
  resize: none;
  background:rgba(253, 248, 234, 0.8);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.story-editor:focus {
  border-color: var(--gold);
  box-shadow:0 0 0 2px rgba(171, 150, 99, 0.25);
}

/* ---------- 工具栏 ---------- */
.story-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 16px;
  border-top: 1px solid var(--gold);
  margin-top: 8px;
}
.st-tool {
  display: flex;
  align-items: center;
  gap: 8px;
}
.st-tool > span { font-size: 12px; color:#6f6854; font-weight: 600; }
.st-tool input[type="color"] {
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--gold);
  border-radius: 4px;
  cursor: pointer;
  padding: 2px;
  background: transparent;
}
.st-fs-btn { padding: 4px 10px !important; font-size: 12px !important; min-width: 36px; }

/* ---------- 书脊外观面板 ---------- */
.story-appearance {
  max-width: 460px;
  margin: 8px auto 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.story-appearance .field { display: flex; flex-direction: column; gap: 8px; }
.story-appearance .field > span {
  font-size: 13px;
  font-weight: 600;
  color:#6f6854;
  letter-spacing: 0.5px;
}
.story-appearance .field > span em {
  font-style: normal;
  color: var(--primary);
  font-weight: 700;
}
.story-appearance .rgb-picker { margin-top: 2px; }

/* 尺寸滑条（中性古金轨道） */
.size-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background:linear-gradient(to right, #cfc5a4, var(--gold));
  border: 1px solid rgba(0, 0, 0, 0.15);
  outline: none;
  cursor: pointer;
}
.size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gold-light);
  border: 2px solid var(--primary-dark);
  box-shadow: 0 1px 4px rgba(30, 20, 5, 0.4);
  cursor: grab;
}
.size-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gold-light);
  border: 2px solid var(--primary-dark);
  box-shadow: 0 1px 4px rgba(30, 20, 5, 0.4);
  cursor: grab;
}
.size-slider:active::-webkit-slider-thumb { cursor: grabbing; }

/* ---------- 人物档案之书 ---------- */
.card-tip {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  margin: 0 0 10px;
}
/* 书脊上的星标（古金） */
.book-person-mark {
  margin-top: 6px;
  font-size: 11px;
  color: var(--gold-light);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  line-height: 1;
}
/* 阅读面板中的档案徽章 */
.story-badge {
  align-self: center;
  font-size: 12px;
  color: var(--primary-dark);
  background:rgba(171, 150, 99, 0.16);
  border: 1px solid var(--gold);
  border-radius: 3px;
  padding: 4px 15px;
  margin-bottom: 14px;
  letter-spacing: 1px;
}
.st-note {
  font-size: 12px;
  color: var(--muted);
  flex: 1;
  min-width: 120px;
}

/* RGB 颜色滑块 */
.st-rgb {
  gap: 8px;
  align-items: center;
}
.rgb-slider {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.rgb-slider i {
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  width: 11px;
}
.rgb-slider em {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
  width: 26px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.r-slider i { color:#ad655f; }
.g-slider i { color:#6a8765; }
.b-slider i { color:#6176ad; }

.rgb-slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 108px;
  height: 8px;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.15);
}
.r-slider input { background:linear-gradient(to right, #2a2622, #ad655f); }
.g-slider input { background:linear-gradient(to right, #2a2622, #6a8765); }
.b-slider input { background:linear-gradient(to right, #2a2622, #6176ad); }

.rgb-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gold-light);
  border: 2px solid var(--primary-dark);
  box-shadow: 0 1px 4px rgba(30, 20, 5, 0.4);
  cursor: grab;
}
.rgb-slider input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gold-light);
  border: 2px solid var(--primary-dark);
  box-shadow: 0 1px 4px rgba(30, 20, 5, 0.4);
  cursor: grab;
}
.rgb-slider input[type="range"]:active::-webkit-slider-thumb { cursor: grabbing; }

.rgb-preview {
  display: inline-block;
  width: 30px;
  height: 30px;
  border-radius: 4px;
  border: 1.5px solid var(--gold);
  flex: none;
}

/* ============================================================
 * 谈话视图 —— 信使卷轴式手机聊天气泡 + 截图
 * ============================================================ */
.chat-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: calc(100vh - 60px);
  position: relative;
  z-index: 1;
}
.chat-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255, 250, 232, 0.45), transparent 70%),
    var(--stage-bg);
}
.btn-gap { height: 8px; }
.chat-tip { font-size: 12px; color: var(--muted); line-height: 1.7; }

/* ---------- 人物选择 chips ---------- */
.participant-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.p-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  background:rgba(253, 248, 234, 0.7);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: border-color .2s, background .2s, box-shadow .2s;
  font-family: inherit;
}
.p-chip:hover { border-color: var(--gold); }
.p-chip.selected {
  border-color: var(--primary);
  background:rgba(70, 82, 122, 0.12);
  box-shadow:inset 0 0 0 1px rgba(70, 82, 122, 0.15);
}

/* 通用小圆头像 */
.mini-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: rgba(255, 246, 220, 0.94);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  flex: none;
}
.mini-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- 手机外框（锻铁黑） ---------- */
.phone {
  width: 375px;
  max-height: 100%;
  background:#d8ccaa;
  border-radius: 22px;
  box-shadow:0 0 0 8px #1c1f26,
    0 0 0 10px var(--gold),
    0 18px 50px rgba(15, 12, 8, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.phone-header {
  flex: none;
  height: 54px;
  background:linear-gradient(180deg, #2c3352, #212744);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  border-bottom: 1.5px solid var(--gold);
}
.phone-back {
  font-size: 26px;
  color: var(--gold-light);
  line-height: 1;
  width: 20px;
}
.phone-title { flex: 1; text-align: center; min-width: 0; }
.phone-title-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 1.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.phone-title-sub {
  font-size: 11px;
  color:#a29a83;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.phone-more { font-size: 20px; color: var(--gold-light); width: 20px; text-align: right; }

.phone-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px 20px;
  min-height: 420px;
  max-height: calc(100vh - 180px);
  background:radial-gradient(ellipse at 50% 0%, rgba(255, 250, 232, 0.55), transparent 65%),
    #e0dac9;
}
.phone-body::-webkit-scrollbar { width: 4px; }
.phone-body::-webkit-scrollbar-thumb { background:rgba(131, 115, 74, 0.45); border-radius: 2px; }

/* ============================================================
   广场（社交媒体信息流，X / 微博风格）
   ============================================================ */

/* ---------- 私聊 / 广场 模式切换 ---------- */
.mode-switch {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  background:rgba(38, 46, 75, 0.08);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.mode-btn {
  flex: 1;
  padding: 8px 0;
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: color .2s, background .2s, box-shadow .2s;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.active {
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: var(--gold-light);
  box-shadow:0 2px 6px rgba(38, 46, 75, 0.3);
}

/* 手机内视图容器：两个视图互斥 */
.phone-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.phone-view[hidden] { display: none; }

/* 广场头部 */
.social-logo {
  font-size: 18px;
  color: var(--gold-light);
  width: 20px;
  text-align: center;
}
.social-body {
  background:radial-gradient(ellipse at 50% 0%, rgba(255, 250, 232, 0.6), transparent 60%),
    #e8e2d1;
}

/* ---------- 发帖框 ---------- */
.post-composer {
  display: flex;
  gap: 10px;
  padding: 12px;
  background:rgba(252, 247, 233, 0.92);
  border:1px solid rgba(150, 128, 80, 0.35);
  border-radius: 8px;
  margin-bottom: 12px;
}
.post-composer .mini-avatar { border-radius: 50%; font-size: 14px; }
.composer-main { flex: 1; min-width: 0; }
#postComposeText {
  width: 100%;
  resize: none;
  border:1px solid rgba(150, 128, 80, 0.35);
  border-radius: 5px;
  background:rgba(255, 252, 242, 0.9);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}
#postComposeText:focus { border-color: var(--gold); box-shadow:0 0 0 2px rgba(171, 150, 99, 0.18); }
.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.composer-count { font-size: 11px; color: var(--muted); }
.composer-pub { padding: 5px 18px; font-size: 13px; }

/* ---------- 动态卡片 ---------- */
.post-card {
  padding: 12px;
  background:rgba(252, 247, 233, 0.92);
  border:1px solid rgba(150, 128, 80, 0.3);
  border-radius: 8px;
  margin-bottom: 10px;
}
.post-head {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}
.post-head .mini-avatar { border-radius: 50%; font-size: 16px; }
.post-who {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 1px;
}
.post-name { font-size: 14px; font-weight: 700; color: var(--text); }
.post-time { font-size: 11px; color: var(--muted); }
.post-del {
  flex: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 3px;
  border-radius: 3px;
  opacity: 0.55;
  transition: color .2s, opacity .2s;
}
.post-del:hover { color: #9a4444; opacity: 1; }
.post-text {
  margin: 8px 0 4px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- 动作栏：评论 / 转发 / 点赞 ---------- */
.post-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  border-top:1px dashed rgba(150, 128, 80, 0.3);
  padding-top: 6px;
}
.pa-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-family: inherit;
  padding: 5px 0;
  border-radius: 4px;
  cursor: pointer;
  transition: color .2s, background .2s;
}
.pa-ic { display: inline-flex; }
.pa-ic svg { width: 16px; height: 16px; }
.pa-btn:hover { background:rgba(70, 82, 122, 0.08); color: var(--primary); }
.pa-comment.active { color: var(--primary); }
.pa-repost:hover, .pa-repost.active { color: #5f7a55; background: rgba(95, 122, 85, 0.1); }
.pa-like:hover { color: #9a4444; background: rgba(154, 68, 68, 0.08); }
.pa-like.active { color: #9a4444; }
.pa-like.active svg path { fill: rgba(154, 68, 68, 0.25); }

/* ---------- 评论面板 ---------- */
.comments-wrap {
  margin-top: 8px;
  border-left: 2px solid var(--gold);
  padding-left: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.comment-row { display: flex; gap: 8px; }
.comment-row .mini-avatar { border-radius: 50%; font-size: 12px; }
.comment-body { flex: 1; min-width: 0; }
.comment-meta { display: flex; align-items: baseline; gap: 8px; }
.comment-name { font-size: 12px; font-weight: 700; color: var(--text); }
.comment-time { font-size: 10.5px; color: var(--muted); }
.comment-text {
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text);
  margin-top: 1px;
  word-break: break-word;
}
.comment-tools { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.comment-like {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  color: var(--muted);
  padding: 0;
}
.comment-like svg { width: 12px; height: 12px; }
.comment-like:hover, .comment-like.active { color: #9a4444; }
.comment-like.active svg path { fill: rgba(154, 68, 68, 0.25); }
.comment-del {
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  color: var(--muted);
  padding: 0;
}
.comment-del:hover { color: #9a4444; }

/* 写评论行 */
.comment-add { display: flex; gap: 6px; margin-top: 2px; }
.comment-input {
  flex: 1;
  min-width: 0;
  border:1px solid rgba(150, 128, 80, 0.35);
  border-radius: 4px;
  background:rgba(255, 252, 242, 0.9);
  padding: 5px 9px;
  font-family: inherit;
  font-size: 12px;
  color: var(--text);
  outline: none;
}
.comment-input:focus { border-color: var(--gold); }
.comment-send { padding: 4px 12px; font-size: 12px; flex: none; }

/* 空状态 */
.social-empty {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 40px 0;
}

.chat-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 60px 0;
}

/* ---------- 消息行 ---------- */
.msg-time {
  text-align: center;
  font-size: 11px;
  color: var(--gold-light);
  background:rgba(20, 28, 62, 0.75);
  border:1px solid rgba(171, 150, 99, 0.35);
  border-radius: 3px;
  padding: 2px 9px;
  margin: 8px auto;
  width: fit-content;
}
.msg-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: flex-start;
}
.msg-row.self { flex-direction: row-reverse; }
.msg-avatar .mini-avatar { border-radius: 4px; }
.msg-inner {
  max-width: 232px;
  position: relative;
}
.msg-row.self .msg-inner { display: flex; flex-direction: column; align-items: flex-end; }
.msg-name {
  font-size: 12px;
  margin: 0 4px 3px;
  color:#6f6854;
  font-weight: 600;
}
.bubble {
  position: relative;
  display: inline-block;
  font-size: 15px;
  line-height: 1.45;
  padding: 8px 12px;
  border-radius: 5px;
  color: #2e2a20;
  word-break: break-word;
  white-space: pre-wrap;
  cursor: default;
}
.msg-row.other .bubble {
  background: #f8f4ea;
  border: 1px solid rgba(150, 130, 85, 0.3);
  box-shadow: 0 1px 2px rgba(90, 75, 40, 0.15);
}
.msg-row.self .bubble {
  background:linear-gradient(180deg, #50608c, #3c4a73);
  color: #f2ead6;
  border:1px solid rgba(171, 150, 99, 0.55);
}
/* 气泡小尾巴 */
.msg-row.other .bubble::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 12px;
  width: 0; height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 7px solid #f8f4ea;
}
.msg-row.self .bubble::before {
  content: '';
  position: absolute;
  right: -6px;
  top: 12px;
  width: 0; height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left:7px solid #41517c;
}

/* 删除按钮（悬停出现） */
.msg-del {
  position: absolute;
  top: -8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background:rgba(125, 75, 75, 0.9);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .2s;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.msg-row.other .msg-del { right: -22px; }
.msg-row.self .msg-del { left: -22px; }
.msg-row:hover .msg-del { opacity: 1; }

/* ============================================================
 * 羊皮卷轴开场 —— 3D 卷轴 + 2D 羊皮纸功能图
 * ============================================================ */
.scroll-intro {
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 30% 110%, rgba(120, 72, 28, 0.28), transparent 55%),
    radial-gradient(ellipse at 50% 42%, #2c2014 0%, #1d150d 46%, #120d07 100%);
  transition: opacity .5s ease;
}
.scroll-intro.intro-out { opacity: 0; pointer-events: none; }

.scene-3d {
  position: absolute;
  inset: 0;
}
.scene-3d canvas {
  display: block;
  transition: opacity .55s ease;
}
.scene-3d canvas.scene-fade { opacity: 0; }

/* 3D 阶段底部提示 */
.intro-3d-ui {
  position: absolute;
  left: 0; right: 0;
  bottom: 9%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  transition: opacity .4s ease;
}
.intro-3d-ui.fading,
.intro-3d-ui.hidden { opacity: 0; pointer-events: none; }
.intro-tap {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 20px;
  letter-spacing: .5em;
  text-indent: .5em;
  color: var(--gold-light);
  text-shadow: 0 2px 14px rgba(0,0,0,.5);
  animation: tapPulse 2.2s ease-in-out infinite;
}
@keyframes tapPulse {
  0%, 100% { opacity: .65; }
  50% { opacity: 1; }
}
.intro-skip {
  background: none;
  border: 1px solid rgba(232,196,106,.5);
  color: rgba(230,222,198,.8);
  font-family: var(--font-serif);
  font-size: 12px;
  letter-spacing: .25em;
  padding: 5px 16px;
  border-radius: 3px;
  cursor: pointer;
  transition: all .25s;
}
.intro-skip:hover {
  border-color: var(--gold-light);
  color: var(--gold-light);
}

/* ---------- 2D 羊皮纸 ---------- */
.sheet-2d {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 24px;
  overflow: auto;
}
.sheet-2d[hidden] { display: none; }

.sheet-inner {
  position: relative;
  width: min(1080px, 100%);
  padding: 46px 52px 42px;
  background:
    radial-gradient(ellipse at 12% 8%, rgba(110,92,58,0.035), transparent 40%),
    radial-gradient(ellipse at 88% 92%, rgba(110,92,58,0.035), transparent 40%),
    repeating-linear-gradient(92deg, rgba(110,92,58,0.035) 0 2px, transparent 2px 9px),
    #e9e2cc;
  border: 1.5px solid rgba(184,137,48,0.65);
  border-radius: 4px;
  box-shadow:
    0 18px 60px rgba(0,0,0,.55),
    inset 0 0 40px rgba(120,100,58,.12);
}
.sheet-head {
  text-align: center;
  margin-bottom: 30px;
}
.sheet-head h2 {
  margin: 6px 0 8px;
  font-family: var(--font-serif);
  font-size: clamp(26px, 3.4vw, 38px);
  font-weight: 700;
  letter-spacing: .42em;
  text-indent: .42em;
  color: var(--primary-dark);
}
.sheet-head p {
  margin: 0;
  font-size: 13px;
  letter-spacing: .22em;
  color: var(--muted);
}
.sheet-rule {
  width: 150px;
  height: 10px;
  margin: 0 auto 4px;
  background:
    radial-gradient(circle at 50% 50%, var(--gold) 0 1.6px, transparent 2px),
    linear-gradient(var(--gold), var(--gold)) left 50% / calc(50% - 12px) 1.2px no-repeat,
    linear-gradient(var(--gold), var(--gold)) right 50% / calc(50% - 12px) 1.2px no-repeat;
}

/* ---------- 五个功能入口 ---------- */
.entry-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 18px;
}
.entry {
  appearance: none;
  background:rgba(255,250,235,.38);
  border: 1.4px solid rgba(184,137,48,0.50);
  border-radius: 5px;
  padding: 18px 12px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  font-family: inherit;
  transition: transform .28s ease, box-shadow .28s ease, border-color .28s ease, background .28s;
}
.entry:hover {
  transform: translateY(-6px);
  border-color: var(--gold);
  background:rgba(255,250,235,.7);
  box-shadow: 0 12px 26px rgba(60,42,16,.25);
}
.entry-art {
  width: 100%;
  max-width: 96px;
  height: auto;
  transition: transform .28s ease;
}
.entry:hover .entry-art { transform: scale(1.07); }
.entry-name {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .28em;
  text-indent: .28em;
  color: var(--primary-dark);
}
.entry:hover .entry-name { color: #7a5f2a; }
.entry-desc {
  font-size: 11.5px;
  letter-spacing: .1em;
  color: var(--muted);
}

/* 2D 羊皮纸入场：由卷中展开 */
.sheet-2d .sheet-inner {
  opacity: 0;
  transform: scaleY(.55) scale(.96);
  transform-origin: 50% 50%;
}
.sheet-2d.sheet-in .sheet-inner {
  animation: sheetOpen .7s cubic-bezier(.25,.8,.3,1) forwards;
}
@keyframes sheetOpen {
  to { opacity: 1; transform: scaleY(1) scale(1); }
}

/* 小屏：入口自动换行 */
@media (max-width: 1000px) {
  .entry-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .sheet-inner { padding: 38px 22px; }
  .entry-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

/* 品牌名悬停提示可回卷 */
.brand:hover h1 { color: #fff3d0; }
