/* AI 短视频创作智能体 - H5 样式（手机优先） */
:root {
  --primary: #6d4df5;
  --primary-dark: #5836e8;
  --primary-light: #efeaff;
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1c1e29;
  --text-sub: #7a7f92;
  --border: #e8e9f0;
  --success: #22b573;
  --danger: #f5484d;
  --warning: #ff9f2e;
  --radius: 14px;
  --shadow: 0 4px 16px rgba(60, 50, 130, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { height: auto; }

body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ===== 布局骨架 ===== */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.app-header {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(135deg, #6d4df5, #9a5cf0);
  color: #fff;
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 10px rgba(109, 77, 245, 0.3);
}
.app-header .h-title { font-size: 17px; font-weight: 700; }
.app-header .h-right { display: flex; align-items: center; gap: 10px; }
.app-header .h-action {
  background: rgba(255,255,255,0.18); border: none; color: #fff;
  padding: 5px 12px; border-radius: 20px; font-size: 12px; cursor: pointer;
}
.mode-badge {
  font-size: 11px; padding: 3px 10px; border-radius: 20px;
  background: rgba(255,255,255,0.2); color: #fff;
}
.mode-badge.real { background: #22b573; }

.app-main {
  flex: 1; width: 100%; max-width: 560px; margin: 0 auto;
  padding: 14px 14px calc(70px + env(safe-area-inset-bottom));
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.app-tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: center;
  background: #fff; border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-inner { display: flex; width: 100%; max-width: 560px; }
.tab-item {
  flex: 1; text-align: center; padding: 8px 0 10px; cursor: pointer;
  color: var(--text-sub); font-size: 11px; text-decoration: none;
}
.tab-item .t-icon { font-size: 20px; display: block; line-height: 1.3; }
.tab-item.active { color: var(--primary); font-weight: 600; }

/* ===== 通用组件 ===== */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.card-desc { font-size: 12px; color: var(--text-sub); margin-bottom: 12px; }

.step-tag {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary-light); color: var(--primary);
  font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.step-tag.done { background: var(--success); color: #fff; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: linear-gradient(135deg, var(--primary), #9a5cf0);
  color: #fff; border: none; border-radius: 24px;
  padding: 11px 22px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: opacity 0.15s;
  -webkit-user-select: none; user-select: none;
}
.btn:active { opacity: 0.85; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-ghost { background: var(--primary-light); color: var(--primary); }
.btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 18px; }
.btn-danger { background: #ffecec; color: var(--danger); }

.input, .textarea {
  width: 100%; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 11px 12px; font-size: 14px; font-family: inherit;
  background: #fafafd; color: var(--text); outline: none;
  transition: border-color 0.15s;
}
.input:focus, .textarea:focus { border-color: var(--primary); }
.textarea { min-height: 120px; resize: vertical; line-height: 1.7; }
.textarea.compact { min-height: 72px; }

.field-label { font-size: 12px; color: var(--text-sub); margin: 10px 0 6px; display: block; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  padding: 5px 12px; border-radius: 18px; font-size: 12px;
  background: var(--primary-light); color: var(--primary); cursor: pointer;
}
.chip.selected { background: var(--primary); color: #fff; }
.chip.static { cursor: default; }
.chip .chip-x { margin-left: 4px; opacity: 0.7; }

.empty {
  text-align: center; color: var(--text-sub); padding: 40px 20px; font-size: 13px;
}
.empty .e-icon { font-size: 40px; margin-bottom: 10px; }

.loading-screen { text-align: center; padding: 80px 0; color: var(--text-sub); }
.loading-spinner {
  width: 32px; height: 32px; margin: 0 auto 12px;
  border: 3px solid var(--primary-light); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 14px; height: 14px; display: inline-block; flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}

/* ===== 任务进度 ===== */
.task-panel {
  margin-top: 12px; background: #f8f7ff; border-radius: 10px; padding: 12px;
}
.task-progress-bar {
  height: 6px; background: #e6e2fb; border-radius: 3px; overflow: hidden; margin-bottom: 10px;
}
.task-progress-bar .bar {
  height: 100%; background: linear-gradient(90deg, var(--primary), #9a5cf0);
  border-radius: 3px; transition: width 0.4s;
}
.task-steps { display: flex; flex-direction: column; gap: 7px; }
.task-step { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-sub); }
.task-step .s-dot {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-size: 10px;
  background: #e3e4ec; color: #fff;
}
.task-step.running { color: var(--primary); font-weight: 600; }
.task-step.running .s-dot { background: var(--primary); animation: pulse 1.2s infinite; }
.task-step.success { color: var(--text); }
.task-step.success .s-dot { background: var(--success); }
.task-step.failed { color: var(--danger); }
.task-step.failed .s-dot { background: var(--danger); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.task-error {
  margin-top: 8px; font-size: 12.5px; color: var(--danger);
  background: #fff2f2; padding: 8px 10px; border-radius: 8px;
}
.task-notice {
  margin-top: 8px; font-size: 11.5px; color: #a07b2c;
  background: #fff8e8; padding: 7px 10px; border-radius: 8px; line-height: 1.5;
}

/* ===== 向导步骤条 ===== */
.wizard-nav {
  display: flex; gap: 4px; margin-bottom: 12px; overflow-x: auto; padding: 2px;
}
.wizard-nav .w-step {
  flex: 1; min-width: 44px; text-align: center; padding: 6px 2px;
  font-size: 10.5px; color: var(--text-sub); border-radius: 8px;
  background: #fff; cursor: pointer; white-space: nowrap;
}
.wizard-nav .w-step.current { background: var(--primary); color: #fff; font-weight: 600; }
.wizard-nav .w-step.done { color: var(--success); }

/* ===== 项目选择条 ===== */
.project-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; overflow-x: auto; }
.project-chip {
  flex-shrink: 0; padding: 7px 14px; border-radius: 20px; font-size: 12.5px;
  background: #fff; color: var(--text-sub); border: 1.5px solid var(--border); cursor: pointer;
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.project-chip.active { border-color: var(--primary); color: var(--primary); font-weight: 600; }
.project-chip.new { border-style: dashed; color: var(--primary); }

/* ===== 素材选择器 ===== */
.asset-picker { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; }
.asset-item {
  flex-shrink: 0; width: 96px; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 8px; cursor: pointer; background: #fafafd; text-align: center;
}
.asset-item.selected { border-color: var(--primary); background: var(--primary-light); }
.asset-item .a-icon { font-size: 22px; }
.asset-item .a-name {
  font-size: 11px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.asset-item .a-sub { font-size: 10px; color: var(--text-sub); }
.asset-add {
  flex-shrink: 0; width: 96px; border: 1.5px dashed var(--border); border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-sub); font-size: 11px; cursor: pointer; min-height: 74px;
}
.asset-add .a-icon { font-size: 22px; }

.media-preview { margin-top: 10px; border-radius: 10px; overflow: hidden; background: #000; }
.media-preview video, .media-preview audio { width: 100%; display: block; }

/* ===== 素材库列表 ===== */
.asset-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.asset-row:last-child { border-bottom: none; }
.asset-row .ar-icon { font-size: 24px; width: 34px; text-align: center; }
.asset-row .ar-info { flex: 1; min-width: 0; }
.asset-row .ar-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-row .ar-sub { font-size: 11px; color: var(--text-sub); }
.asset-row .ar-actions { display: flex; gap: 6px; }
.icon-btn {
  border: none; background: var(--primary-light); color: var(--primary);
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn.del { background: #ffecec; color: var(--danger); }

/* ===== 作品网格 ===== */
.works-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.work-card {
  background: #fff; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); cursor: pointer; text-decoration: none; color: var(--text);
  display: block;
}
.work-card .w-cover {
  width: 100%; aspect-ratio: 9/12; background: #e9e9f2; object-fit: cover; display: block;
}
.work-card .w-cover-placeholder {
  width: 100%; aspect-ratio: 9/12; background: linear-gradient(135deg, #6d4df5, #9a5cf0);
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 30px;
}
.work-card .w-info { padding: 10px 12px 12px; }
.work-card .w-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.work-card .w-sub { font-size: 11px; color: var(--text-sub); margin-top: 3px; }

/* ===== 发布页 ===== */
.publish-video { width: 100%; border-radius: var(--radius); overflow: hidden; background: #000; margin-bottom: 12px; }
.publish-video video { width: 100%; display: block; max-height: 60vh; }
.copy-box {
  background: #f8f7ff; border-radius: 10px; padding: 12px; font-size: 13px;
  line-height: 1.7; word-break: break-all; margin-top: 8px;
}
.platform-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 0; border-bottom: 1px solid var(--border);
}
.platform-row:last-child { border-bottom: none; }
.platform-row .p-name { font-weight: 600; font-size: 14px; }
.platform-row .p-hint { font-size: 11px; color: var(--text-sub); }
.platform-row .p-check { transform: scale(1.2); accent-color: var(--primary); }

/* ===== 登录页 ===== */
.login-wrap { padding-top: 10vh; }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .l-icon {
  width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 20px;
  background: linear-gradient(135deg, #6d4df5, #9a5cf0);
  display: flex; align-items: center; justify-content: center; font-size: 34px;
  box-shadow: 0 8px 24px rgba(109, 77, 245, 0.35);
}
.login-logo .l-title { font-size: 20px; font-weight: 800; }
.login-logo .l-sub { font-size: 12px; color: var(--text-sub); margin-top: 4px; }

/* ===== Toast/Modal ===== */
.toast-layer { position: fixed; top: 60px; left: 0; right: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: rgba(28, 30, 41, 0.92); color: #fff; padding: 10px 20px;
  border-radius: 22px; font-size: 13px; max-width: 80vw;
  animation: toastIn 0.25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.modal-layer {
  position: fixed; inset: 0; z-index: 150; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; padding: 30px;
}
  .modal-layer[hidden] { display: none !important;}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 340px; overflow: hidden;
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: none; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 15px;
}
.modal-header .h-action { background: none; border: none; font-size: 15px; cursor: pointer; color: var(--text-sub); }
.modal-body { padding: 16px; max-height: 60vh; overflow-y: auto; }
.modal-footer { display: flex; gap: 10px; padding: 0 16px 16px; }
.modal-footer .btn { flex: 1; }

/* 上传进度条 */
.upload-progress { font-size: 11px; color: var(--primary); margin-top: 4px; }
