:root {
  --bg: #f6f6f8;
  --card: #ffffff;
  --text: #1c1c22;
  --muted: #6b6b76;
  --line: #dcdce3;
  --accent: #ff4d6d;
  --accent-text: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111114;
    --card: #1c1c21;
    --text: #ececf1;
    --muted: #9a9aa6;
    --line: #33333b;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
header, main, footer {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
}
header { padding-top: 40px; text-align: center; }
h1 { margin: 0; font-size: 32px; }
.sub { color: var(--muted); margin: 8px 0 28px; }

form, .result {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
}
.pickers {
  display: flex;
  align-items: center;
  gap: 12px;
}
.picker { flex: 1; cursor: pointer; }
.preview {
  aspect-ratio: 3 / 4;
  border: 2px dashed var(--line);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  background: var(--bg);
  transition: border-color .15s;
}
.picker:hover .preview { border-color: var(--accent); }
.preview img { width: 100%; height: 100%; object-fit: cover; }
.preview b { color: var(--text); }
.arrow { font-size: 24px; color: var(--muted); }

.consent {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 18px 0;
  font-size: 13px;
  color: var(--muted);
}
.consent input { margin-top: 3px; }

button, .btn {
  display: inline-block;
  border: 0;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
  text-align: center;
}
#submit { width: 100%; }
button:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }

.status { min-height: 1.5em; margin: 10px 0 0; text-align: center; color: var(--muted); font-size: 14px; }
.status.error { color: var(--accent); }

.result { margin-top: 20px; text-align: center; }
.result img { max-width: 100%; border-radius: 12px; }
.actions { display: flex; gap: 12px; justify-content: center; margin-top: 16px; }

footer { text-align: center; color: var(--muted); font-size: 12px; padding: 32px 16px; }

@media (max-width: 480px) {
  .arrow { font-size: 18px; }
  .pickers { gap: 8px; }
  h1 { font-size: 26px; }
}

.preview video { width: 100%; height: 100%; object-fit: cover; }
.preview small { display: block; margin-top: 6px; font-size: 12px; opacity: .8; }
.modes { display: flex; gap: 20px; justify-content: center; margin-top: 18px; font-size: 14px; }
.modes label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 10px; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width 1s linear; }
.result video { max-width: 100%; max-height: 70vh; border-radius: 12px; background: #000; }
.engines { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.engine { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 14px; }
.engine:has(input:checked) { border-color: var(--accent); }
.engine input { display: none; }
.engine small { color: var(--muted); font-size: 12px; }
.prompt { margin-top: 12px; }
.prompt textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font: inherit; font-size: 14px; background: var(--bg); color: var(--text); resize: vertical; }
@media (max-width: 480px) { .engines { grid-template-columns: 1fr; } }
.step { font-size: 15px; margin: 18px 0 10px; }
.step:first-child { margin-top: 0; }
.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.template { position: relative; border: 2px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text); overflow: hidden; cursor: pointer; font-size: 13px; font-weight: 500; text-align: center; }
.template video { display: block; width: 100%; aspect-ratio: 9 / 16; object-fit: cover; background: #000; }
.template span { display: block; padding: 6px 4px; }
.template.active { border-color: var(--accent); }
.template.active::after { content: "✓ 已选"; position: absolute; top: 6px; left: 6px; background: var(--accent); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 6px; }
.template .play { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; cursor: pointer; }
.template .play:hover { background: var(--accent); }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.lightbox-box { position: relative; background: var(--card); border-radius: 16px; padding: 20px; max-width: 720px; width: 100%; text-align: center; }
.lightbox-close { position: absolute; top: 8px; right: 12px; border: 0; background: none; font-size: 28px; color: var(--muted); cursor: pointer; }
.lightbox-videos { display: flex; gap: 16px; justify-content: center; margin: 10px 0 16px; }
.lightbox-videos figure { margin: 0; flex: 1; max-width: 300px; }
.lightbox-videos video { width: 100%; max-height: 60vh; border-radius: 10px; background: #000; }
.lightbox-videos figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; }

.pickers .picker { max-width: 200px; }
@media (max-width: 480px) { .lightbox-videos { flex-direction: column; align-items: center; } .lightbox-videos video { max-height: 40vh; } }
.own { margin-top: 12px; font-size: 14px; color: var(--muted); }
.own summary { cursor: pointer; }
.own .picker { display: block; max-width: 200px; margin-top: 10px; }
.muted { color: var(--muted); font-size: 14px; }

.lightbox[hidden], [hidden] { display: none !important; }
.enhance { display: flex; flex-direction: column; gap: 6px; max-width: 200px; }
.enhance .preview { flex: 1; }
.use-enhanced { font-size: 13px; display: flex; gap: 6px; align-items: center; cursor: pointer; }
.tip { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
