/* 云影工场 · 口播录制台
   暗色全息舞台 + 玻璃拟态控制台 · 零内联（所有样式集中于此文件）
   基于开源项目 TalkingHead (MIT) 构建
   沈阳来电卫士数字软件开发有限公司 */

:root {
  --bg: #030712;
  --bg-2: #060b1a;
  --fg: #e8eefc;
  --muted: #8ea0c8;
  --cyan: #22d3ee;
  --violet: #a78bfa;
  --pink: #f0abfc;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #fb7185;
  --line: rgba(255, 255, 255, 0.10);
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  background:
    radial-gradient(1200px 720px at 50% -12%, rgba(34, 211, 238, 0.16) 0%, rgba(34, 211, 238, 0) 58%),
    radial-gradient(900px 620px at 84% 4%, rgba(167, 139, 250, 0.14) 0%, rgba(167, 139, 250, 0) 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
}

/* ---------- Top bar ---------- */
.top {
  max-width: 1160px;
  margin: 0 auto;
  padding: 16px 16px 6px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.brand { min-width: 0; }
.hero-title {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.03em;
  background: linear-gradient(90deg, #eafcff 0%, #a9f0ff 42%, #c9b6ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: neonPulse 4.5s ease-in-out infinite;
}
@keyframes neonPulse {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(34, 211, 238, 0.50)) drop-shadow(0 0 18px rgba(167, 139, 250, 0.35)); }
  50% { filter: drop-shadow(0 0 14px rgba(34, 211, 238, 0.90)) drop-shadow(0 0 34px rgba(167, 139, 250, 0.70)); }
}
.hero-sub {
  margin: 7px 0 0;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.nav-back {
  flex: none;
  color: var(--fg);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  transition: background 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
}
.nav-back:hover { background: rgba(34, 211, 238, 0.10); border-color: rgba(34, 211, 238, 0.35); }

/* ---------- Workbench layout ---------- */
.workbench {
  max-width: 1160px;
  margin: 0 auto;
  padding: 12px 16px 8px;
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) {
  .workbench { grid-template-columns: 1fr; }
}

/* ---------- Stage ---------- */
.stage-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(126, 240, 255, 0.16);
  background:
    radial-gradient(60% 55% at 50% 34%, rgba(26, 44, 92, 0.85) 0%, rgba(6, 10, 26, 0.96) 100%),
    linear-gradient(180deg, #050a18 0%, #030712 100%);
  box-shadow:
    0 18px 60px rgba(0, 0, 0, 0.55),
    inset 0 0 60px rgba(34, 211, 238, 0.05);
}
.stage {
  position: absolute;
  inset: 0;
  isolation: isolate;
}
.avatar-host {
  position: absolute;
  inset: 0;
  z-index: 2;
}
.avatar-host canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* 底面光台 */
.floor {
  position: absolute;
  left: 50%;
  bottom: 1%;
  width: 78%;
  height: 26%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse at center,
      rgba(34, 211, 238, 0.45) 0%,
      rgba(34, 211, 238, 0.14) 42%,
      rgba(34, 211, 238, 0) 72%);
  filter: blur(14px);
  opacity: 0.72;
  z-index: 1;
  transition: opacity 0.45s ease, filter 0.45s ease;
}

/* 环形能量光环 */
.ring-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
.ring {
  position: absolute;
  left: 50%;
  top: 46%;
  width: var(--size);
  height: var(--size);
  margin-left: calc(var(--size) / -2);
  margin-top: calc(var(--size) / -2);
  border-radius: 50%;
  background: conic-gradient(from 0deg,
      var(--cyan) 0deg, var(--violet) 120deg, var(--pink) 200deg, var(--cyan) 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - var(--w)), #000 calc(100% - var(--w)));
  mask: radial-gradient(farthest-side, transparent calc(100% - var(--w)), #000 calc(100% - var(--w)));
  opacity: var(--op);
  animation: ringSpin var(--dur) linear infinite;
  animation-direction: var(--dir, normal);
  will-change: transform;
  transition: opacity 0.45s ease, filter 0.45s ease;
}
.ring::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px dashed rgba(167, 139, 250, 0.32);
  animation: ringSpin var(--dur2, 40s) linear infinite reverse;
}
@keyframes ringSpin { to { transform: rotate(360deg); } }
.ring-a { --size: 62%; --w: 3px; --dur: 26s; --dur2: 40s; --dir: normal;  --op: 0.62; }
.ring-b { --size: 84%; --w: 2px; --dur: 34s; --dur2: 52s; --dir: reverse; --op: 0.42; }
.ring-c { --size: 106%; --w: 2px; --dur: 46s; --dur2: 66s; --dir: normal; --op: 0.28; }

/* 粒子星尘 */
.dust {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 3;
  pointer-events: none;
}
.dust i {
  position: absolute;
  left: calc(var(--x, 50) * 1%);
  top: calc(var(--y, 50) * 1%);
  width: var(--s, 2px);
  height: var(--s, 2px);
  border-radius: 50%;
  background: radial-gradient(circle, #e6faff 0%, var(--cyan) 55%, rgba(34, 211, 238, 0) 100%);
  box-shadow: 0 0 6px rgba(34, 211, 238, 0.85);
  opacity: 0;
  animation: twinkle var(--dur, 7s) ease-in-out infinite;
  animation-delay: calc(var(--d, 0) * -1s);
}
.dust i:nth-child(3n) {
  background: radial-gradient(circle, #f6ecff 0%, var(--violet) 55%, rgba(167, 139, 250, 0) 100%);
  box-shadow: 0 0 6px rgba(167, 139, 250, 0.85);
}
@keyframes twinkle {
  0%, 100% { opacity: 0; transform: translateY(0) scale(0.7); }
  50% { opacity: 0.92; transform: translateY(-11px) scale(1.15); }
}
.dust i:nth-child(1)  { --x: 8;  --y: 18; --dur: 7.5s; --d: 1.1; --s: 2px; }
.dust i:nth-child(2)  { --x: 16; --y: 42; --dur: 8.5s; --d: 2.4; --s: 2.5px; }
.dust i:nth-child(3)  { --x: 6;  --y: 66; --dur: 6.5s; --d: 3.2; --s: 2px; }
.dust i:nth-child(4)  { --x: 12; --y: 82; --dur: 9s;   --d: 0.6; --s: 2px; }
.dust i:nth-child(5)  { --x: 22; --y: 12; --dur: 7s;   --d: 2.9; --s: 2.5px; }
.dust i:nth-child(6)  { --x: 28; --y: 58; --dur: 8s;   --d: 1.7; --s: 2px; }
.dust i:nth-child(7)  { --x: 34; --y: 88; --dur: 6.8s; --d: 3.6; --s: 2px; }
.dust i:nth-child(8)  { --x: 40; --y: 16; --dur: 9.5s; --d: 0.9; --s: 2.5px; }
.dust i:nth-child(9)  { --x: 46; --y: 72; --dur: 7.2s; --d: 2.1; --s: 2px; }
.dust i:nth-child(10) { --x: 52; --y: 10; --dur: 8.2s; --d: 3.9; --s: 2.5px; }
.dust i:nth-child(11) { --x: 58; --y: 34; --dur: 6.6s; --d: 1.4; --s: 2px; }
.dust i:nth-child(12) { --x: 64; --y: 84; --dur: 9.2s; --d: 2.7; --s: 2px; }
.dust i:nth-child(13) { --x: 70; --y: 20; --dur: 7.8s; --d: 0.4; --s: 2.5px; }
.dust i:nth-child(14) { --x: 76; --y: 50; --dur: 8.8s; --d: 3.3; --s: 2px; }
.dust i:nth-child(15) { --x: 82; --y: 74; --dur: 6.9s; --d: 1.9; --s: 2.5px; }
.dust i:nth-child(16) { --x: 88; --y: 30; --dur: 9.8s; --d: 2.2; --s: 2px; }
.dust i:nth-child(17) { --x: 92; --y: 58; --dur: 7.4s; --d: 3.7; --s: 2px; }
.dust i:nth-child(18) { --x: 86; --y: 88; --dur: 8.6s; --d: 1.2; --s: 2px; }
.dust i:nth-child(19) { --x: 18; --y: 72; --dur: 7.1s; --d: 2.6; --s: 2px; }
.dust i:nth-child(20) { --x: 44; --y: 40; --dur: 9.1s; --d: 0.8; --s: 2.5px; }
.dust i:nth-child(21) { --x: 60; --y: 62; --dur: 6.7s; --d: 3.4; --s: 2px; }
.dust i:nth-child(22) { --x: 78; --y: 12; --dur: 8.4s; --d: 1.6; --s: 2.5px; }
.dust i:nth-child(23) { --x: 24; --y: 30; --dur: 7.6s; --d: 2.8; --s: 2px; }
.dust i:nth-child(24) { --x: 68; --y: 68; --dur: 9.4s; --d: 0.5; --s: 2px; }
.dust i:nth-child(25) { --x: 96; --y: 44; --dur: 7s;   --d: 1.3; --s: 2px; }
.dust i:nth-child(26) { --x: 4;  --y: 40; --dur: 8s;   --d: 3.1; --s: 2px; }
.dust i:nth-child(27) { --x: 54; --y: 52; --dur: 6.5s; --d: 2.3; --s: 2.5px; }
.dust i:nth-child(28) { --x: 38; --y: 64; --dur: 8.9s; --d: 3.8; --s: 2px; }

/* 扫描线 */
.scan {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 34%;
  z-index: 4;
  pointer-events: none;
  mix-blend-mode: screen;
  background: linear-gradient(100deg,
      rgba(34, 211, 238, 0) 0%,
      rgba(34, 211, 238, 0.06) 38%,
      rgba(160, 246, 255, 0.20) 50%,
      rgba(167, 139, 250, 0.06) 64%,
      rgba(167, 139, 250, 0) 100%);
  animation: scanX 7s linear infinite;
}
@keyframes scanX {
  from { transform: translateX(-115%); }
  to { transform: translateX(330%); }
}

/* 舞台内字幕气泡 */
.bubble {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translate(-50%, 12px);
  max-width: 90%;
  padding: 10px 15px;
  border-radius: 16px;
  background: rgba(9, 16, 36, 0.62);
  border: 1px solid rgba(126, 240, 255, 0.28);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.45), inset 0 0 22px rgba(34, 211, 238, 0.08);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 5;
}
.bubble.show { opacity: 1; transform: translate(-50%, 0); }
.bubble-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
  color: #e9f7ff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}

/* 降级态 */
.fallback {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  pointer-events: none;
}
.stage.fallback .fallback { display: flex; }
.stage.fallback .avatar-host { display: none; }
.fallback-orb {
  width: 38%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #c4f8ff 0%, var(--cyan) 42%, var(--violet) 78%, #2a1548 100%);
  box-shadow: 0 0 44px rgba(34, 211, 238, 0.65), 0 0 96px rgba(167, 139, 250, 0.50), inset 0 0 40px rgba(255, 255, 255, 0.25);
  animation: orbFloat 5s ease-in-out infinite;
}
@keyframes orbFloat {
  0%, 100% { transform: translateY(-7px) scale(1); }
  50% { transform: translateY(7px) scale(1.04); }
}
.fallback-text {
  margin: 0;
  color: #cfe9ff;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-shadow: 0 0 12px rgba(34, 211, 238, 0.5);
}

/* 加载态 */
.stage-loading {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12px;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.stage-loading.is-hidden { opacity: 0; }
.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: var(--cyan);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 录制/说话态：光环加速脉动 */
.stage.speaking .ring { filter: drop-shadow(0 0 14px rgba(34, 211, 238, 0.55)); }
.stage.speaking .ring-a { --dur: 9s;  --dur2: 14s; --op: 0.85; }
.stage.speaking .ring-b { --dur: 12s; --dur2: 19s; --op: 0.62; }
.stage.speaking .ring-c { --dur: 16s; --dur2: 25s; --op: 0.46; }
.stage.speaking .floor {
  opacity: 1;
  filter: blur(18px);
  background: radial-gradient(ellipse at center,
      rgba(34, 211, 238, 0.62) 0%, rgba(167, 139, 250, 0.22) 46%, rgba(34, 211, 238, 0) 74%);
}
.stage.speaking .scan { animation-duration: 1.7s; }

/* 舞台下方字幕条 */
.caption {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(9, 16, 36, 0.55);
  border: 1px solid rgba(126, 240, 255, 0.22);
  box-shadow: inset 0 0 20px rgba(34, 211, 238, 0.06);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
  min-height: 52px;
}
.caption-tag {
  flex: none;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: #04121a;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  border-radius: 6px;
  padding: 2px 7px;
  font-weight: 700;
}
.caption-text {
  font-size: 15px;
  line-height: 1.5;
  color: #eaf6ff;
  text-shadow: 0 0 10px rgba(34, 211, 238, 0.25);
  word-break: break-word;
}

/* 出片合成画布：布局中保留但移出可视区（captureStream 需要其持续绘制） */
.out-canvas {
  position: absolute;
  left: -10000px;
  top: 0;
  width: 1080px;
  height: 1440px;
  pointer-events: none;
}

/* ---------- Console ---------- */
.console-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.card {
  padding: 14px;
  border-radius: var(--radius);
  background: rgba(12, 20, 40, 0.55);
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.38), inset 0 0 30px rgba(34, 211, 238, 0.04);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
  backdrop-filter: blur(12px) saturate(130%);
}
.field-label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.select, .textarea {
  width: 100%;
  color: var(--fg);
  background: rgba(3, 8, 22, 0.75);
  border: 1px solid rgba(126, 240, 255, 0.20);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.select:focus, .textarea:focus {
  border-color: rgba(34, 211, 238, 0.55);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.14);
}
.textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}
.hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.btn {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 600;
  padding: 13px 14px;
  border-radius: 13px;
  border: 1px solid transparent;
  transition: transform 0.06s ease, filter 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  color: #04121a;
  background: linear-gradient(90deg, var(--cyan), #7cd8ff 45%, var(--violet) 100%);
  box-shadow: 0 10px 26px rgba(34, 211, 238, 0.32), 0 4px 16px rgba(167, 139, 250, 0.26);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line);
}
.btn-ghost:hover { background: rgba(34, 211, 238, 0.10); border-color: rgba(34, 211, 238, 0.32); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.3); }

