:root {
  /* 这些默认值会被 theme.js 在运行时覆盖，改这里只影响"首屏闪一下"的观感 */
  --bg-pod-1: #1b2a4a;
  --bg-pod-2: #0c1428;
  --bg-city-1: #3b1d6e;
  --bg-city-2: #1a1140;
  --bg-city-3: #0b1e3a;
  --bg-forest-1: #123d24;
  --bg-forest-2: #0c2a1a;
  --bg-forest-3: #1b5e3a;
  --fg: #eef1ff;
  --muted: #aab0c8;
  --accent: #5ee0ff;
  --accent2: #7cffb2;
  --card: #120a2e;
  --radius: 14px;

  /* 派生色（theme.js 会重算，这里给默认值兜底） */
  --accent-a06: rgba(94,224,255,0.06);
  --accent-a10: rgba(94,224,255,0.10);
  --accent-a18: rgba(94,224,255,0.18);
  --accent-a22: rgba(94,224,255,0.22);
  --accent-a35: rgba(94,224,255,0.35);
  --accent-a50: rgba(94,224,255,0.50);
  --accent-a70: rgba(94,224,255,0.70);
  --accent2-a15: rgba(124,255,178,0.15);
  --accent2-a20: rgba(124,255,178,0.20);
  --accent2-a40: rgba(124,255,178,0.40);
  --on-accent: #bff4ff;
  --on-accent2: #d6ffe6;
  --panel: rgba(0,0,0,0.35);
  --glow: 0 0 14px rgba(94,224,255,0.45);

  /* 场景渐变（theme.js 覆盖） */
  --s-pod-1: #1b2a4a;   --s-pod-2: #0c1428;
  --s-city-1: #3b1d6e;  --s-city-2: #0b1e3a;
  --s-forest-1: #123d24;--s-forest-2: #1b5e3a;
  --s-default-1: #232044; --s-default-2: #050510;

  /* 背景层 */
  --bg-image: none;
  --node-img: none;
  --node-fit: cover;
  --bg-fit: cover;
  --overlay: 0;
  --bg-dim: 0;
  --vignette: 1;
  /* 图层模块（js/layers.js）写入的额外三层控制 */
  --bg-blur: 0px;
  --bg-opacity: 1;
  --bg-extra-dim: 0;

  /* 排版 */
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-title: var(--font);
  --fs-base: 16px;
  --fs-title: 22px;
  --lh: 1.85;
  --align: left;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: var(--fs-base);
  color: var(--fg);
  background: #0a0820;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

#app { position: relative; min-height: 100vh; min-height: 100dvh; }

/* ---------- 背景层 ---------- */
/* 两层合成：上层 = 背景图（--node-img 由引擎按节点写，--bg-image 是主题的全局图），
   下层 = 场景径向渐变。
   注意：这里绝对不要对 background-image 加 !important，
   否则会把引擎/主题刚写进来的图一起干掉（曾导致美术填的图永远不显示）。 */
.bg {
  position: fixed; inset: 0; z-index: 0;
  transition: background-image 0.6s ease;
  /* 背景层的独立控制项：模糊 / 不透明度，都由 layers.js 写变量。
     注意这里不能用 filter:none 兜底成 None 之外的写法，
     0px 时浏览器会自己优化掉。 */
  filter: blur(var(--bg-blur, 0px));
  opacity: var(--bg-opacity, 1);
  background-image:
    var(--node-img, none),
    var(--bg-image, none),
    radial-gradient(120% 90% at 50% 0%, var(--s-pod-1), var(--s-pod-2) 70%, #050510 100%);
  background-size: var(--node-fit, cover), var(--bg-fit, cover), cover;
  background-position: center, center, center;
  background-repeat: no-repeat, no-repeat, no-repeat;
}
.bg-city {
  background-image:
    var(--node-img, none),
    var(--bg-image, none),
    radial-gradient(120% 90% at 50% 0%, var(--s-city-1), var(--s-city-2) 60%, #000 100%);
}
.bg-forest {
  background-image:
    var(--node-img, none),
    var(--bg-image, none),
    radial-gradient(120% 90% at 50% 0%, var(--s-forest-1), var(--s-forest-2) 60%, #000 100%);
}
.bg-default {
  background-image:
    var(--node-img, none),
    var(--bg-image, none),
    radial-gradient(120% 90% at 50% 0%, var(--s-default-1), var(--s-default-2) 70%);
}
/* 背景图存在时，用遮罩 + 压暗保证文字可读。
   --overlay 来自主题，--bg-extra-dim 来自图层面板的"额外压暗"，两者叠加（上限仍是 1）。 */
#bg::after {
  content: ""; position: absolute; inset: 0;
  background: #000;
  opacity: calc(var(--overlay) + var(--bg-extra-dim, 0));
  transition: opacity 0.4s ease;
  pointer-events: none;
}
/* 无背景图时用 bg-dim 压暗渐变 */
#bg.no-img::before {
  content: ""; position: absolute; inset: 0;
  background: #000; opacity: var(--bg-dim);
  pointer-events: none;
}
/* 四周暗角 */
#vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 45%, rgba(0,0,0,0.55) 100%);
  opacity: var(--vignette);
  transition: opacity 0.4s ease;
}

/* 粒子层 */
#fx { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
body.no-fx #fx { display: none; }

/* 舞台 */
.stage {
  position: relative; z-index: 2;
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: center;
  max-width: 680px; margin: 0 auto;
  padding: 24px;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
}
.content { width: 100%; }

.kicker { text-align: center; color: var(--accent); font-size: 12px; letter-spacing: 3px; margin-bottom: 10px; opacity: 0.8; }
body.no-kicker .kicker { display: none; }

#scene-title {
  font-family: var(--font-title);
  font-size: var(--fs-title);
  font-weight: 600; text-align: center;
  margin-bottom: 18px; letter-spacing: 1px;
  text-shadow: var(--glow);
  transition: font-size 0.2s, text-shadow 0.2s;
}
#scene-text {
  font-size: var(--fs-base); line-height: var(--lh); color: var(--fg);
  text-align: var(--align);
  background: var(--panel);
  border: 1px solid var(--accent-a18);
  padding: 18px 20px; border-radius: var(--radius);
  backdrop-filter: blur(4px);
  white-space: pre-wrap;
  transition: font-size 0.2s, line-height 0.2s, border-radius 0.2s;
}

