/* 口播搭子 · 样式
 * 深色为主：拍摄时屏幕不刺眼，也方便判断肤色和光线
 */

:root {
  --bg: #151922;
  --bg2: #1B2129;
  --card: #1E2531;
  --card2: #252D3A;
  --line: #2C3542;
  --txt: #F2F5FA;
  --txt2: #9AA5B8;
  --txt3: #6B7688;
  --brand: #FFA23A;
  --brand-soft: rgba(255, 162, 58, .14);
  --rec: #FF5252;
  --ok: #4CD08A;
  --r: 14px;
  --r-sm: 10px;
  --safe-b: max(10px, env(safe-area-inset-bottom));
  --safe-t: env(safe-area-inset-top);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body.is-shoot { overflow: hidden; }

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }

#app { min-height: 100vh; }

/* ---------- 通用页面 ---------- */
.pad { padding: 14px 14px calc(96px + var(--safe-b)); padding-top: calc(14px + var(--safe-t)); }
.page-title { font-size: 20px; font-weight: 800; margin: 4px 0 2px; letter-spacing: .3px; }
.page-sub { color: var(--txt2); font-size: 12.5px; margin-bottom: 14px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px; margin-bottom: 12px;
}
.card.tight { padding: 12px; }

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

.muted { color: var(--txt2); }
.tiny { font-size: 11.5px; }
.mono-num { font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--card2); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 14px; font-size: 14px; font-weight: 600;
  transition: transform .08s ease, background .15s;
}
.btn:active { transform: scale(.96); }
.btn-primary { background: var(--brand); color: #22160A; border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-danger { background: rgba(255, 82, 82, .12); color: #FF8A8A; border-color: rgba(255, 82, 82, .3); }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .45; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--txt2); margin-bottom: 6px; }
.input, .textarea {
  width: 100%; background: var(--bg2); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 10px 12px; font-size: 15px; outline: none;
}
.input:focus, .textarea:focus { border-color: var(--brand); }
.textarea { min-height: 150px; line-height: 1.7; resize: vertical; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--card2); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--txt2);
}
.chip.on { background: var(--brand-soft); border-color: rgba(255, 162, 58, .45); color: var(--brand); }

.empty {
  text-align: center; color: var(--txt3); padding: 46px 20px; font-size: 13.5px; line-height: 1.9;
}
.empty .big { font-size: 40px; display: block; margin-bottom: 10px; opacity: .8; }

/* ---------- 底部 Tab ---------- */
.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; background: rgba(21, 25, 34, .94);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; color: var(--txt3); font-size: 10.5px; font-weight: 600;
}
.tab .ic { font-size: 20px; line-height: 1.1; }
.tab.on { color: var(--brand); }

/* ---------- 稿子列表 ---------- */
.script-item {
  display: block; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 13px 14px; margin-bottom: 10px;
  transition: transform .08s;
}
.script-item:active { transform: scale(.99); }
.script-item .t { font-size: 15.5px; font-weight: 700; margin-bottom: 5px; }
.script-item .m { font-size: 11.5px; color: var(--txt3); display: flex; gap: 10px; flex-wrap: wrap; }
.script-item .acts { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.mini-act {
  background: var(--brand-soft); border: 1px solid rgba(255, 162, 58, .25);
  color: var(--brand); border-radius: 999px; padding: 2px 8px; font-size: 11px;
}

.fab {
  position: fixed; right: 16px; z-index: 55;
  bottom: calc(74px + var(--safe-b));
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--brand); color: #22160A; font-size: 28px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 22px rgba(255, 162, 58, .34);
}

/* ---------- 编排页（每句配动作） ---------- */
.ed-line {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 11px 12px; margin-bottom: 9px;
}
.ed-line .no {
  flex: 0 0 22px; height: 22px; border-radius: 50%; background: var(--card2);
  color: var(--txt3); font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-top: 2px;
}
.ed-line .tx { flex: 1; min-width: 0; font-size: 14.5px; line-height: 1.5; }
.ed-line .pick {
  flex: 0 0 auto; max-width: 118px; display: flex; align-items: center; gap: 4px;
  background: var(--card2); border: 1px dashed var(--line); border-radius: 999px;
  padding: 4px 9px; font-size: 11.5px; color: var(--txt2);
}
.ed-line .pick.has { border-style: solid; border-color: rgba(255, 162, 58, .5); color: var(--brand); background: var(--brand-soft); }
.ed-line .pick .e { font-size: 14px; }