.progress {
  margin-top: 12px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.55);
  transition: width 0.3s ease;
}
.status-line {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  min-height: 1.2em;
}

/* ---------- Jobs ---------- */
.card-list { padding-bottom: 6px; }
.jobs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.jobs-count { color: var(--cyan); }
.jobs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 40vh;
  overflow-y: auto;
}
.job {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
}
.job-n {
  flex: none;
  width: 24px;
  height: 24px;
  line-height: 24px;
  text-align: center;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #04121a;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
}
.job-mid { flex: 1; min-width: 0; }
.job-text {
  font-size: 13.5px;
  color: #e6eefc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.job-meta {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
}
.job-st {
  flex: none;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  white-space: nowrap;
}
.st-pending     { color: var(--muted); }
.st-generating  { color: var(--warn); border-color: rgba(251, 191, 36, 0.4); }
.st-ready       { color: var(--cyan); border-color: rgba(34, 211, 238, 0.4); }
.st-recording   { color: var(--pink); border-color: rgba(240, 171, 252, 0.4); }
.st-done        { color: var(--ok); border-color: rgba(52, 211, 153, 0.45); }
.st-error       { color: var(--err); border-color: rgba(251, 113, 133, 0.45); }
.job-link {
  flex: none;
  font-size: 12px;
  color: var(--cyan);
  text-decoration: none;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.35);
}
.job-link:hover { background: rgba(34, 211, 238, 0.12); }

/* ---------- Footer ---------- */
.footer {
  max-width: 1160px;
  margin: 6px auto 0;
  padding: 14px 16px calc(20px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
.footer p { margin: 3px 0; }
.footer-org { color: #c7d2ee; font-weight: 600; }
.footer-icp { letter-spacing: 0.02em; }

@media (prefers-reduced-motion: reduce) {
  .ring, .ring::after, .dust i, .scan, .hero-title, .fallback-orb, .spinner {
    animation-duration: 20s;
    animation-iteration-count: 1;
  }
}
