:root {
  --bg: #f5f6f8;
  --bg-card: #ffffff;
  --text: #1a1d24;
  --text-sub: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff4ff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; -webkit-font-smoothing: antialiased; }

.app { max-width: 1080px; margin: 0 auto; padding: 0 20px 60px; }

/* ─── 顶栏 ─── */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 20px 0; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff; font-size: 20px; font-weight: 700; flex-shrink: 0; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.3; }
.brand-name { font-size: 18px; font-weight: 700; }
.brand-sub { font-size: 12px; color: var(--text-sub); }

/* ─── 按钮 ─── */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 10px 18px; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid transparent; transition: all .18s ease;
  text-decoration: none; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--text-sub); border-color: var(--border); }
.btn-ghost:hover { background: #f0f1f3; color: var(--text); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-spinner { display: none; }
.btn.loading .btn-spinner { display: block; animation: spin 1s linear infinite; }
.btn.loading .btn-label { opacity: .7; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── 分类 tab ─── */
.tabs { display: flex; gap: 10px; margin: 4px 0 14px; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 14px 12px; border-radius: 14px; background: var(--bg-card); border: 2px solid var(--border);
  cursor: pointer; transition: all .18s ease; }
.tab .tab-icon { font-size: 26px; }
.tab .tab-name { font-size: 15px; font-weight: 700; }
.tab .tab-desc { font-size: 11px; color: var(--text-sub); }
.tab:hover { border-color: #c7d6f7; }
.tab.active { border-color: var(--primary); background: var(--primary-soft); box-shadow: var(--shadow); }

/* ─── 状态条 ─── */
.status-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; min-height: 20px; }
.status-chip { font-size: 12px; padding: 4px 10px; border-radius: 20px; background: #fff; border: 1px solid var(--border); color: var(--text-sub); }
.status-chip.ok { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.status-chip.warn { background: #fffbeb; border-color: #fde68a; color: #b45309; }

/* ─── 面板 ─── */
.space-panel, .role-panel, .gen-panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-title { font-size: 16px; font-weight: 700; }
.panel-hint { font-size: 12px; color: var(--text-sub); }

/* ─── 横向时间线 ─── */
.timeline { position: relative; overflow-x: auto; overflow-y: hidden; scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch; padding: 8px 0 12px; }
.timeline::-webkit-scrollbar { height: 6px; }
.timeline::-webkit-scrollbar-thumb { background: #d3d7dd; border-radius: 3px; }
.timeline-track { display: flex; gap: 14px; align-items: center; width: max-content; padding: 0 42%; }
.timeline::before, .timeline::after { content: ""; position: absolute; top: 0; bottom: 0; width: 34px; z-index: 2; pointer-events: none; }
.timeline::before { left: 0; background: linear-gradient(90deg, var(--bg-card), transparent); }
.timeline::after { right: 0; background: linear-gradient(-90deg, var(--bg-card), transparent); }

.tl-card { position: relative; width: 168px; flex-shrink: 0; border-radius: 14px; overflow: hidden;
  cursor: pointer; border: 2px solid transparent; transition: all .2s ease; background: #000; }
.tl-card .thumb { width: 100%; height: 298px; object-fit: cover; display: block; }
.tl-card .tl-time { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.6); color: #fff;
  font-size: 11px; padding: 2px 8px; border-radius: 6px; }
.tl-card .tl-play { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.28); opacity: 0; transition: opacity .2s; }
.tl-card .tl-play span { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.92); display: grid; place-items: center; font-size: 18px; color: #1a1d24; }
.tl-card:hover .tl-play { opacity: 1; }
.tl-card.active { border-color: var(--primary); transform: scale(1.04); box-shadow: var(--shadow-lg); }
.tl-card .tl-title { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 10px 8px; font-size: 12px; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.78)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-loading { width: 40px; flex-shrink: 0; display: grid; place-items: center; color: var(--text-sub); font-size: 20px; }
.tl-loading .spinner { animation: spin 1s linear infinite; }

/* ─── 角色选择 ─── */
.role-track { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
.role-track::-webkit-scrollbar { height: 5px; }
.role-card { position: relative; width: 116px; flex-shrink: 0; cursor: pointer; text-align: center; }
.role-card .avatar { width: 92px; height: 92px; border-radius: 50%; object-fit: cover; margin: 0 auto 8px;
  border: 3px solid var(--border); transition: all .18s ease; display: block; }
.role-card .rname { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-card .rtags { font-size: 11px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-card .check { position: absolute; top: 2px; right: 10px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); color: #fff; display: none; place-items: center; font-size: 12px; }
.role-card.selected .avatar { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.role-card.selected .check { display: grid; }
.role-card.selected .rname { color: var(--primary); }
.role-badge { display: inline-block; font-size: 10px; color: #fff; background: var(--primary); border-radius: 4px; padding: 1px 5px; margin-left: 4px; vertical-align: 1px; }

/* ─── 生成区 ─── */
.gen-panel { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.gen-current { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.gen-label { font-size: 12px; color: var(--text-sub); background: #f0f1f3; padding: 2px 8px; border-radius: 6px; }
.gen-role { font-size: 16px; font-weight: 700; }
.gen-desc { font-size: 13px; color: var(--text-sub); }
.btn-gen { padding: 14px 26px; font-size: 15px; }

/* ─── 生成进度 ─── */
.progress-card { padding: 6px 0; }
.progress-head { display: flex; justify-content: space-between; margin-bottom: 10px; }
.progress-title { font-weight: 600; }
.progress-status { font-size: 13px; color: var(--primary); }
.progress-bar { height: 8px; border-radius: 4px; background: #eef0f3; overflow: hidden; }
.progress-fill { height: 100%; width: 20%; border-radius: 4px; background: linear-gradient(90deg, #2563eb, #7c3aed); transition: width .5s ease; animation: loading 1.6s ease-in-out infinite; }
@keyframes loading { 0% { width: 8%; } 50% { width: 72%; } 100% { width: 92%; } }
.progress-result video { width: 100%; max-width: 320px; aspect-ratio: 9/16; border-radius: 12px; background: #000; margin: 14px auto; display: block; }
.result-actions { display: flex; gap: 10px; justify-content: center; }

/* ─── 播放遮罩 ─── */
.player-mask { position: fixed; inset: 0; background: rgba(0,0,0,.82); z-index: 100; display: flex; align-items: center; justify-content: center; }
.player-box { position: relative; width: min(90vw, 360px); }
.player-box video { width: 100%; aspect-ratio: 9/16; background: #000; border-radius: 12px; display: block; }
.player-caption { color: #fff; text-align: center; padding: 12px 4px; font-size: 14px; }
.player-close { position: absolute; top: -38px; right: 0; width: 34px; height: 34px; border-radius: 50%; border: none; background: rgba(255,255,255,.15); color: #fff; font-size: 16px; cursor: pointer; }

/* ─── 弹窗 ─── */
.modal { position: fixed; inset: 0; z-index: 90; }
.modal-mask { position: absolute; inset: 0; background: rgba(16,24,40,.5); }
.modal-card { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(92vw, 460px);
  background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 0; }
.modal-head h3 { font-size: 16px; }
.modal-close { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--text-sub); }
.modal-body { padding: 14px 20px; max-height: 64vh; overflow-y: auto; }
.modal-desc { font-size: 13px; color: var(--text-sub); margin-bottom: 14px; }
.field-label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
.field-input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; font-family: inherit; }
.field-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.preview { margin-top: 10px; }
.preview img { width: 100%; max-height: 200px; object-fit: contain; border-radius: 10px; border: 1px solid var(--border); }
.or-divider { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--text-sub); font-size: 12px; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.modal-note { font-size: 12px; color: var(--text-sub); margin-top: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px 18px; border-top: 1px solid var(--border); }

/* ─── 通用 ─── */
.hidden { display: none !important; }
.footer { text-align: center; font-size: 12px; color: var(--text-sub); padding: 24px 0 8px; }

@media (max-width: 720px) {
  .brand-sub { display: none; }
  .gen-panel { flex-direction: column; align-items: stretch; }
  .btn-gen { width: 100%; justify-content: center; }
  .tab .tab-desc { display: none; }
}

/* ─── 勾选删除 ─── */
.panel-head-actions { display: flex; align-items: center; gap: 12px; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-danger:disabled { opacity: .6; cursor: not-allowed; }
.card-check {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid #fff; background: rgba(0,0,0,.35);
  color: #fff; font-size: 14px; line-height: 1;
  display: grid; place-items: center; cursor: pointer;
  transition: all .15s ease; padding: 0;
}
.card-check.on { background: var(--primary); border-color: var(--primary); }
.tl-card.checked { border-color: #ef4444; }