.batch-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }

/* ---------- 底部弹层 ---------- */
.sheet-mask {
  position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .55);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  max-height: 82vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg2); border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0; padding: 14px 14px calc(18px + var(--safe-b));
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .5);
}
.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; }
.sheet-title { font-size: 16px; font-weight: 800; margin-bottom: 10px; }

.cat-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 10px; }
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  flex: 0 0 auto; background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px; color: var(--txt2);
}
.cat-tab.on { background: var(--brand); color: #22160A; border-color: transparent; font-weight: 700; }

.act-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.act-item {
  display: flex; align-items: center; gap: 8px; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 9px 10px;
}
.act-item:active { transform: scale(.97); }
.act-item .e { font-size: 20px; flex: 0 0 auto; }
.act-item .n { font-size: 13px; font-weight: 600; }
.act-item .h { font-size: 10.5px; color: var(--txt3); line-height: 1.3; }
.act-item.on { border-color: var(--brand); background: var(--brand-soft); }

/* ---------- 拍摄页 ---------- */
.shoot { position: fixed; inset: 0; background: #000; overflow: hidden; z-index: 40; }
.cam-layer { position: absolute; inset: 0; background: #000; }
.cam-layer video, .cam-layer canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.cam-layer video { visibility: hidden; }
.cam-layer.show-video video { visibility: visible; }
.cam-layer.show-canvas canvas { visibility: visible; }
.cam-layer canvas { visibility: hidden; }

.cam-fallback {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; padding: 30px;
  text-align: center; color: var(--txt2); font-size: 13px; background: #0C0F15;
}

.shoot-top {
  position: absolute; top: calc(8px + var(--safe-t)); left: 10px; right: 10px; z-index: 12;
  display: flex; align-items: center; gap: 8px;
}
.pill-top {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(12, 15, 21, .62); border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 999px; padding: 5px 11px; font-size: 12px;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.rec-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--rec);
  animation: blink 1s infinite;
}
@keyframes blink { 0%, 45% { opacity: 1; } 55%, 100% { opacity: .25; } }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(12, 15, 21, .62); border: 1px solid rgba(255, 255, 255, .1);
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}

/* 提词覆盖层（可上下拖动） */
.prompter-overlay {
  position: absolute; left: 8px; right: 8px; top: 34%; z-index: 11;
  touch-action: none;
}
.drag-handle {
  width: 46px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .28);
  margin: 0 auto 7px;
}