/* ---------- 转场动画（由 fx-transition.js 触发 class） ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes slideInL { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: none; } }
@keyframes slideInR { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes zoomIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: none; } }
.anim-fade   { animation: fadeUp 0.5s ease both; }
.anim-slideL { animation: slideInL 0.5s ease both; }
.anim-slideR { animation: slideInR 0.5s ease both; }
.anim-zoom   { animation: zoomIn 0.55s ease both; }
/* 主题关掉转场动画时，直接跳过入场 */
body.no-anim .anim-fade,
body.no-anim .anim-slideL,
body.no-anim .anim-slideR,
body.no-anim .anim-zoom { animation: none; }

/* 选项按钮 */
.choices { display: flex; flex-direction: column; gap: 12px; margin-top: 22px; }
.choice {
  position: relative;
  appearance: none; width: 100%; text-align: left;
  border: 1px solid var(--accent-a50);
  background: var(--accent-a10);
  color: var(--fg); padding: 16px 18px;
  font-family: var(--font);
  font-size: var(--fs-base); border-radius: var(--radius); cursor: pointer;
  transition: background 0.2s, transform 0.2s, border-radius 0.2s;
}
.choice:hover:not(.locked), .choice:active:not(.locked) { background: var(--accent-a22); transform: translateY(-1px); }

/* 未解锁选项 */
.choice.locked {
  opacity: 0.55; cursor: not-allowed;
  border-style: dashed; border-color: var(--accent-a35);
  background: var(--accent-a06);
  display: flex; flex-direction: column; gap: 4px;
}
.choice.locked .lock-ico { margin-right: 6px; }
.choice.locked .lock-tip { font-size: 12px; color: var(--muted); }

