:root {
  --bg: #0b0d12;
  --bg-soft: #11141c;
  --panel: #151924;
  --panel-2: #1b2030;
  --line: #272d3d;
  --text: #eef1f8;
  --muted: #8b93a7;
  --accent: #ff8a3d;
  --accent-2: #ff5f7e;
  --green: #35d0a5;
  --red: #ff6273;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.view { display: none; min-height: 100vh; }
.view.active { display: block; }

/* ---------- 按钮 ---------- */
.btn {
  border: 0; border-radius: 10px; padding: 11px 18px; font-size: 14px; font-weight: 600;
  color: #fff; background: var(--panel-2); transition: transform .15s, filter .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 6px 20px rgba(255, 110, 90, .24); }
.btn-danger { background: rgba(255, 98, 115, .16); color: #ff9aa7; border: 1px solid rgba(255, 98, 115, .3); }
.btn-secondary { background: rgba(122,162,247,.14); color: #a9c4ff; border: 1px solid rgba(122,162,247,.35); }
.btn-secondary:hover { background: rgba(122,162,247,.24); }
.camera-preview { width: 100%; height: 100%; object-fit: contain; transform: scaleX(-1); background: #000; }
.camera-preview.is-file { transform: none; }
.camera-preview-label { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); background: rgba(0,0,0,.6); color: #dff0ff; padding: 6px 14px; border-radius: 20px; font-size: 12px; z-index: 4; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- 登录页 ---------- */
#view-auth, #adminAuth { position: relative; display: none; align-items: center; justify-content: center; padding: 32px 18px; overflow: hidden; }
#view-auth.active, #adminAuth.active { display: flex; }
.admin-auth-shell { max-width: 420px; }
@media (min-width: 821px) {
  #adminAuth { min-height: 100vh; }
  #adminAuth .auth-card { width: 100%; }
}
.auth-bg {
  position: absolute; inset: 0; z-index: 0;
  background: radial-gradient(900px 500px at 18% 12%, rgba(255,138,61,.16), transparent 60%),
              radial-gradient(700px 500px at 85% 85%, rgba(255,95,126,.14), transparent 60%);
  pointer-events: none;
}
.auth-shell { position: relative; z-index: 1; width: 100%; max-width: 900px; display: grid; grid-template-columns: 1fr 400px; gap: 56px; align-items: center; }
.brand-block h1 { font-size: 38px; line-height: 1.2; margin: 20px 0 12px; letter-spacing: -.5px; }
.brand-block p { color: var(--muted); font-size: 15px; line-height: 1.7; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); font-weight: 800; font-size: 26px; color: #fff;
  box-shadow: 0 8px 26px rgba(255, 110, 90, .3);
}
.brand-mark.small { width: 30px; height: 30px; border-radius: 9px; font-size: 17px; }
.feature-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.feature-pills span { border: 1px solid var(--line); border-radius: 999px; padding: 6px 13px; color: var(--muted); font-size: 12px; background: rgba(255,255,255,.02); }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 30px; box-shadow: 0 24px 70px rgba(0,0,0,.4); }
.auth-tabs { display: flex; background: var(--bg-soft); padding: 4px; border-radius: 11px; margin-bottom: 24px; }
.auth-tab { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 9px; border-radius: 8px; font-weight: 600; }
.auth-tab.active { background: var(--panel-2); color: var(--text); }
.auth-card h2 { margin: 0 0 6px; font-size: 22px; }
.auth-card > p { margin-top: 0; }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 7px; }
.field input {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 13px; color: var(--text); outline: none; transition: border-color .15s;
}
.field input:focus { border-color: var(--accent); }
.form-error { color: var(--red); min-height: 18px; font-size: 12px; margin: 0 0 8px; }
.auth-footnote { text-align: center; color: var(--muted); font-size: 12px; margin: 18px 0 0; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50; height: 64px; display: flex; align-items: center; gap: 20px;
  padding: 0 24px; background: rgba(11,13,18,.86); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.topbar-left, .topbar-right, .topnav { display: flex; align-items: center; gap: 12px; }
.brand-name { font-weight: 700; letter-spacing: .3px; }
.topnav { margin-left: 18px; }
.nav-btn { background: transparent; border: 0; color: var(--muted); padding: 8px 14px; border-radius: 9px; font-weight: 600; }
.nav-btn.active { background: var(--panel-2); color: var(--text); }
.topbar-right { margin-left: auto; }
.points-chip { display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); padding: 7px 12px; border-radius: 999px; }
.points-icon { color: var(--accent); }
.points-chip strong { font-size: 15px; }
.points-label, .points-sub { color: var(--muted); font-size: 11px; }
.points-sub { border-left: 1px solid var(--line); padding-left: 8px; }
.username { color: var(--muted); font-size: 12px; }
.icon-btn { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 6px 10px; font-size: 12px; }

/* ---------- 主体 ---------- */
.main { max-width: 1360px; margin: 0 auto; padding: 28px 24px 60px; }
.panel { display: none; }
.panel.active { display: block; }
.hero, .studio-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.hero h2, .studio-head h2, .card h3 { margin: 4px 0 6px; }
.hero h2, .studio-head h2 { font-size: 26px; }
.eyebrow { color: var(--accent); font-size: 11px; letter-spacing: 1.6px; font-weight: 700; margin: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h3 { font-size: 15px; margin: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.stat-card.accent { background: linear-gradient(135deg, rgba(255,138,61,.16), rgba(255,95,126,.08)); border-color: rgba(255,138,61,.35); }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-card strong { font-size: 26px; letter-spacing: -.5px; }
.stat-card small { color: var(--muted); font-size: 11px; }
.content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.chart { height: 150px; display: flex; align-items: flex-end; gap: 3px; overflow: hidden; }
.chart-bar { flex: 1; min-width: 2px; background: linear-gradient(180deg, var(--accent), rgba(255,95,126,.35)); border-radius: 3px 3px 0 0; position: relative; }
.chart-bar:hover::after { content: attr(data-value); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: #000; padding: 3px 6px; border-radius: 4px; font-size: 10px; white-space: nowrap; }
.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.plan-card { border: 1px solid var(--line); border-radius: 12px; padding: 13px; background: var(--bg-soft); }
.plan-card h4 { margin: 0 0 6px; font-size: 14px; }
.plan-card .price { color: var(--accent); font-size: 20px; font-weight: 700; }
.plan-card .pts { color: var(--muted); font-size: 11px; margin: 4px 0 10px; }
.plan-card.recommended { border-color: rgba(255,138,61,.55); background: rgba(255,138,61,.07); }
.list { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--bg-soft); font-size: 12px; }
.list-row .main-text { font-weight: 600; }
.list-row .sub-text { color: var(--muted); font-size: 11px; margin-top: 3px; }
.tag { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: rgba(53,208,165,.13); color: var(--green); }
.tag.pending { background: rgba(255,138,61,.13); color: var(--accent); }
.tag.fail { background: rgba(255,98,115,.13); color: var(--red); }
.empty { color: var(--muted); font-size: 12px; padding: 18px 0; text-align: center; }

/* ---------- 工作台 ---------- */
.studio-layout { display: grid; grid-template-columns: 268px 1fr; gap: 18px; align-items: start; }
.materials { max-height: calc(100vh - 110px); overflow-y: auto; }
.upload-card { width: 100%; border: 1px dashed rgba(255,138,61,.45); background: rgba(255,138,61,.06); color: var(--text); border-radius: 12px; padding: 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 12px; }
.upload-plus { font-size: 22px; color: var(--accent); }
.upload-card small { color: var(--muted); font-size: 10px; }
.material-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.material-cell { position: relative; aspect-ratio: 1; }
.material-cell.selected .material-item { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,138,61,.2); }
.material-cell .material-item { width: 100%; height: 100%; }
.material-delete { position: absolute; top: 3px; right: 3px; z-index: 3; width: 20px; height: 20px; border: 0; border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; font-size: 15px; line-height: 1; display: none; align-items: center; justify-content: center; padding: 0; }
.material-cell:hover .material-delete { display: flex; }
.material-delete:hover { background: var(--red); }
.material-item { position: relative; border: 2px solid transparent; border-radius: 10px; overflow: hidden; aspect-ratio: 1; background: var(--bg-soft); padding: 0; }
.material-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.material-item span { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(transparent, rgba(0,0,0,.85)); color: #fff; font-size: 10px; padding: 12px 4px 4px; text-align: center; }
.material-item.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,138,61,.2); }
.custom-badge { position: absolute; top: 4px; left: 4px; background: rgba(255,138,61,.9); color: #1a1206; font-size: 9px; font-style: normal; font-weight: 700; padding: 1px 5px; border-radius: 4px; }
.stage-wrap { min-width: 0; }
.stage { position: relative; width: 100%; aspect-ratio: 16/10; min-height: 340px; max-height: 72vh; background: #05060a; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.video-mount { position: absolute; inset: 0; }
/* SDK 的视图根元素默认没有宽高（内部 video 为 absolute inset:0），
   必须保证其撑满容器，否则画面高度为 0 导致黑屏。 */
.video-mount > div { width: 100%; height: 100%; }
.video-mount video { width: 100%; height: 100%; }
/* 预览提示条不参与撑满 */
.video-mount > .camera-preview-label { width: auto; height: auto; }
.stage-overlay { position: absolute; inset: 0; pointer-events: none; }
.stage-badges { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.stage-badge { background: rgba(0,0,0,.55); backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,.12); padding: 5px 10px; border-radius: 999px; font-size: 11px; }
.stage-badge.timer { font-variant-numeric: tabular-nums; }
.stage-badge.cost { color: var(--accent); }
.stage-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; color: var(--muted); }
.stage-placeholder h3 { color: var(--text); margin: 0; font-size: 17px; }
.stage-placeholder p { margin: 0; font-size: 12px; }
.placeholder-icon { width: 62px; height: 62px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; font-size: 30px; color: var(--accent); margin-bottom: 8px; }
.fullscreen-btn { position: absolute; bottom: 12px; right: 12px; pointer-events: auto; background: rgba(0,0,0,.6); border: 1px solid rgba(255,255,255,.16); color: #fff; border-radius: 9px; padding: 7px 12px; font-size: 12px; }
.stage:fullscreen, .stage:-webkit-full-screen { width: 100vw !important; height: 100vh !important; max-height: none; aspect-ratio: auto; border-radius: 0; }
.stage.fake-fullscreen { position: fixed; inset: 0; z-index: 9999; width: 100vw; height: 100vh; max-height: none; border-radius: 0; }
.control-bar { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.control-info { display: flex; gap: 24px; align-items: center; }
.material-selected { display: flex; align-items: center; gap: 10px; }
.material-selected img { width: 42px; height: 42px; border-radius: 9px; object-fit: cover; background: var(--bg-soft); }
.material-selected div { display: flex; flex-direction: column; gap: 2px; }
.material-selected span, .account-info span { font-size: 10px; }
.material-selected strong, .account-info strong { font-size: 13px; }
.control-buttons { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.camera-pick select {
  max-width: 210px; background: var(--bg-soft); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 11px 12px; font-size: 13px; outline: none;
}
.camera-pick select:focus { border-color: var(--accent); }
.netcam-bar { margin-top: 12px; padding: 14px; }
.netcam-input { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.netcam-title { color: var(--muted); font-size: 12px; white-space: nowrap; }
.netcam-input input {
  flex: 1; min-width: 220px; background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; color: var(--text); outline: none; font-size: 13px;
}
.netcam-input input:focus { border-color: var(--accent); }
.netcam-tip { color: var(--muted); font-size: 11px; line-height: 1.7; margin: 10px 0 0; }
.netcam-tip code { background: var(--bg-soft); padding: 1px 5px; border-radius: 4px; }
.screen-crop {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 10px; color: var(--text); font-size: 12px; outline: none;
}
.screen-crop:focus { border-color: var(--accent); }
.diag-out {
  margin: 10px 0 0; padding: 12px; max-height: 260px; overflow: auto;
  background: #06070c; border: 1px solid var(--line); border-radius: 10px;
  color: #b9c2d0; font-size: 11px; line-height: 1.75; white-space: pre-wrap; word-break: break-all;
}
.studio-tip { color: var(--muted); font-size: 11px; margin-top: 10px; }

/* ---------- 离线制作 ---------- */
.offline-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.offline-form .card-head, .offline-tasks .card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.offline-form .card-head h3, .offline-tasks .card-head h3 { margin: 0; font-size: 15px; }
.offline-preview { width: 100%; max-height: 300px; border-radius: 12px; background: #05060a; display: block; margin-bottom: 4px; }
.offline-materials { grid-template-columns: repeat(6, 1fr); max-height: 210px; overflow-y: auto; }
.offline-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.offline-row select {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 13px; color: var(--text); outline: none;
}
.offline-row select:focus { border-color: var(--accent); }
.offline-estimate { color: var(--muted); font-size: 12px; margin: 6px 0 12px; }
.offline-progress { margin-top: 12px; }
.offline-progress-bar { height: 6px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; }
.offline-progress-bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); transition: width .2s; }
.offline-progress span { display: block; color: var(--muted); font-size: 11px; margin-top: 6px; }
.offline-tasks .list { display: grid; gap: 8px; max-height: calc(100vh - 200px); overflow-y: auto; }
.offline-task { align-items: flex-start; }
.offline-task-main { min-width: 0; }
.offline-task-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.offline-task-actions .btn { text-decoration: none; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: #202634; border: 1px solid var(--line); color: var(--text); padding: 11px 18px; border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; z-index: 10000; box-shadow: 0 12px 40px rgba(0,0,0,.5); max-width: 88vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(255,98,115,.5); }
.toast.success { border-color: rgba(53,208,165,.5); }

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .studio-layout { grid-template-columns: 220px 1fr; }
}
@media (max-width: 820px) {
  .auth-shell { grid-template-columns: 1fr; gap: 28px; max-width: 460px; }
  .brand-block { text-align: center; }
  .brand-block .brand-mark { margin: 0 auto; }
  .feature-pills { justify-content: center; }
  .brand-block h1 { font-size: 27px; }
  .topbar { height: auto; min-height: 60px; flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .topnav { order: 3; width: 100%; margin-left: 0; }
  .nav-btn { flex: 1; }
  .topbar-right { gap: 8px; }
  .username { display: none; }
  .main { padding: 18px 14px 50px; }
  .hero, .studio-head { align-items: flex-start; flex-direction: column; }
  .content-grid { grid-template-columns: 1fr; }
  .studio-layout { grid-template-columns: 1fr; }
  .offline-layout { grid-template-columns: 1fr; }
  .materials { max-height: none; }
  .material-grid { grid-template-columns: repeat(6, 1fr); }
  .stage { min-height: 300px; }
}
@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 13px; }
  .stat-card strong { font-size: 21px; }
  .plan-grid { grid-template-columns: 1fr; }
  .material-grid { grid-template-columns: repeat(4, 1fr); }
  .control-bar { flex-direction: column; align-items: stretch; }
  .control-buttons .btn { flex: 1; }
.btn.is-active { background: var(--accent); color: #14181f; border-color: var(--accent); box-shadow: 0 4px 14px rgba(122,162,247,.35); }

/* WebRTC 二维码（默认隐藏，点按钮才展开） */
.rtc-qr-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.rtc-qr-box {
  display: flex; gap: 14px; align-items: center; margin-top: 10px;
  padding: 12px; border-radius: 12px; background: var(--bg-soft);
  border: 1px solid var(--line); flex-wrap: wrap;
}
.rtc-qr-canvas {
  border-radius: 8px; background: #fff; max-width: 100%;
  image-rendering: pixelated; flex: 0 0 auto;
}
.rtc-qr-side { flex: 1; min-width: 180px; }
.rtc-qr-url { font: 12px/1.5 ui-monospace, monospace; color: var(--text); word-break: break-all; }
.rtc-qr-tip { font-size: 12px; margin-top: 6px; line-height: 1.6; }
  .points-sub { display: none; }
  .stage { min-height: 260px; }
}
