/* NJ 提词器 —— 界面样式 */
:root {
  --ink: #0d0f12;
  --panel: #15181d;
  --panel-2: #1d2128;
  --line: #2b3039;
  --text: #e8eaed;
  --muted: #8b93a1;
  --amber: #ffb224;
  --red: #ff5247;
  --ui-font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--ink); color: var(--text);
  font: 14px/1.5 var(--ui-font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- 通用按钮 ---------- */
.btn, .cbtn {
  height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover, .cbtn:hover { border-color: #4a5160; background: #252a33; }
.btn:focus-visible, .cbtn:focus-visible, .preset:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.btn-primary { background: var(--amber); border-color: var(--amber); color: #1a1200; font-weight: 700; }
.btn-primary:hover { background: #ffc24d; border-color: #ffc24d; }
.btn-small { height: 28px; padding: 0 10px; font-size: 13px; }

/* ---------- 编辑视图 ---------- */
.editor-view { height: 100%; display: flex; flex-direction: column; }
.topbar {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
.brand-mark {
  width: 12px; height: 12px; border-radius: 50%; background: var(--red);
  box-shadow: 0 0 0 4px rgba(255, 82, 71, .18);
}
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 250px 1fr; }
.sidebar { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; color: var(--muted); font-size: 13px; }
.script-list { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; flex: 1; min-height: 0; }
.script-list li {
  display: flex; align-items: center; gap: 6px; padding: 9px 10px; border-radius: 8px;
  cursor: pointer; border: 1px solid transparent;
}
.script-list li:hover { background: var(--panel-2); }
.script-list li.active { background: var(--panel-2); border-color: var(--line); box-shadow: inset 3px 0 0 var(--amber); }
.script-list .s-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.script-list .s-meta { color: var(--muted); font-size: 12px; flex: none; }
.script-list .s-del {
  flex: none; width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); opacity: 0; font-size: 14px; line-height: 1;
}
.script-list li:hover .s-del, .script-list .s-del:focus-visible { opacity: 1; }
.script-list .s-del:hover { background: rgba(255, 82, 71, .16); color: var(--red); }
.sidebar-note { margin: 0; padding: 10px 14px 14px; color: var(--muted); font-size: 12px; }

.editor-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 18px 26px 0; }
.title-input {
  flex: none; border: 0; border-bottom: 1px solid var(--line); background: transparent;
  font-size: 22px; font-weight: 700; padding: 4px 0 10px; outline: none;
}
.title-input:focus { border-bottom-color: var(--amber); }
.editor {
  flex: 1; min-height: 0; resize: none; border: 0; outline: none; background: transparent;
  padding: 16px 0; font-size: 18px; line-height: 1.9; color: var(--text);
}
.editor::placeholder, .title-input::placeholder { color: #566070; }
.editor-foot {
  flex: none; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 10px 0 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px;
}
.editor-foot b { color: var(--amber); font-weight: 600; }
.drop-mask {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background: rgba(13, 15, 18, .86); pointer-events: none;
}
.drop-mask div { padding: 28px 44px; border: 2px dashed var(--amber); border-radius: 16px; font-size: 20px; color: var(--amber); }

/* ---------- 提词视图 ---------- */
.prompter-view { position: fixed; inset: 0; background: #000; }
.stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.stage.idle { cursor: none; }
.output {
  position: absolute; inset: 0; overflow: hidden; background: var(--bg, #000);
  --u: 1px; --fs: 84; --lh: 1.5; --gap: .5; --margin: 12; --gy: 300px; --lp: 126px;
  --fg: #fff; --bg: #000; --accent: #ffd400;
}
.viewport { position: absolute; inset: 0; overflow: hidden; }
.scroller {
  position: absolute; top: 0; left: calc(var(--margin) * 1%); right: calc(var(--margin) * 1%);
  font-size: calc(var(--u) * var(--fs)); line-height: var(--lh); color: var(--fg);
  white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2;
  will-change: transform; backface-visibility: hidden;
}
.scroller.f-hei { font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", "Heiti SC", sans-serif; }
.scroller.f-song { font-family: "Songti SC", "Source Han Serif SC", "Noto Serif SC", "SimSun", "STSong", serif; }
.scroller.f-kai { font-family: "Kaiti SC", "STKaiti", "KaiTi", "BiauKai", serif; }
.scroller.bold { font-weight: 700; }
.scroller.center { text-align: center; }
.script p { margin: 0 0 calc(var(--gap) * 1em); min-height: calc(var(--lh) * 1em); }
.script p.blank { margin: 0; }
.script p:last-child { margin-bottom: 0; }
.script p.marker { color: var(--accent); }
.script em { font-style: normal; color: var(--accent); }
.script .cue { color: var(--accent); opacity: .7; font-size: .8em; }
.end-mark { text-align: center; opacity: .35; font-size: .55em; padding: 1.6em 0 0; }

/* 阅读引导 */
.guide { position: absolute; inset: 0; pointer-events: none; font-size: calc(var(--u) * var(--fs)); }
.guide.arrow::before {
  content: ''; position: absolute; left: calc(var(--u) * 26); top: var(--gy); transform: translateY(-50%);
  border: .27em solid transparent; border-left: .42em solid var(--accent); border-right: 0;
}
.guide.line::before {
  content: ''; position: absolute; left: 0; right: 0; top: calc(var(--gy) - var(--lp) * .5); height: var(--lp);
  border-top: max(2px, .03em) solid var(--accent); border-bottom: max(2px, .03em) solid var(--accent); opacity: .42;
}
.guide.band::before, .guide.band::after { content: ''; position: absolute; left: 0; right: 0; background: var(--bg); opacity: .64; }
.guide.band::before { top: 0; height: max(0px, calc(var(--gy) - var(--lp) * .85)); }
.guide.band::after { top: calc(var(--gy) + var(--lp) * .85); bottom: 0; }

/* 计时 / 时钟 / 进度 / 倒计时 */
.hud {
  position: absolute; top: calc(var(--u) * 18); left: calc(var(--u) * 28); right: calc(var(--u) * 28);
  display: flex; justify-content: space-between; pointer-events: none; opacity: .72;
  font: 600 max(12px, calc(var(--u) * 34))/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums; color: var(--fg);
}
.hud span { background: var(--bg); padding: .3em .55em; border-radius: .35em; }
.hud span:empty { visibility: hidden; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: max(3px, calc(var(--u) * 6)); pointer-events: none; }
.progress i { display: block; height: 100%; background: var(--accent); opacity: .85; transform-origin: left center; transform: scaleX(0); }
.countdown {
  position: absolute; inset: 0; display: grid; place-items: center; isolation: isolate;
  font: 800 calc(var(--u) * 380)/1 var(--ui-font); color: var(--accent); font-variant-numeric: tabular-nums;
}
.countdown::before { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--bg); opacity: .78; }

.output-hint {
  position: absolute; left: 50%; bottom: 8%; transform: translateX(-50%); z-index: 4;
  padding: 12px 20px; border-radius: 999px; background: rgba(21, 24, 29, .94); border: 1px solid var(--line);
  color: var(--text); font-size: 15px; white-space: nowrap; pointer-events: none;
}
.output-hint b { color: var(--amber); }

/* ---------- 操作栏 ---------- */
.controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(13, 15, 18, .93); border-top: 1px solid var(--line);
  transition: transform .25s ease, opacity .25s ease; cursor: default;
}
.stage.idle .controls { transform: translateY(100%); opacity: 0; pointer-events: none; }
.ctl-group { display: flex; align-items: center; gap: 6px; }
.ctl-right { margin-left: auto; }
.ctl-label { color: var(--muted); font-size: 13px; }
.ctl-val { min-width: 34px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.ctl-range { width: 150px; accent-color: var(--amber); }
.cbtn-sq { width: 36px; padding: 0; font-size: 17px; }
.cbtn.on { border-color: var(--amber); color: var(--amber); background: rgba(255, 178, 36, .12); }
.cbtn-play { min-width: 96px; background: var(--amber); border-color: var(--amber); color: #1a1200; font-weight: 700; }
.cbtn-play:hover { background: #ffc24d; border-color: #ffc24d; }
.cbtn-play.playing { background: transparent; border-color: var(--red); color: var(--red); }
.cbtn-play.playing:hover { background: rgba(255, 82, 71, .14); }

/* ---------- 设置抽屉 ---------- */
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 6; width: min(340px, 100%);
  display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line);
  cursor: default; user-select: text; -webkit-user-select: text; touch-action: auto;
}
.drawer-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 12px 18px; border-bottom: 1px solid var(--line); font-size: 15px; }
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 18px 24px; }
.drawer section { padding: 12px 0 8px; border-bottom: 1px solid var(--line); }
.drawer h4 { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .08em; color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.row > span:first-child { flex: none; width: 76px; color: #c4c9d2; }
.row input[type=range] { flex: 1; min-width: 0; accent-color: var(--amber); }
.row output { flex: none; width: 40px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.row select, .fit-input {
  flex: 1; min-width: 0; height: 32px; padding: 0 8px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
}
.row input[type=color] { width: 44px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; }
.row.check { cursor: pointer; }
.row.check input { width: 16px; height: 16px; accent-color: var(--amber); }
.row.check > span:first-child, .row.check > span { width: auto; flex: 1; }
.row .cbtn { height: 32px; flex: none; }
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.preset { height: 38px; border-radius: 8px; border: 1px solid var(--line); font-weight: 700; }
.note { margin: 2px 0 6px; color: var(--muted); font-size: 12px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
.keys dt { color: var(--amber); font-family: ui-monospace, Menlo, Consolas, monospace; white-space: nowrap; }
.keys dd { margin: 0; color: #c4c9d2; }
.reset-btn { width: 100%; margin-top: 16px; }

/* ---------- 输出窗口（只显示画面） ---------- */
body.role-output .controls, body.role-output .drawer, body.role-output .editor-view { display: none !important; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed; left: 50%; top: 22px; transform: translateX(-50%); z-index: 30;
  max-width: min(520px, 90vw); padding: 10px 18px; border-radius: 10px;
  background: #262b34; border: 1px solid #3a4150; box-shadow: 0 8px 30px rgba(0, 0, 0, .45);
}

/* ---------- 窄屏 ---------- */
@media (max-width: 760px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .script-list { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; }
  .script-list li { flex: none; max-width: 180px; }
  .script-list .s-meta, .sidebar-note, .editor-foot .hint { display: none; }
  .script-list .s-del { opacity: 1; }
  .editor-main { padding: 14px 16px 0; }
  .brand { font-size: 15px; }
  .ctl-range { width: 96px; }
  .ctl-right { margin-left: 0; }
}