/* 结局卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--accent2-a40);
  border-radius: calc(var(--radius) + 4px); padding: 28px;
  box-shadow: 0 0 30px var(--accent2-a15);
}
#card-img { margin-bottom: 16px; }
#card-img img { width: 100%; border-radius: 12px; display: block; }
#card-code {
  display: inline-block; margin-bottom: 10px;
  font-size: 11px; letter-spacing: 3px; font-weight: 700;
  color: var(--on-accent2); background: var(--accent2);
  padding: 3px 10px; border-radius: 999px;
}
#card-code:empty { display: none; }
#card-title { font-family: var(--font-title); font-size: 20px; font-weight: 600; margin-bottom: 16px; }
#card-body { font-size: 15px; line-height: 1.9; white-space: pre-wrap; color: var(--fg); }
.card-data { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.card-data span {
  font-size: 12px; color: var(--muted);
  border: 1px solid var(--accent-a18);
  padding: 4px 10px; border-radius: 999px;
}
.card-data .hot { color: var(--accent); border-color: var(--accent); }
#card-tag { margin-top: 18px; color: var(--accent2); font-size: 14px; }
.card-shot { width: 100%; margin-top: 18px; border-radius: 12px; border: 1px solid var(--accent-a18); }
.card-btns { margin-top: 16px; }

.restart {
  display: block; width: 100%; margin-top: 22px;
  padding: 14px; border-radius: var(--radius);
  border: 1px solid var(--accent); background: transparent;
  color: var(--accent); font-family: var(--font);
  font-size: 15px; cursor: pointer;
}
.card-btns .restart { margin-top: 0; }
.ghost-restart { margin-top: 12px; opacity: 0.7; font-size: 14px; padding: 11px; }

.hidden { display: none !important; }

/* 顶部工具条 */
.playbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
}
.iconbtn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--accent-a35); background: rgba(0,0,0,0.4);
  color: var(--fg); font-size: 18px; cursor: pointer;
}
.plabel { color: var(--muted); font-size: 12px; }
body.no-progress .plabel { display: none; }
body.no-back #backBtn { display: none !important; }

/* 恢复进度提示 */
.resume-tip {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
  z-index: 20; background: rgba(20,18,42,0.95); color: var(--accent);
  border: 1px solid var(--accent); padding: 8px 16px; border-radius: 999px;
  font-size: 13px; box-shadow: 0 0 16px var(--accent-a35);
}

/* 未解锁弹窗 */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(3px);
}
.modal-card {
  width: min(360px, 88vw);
  background: #14122a; border: 1px solid var(--accent);
  border-radius: 16px; padding: 26px 24px; text-align: center;
  box-shadow: 0 0 30px var(--accent-a35);
  animation: zoomIn 0.3s ease both;
}
.modal-title { color: var(--accent); font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.modal-text { color: var(--fg); font-size: 15px; line-height: 1.8; white-space: pre-wrap; margin-bottom: 20px; }
.modal-btn {
  width: 100%; padding: 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent);
  color: var(--on-accent); font-weight: 600; font-size: 15px;
}

/* 编辑入口 ⚙ */
.gear {
  position: fixed; right: 14px; bottom: 14px; z-index: 6;
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--accent-a50); background: rgba(10,8,30,0.85);
  color: var(--accent); font-size: 22px; cursor: pointer;
  box-shadow: 0 0 16px var(--accent-a35);
}
body.ed-on .gear { display: none; }

/* 试玩模式工具条（仅管理员试玩时可见） */
.playtools {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: max(14px, env(safe-area-inset-bottom)); z-index: 45;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; border-radius: 12px;
  background: rgba(12,10,32,0.92); border: 1px solid var(--accent-a35);
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  max-width: calc(100vw - 24px);
}
.pt-badge {
  font-size: 11px; letter-spacing: 1px; color: var(--on-accent);
  background: var(--accent); padding: 3px 7px; border-radius: 999px; font-weight: 700;
}
.pt-sel {
  background: #1e1b3a; color: #e8eaff; font-size: 12px;
  border: 1px solid var(--accent-a35); border-radius: 8px; padding: 5px 6px;
  max-width: 40vw;
}
.pt-btn {
  background: #262150; color: #e8eaff; border: 1px solid var(--accent-a35);
  font-size: 12px; padding: 6px 10px; border-radius: 8px; cursor: pointer;
}
.pt-btn:hover { background: #353066; }
.pt-btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 600; }

