:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #17191c;
  --muted: #6b7280;
  --line: #e8eaee;
  --brand: #ff5a3c;
  --brand-2: #ff8a3d;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(20, 22, 28, .06);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 14px calc(36px + env(safe-area-inset-bottom));
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 2px 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 42px; height: 42px; flex: none;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-weight: 800; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(255, 90, 60, .28);
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: .2px; }
.topbar p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.badge {
  flex: none;
  font-size: 11px; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
}
.badge-ai { color: var(--ok); border-color: #bbf7d0; background: #f0fdf4; }
.badge-local { color: var(--warn); border-color: #fde68a; background: #fffbeb; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; font-size: 15.5px; font-weight: 650; flex: 1; }
.step {
  width: 24px; height: 24px; flex: none;
  border-radius: 8px; background: #f1f2f5; color: var(--muted);
  font-size: 12.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.step.ok { background: #dcfce7; color: var(--ok); }
.step.spin { animation: spin 1.1s linear infinite; background: #fff1ec; color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }
.hint { font-size: 12px; color: var(--muted); }
.tip { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

/* ---------------- 上传 ---------------- */
.uploader { display: block; cursor: pointer; }
.uploader-body {
  border: 1.5px dashed #d6d9e0;
  border-radius: 12px;
  padding: 26px 12px;
  text-align: center;
  color: var(--muted);
  background: #fafbfc;
  transition: .18s;
}
.uploader-body:active { background: #f2f4f7; border-color: var(--brand); }
.uploader-body strong { display: block; color: var(--text); font-size: 14px; margin: 6px 0 2px; }
.uploader-body span { font-size: 12px; }
.ico { width: 30px; height: 30px; fill: none; stroke: var(--brand); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.video-preview { width: 100%; border-radius: 12px; display: block; background: #000; max-height: 320px; }
.meta-row { margin-top: 10px; font-size: 12px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------------- 图片网格 ---------------- */
.grid-imgs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 8px;
}
.add-tile {
  aspect-ratio: 1/1;
  border: 1.5px dashed #d6d9e0;
  border-radius: 12px;
  background: #fafbfc;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--muted); font-size: 12px; cursor: pointer;
}
.add-tile:active { border-color: var(--brand); }
.img-tile { position: relative; aspect-ratio: 1/1; border-radius: 12px; overflow: hidden; background: #f0f1f4; }
.img-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-tile .del {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 13px; line-height: 1;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}

/* ---------------- 表单 ---------------- */
textarea, input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fafbfc;
  resize: vertical;
  outline: none;
}
textarea:focus, input[type="text"]:focus { border-color: var(--brand); background: #fff; }

.adv { margin-top: 12px; }
.adv summary { font-size: 13px; color: var(--muted); cursor: pointer; }
.adv-body { margin-top: 10px; display: flex; flex-direction: column; gap: 12px; }
.field span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.switch { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.switch input { width: 18px; height: 18px; accent-color: var(--brand); }

.btn-primary {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 15px;
  font-size: 16px; font-weight: 650; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 6px 18px rgba(255, 90, 60, .3);
  cursor: pointer;
  font-family: inherit;
}
.btn-primary:disabled { background: #dcdfe5; box-shadow: none; cursor: not-allowed; }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.form-tip { text-align: center; font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.form-tip.err { color: #dc2626; }

/* ---------------- 进度 ---------------- */
.bar { height: 8px; background: #f0f1f4; border-radius: 999px; overflow: hidden; }
.bar-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  border-radius: 999px; transition: width .4s ease;
}
.progress-msg { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.log { list-style: none; margin: 10px 0 0; padding: 0; max-height: 150px; overflow: auto; }
.log li { font-size: 12.5px; color: var(--muted); padding: 3px 0; border-top: 1px dashed var(--line); }
.log li b { color: var(--text); font-weight: 600; }

/* ---------------- 结果 ---------------- */
.player-wrap { border-radius: 12px; overflow: hidden; background: #000; }
#resultVideo { width: 100%; display: block; max-height: 420px; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btn-soft {
  flex: 1; min-width: 96px; text-align: center;
  border: 1px solid var(--line); background: #fff;
  border-radius: 11px; padding: 10px 8px;
  font-size: 13.5px; color: var(--text); text-decoration: none; cursor: pointer;
  font-family: inherit;
}
.btn-soft:active { background: #f4f5f7; }

.sub-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 10px; }
.sub-head h3 { margin: 0; font-size: 14px; font-weight: 650; }
.mini-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  font-size: 12px; padding: 4px 10px; color: var(--muted); cursor: pointer; font-family: inherit;
}
.grid-shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.shot {
  position: relative; border-radius: 12px; overflow: hidden; background: #f0f1f4;
  aspect-ratio: 9/16; cursor: pointer;
}
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot .no {
  position: absolute; left: 5px; top: 5px;
  background: rgba(0, 0, 0, .5); color: #fff;
  font-size: 11px; padding: 1px 6px; border-radius: 6px;
}
.shot .cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, .68));
  color: #fff; font-size: 11px; padding: 12px 6px 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.style-box { display: flex; flex-direction: column; gap: 10px; }
.style-row { display: flex; gap: 8px; font-size: 13px; }
.style-row .k { color: var(--muted); width: 62px; flex: none; }
.style-row .v { flex: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 11.5px; padding: 3px 9px; border-radius: 999px; background: #f2f4f7; color: #4b5563; }
.palette { display: flex; gap: 6px; }
.swatch { width: 26px; height: 26px; border-radius: 8px; border: 1px solid rgba(0, 0, 0, .08); }

.script { margin: 0; padding-left: 20px; font-size: 13px; color: #374151; }
.script li { padding: 4px 0; }
.script li em { color: var(--muted); font-style: normal; font-size: 12px; }

.warn-box {
  margin-top: 12px; padding: 10px 12px;
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px;
  font-size: 12.5px; color: #92400e;
}

.foot { text-align: center; font-size: 11.5px; color: #9aa1ac; margin-top: 22px; }

/* ---------------- 图片预览 ---------------- */
.lightbox {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .9);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }

@media (min-width: 700px) {
  body { font-size: 15.5px; }
  .app { padding-top: 28px; }
}