.act-card {
  display: flex; align-items: center; gap: 9px;
  background: rgba(12, 15, 21, .8); border: 1px solid rgba(255, 162, 58, .55);
  border-radius: 12px; padding: 7px 11px; margin-bottom: 7px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
}
.act-card .e { font-size: 24px; flex: 0 0 auto; }
.act-card .txt { min-width: 0; flex: 1; }
.act-card .n { font-size: 14.5px; font-weight: 800; color: #FFC97A; line-height: 1.25; }
.act-card .h { font-size: 10.5px; color: #A8B2C4; line-height: 1.3; }
.act-card.pop { animation: actPop .42s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes actPop {
  0% { transform: scale(.9); box-shadow: 0 0 0 0 rgba(255, 162, 58, .55); }
  60% { transform: scale(1.03); box-shadow: 0 0 0 9px rgba(255, 162, 58, 0); }
  100% { transform: scale(1); }
}
.act-card.pre { animation: actPre .34s ease-in-out infinite alternate; }
@keyframes actPre {
  from { border-color: rgba(255, 162, 58, .4); }
  to { border-color: #FFD79A; box-shadow: 0 0 16px rgba(255, 162, 58, .55); }
}
.act-card.none { border-color: rgba(255, 255, 255, .14); }
.act-card.none .n { color: #8F9AAD; }

.tp-viewport {
  position: relative; height: 178px; overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 20%, #000 74%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 20%, #000 74%, transparent);
}
.tp-track { will-change: transform; padding: 0 4px; }
.tp-line {
  margin: 0 0 15px; font-size: 26px; line-height: 1.5; font-weight: 500;
  color: #7C869A; transition: color .22s ease, opacity .22s ease; word-break: break-word;
}
.tp-line.is-current { color: #fff; font-weight: 800; }
.tp-line.is-done { color: #59637A; opacity: .75; }
.tp-track.is-mirror { transform-origin: center; filter: none; }
.tp-track.is-mirror .tp-line { transform: scaleX(-1); }
.tp-readline {
  position: absolute; left: 0; right: 0; top: 42%; height: 2px; pointer-events: none;
  background: linear-gradient(90deg, rgba(255, 162, 58, .95), rgba(255, 162, 58, .05));
}

/* 底部控制条 */
.shoot-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 14;
  padding: 10px 12px calc(12px + var(--safe-b));
  background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, .88) 42%);
  display: flex; flex-direction: column; gap: 9px;
}
.bar-row { display: flex; align-items: center; gap: 8px; justify-content: center; }
.cbtn {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .16);
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.cbtn:active { transform: scale(.93); }
.cbtn.main { width: 58px; height: 58px; background: var(--brand); border-color: transparent; color: #22160A; font-size: 23px; }
.cbtn.rec { background: var(--rec); color: #fff; }
.cbtn.on { background: var(--brand); color: #22160A; border-color: transparent; }
.cbtn.sm { width: 36px; height: 36px; font-size: 13px; }
.prog { height: 3px; background: rgba(255, 255, 255, .16); border-radius: 2px; overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--brand); transition: width .2s; }

/* 倒计时遮罩 */
.countdown {
  position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .35); font-size: 96px; font-weight: 900; color: var(--brand);
  text-shadow: 0 6px 30px rgba(0, 0, 0, .6);
}

/* ---------- 动作库 / 设置 ---------- */
.group-title {
  font-size: 12px; color: var(--txt3); font-weight: 700; letter-spacing: .6px;
  margin: 16px 2px 8px;
}
.set-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); margin-bottom: 8px;
}
.set-row .lb { flex: 1; font-size: 14px; font-weight: 600; }
.set-row .lb small { display: block; font-size: 11px; color: var(--txt3); font-weight: 400; margin-top: 2px; }

.switch {
  flex: 0 0 46px; width: 46px; height: 27px; border-radius: 999px;
  background: var(--card2); border: 1px solid var(--line); position: relative; transition: background .2s;
}
.switch i {
  position: absolute; top: 2px; left: 2px; width: 21px; height: 21px; border-radius: 50%;
  background: var(--txt2); transition: transform .2s, background .2s;
}
.switch.on { background: var(--brand); border-color: transparent; }
.switch.on i { transform: translateX(19px); background: #22160A; }

.slider { flex: 0 0 128px; }
.slider input[type=range] { width: 100%; accent-color: var(--brand); }
.slider .v { text-align: right; font-size: 11.5px; color: var(--txt2); font-variant-numeric: tabular-nums; }

.seg { display: flex; gap: 4px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { flex: 1; padding: 6px 8px; border-radius: 7px; font-size: 12.5px; color: var(--txt2); }
.seg button.on { background: var(--brand); color: #22160A; font-weight: 700; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(96px + var(--safe-b)); z-index: 200;
  background: rgba(12, 15, 21, .95); border: 1px solid var(--line);
  color: var(--txt); border-radius: 999px; padding: 9px 18px; font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5); max-width: 88vw; text-align: center;
}

.view { animation: fadeUp .28s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (min-width: 700px) {
  .pad { max-width: 560px; margin: 0 auto; }
  .act-grid { grid-template-columns: repeat(3, 1fr); }
  .sheet { max-width: 560px; left: 50%; transform: translateX(-50%); }
  .fab { right: calc(50% - 280px + 16px); }
}
