:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #2563eb;
  --brand-2: #7c3aed;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; background: var(--bg); color: var(--ink); }
.app { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }

/* 侧边栏 */
.sidebar { background: linear-gradient(180deg, #0f172a, #111827); color: #d8e2f0; padding: 18px 14px; display: flex; flex-direction: column; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.logo { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); display: grid; place-items: center; font-size: 20px; color: #fff; font-weight: 700; }
.brand-text b { font-size: 15px; display: block; } .brand-text small { color: #93a4bd; font-size: 11px; }
.nav { display: flex; flex-direction: column; gap: 4px; overflow: auto; }
.nav button { display: flex; align-items: center; gap: 10px; background: transparent; border: 0; color: #c4d0e3; padding: 10px 12px; border-radius: 10px; cursor: pointer; text-align: left; font-size: 14px; transition: .15s; }
.nav button:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav button.active { background: linear-gradient(90deg, rgba(37,99,235,.35), transparent); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.nav .ic { width: 20px; text-align: center; }
.side-meta { display: flex; gap: 8px; margin-top: auto; }
.side-meta .mini { flex: 1; background: rgba(255,255,255,.05); border-radius: 10px; padding: 8px; text-align: center; }
.side-meta .n { font-size: 17px; font-weight: 700; color: #fff; } .side-meta .l { font-size: 11px; color: #93a4bd; }

/* 主区 */
.main { padding: 18px 20px; overflow: auto; }
.topbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }
.search { flex: 1; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 10px 16px; box-shadow: var(--shadow); }
.search input { width: 100%; border: 0; outline: none; font-size: 14px; color: var(--ink); background: transparent; }
.btn { background: var(--brand); color: #fff; border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer; font-size: 14px; font-weight: 600; }
.btn:hover { filter: brightness(1.05); }
.btn.secondary { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.me { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.me .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.viewas { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; box-shadow: var(--shadow); }
.viewas select { border: 0; outline: none; background: transparent; font-size: 12px; color: var(--ink); }

.section { display: none; } .section.active { display: block; animation: fade .2s; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 980px) { .grid, .grid-3, .split { grid-template-columns: 1fr; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.panel.soft { background: linear-gradient(180deg, #fbfdff, #fff); }
.panel.tight { padding: 14px; }
.module-title { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.module-title h3 { font-size: 15px; } .module-title .sub { font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); font-size: 13px; line-height: 1.7; }

.tag-wrap { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.tag { background: #eef2ff; color: var(--brand); border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.card { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.card strong { display: block; margin-bottom: 4px; font-size: 14px; }
.card span { font-size: 12px; color: var(--muted); line-height: 1.6; }

.list { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.row b { font-size: 14px; } .row small { display: block; color: var(--muted); font-size: 12px; }
.row .badge { font-size: 12px; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge.pending { background: #fef3c7; color: var(--amber); }
.badge.ok { background: #dcfce7; color: var(--green); }
.badge.reject { background: #fee2e2; color: var(--red); }
.badge.risk { background: #ede9fe; color: var(--brand-2); }

.grid-3 .kpi, .kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.kpi .n { font-size: 26px; font-weight: 800; } .kpi .l { font-size: 12px; color: var(--muted); }
.kpi.blue .n { color: var(--brand); } .kpi.green .n { color: var(--green); } .kpi.purple .n { color: var(--brand-2); } .kpi.amber .n { color: var(--amber); }

/* 表单 */
.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form input, .form select, .form textarea { border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font-size: 14px; font-family: inherit; outline: none; background: #fff; color: var(--ink); }
.form input:focus, .form select:focus, .form textarea:focus { border-color: var(--brand); }
.form textarea { resize: vertical; }

.output { background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 14px; font-size: 13px; line-height: 1.7; white-space: pre-wrap; min-height: 160px; max-height: 360px; overflow: auto; }

.table-wrap { overflow: auto; } .table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 600; }
.tag-cell { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eef2ff; color: var(--brand); }
.status-ok { color: var(--green); } .status-off { color: var(--muted); }

.photo-item { position: relative; }
.photo-item img { width: 100%; border-radius: 10px; display: block; aspect-ratio: 1; object-fit: cover; }
.photo-item .cap { font-size: 11px; color: var(--muted); margin-top: 4px; }

.toggles { display: flex; flex-direction: column; gap: 10px; }
.toggle { display: flex; align-items: center; justify-content: space-between; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.toggle b { font-size: 14px; }
.switch { position: relative; width: 44px; height: 24px; }
.switch input { display: none; }
.slider { position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; cursor: pointer; transition: .2s; }
.slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 99; }
.toast.show { opacity: 1; }

.statusbar { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.status { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 12px; color: var(--muted); }
.status b { color: var(--ink); }
.foot { margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.actions { display: flex; gap: 6px; }
.actions button { border: 0; border-radius: 8px; padding: 5px 10px; font-size: 12px; cursor: pointer; }
.act-ok { background: #dcfce7; color: var(--green); }
.act-reject { background: #fee2e2; color: var(--red); }
.act-risk { background: #ede9fe; color: var(--brand-2); }

/* 登录门禁 */
.login-mask { position: fixed; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 200; }
.login-mask.hide { display: none; }
.login-card { position: relative; width: 320px; background: #fff; border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.login-card .form { margin-top: 4px; }
.login-card .btn { width: 100%; }
.login-close { position: absolute; top: 10px; right: 12px; width: 32px; height: 32px; border: none; background: transparent; color: #94a3b8; font-size: 22px; line-height: 1; cursor: pointer; border-radius: 50%; transition: background .15s, color .15s; }
.login-close:hover { background: #f1f5f9; color: #475569; }

/* ===== 视频生产模块 ===== */
.field-group { display: flex; gap: 10px; align-items: flex-end; }
.field-group label { flex: 1; margin-bottom: 0; }
.field-group .btn { white-space: nowrap; }

.material-card { cursor: pointer; transition: .15s; }
.material-card:hover { box-shadow: 0 2px 10px rgba(15,23,42,.06); }
.material-card.picked { border-color: var(--brand); background: #eef2ff; }

.selected-materials { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.selected-tag { background: var(--brand); color: #fff; border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.selected-tag:hover { background: var(--brand-2); }

.upload-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
/* 背景风格选择：带动态渐变预览的小卡片 */
.vf-bg-presets { display:flex; gap:10px; flex-wrap:wrap; margin-top:8px; }
.vf-bg-chip { display:flex; flex-direction:column; align-items:center; width:86px; padding:5px 5px 8px; border:2px solid transparent; border-radius:12px; background:#fff; cursor:pointer; box-shadow:0 1px 3px rgba(0,0,0,.08); transition:box-shadow .15s, transform .15s, border-color .15s; position:relative; }
.vf-bg-chip .vf-bg-preview { width:74px; height:100px; border-radius:8px; overflow:hidden; position:relative; margin-bottom:6px; }
.vf-bg-chip .vf-bg-glow { position:absolute; width:220%; height:220%; top:-60%; left:-60%; background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.55), transparent 45%), radial-gradient(circle at 70% 70%, rgba(255,255,255,.25), transparent 40%); animation:vfBgMove 6s ease-in-out infinite alternate; pointer-events:none; }
.vf-bg-chip span { font-size:12px; color:#334155; font-weight:600; line-height:1.2; text-align:center; }
.vf-bg-chip:hover { transform:translateY(-2px); box-shadow:0 6px 16px rgba(0,0,0,.12); border-color:#cbd5e1; }
.vf-bg-chip:hover::after { content:attr(data-title); position:absolute; bottom:calc(100% + 6px); left:50%; transform:translateX(-50%); white-space:nowrap; background:rgba(15,23,42,.85); color:#fff; font-size:11px; padding:5px 9px; border-radius:6px; pointer-events:none; z-index:2; }
.vf-bg-chip.active { border-color:#5b8def; box-shadow:0 0 0 3px rgba(91,141,239,.25), 0 4px 12px rgba(91,141,239,.15); }
.vf-bg-chip.active span { color:#3b82f6; }
@keyframes vfBgMove { from { transform:translate(-18%,-18%) scale(1); } to { transform:translate(4%,4%) scale(1.08); } }
.thumb-wrap { position: relative; width: 80px; height: 80px; }
.thumb { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.thumb-del { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--red); color: #fff; border: 0; cursor: pointer; font-size: 12px; line-height: 1; }

.preview-box { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px; min-height: 80px; }

#videoForm .actions { flex-wrap: wrap; }
#videoForm .actions .btn { padding: 10px 16px; font-size: 14px; border-radius: 10px; }

audio#bgmPreview { border-radius: 10px; }

/* ===== 历史视频列表卡片 ===== */
.video-history-item { display:flex; gap:12px; align-items:center; padding:10px; border:1px solid var(--line); border-radius:12px; background:#fff; margin-bottom:10px; }
.vh-thumb-wrap { position:relative; width:120px; height:68px; flex-shrink:0; border-radius:8px; overflow:hidden; cursor:pointer; background:#f1f5f9; }
.vh-thumb { width:100%; height:100%; object-fit:cover; display:block; }
.vh-no-thumb { display:grid; place-items:center; color:#94a3b8; font-size:13px; }
.vh-play-icon { position:absolute; inset:0; display:grid; place-items:center; color:#fff; font-size:22px; text-shadow:0 1px 4px rgba(0,0,0,.4); pointer-events:none; opacity:.85; }
.vh-info { flex:1; min-width:0; }
.vh-title { font-weight:600; font-size:15px; margin-bottom:4px; color:#0f172a; }
.vh-meta { font-size:12px; color:#64748b; margin-bottom:8px; }
.vh-actions { display:flex; gap:8px; flex-wrap:wrap; }
.vh-actions .btn.small, .vh-actions .btn.secondary.small, .vh-actions .btn.danger.small { padding:5px 10px; font-size:12px; border-radius:6px; }
.vh-actions .btn.danger { background:#ef4444; color:#fff; border-color:#ef4444; }
.vh-actions .btn.danger:hover { background:#dc2626; }

/* ===== 价格卡片 ===== */
.price-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 10px; }
.price-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 10px; text-align: center; transition: .15s; }
.price-card:hover { box-shadow: var(--shadow); border-color: var(--brand); }
.price-card.best { border-color: var(--brand); background: linear-gradient(180deg, #fff, #f5f8ff); position: relative; }
.price-card.best::after { content: "推荐"; position: absolute; top: -1px; right: -1px; background: var(--brand); color: #fff; font-size: 10px; padding: 2px 8px; border-radius: 0 12px 0 8px; }
.price-card.trial { border-color: var(--green); }
.price-card .name { font-weight: 600; font-size: 14px; color: var(--ink); }
.price-card .price { font-size: 24px; font-weight: 800; color: var(--brand); margin: 8px 0 4px; line-height: 1; }
.price-card .price small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.price-card .desc { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ===== 移动端适配 ===== */
@media (max-width: 768px) {
  .app { display: flex; flex-direction: column; min-height: 100vh; }
  .sidebar { position: fixed; bottom: 0; left: 0; right: 0; top: auto; z-index: 100; flex-direction: row; padding: 6px 8px; gap: 4px; overflow-x: auto; height: auto; border-top: 1px solid rgba(255,255,255,.1); background: linear-gradient(180deg, #0f172a, #111827); }
  .brand, .side-meta { display: none; }
  .nav { flex-direction: row; gap: 4px; width: 100%; overflow-x: auto; }
  .nav button { flex: 1 0 auto; flex-direction: column; padding: 6px 8px; font-size: 11px; gap: 2px; text-align: center; min-width: 64px; }
  .nav button .ic { font-size: 16px; }
  .main { padding: 12px; padding-bottom: 90px; overflow-x: hidden; }
  .topbar { flex-wrap: wrap; gap: 8px; }
  .search { width: 100%; min-width: 0; }
  .grid, .grid-3, .split { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .row { flex-wrap: wrap; }
  .actions { flex-wrap: wrap; }
  .panel { padding: 12px; }
  .login-card { width: 92vw; max-width: 360px; margin: 0 auto; }
  .video-history-item { flex-direction: column; align-items: flex-start; gap: 10px; }
  .vh-thumb-wrap { width: 100%; height: 160px; }
  .vh-actions { width: 100%; }
  .price-cards { grid-template-columns: repeat(2, 1fr); }
  .price-card .price { font-size: 20px; }
  #videoForm .actions { flex-direction: column; }
  #videoForm .actions .btn { width: 100%; }
}
@media (max-width: 420px) {
  .price-cards { grid-template-columns: 1fr; }
  .nav button { font-size: 10px; min-width: 56px; }
}
/* 模块内二级 tab 切换（tab 栏在 section 顶部，不随 panel 隐藏） */
.module-tabbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.module-tabbar .tab-btn {
  background: #fff; border: 1px solid var(--line); padding: 7px 16px; margin: 0;
  font-size: 13px; color: var(--muted); cursor: pointer; border-radius: 999px;
  line-height: 1.4; font-family: inherit; transition: .15s; box-shadow: var(--shadow);
}
.module-tabbar .tab-btn:hover { color: var(--brand); border-color: var(--brand); }
.module-tabbar .tab-btn.active { color: #fff; background: var(--brand); border-color: var(--brand); font-weight: 600; }