/* ===================== 管理员编辑模式 ===================== */
#editor {
  position: fixed; inset: 0; z-index: 50;
  background: #0b0a18; color: #e8eaff;
  display: flex; flex-direction: column;
}
/* 编辑器本身永远用固定深色，不受主题影响（否则改主题时编辑器也跟着变色会看不清） */
.ed-head {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.1);
  background: #14122a;
}
.ed-title-wrap { display: flex; align-items: center; gap: 10px; }
.ed-logo { color: var(--accent); font-weight: 600; font-size: 14px; white-space: nowrap; }
.ed-title-input {
  background: #1e1b3a; border: 1px solid rgba(255,255,255,0.15); color: #fff;
  padding: 8px 10px; border-radius: 8px; font-size: 14px; width: 180px;
}
.ed-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ed-btn {
  background: #2a2650; color: #fff; border: 1px solid rgba(255,255,255,0.15);
  padding: 8px 12px; border-radius: 8px; font-size: 13px; cursor: pointer;
}
.ed-btn:hover { background: #353066; }
.ed-btn.primary { background: var(--accent); color: #06121a; border-color: transparent; font-weight: 600; }
.ed-btn.ghost { background: transparent; }
.ed-btn.danger { background: #5a1f2e; border-color: #8a3346; }
.ed-btn.small { font-size: 12px; padding: 6px 10px; }
.ed-btn.tiny { padding: 4px 8px; font-size: 12px; }

.ed-body { flex: 1; display: flex; min-height: 0; }
.ed-list {
  width: 200px; border-right: 1px solid rgba(255,255,255,0.1);
  overflow-y: auto; padding: 10px; background: #0e0c20;
}
.ed-node {
  padding: 9px 10px; border-radius: 8px; cursor: pointer; margin-bottom: 6px;
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  border: 1px solid transparent;
}
.ed-node:hover { background: #1a1733; }
.ed-node.active { background: #25224a; border-color: var(--accent); }
.ed-badge { font-size: 10px; padding: 2px 6px; border-radius: 4px; flex: none; }
.ed-badge.scene { background: #1d3a5a; color: #9fd0ff; }
.ed-badge.ending { background: #2e4a2a; color: #aef0a0; }
.ed-node-id { color: #cfd2ff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-list-head {
  font-size: 11px; color: #7cffb2; letter-spacing: 1px;
  padding: 4px 10px 10px; border-bottom: 1px solid rgba(255,255,255,0.08); margin-bottom: 10px;
}

.ed-form { flex: 1; overflow-y: auto; padding: 18px 22px; }
.ed-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.ed-row label { font-size: 12px; color: #aab0d8; }
.ed-row label small { color: #6f76a0; }
.ed-in {
  background: #16142e; border: 1px solid rgba(255,255,255,0.15); color: #fff;
  padding: 10px 12px; border-radius: 8px; font-size: 14px; width: 100%;
  font-family: inherit;
}
.ed-in:focus { outline: none; border-color: #5ee0ff; }
textarea.ed-in { resize: vertical; line-height: 1.6; }
.ed-hr { border: none; border-top: 1px solid rgba(255,255,255,0.1); margin: 16px 0; }
.ed-form h4 { color: #7cffb2; font-size: 14px; margin: 4px 0 10px; }

/* ---------- 主题编辑面板 ---------- */
/* 顶部标签页：剧情 / 外观 */
.ed-tabs { display: flex; gap: 6px; }
.ed-tab {
  background: #1e1b3a; color: #cfd2ff; border: 1px solid rgba(255,255,255,0.12);
  padding: 8px 14px; border-radius: 8px; font-size: 13px; cursor: pointer;
}
.ed-tab.active { background: #5ee0ff; color: #06121a; border-color: transparent; font-weight: 600; }

/* 颜色行：色块 + 取色器 + 色值 */
.color-row { display: flex; align-items: center; gap: 8px; }
.color-chip {
  width: 34px; height: 34px; border-radius: 8px; flex: none;
  border: 1px solid rgba(255,255,255,0.25); cursor: pointer;
  position: relative; overflow: hidden;
}
.color-chip input[type="color"] {
  position: absolute; inset: -8px; width: 50px; height: 50px;
  border: none; padding: 0; background: transparent; cursor: pointer;
}
.color-val {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px; color: #aab0d8;
}

/* 滑杆行 */
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row input[type="range"] { flex: 1; accent-color: #5ee0ff; }
.slider-num {
  min-width: 46px; text-align: right; font-size: 12px;
  color: #7cffb2; font-family: ui-monospace, Consolas, monospace;
}

/* 开关行 */
.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-radius: 8px; background: #16142e;
  border: 1px solid rgba(255,255,255,0.08); margin-bottom: 8px;
}
.switch-row span { font-size: 13px; color: #dfe2ff; }
.switch-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: #5ee0ff; cursor: pointer; }

/* 主题预设卡 */
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.preset-card {
  border: 1px solid rgba(255,255,255,0.12); border-radius: 10px;
  padding: 8px; cursor: pointer; background: #16142e;
  transition: border-color 0.15s, transform 0.15s;
}
.preset-card:hover { border-color: #5ee0ff; transform: translateY(-1px); }
.preset-card b { display: block; font-size: 12px; color: #e8eaff; margin-bottom: 6px; font-weight: 600; }
.preset-dots { display: flex; gap: 3px; }
.preset-dots i { width: 15px; height: 15px; border-radius: 4px; display: block; }

/* 字体预设下拉旁的说明 */
.ed-note {
  font-size: 11px; color: #6f76a0; line-height: 1.7;
  background: #12102a; border-left: 2px solid #5ee0ff;
  padding: 8px 10px; border-radius: 0 6px 6px 0; margin: 8px 0 14px;
}
/* 一行两列 */
.ed-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ed-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ed-scene-title {
  font-size: 11px; color: #8b91b8; letter-spacing: 1px;
  margin: 10px 0 4px; padding-left: 2px;
}
.ed-h4-tip { font-size: 11px; color: #6f76a0; font-weight: 400; margin-left: 6px; }

/* ---------- 场景专属配色 ---------- */
/* 场景切换标签：一排小按钮，点一下左边实时预览 */
.ov-scene-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.ov-scene-tab {
  display: flex; align-items: center; gap: 5px;
  background: #1e1b3a; color: #cfd2ff; border: 1px solid rgba(255,255,255,0.12);
  padding: 6px 10px; border-radius: 16px; font-size: 12px; cursor: pointer;
  font-family: inherit;
}
.ov-scene-tab:hover { background: #2a2650; }
.ov-scene-tab.active { background: var(--accent); color: #06121a; border-color: transparent; font-weight: 500; }
.ov-dot { width: 9px; height: 9px; border-radius: 50%; display: block; flex: none; }
.ov-edit-for { font-size: 12px; color: #aab0d8; margin-bottom: 8px; }
.ov-edit-for b { color: var(--accent); }
.ov-preview-tag {
  font-size: 10px; color: #06121a; background: var(--accent);
  padding: 1px 6px; border-radius: 8px; margin-left: 4px;
}
.ov-preview-tag-off { font-size: 10px; color: #6f76a0; margin-left: 4px; }
/* 「留空 = 跟随全局」的可选色块：画成棋盘格，一眼看出没设置 */
.color-chip.empty {
  background-image:
    linear-gradient(45deg, #2a2a3a 25%, transparent 25%, transparent 75%, #2a2a3a 75%),
    linear-gradient(45deg, #2a2a3a 25%, transparent 25%, transparent 75%, #2a2a3a 75%);
  background-size: 10px 10px;
  background-position: 0 0, 5px 5px;
  border-style: dashed;
}
.ov-unset { flex: none; padding: 3px 8px; font-size: 11px; }
.ov-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.ov-empty {
  font-size: 11px; color: #7cffb2; line-height: 1.7;
  background: rgba(124,255,178,0.08); border-left: 2px solid #7cffb2;
  padding: 8px 10px; border-radius: 0 6px 6px 0; margin: 4px 0 12px;
}

.choice-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
  flex-wrap: wrap;
}
.choice-row .c-label { flex: 1; min-width: 120px; }
.choice-row .c-target { flex: 1; min-width: 100px; }
.c-lock { font-size: 12px; color: #aab0d8; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.c-flag { font-size: 11px; }

/* 提示 toast */
#toast {
  position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%) translateY(10px);
  background: rgba(20,18,42,0.96); color: #fff; padding: 10px 18px; border-radius: 10px;
  border: 1px solid var(--accent); font-size: 13px; z-index: 99;
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
 *  管理员密码验证弹窗（admin-auth.js）
 * ============================================================ */
.auth-form { margin-top: 6px; }
.auth-input {
  width: 100%; padding: 11px 12px; border-radius: 10px; font-size: 15px;
  background: #16142e; border: 1px solid rgba(255,255,255,0.2); color: #fff;
  text-align: center; letter-spacing: 2px;
}
.auth-input:focus { outline: none; border-color: var(--accent); }
.auth-btns { display: flex; gap: 10px; margin-top: 14px; }
.auth-btns .modal-btn { flex: 1; width: auto; }
.auth-btns .ghost-auth {
  background: transparent; color: #aab0d8; border-color: rgba(255,255,255,0.25);
}
.auth-err { color: #ff8a9a; font-size: 12px; margin-top: 10px; min-height: 16px; }

/* ============================================================
 *  媒体上传复合控件（editor.js 图片/音频上传）
 * ============================================================ */
.media-field { display: flex; flex-direction: column; gap: 8px; }
.media-btns { display: flex; gap: 8px; }
.media-preview { min-height: 0; }
.media-thumb {
  max-width: 100%; max-height: 140px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2); display: block;
}
.media-tag {
  display: inline-block; font-size: 12px; color: #7cffb2;
  background: rgba(124,255,178,0.1); padding: 4px 10px; border-radius: 999px;
  border: 1px solid rgba(124,255,178,0.3);
}

/* ============================================================
 *  报错横幅：右上角一条，可关闭、8 秒自动消失。
 *  刻意不做成全屏遮罩——一个小按钮点错就把人锁死在错误页上太糟了。
 * ============================================================ */
.fallback-bar {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%) translateY(-20px);
  z-index: 200; max-width: min(92vw, 560px);
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: rgba(60, 20, 32, 0.96); color: #ffd9e0;
  border: 1px solid #a4455c; box-shadow: 0 8px 28px rgba(0,0,0,0.5);
  font-size: 12px; line-height: 1.6;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.fallback-bar.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.fallback-bar .fb-msg { flex: 1; word-break: break-word; }
.fallback-bar .fb-x {
  flex: none; background: transparent; border: none; color: #ffd9e0;
  font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px;
}

/* ============================================================
 *  外观编辑：左右分栏，左边露出真实画面，改配色立刻能看到效果
 * ============================================================ */
body.ed-theme-mode #editor {
  left: auto; right: 0; width: min(560px, 100%);
  border-left: 1px solid rgba(255,255,255,0.12);
  box-shadow: -18px 0 50px rgba(0,0,0,0.55);
}
/* 分栏时把真实舞台往左挪，别被面板压住 */
body.ed-theme-mode .stage { margin-right: auto; margin-left: 0; }
body.ed-theme-mode .stage,
body.ed-theme-mode #playbar { max-width: calc(100% - min(560px, 100%)); }
/* 收起面板：编辑器整体让开，只留一个小悬浮按钮 */
body.ed-peek #editor { display: none !important; }
#edRestore {
  position: fixed; right: 14px; bottom: 24px; z-index: 60;
  background: var(--accent); color: #06121a; border: none;
  padding: 10px 16px; border-radius: 22px; font-size: 13px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,0.45); cursor: pointer;
  display: none;
}
body.ed-peek #edRestore { display: block; }

/* ---------- 大字幕屏（开场「2176」这类）----------
   去掉正文面板，整屏只剩一个放大的字块，配合镜头"起幕" */
#scene.big-card #scene-text {
  background: none; border: 0; padding: 0; backdrop-filter: none;
  text-align: center;
  font-size: clamp(44px, 15vw, 96px);
  font-weight: 700; letter-spacing: 0.4em; text-indent: 0.4em;
  line-height: 1.25; color: var(--fg);
  text-shadow: var(--glow);
}
#scene.big-card #scene-title { display: none; }
/* 标题留空时不占位（开场六屏只有正文，无标题） */
#scene-title:empty { display: none; }
#scene.big-card .content { display: flex; flex-direction: column; justify-content: center; min-height: 70vh; }
#scene.big-card #choices { justify-content: center; }

/* 大屏微调 */
@media (min-width: 600px) {
  #scene-title { font-size: calc(var(--fs-title) + 4px); }
  #scene-text { font-size: calc(var(--fs-base) + 1px); }
  .card { padding: 36px; }
}
@media (max-width: 560px) {
  .ed-list { width: 130px; }
  .ed-title-input { width: 120px; }
  .ed-row-2, .ed-row-3 { grid-template-columns: 1fr; }
}

/* ============================================================
 *  ① 人物图层（与背景层分离）
 *  层级：bg(0) → actor(1) → fx(1) → vignette(1) → 文字舞台(2)
 *  所有取值由 js/layers.js 写成 CSS 变量，这里只负责呈现：
 *    --actor-x / --actor-y   锚点位置（%）
 *    --actor-h               人物高度（vh）
 *    --actor-opacity         不透明度
 *    --actor-blend           混合模式
 *    --actor-flip            1 / -1 水平翻转
 * ============================================================ */
.actor {
  position: fixed; inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
  opacity: var(--actor-opacity, 1);
  mix-blend-mode: var(--actor-blend, normal);
  transition: opacity 0.45s ease;
}
.actor.hidden { display: none; }

.actor-box {
  position: absolute;
  left: var(--actor-x, 50%);
  top: var(--actor-y, 100%);
  transform: translate(-50%, -100%);   /* 锚点定在"脚底"，站得住 */
  transform-origin: bottom center;
}
.actor-img {
  display: block;
  height: var(--actor-h, 60vh);
  width: auto; max-width: none;
  transform: scaleX(var(--actor-flip, 1));
  opacity: 0;                          /* 加载完再淡入，避免"啪"地弹出来 */
  transition: opacity 0.5s ease;
  will-change: transform;
}
.actor-img.actor-ready { opacity: 1; }

/* 动效挂在 .actor-ready 上：图没加载完就不起动画，
   免得动画跑完了图才出现，白演一遍。
   注意每个 keyframes 都要带上 scaleX，否则会把"左右翻转"覆盖掉。 */
.actor-img.actor-ready.anim-float { animation: actorFloat 4.5s ease-in-out infinite; }
.actor-img.actor-ready.anim-breathe { animation: actorBreathe 3.2s ease-in-out infinite; }
.actor-img.actor-ready.anim-slidein { animation: actorSlideIn 0.75s cubic-bezier(0.2, 0.8, 0.25, 1) both; }
.actor-img.actor-ready.anim-fadein { animation: actorFadeIn 1.1s ease both; }

@keyframes actorFloat {
  0%, 100% { transform: scaleX(var(--actor-flip, 1)) translateY(0); }
  50% { transform: scaleX(var(--actor-flip, 1)) translateY(-12px); }
}
@keyframes actorBreathe {
  0%, 100% { transform: scaleX(var(--actor-flip, 1)) scale(1); }
  50% { transform: scaleX(var(--actor-flip, 1)) scale(1.025); }
}
@keyframes actorSlideIn {
  from { transform: scaleX(var(--actor-flip, 1)) translateX(-46px); }
  to { transform: scaleX(var(--actor-flip, 1)) translateX(0); }
}
@keyframes actorFadeIn {
  from { transform: scaleX(var(--actor-flip, 1)) translateY(14px); }
  to { transform: scaleX(var(--actor-flip, 1)) translateY(0); }
}

/* 脚下投影（可选，让人物不"飘"在背景上） */
.actor-shadow { display: none; }
.actor.actor-shadow-on .actor-shadow {
  display: block;
  position: absolute;
  left: var(--actor-x, 50%);
  top: var(--actor-y, 100%);
  width: calc(var(--actor-h, 60vh) * 0.46);
  height: calc(var(--actor-h, 60vh) * 0.075);
  transform: translate(-50%, -46%);
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.6), transparent 70%);
  filter: blur(4px);
}

/* ============================================================
 *  ② 开场影片层（管理员在「视频」页配的片头）
 *  盖住整个页面，播完整体淡出，中间没有跳转。
 * ============================================================ */
.film-layer {
  position: fixed; inset: 0; z-index: 900;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.6s ease;      /* 时长要和 film.js 里的 620ms 对齐 */
}
.film-layer.hidden { display: none; }
.film-layer.film-out { opacity: 0; pointer-events: none; }

.film-video {
  width: 100%; height: 100%;
  object-fit: contain;                /* 竖屏片子不裁切；想铺满整屏改成 cover */
  background: #000; display: block;
}
.film-veil {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.5) 100%);
}
.film-skip, .film-sound {
  position: absolute; z-index: 2;
  font-family: inherit; font-size: 13px; cursor: pointer;
  background: rgba(10, 8, 32, 0.62); color: #eef1ff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px; padding: 8px 16px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.film-skip {
  right: max(14px, env(safe-area-inset-right));
  top: max(14px, env(safe-area-inset-top));
}
.film-sound {
  left: max(14px, env(safe-area-inset-left));
  top: max(14px, env(safe-area-inset-top));
  padding: 8px 12px;
}
.film-skip.hidden, .film-sound.hidden, .film-play.hidden, .film-bar.hidden { display: none; }
.film-skip-ico { opacity: 0.75; margin-left: 2px; }

.film-play {
  position: absolute; z-index: 3; cursor: pointer; font-family: inherit;
  background: rgba(94, 224, 255, 0.92); color: #06121a;
  border: none; border-radius: 999px; padding: 13px 26px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
}
.film-bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px; z-index: 2;
  background: rgba(255, 255, 255, 0.14);
}
.film-bar i { display: block; height: 100%; width: 0; background: var(--accent, #5ee0ff); }
body.film-on { overflow: hidden; }

/* ============================================================
 *  ③ 编辑器 · 视频管理面板
 * ============================================================ */
.film-lib { display: grid; gap: 10px; margin: 10px 0 4px; }
.film-card {
  display: flex; gap: 10px; align-items: flex-start;
  background: #16142e; border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px; padding: 10px;
}
.film-card.current { border-color: var(--accent); background: #1d1a3d; }
.film-card .fc-thumb {
  width: 104px; height: 58px; border-radius: 6px; flex: none;
  object-fit: cover; background: #000; border: 1px solid rgba(255, 255, 255, 0.14);
}
.film-card .fc-thumb-empty {
  width: 104px; height: 58px; border-radius: 6px; flex: none;
  background: #0e0c20; border: 1px dashed rgba(255, 255, 255, 0.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #565c86;
}
.film-card .fc-main { flex: 1; min-width: 0; }
.film-card .fc-name {
  font-size: 13px; color: #eef1ff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.film-card .fc-meta { font-size: 11px; color: #8b91b8; margin-top: 3px; }
.film-card .fc-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.film-badge {
  display: inline-block; font-size: 10px; font-weight: 600;
  background: var(--accent); color: #06121a;
  padding: 2px 8px; border-radius: 999px; margin-left: 6px;
}
.film-empty {
  font-size: 12px; color: #6f76a0; text-align: center;
  padding: 18px 12px; border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 10px;
}
.quota-meter { height: 6px; border-radius: 3px; background: #1e1b3a; overflow: hidden; margin: 7px 0 4px; }
.quota-meter i { display: block; height: 100%; background: var(--accent); transition: width 0.25s; }
.quota-meter.warn i { background: #ffb15e; }
.quota-meter.danger i { background: #d9526a; }
.quota-text { font-size: 11px; color: #8b91b8; }

/* ============================================================
 *  ④ 编辑器 · 图层管理面板
 * ============================================================ */
.layer-mini {
  position: relative; width: 100%; max-width: 190px;
  aspect-ratio: 9 / 16; max-height: 210px;
  margin: 4px auto 12px;
  border-radius: 10px; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(165deg, #232044, #050510);
}
.layer-mini .lm-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  opacity: var(--lm-bg-opacity, 1);
  filter: blur(var(--lm-bg-blur, 0px));
}
.layer-mini .lm-bg::after {
  content: ""; position: absolute; inset: 0;
  background: #000; opacity: var(--lm-bg-dim, 0);
}
.layer-mini .lm-actor {
  position: absolute;
  left: var(--lm-x, 50%); top: var(--lm-y, 100%);
  transform: translate(-50%, -100%);
  height: var(--lm-h, 60%);
  width: auto; max-width: none;
  opacity: var(--lm-opacity, 1);
}
.layer-mini .lm-tag {
  position: absolute; left: 6px; bottom: 4px; font-size: 9px;
  color: #8b91b8; letter-spacing: 1px;
}
.layer-mini .lm-none {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-size: 11px; color: #565c86;
}
.layer-block {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px; padding: 10px 12px 4px; margin: 10px 0 14px;
  background: #12102a;
}
.layer-block > h5 {
  font-size: 12px; color: var(--accent); letter-spacing: 1px;
  font-weight: 600; margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
}
.layer-block .lb-hint { font-size: 10px; color: #6f76a0; font-weight: 400; letter-spacing: 0; }
.layer-empty-tip {
  font-size: 11px; color: #ffb15e; background: rgba(255, 177, 94, 0.09);
  border-left: 2px solid #ffb15e; padding: 6px 9px; border-radius: 0 6px 6px 0;
  margin-bottom: 10px; line-height: 1.6;
}

