:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #e2e5ea;
  --text: #1d2129;
  --muted: #6b7380;
  --accent: #e8a317;
  --accent-bg: #fff3d6;
  --accent-ink: #6b4700;
  --hot: #e8590c;
  --radius: 10px;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  height: 100vh;
  overflow: hidden;
}
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

/* ── header */
.top {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.title { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: 1; }
.title b { font-size: 17px; letter-spacing: 0.02em; white-space: nowrap; }
.title span { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title .draft { color: var(--accent-ink); background: var(--accent-bg); border-radius: 999px; padding: 1px 8px; font-size: 11.5px; }
.modes { display: flex; background: #f0f2f5; border-radius: 9px; padding: 3px; }
.modes button {
  border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; font-size: 13px; color: var(--muted);
}
.modes button i { font-style: normal; font-size: 11.5px; opacity: 0.7; }
.modes button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(20, 30, 50, 0.12); }
.chip, .tog {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 5px 11px; font-size: 13px; color: var(--muted);
}
.chip.on, .tog.on { background: var(--accent-bg); border-color: #f1d08a; color: var(--accent-ink); }

/* ── stage */
.stage-wrap { display: flex; align-items: center; justify-content: center; padding: 14px 18px 10px; min-height: 0; }
.stage {
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  background: #e9edf1;
  box-shadow: 0 1px 2px rgba(20, 30, 50, 0.06), 0 8px 28px rgba(20, 30, 50, 0.1);
}
.stage canvas#gl { display: block; width: 100%; height: 100%; }
.shot-badge {
  position: absolute; left: 12px; top: 10px;
  font: 12px/1 ui-monospace, "JetBrains Mono", Consolas, monospace;
  color: #fff; background: rgba(20, 24, 30, 0.55); padding: 5px 8px; border-radius: 6px;
  backdrop-filter: blur(4px); pointer-events: none;
}
.shot-badge b { color: #ffd166; margin-right: 6px; }
.minimap {
  position: absolute; right: 12px; top: 10px; width: 220px; height: 220px;
  border-radius: 8px; box-shadow: 0 2px 10px rgba(20, 30, 50, 0.18);
}
.stage[data-mode="plan"] .minimap { display: none; }
.pip {
  position: absolute; left: 12px; bottom: 12px; width: 30%;
  border-radius: 8px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); background: #000;
}
.subs {
  position: absolute; left: 50%; bottom: 5.5%; transform: translateX(-50%);
  width: max-content; max-width: 70%; text-align: center; pointer-events: none;
}
.subs .who {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: #fff; background: rgba(20, 24, 30, 0.55); border-radius: 999px; padding: 2px 9px 2px 7px; margin-bottom: 4px;
}
.subs .who i, .legend i, .tag i, .tl-tip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.subs .zh, .subs .en { color: #fff; text-shadow: 0 0 2px #000, 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 12px rgba(0, 0, 0, 0.45); }
.subs .zh { font-size: clamp(16px, 2.3vw, 26px); font-weight: 600; letter-spacing: 0.04em; }
.subs .en { font-size: clamp(12px, 1.5vw, 17px); margin-top: 2px; }
.labels { position: absolute; inset: 0; pointer-events: none; }
.tag {
  position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 5px; white-space: nowrap;
  font-size: 12px; padding: 2px 8px 2px 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.92); box-shadow: 0 1px 4px rgba(20, 30, 50, 0.2);
}
.bigplay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  border: 0; background: rgba(240, 243, 246, 0.25);
}
.bigplay span {
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; padding-left: 6px;
  font-size: 30px; color: var(--accent-ink); background: #ffd166; box-shadow: 0 6px 22px rgba(232, 163, 23, 0.45);
}
.bigplay em { font-style: normal; font-size: 13px; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
.bigplay[hidden], .loading[hidden], .tag[hidden], .pip[hidden], .minimap[hidden] { display: none; }
.loading {
  position: absolute; inset: 0; display: grid; place-items: center; background: #eef1f4; color: var(--muted); font-size: 14px;
}
.loading.err { color: #b42318; padding: 24px; text-align: center; }

/* ── ?bare: the picture only (screenshots, recording) */
body.bare { grid-template-rows: minmax(0, 1fr); background: #000; }
body.bare .top, body.bare .timeline, body.bare .controls { display: none; }
body.bare .stage-wrap { padding: 0; }
body.bare .stage { border-radius: 0; box-shadow: none; }
body.bare .minimap, body.bare .shot-badge, body.bare .labels { display: none; }

/* ── export progress */
.export-bar {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%); max-width: 90%;
  font-size: 12.5px; color: var(--accent-ink); background: var(--accent-bg); border: 1px solid #f1d08a;
  padding: 5px 12px; border-radius: 8px; box-shadow: 0 2px 10px rgba(20, 30, 50, 0.15); z-index: 6; word-break: break-all;
}
.export-bar[hidden] { display: none; }

/* ── production picker */
.prod { font-size: 13px; max-width: 200px; }
.prod[hidden] { display: none; }

/* ── overlays: title cards and inserts (phone screens, pages) */
.overlays { position: absolute; inset: 0; pointer-events: none; }
.overlays [hidden] { display: none; }
.card {
  position: absolute; left: 4%; top: 9%; display: flex; flex-direction: column; gap: 4px;
  color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7), 0 0 14px rgba(0, 0, 0, 0.35);
  border-left: 3px solid #ffd166; padding: 2px 0 2px 12px;
}
.card b { font-size: clamp(15px, 2vw, 24px); letter-spacing: 0.06em; font-weight: 600; }
.card span { font-size: clamp(11px, 1.2vw, 14px); opacity: 0.9; letter-spacing: 0.08em; }
.card.black { inset: 0; left: 0; top: 0; background: #000; border: 0; padding: 0; align-items: center; justify-content: center; }
.card.black b { font-weight: 400; letter-spacing: 0.3em; opacity: 0.85; }
.insert { position: absolute; transition: none; }
.insert.phone {
  left: 4%; top: 50%; transform: translateY(-50%); width: 22%; aspect-ratio: 9 / 19;
  border-radius: 22px; background: #111; padding: 7px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.insert.full { left: 50%; top: 50%; transform: translate(-50%, -50%); width: 46%; }
.insert .screen { width: 100%; height: 100%; border-radius: 16px; overflow: hidden; background: #f3f3f3; position: relative; font-size: clamp(9px, 1vw, 13px); color: #222; }
.screen.call { background: linear-gradient(#3a4a5c, #1d2630); color: #fff; display: flex; flex-direction: column; align-items: center; padding-top: 28%; gap: 6px; }
.screen.call .avatar { width: 34%; aspect-ratio: 1; border-radius: 50%; background: #6d8db0; display: grid; place-items: center; font-size: 2.2em; }
.screen.call b { font-size: 1.4em; margin-top: 6px; }
.screen.call span { opacity: 0.75; }
.screen.call .btns { position: absolute; bottom: 10%; display: flex; gap: 38%; width: 70%; justify-content: center; }
.screen.call .btns i { font-style: normal; width: 22%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font-size: 1.4em; min-width: 36px; }
.screen.call .no { background: #e5484d; } .screen.call .yes { background: #30a46c; }
.screen.photo { background: #000; }
.photo-in { position: absolute; inset: 0; transform-origin: 63% 47%; }
.photo-in .bg { position: absolute; inset: 0; background: linear-gradient(#d7d2c8 0 30%, #b9b3a8 30% 32%, #e6e1d8 32%); filter: blur(2px); }
.photo-in .fig { position: absolute; border-radius: 40% 40% 10% 10%; filter: blur(3.5px); }
.photo-in .fig.a { left: 40%; top: 28%; width: 18%; height: 55%; background: #b98a70; }
.photo-in .fig.b { left: 52%; top: 22%; width: 20%; height: 62%; background: #4e5c6b; }
.photo-in .pack { position: absolute; left: 60%; top: 34%; width: 12%; height: 22%; background: #6b7178; border-radius: 4px; filter: blur(2.5px); }
.photo-in .badge { position: absolute; left: 60%; top: 44%; width: 12%; padding: 0.4%; background: #fff; border: 1px solid #2f7d6d; font-size: 0.4em; line-height: 1.2; color: #123; opacity: 0; }
.photo-in .badge p { margin: 0; white-space: nowrap; transform-origin: left; }
.screen.photo .cap { position: absolute; bottom: 4%; width: 100%; text-align: center; color: #fff; opacity: 0.7; }
.screen.chat { display: flex; flex-direction: column; background: #ededed; }
.screen.chat header { padding: 14% 8px 8px; text-align: center; font-weight: 600; background: #ededed; border-bottom: 1px solid #ddd; }
.screen.chat .msgs { flex: 1; padding: 8px; display: flex; flex-direction: column; gap: 8px; justify-content: flex-end; }
.screen.chat .msgs p { margin: 0; max-width: 78%; padding: 6px 8px; border-radius: 6px; line-height: 1.35; }
.screen.chat .them { background: #fff; align-self: flex-start; }
.screen.chat .me { background: #95ec69; align-self: flex-end; }
.screen.chat footer { display: flex; gap: 6px; padding: 8px 8px 14%; background: #f7f7f7; align-items: center; }
.screen.chat footer span { flex: 1; background: #fff; border-radius: 4px; padding: 5px 6px; min-height: 1.6em; }
.screen.chat footer em { font-style: normal; background: #07c160; color: #fff; padding: 4px 8px; border-radius: 4px; }
.caret { display: inline-block; width: 1px; height: 1em; background: #07c160; vertical-align: middle; margin-left: 1px; }
.screen.notify { background: linear-gradient(#2c3e55, #6b5b73); color: #fff; padding: 22% 6% 0; display: flex; flex-direction: column; gap: 8px; }
.screen.notify .clock { font-size: 3.2em; text-align: center; font-weight: 300; margin-bottom: 14%; }
.screen.notify .note { background: rgba(255, 255, 255, 0.82); color: #222; border-radius: 10px; padding: 7px 9px; display: flex; flex-direction: column; gap: 2px; }
.screen.ticket { background: #f4f6f9; padding: 14% 8% 0; display: flex; flex-direction: column; gap: 10px; }
.screen.ticket header { font-weight: 600; text-align: center; }
.screen.ticket .route { display: flex; justify-content: space-between; align-items: center; background: #fff; border-radius: 10px; padding: 14px 10px; }
.screen.ticket .route b { font-size: 1.15em; } .screen.ticket .route i { font-style: normal; color: #3b82f6; }
.screen.ticket .pay, .screen.ticket .paid { text-align: center; padding: 9px; border-radius: 8px; font-weight: 600; }
.screen.ticket .pay { background: #3b82f6; color: #fff; } .screen.ticket .paid { background: #e8f7ee; color: #1a7f45; }
.screen.search { background: #fff; padding: 14% 6% 0; }
.screen.search .bar { background: #f2f2f2; border-radius: 999px; padding: 7px 10px; }
.screen.search .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.screen.search .grid i { aspect-ratio: 3 / 4; border-radius: 6px; background: linear-gradient(#e9d9d2, #cfd8e3); filter: blur(3px); }
.insert .page {
  background: #fbf7ec; border-radius: 4px; padding: 18px 26px 22px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  font-family: "KaiTi", "STKaiti", "Kaiti SC", serif; color: #1f2a44; font-size: clamp(14px, 1.9vw, 24px);
  background-image: repeating-linear-gradient(transparent 0 1.75em, rgba(70, 110, 170, 0.18) 1.75em calc(1.75em + 1px));
}
.insert .page h4 { margin: 0 0 6px; font-family: "Microsoft YaHei", sans-serif; font-size: 0.6em; color: #8a8f99; font-weight: 400; letter-spacing: 0.1em; }
.insert .page p { margin: 0; line-height: 1.75; }

/* ── timeline */
.timeline { position: relative; margin: 0 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px 4px; }
.timeline canvas { display: block; width: 100%; height: 118px; cursor: pointer; touch-action: none; }
.tl-tip {
  position: absolute; max-width: 420px; padding: 7px 10px; border-radius: 8px; font-size: 12.5px; line-height: 1.5;
  background: #1f242c; color: #fff; pointer-events: none; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2); z-index: 5;
}
.tl-tip span { color: #a7b0bc; font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; }
.tl-tip i { margin-right: 5px; }

/* ── controls */
.controls { display: flex; align-items: center; gap: 10px; padding: 10px 18px 14px; flex-wrap: wrap; }
.play {
  width: 38px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); font-size: 14px;
}
.time { font: 13px ui-monospace, "JetBrains Mono", Consolas, monospace; min-width: 132px; }
select { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 5px 8px; font-size: 13px; }
.vol { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.vol[hidden] { display: none; }
.vol input { width: 78px; accent-color: var(--accent); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; margin-left: 6px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.keys { margin-left: auto; font-size: 11.5px; color: var(--muted); }
kbd { font: 10.5px ui-monospace, Consolas, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--panel); margin: 0 1px; }
.fps { font: 11px ui-monospace, Consolas, monospace; color: #a0a7b1; min-width: 44px; text-align: right; }

@media (max-width: 760px) {
  .top { flex-wrap: wrap; padding: 8px 12px; }
  .stage-wrap { padding: 10px 12px 8px; }
  .timeline { margin: 0 12px; }
  .controls { padding: 8px 12px 12px; }
  .keys { display: none; }
  .minimap { width: 150px; height: 150px; }
}

.camera-tools{position:absolute;top:12px;right:12px;z-index:12;padding:10px 12px;border-radius:10px;background:rgba(255,255,255,.93);border:1px solid #d9dce1;color:#545b68;box-shadow:0 3px 14px #0001;font-size:12px}
.camera-tools[hidden]{display:none}.camera-buttons{display:flex;align-items:center;gap:6px;margin-bottom:6px}.camera-buttons button{font:inherit;border:1px solid #d4d8df;border-radius:6px;background:#fff;color:#303745;padding:6px 9px;cursor:pointer}.camera-buttons button:hover{background:#fff3cc}.camera-tools small{line-height:1.7}.shot-location{margin-left:9px;padding-left:9px;border-left:1px solid #fff6;font-size:11px}
@media(max-width:650px){.camera-tools{top:8px;right:8px;padding:7px;font-size:10px}.camera-buttons{gap:3px}.camera-buttons button{padding:4px 5px}.camera-tools small{font-size:9px}}

.camera-tools{max-width:calc(100% - 24px)}.camera-buttons{flex-wrap:wrap}.camera-tools.overview small{display:none}.camera-tools.overview .camera-buttons{margin-bottom:0}.stage[data-overview="true"] .subs .zh{font-size:clamp(12px,1.5vw,18px)}

body{height:100dvh}.recovery{position:absolute;inset:0;z-index:30;background:#fffffff2;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;text-align:center;padding:20px}.recovery[hidden]{display:none}.recovery button,.recovery a{padding:10px 16px;border-radius:8px;border:1px solid #d4d8df;background:#fff;color:#303745;font:inherit}#playbackStatus{font-size:12px;color:#845400}#playbackStatus[hidden]{display:none}
@media(max-width:760px){.top{gap:7px}.title{flex:1 1 70px}.title span{display:none}.modes{order:5;width:100%;justify-content:center}.modes button{padding:6px 9px}.modes i{display:none}.stage-wrap{padding:5px 6px}.timeline{margin:0 6px;padding:4px}.timeline canvas{height:92px}.controls{gap:7px;padding:7px 8px max(8px,env(safe-area-inset-bottom))}.legend,.fps{display:none}.vol input{width:58px}.time{min-width:120px}.camera-tools small{display:none}.camera-buttons{margin:0}.shot-badge{left:6px;top:6px;font-size:10px}.shot-location{display:none}.subs{max-width:94%;bottom:5%}.subs .zh{font-size:clamp(13px,3.8vw,20px)}.subs .who{font-size:10px}}
@media(max-height:480px) and (orientation:landscape){.top{padding:3px 8px;flex-wrap:nowrap;gap:6px}.modes{order:initial;width:auto}.timeline{display:none}.controls{padding:4px 8px;gap:6px}.controls .legend,.controls .keys,.controls .fps{display:none}.stage-wrap{padding:3px}.camera-tools{padding:5px}.camera-tools small{display:none}}
