:root {
  --bg: #f8f9fb;
  --panel: #ffffff;
  --border: #e1e4e8;
  --text: #1a1a2e;
  --muted: #6b7280;
  --accent: #4f6ef6;
  --success: #22c55e;
  --error: #ef4444;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.topbar h1 { font-size: 18px; margin: 0; }

.badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fcd34d;
}
.hidden { display: none !important; }

/* main 样式已迁移到 .app-layout main */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.panel h2 { margin-top: 0; font-size: 16px; }
.muted { color: var(--muted); font-size: 13px; }

textarea {
  width: 100%;
  min-height: 80px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  resize: vertical;
}

.row { display: flex; gap: 20px; margin: 14px 0; flex-wrap: wrap; }
.row label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 220px;
}

.btn {
  display: inline-block;
  padding: 9px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #e5e7eb;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; font-weight: 600; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.status { margin-top: 10px; font-size: 13px; color: var(--muted); min-height: 18px; }
.status.error { color: var(--error); }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}
.actions { display: flex; gap: 10px; }

.scenes-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.scene-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.scene-card .thumb {
  aspect-ratio: 9/16;
  background: #e5e7eb url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><rect width="24" height="24" fill="none"/></svg>') center/40% no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}
.scene-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scene-card .body { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.scene-card .idx { font-size: 11px; color: var(--muted); }
.scene-card textarea.narration {
  width: 100%; min-height: 50px; font-size: 12.5px;
  background: #fff; color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px; resize: vertical;
}
.scene-card .field-label {
  font-size: 11px; color: var(--muted); margin-top: 4px;
}
.scene-card .prompt {
  width: 100%; min-height: 120px; font-size: 11.5px; color: var(--text);
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 8px; resize: vertical; line-height: 1.5;
}
.scene-card .prompt:focus { outline: none; border-color: var(--accent); }
.scene-card .btn-row { display: flex; gap: 6px; margin-top: auto; }
.scene-card .btn-row .btn { flex: 1; padding: 6px 8px; font-size: 12px; text-align: center; }
.scene-card audio { width: 100%; height: 32px; margin-top: 4px; }

.scene-card .duration-row {
  font-size: 11px;
  color: var(--muted);
  background: #eef2ff;
  padding: 4px 8px;
  border-radius: 6px;
  margin-top: 2px;
}

.scene-card .narration-list { display: flex; flex-direction: column; gap: 8px; }
.scene-card .narration-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.scene-card .narration-item .narration {
  min-height: 46px;
  background: transparent;
  border: none;
  padding: 0;
  font-size: 12.5px;
}
.scene-card .narration-item .narration:focus { outline: none; }
.scene-card .narration-meta {
  font-size: 10px;
  color: var(--muted);
}
.scene-card .narration-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scene-card .narration-remove:disabled { opacity: 0.3; cursor: not-allowed; }
.scene-card .btn-small {
  padding: 5px 10px;
  font-size: 12px;
  align-self: flex-start;
}

.tag { font-size: 10px; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--border); }
.tag.idle { color: var(--muted); }
.tag.generating { color: #b45309; border-color: #fcd34d; background: #fef3c7; }
.tag.done { color: #15803d; border-color: #86efac; background: #dcfce7; }
.tag.error { color: #b91c1c; border-color: #fca5a5; background: #fee2e2; }

video { width: 100%; max-width: 420px; border-radius: 10px; background: #000; display: block; margin-bottom: 12px; }

/* ---------- 新版输入卡片（参考图 + 文件 + 模型/参数选择） ---------- */
.input-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.input-media-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 72px;
}

.image-upload-btn {
  width: 68px;
  height: 68px;
  flex-shrink: 0;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--panel);
  color: var(--muted);
}
.image-upload-btn:hover { border-color: var(--accent); background: #f3f4f6; color: var(--accent); }
.image-upload-btn .image-icon { width: 24px; height: 24px; }
.image-upload-btn span { font-size: 12px; }

.image-preview-list {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.image-preview-list:empty { display: none; }

.image-preview-thumb {
  width: 68px;
  height: 68px;
  border-radius: 10px;
  position: relative;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--bg);
}
.image-preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 10px;
}
.image-preview-thumb .remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1.5px solid #fff;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  z-index: 1;
}
.image-preview-thumb .remove:hover { background: var(--error); }

.input-box textarea {
  width: 100%;
  min-height: 90px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  resize: none;
  padding: 0;
  margin: 0;
}
.input-box textarea::placeholder { color: #a1a1aa; }
.input-box textarea:focus { outline: none; }

.input-card-attachments {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.attachment-trigger {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.attachment-trigger:hover { background: #f3f4f6; border-color: var(--accent); }

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text);
}
.attachment-chip .remove {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}
.attachment-chip .remove:hover { color: var(--error); }

.input-card-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.toolbar-spacer { flex: 1; }
.voice-preview-group, .bgm-preview-group { display: flex; align-items: center; gap: 6px; }
.volume-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.volume-control input[type="range"] {
  width: 90px;
  accent-color: var(--accent);
}
.volume-control span:first-child { min-width: 66px; }
.volume-control span:last-child { min-width: 38px; text-align: right; }
.btn-small {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
}
.btn-small:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-small:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }
.toolbar-select {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  min-width: 110px;
  cursor: pointer;
}
.toolbar-select option { background: var(--panel); color: var(--text); }
.toolbar-generate {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 13px;
}

#inputPanel.panel {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}



/* ---------- 字幕设置 ---------- */
.subtitle-settings {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.settings-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: block;
}
.settings-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.settings-row label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.settings-row .toolbar-select {
  min-width: auto;
  width: auto;
  padding: 5px 8px;
  font-size: 12px;
}
.color-input {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  padding: 2px;
  background: var(--panel);
}
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border-radius: 4px; border: none; }
.bg-check { cursor: pointer; }
.bg-check input { cursor: pointer; }

/* ===== 任务管理侧边栏 ===== */
.app-layout {
  display: flex;
  gap: 0;
  min-height: calc(100vh - 65px);
}

.task-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: width 0.25s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s, background 0.15s, transform 0.3s;
}
.sidebar-toggle:hover { color: var(--text); background: #f3f4f6; }

.sidebar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.sidebar-new-btn {
  padding: 5px 12px;
  font-size: 12px;
}

.project-list {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.project-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}
.project-item:hover { background: #f3f4f6; }
.project-item.active {
  background: #eef2ff;
  border-color: var(--accent);
}

.project-item-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  background: #e5e7eb;
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.project-item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.project-item-thumb .no-thumb {
  font-size: 20px;
  color: var(--muted);
}

.project-item-info {
  flex: 1;
  min-width: 0;
}

.project-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
  line-height: 1.3;
}

.project-item-meta {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.project-item-status {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid;
}
.project-item-status.pending { color: #92400e; border-color: #fcd34d; background: #fef3c7; }
.project-item-status.scripting { color: #0369a1; border-color: #7dd3fc; background: #e0f2fe; }
.project-item-status.ready { color: #6b21a8; border-color: #d8b4fe; background: #f3e8ff; }
.project-item-status.generating { color: #b45309; border-color: #fcd34d; background: #fef3c7; }
.project-item-status.composing { color: #92400e; border-color: #fcd34d; background: #fef3c7; }
.project-item-status.done { color: #15803d; border-color: #86efac; background: #dcfce7; }
.project-item-status.error { color: #b91c1c; border-color: #fca5a5; background: #fee2e2; }

.project-item-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-end;
}

.project-item-delete {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.project-item:hover .project-item-delete { opacity: 1; }
.project-item-delete:hover { color: var(--error); background: #fee2e2; }

.task-sidebar-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

/* 侧边栏折叠状态 */
.task-sidebar.collapsed {
  width: 44px;
  min-width: 44px;
}
.task-sidebar.collapsed .sidebar-title,
.task-sidebar.collapsed .sidebar-new-btn,
.task-sidebar.collapsed .project-list,
.task-sidebar.collapsed .project-item-info,
.task-sidebar.collapsed .project-item-actions,
.task-sidebar.collapsed .project-item-thumb {
  display: none;
}
.task-sidebar.collapsed .sidebar-header {
  padding: 12px 8px;
  justify-content: center;
}
.task-sidebar.collapsed .sidebar-toggle {
  transform: rotate(180deg);
}

.app-layout main {
  flex: 1;
  min-width: 0;
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ---------- 顶部用户信息 ---------- */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-balance {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  background: #eef2ff;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.user-balance .currency { font-size: 12px; margin-right: 2px; }

.user-name {
  font-size: 13px;
  color: var(--muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-content {
  position: relative;
  background: var(--panel);
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  z-index: 1;
}

.modal-content.modal-small { max-width: 360px; }
.modal-content.modal-wide { max-width: 680px; max-height: 80vh; display: flex; flex-direction: column; }

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

.modal-content h3 { margin: 0 0 18px; font-size: 18px; }

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-row label {
  font-size: 13px;
  color: var(--muted);
}

.form-row input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}

.form-row input:focus { outline: none; border-color: var(--accent); }

.modal-actions { margin-top: 8px; }
.modal-actions .btn { width: 100%; }

.modal-switch {
  margin-top: 14px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  margin-left: 4px;
}
.btn-link:hover { text-decoration: underline; }

.btn-logout {
  color: var(--error);
  border-color: transparent;
  background: transparent;
}
.btn-logout:hover { background: #fef2f2; }

.recharge-hint {
  font-size: 12px;
  color: var(--muted);
  margin: -8px 0 14px;
}

.recharge-amount-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.recharge-amount-btn {
  flex: 1 1 calc(20% - 8px);
  min-width: 52px;
  padding: 8px 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.recharge-amount-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.recharge-amount-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- 流水明细表 ---------- */
.transactions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 8px;
  overflow-y: auto;
}

.transactions-table th,
.transactions-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.transactions-table th {
  color: var(--muted);
  font-weight: 600;
  background: var(--bg);
}

.transactions-table .empty {
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

.transactions-table .type-recharge { color: var(--success); }
.transactions-table .type-consume { color: var(--error); }
.transactions-table .type-refund { color: var(--accent); }

/* 类型、变动、余额列禁止换行 */
.transactions-table th:nth-child(2),
.transactions-table th:nth-child(3),
.transactions-table th:nth-child(4),
.transactions-table td:nth-child(2),
.transactions-table td:nth-child(3),
.transactions-table td:nth-child(4) {
  white-space: nowrap;
}

/* 合成进度条 */
.compose-progress {
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.compose-progress-bar {
  width: 100%;
  height: 10px;
  background: #e5e7eb;
  border-radius: 5px;
  overflow: hidden;
}
.compose-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 5px;
  width: 0%;
  transition: width 0.3s ease;
}
.compose-progress-text {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
