: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; }

.preview { position: relative; }
.preview .zoom { position: absolute; right: 6px; bottom: 6px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 14px; cursor: pointer; display: none; }
.preview:hover .zoom, .enhanced .zoom { display: block; }
.enhanced img { cursor: zoom-in; }
.imgbox-box { position: relative; background: var(--card); border-radius: 16px; padding: 20px; max-width: 92vw; max-height: 92vh; text-align: center; }
.imgbox-box img { max-width: 100%; max-height: 80vh; border-radius: 10px; object-fit: contain; }
.imgbox-box p { margin: 10px 0 0; }

.tips { margin: 10px 0 0; padding-left: 18px; font-size: 12px; color: var(--muted); line-height: 1.7; }

.history { margin-top: 20px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.history .step small { font-weight: 400; font-size: 12px; margin-left: 8px; }
.history-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.work { display: flex; gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--bg); }
.work video, .work-thumb { width: 72px; height: 128px; border-radius: 8px; object-fit: cover; background: #000; flex: none; }
.work-thumb { display: flex; align-items: center; justify-content: center; font-size: 26px; color: #fff; }
.work-thumb.wait { background: #6b6b76; animation: pulse 1.5s infinite; }
.work-thumb.bad { background: var(--accent); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
.work-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 13px; }
.work-info b { font-size: 14px; }
.work-info span { color: var(--muted); }
.work-info small { color: var(--accent); font-size: 12px; }
.work-actions { display: flex; gap: 8px; margin-top: auto; }
.btn.small { padding: 6px 12px; font-size: 13px; }

.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: 2px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 14px; }
.engine:has(input:checked) { border-color: var(--accent); }
.engine:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.engine input { display: none; }
.engine small { color: var(--muted); font-size: 12px; }
.engine em { font-style: normal; font-size: 12px; }
.template[hidden] { display: none; }
@media (max-width: 480px) { .engines { grid-template-columns: 1fr; } }
.warn { color: var(--accent); font-size: 12px; }
.gpu-line { margin: 16px 0 0; font-size: 13px; color: var(--muted); }
.gpu-line em { font-style: normal; color: var(--text); }

.modebar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; margin-bottom: 18px; }
.mode-btn { display: flex; flex-direction: column; gap: 2px; padding: 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text); font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; text-align: left; }
.mode-btn small { font-size: 12px; font-weight: 400; color: var(--muted); }
.mode-btn.active { border-color: var(--accent); }
.product-name { margin-top: 12px; }
.product-name input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font: inherit; font-size: 14px; background: var(--bg); color: var(--text); }

/* ---- 访客体验调整 2026-10-23 ---- */
.templates { grid-template-columns: repeat(auto-fill, minmax(120px, 150px)); }
.template .t-title { display: block; padding: 6px 6px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 600; }
.template .t-meta { display: flex; gap: 6px; justify-content: center; align-items: center; padding: 2px 6px 8px; font-size: 11px; color: var(--muted); font-weight: 400; }
.template .t-meta em { font-style: normal; color: var(--accent); font-weight: 600; }
.upload-row { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.upload-row .pickers { flex: none; }
.upload-row .tips, .upload-row .product-name { flex: 1; min-width: 240px; margin-top: 4px; }
.modes { flex-wrap: wrap; gap: 10px; }
.modes label { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.modes label:has(input:checked) { border-color: var(--accent); }
.gpu-line { text-align: center; }
@media (max-width: 600px) {
  /* 手机：模板改成横向滑动的一行，不再占满几屏 */
  .templates { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; padding-bottom: 6px; margin: 0 -4px; }
  .templates .template { flex: 0 0 118px; scroll-snap-align: start; }
  .modes { flex-direction: column; align-items: stretch; }
  .modes label { justify-content: flex-start; }
  .upload-row { flex-direction: column; gap: 8px; }
}
.upload-row .enhance { width: 200px; }

.mode-btn[hidden] { display: none; }
@media (max-width: 600px) { .modebar { gap: 6px; } .mode-btn { padding: 10px 8px; font-size: 15px; text-align: center; } .mode-btn small { font-size: 11px; line-height: 1.35; } }
@media (max-width: 600px) { .upload-row .product-name, .upload-row .tips { flex-basis: 100%; min-width: 0; } }
/* 换衣服：试穿上身图 + 衣服类型 + 自己的模特 */
#tryonPreview .tag { position: absolute; left: 6px; top: 6px; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; }
#tryonRetry { align-self: flex-start; }
.garment-opts { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.cat-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px; }
.cat-row > span { color: var(--muted); }
.cat-row label { border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; cursor: pointer; }
.cat-row label:has(input:checked) { border-color: var(--accent); }
.own-model summary { cursor: pointer; font-size: 14px; color: var(--muted); }
.own-model .picker.small { display: block; max-width: 140px; margin-top: 8px; }
@media (max-width: 600px) { .garment-opts { flex-basis: 100%; min-width: 0; } }
/* 原图和 AI 图（标准照/上身图）一样大并排 */
.pickers { align-items: flex-start; }
.upload-row .pickers { display: flex; gap: 10px; }
.upload-row .pickers > .picker, .upload-row .pickers > .enhance { width: 190px; max-width: none; flex: none; }
.enhance .preview { flex: none; width: 100%; }
@media (max-width: 600px) {
  .upload-row .pickers { width: 100%; }
  .upload-row .pickers > .picker, .upload-row .pickers > .enhance { flex: 1 1 0; width: auto; min-width: 0; max-width: 220px; }
}
.garment-note { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.garment-note b { color: var(--accent); }
/* 换衣服：第二件衣服 + 模特照 */
.extra-row { display: flex; gap: 10px; flex-wrap: wrap; }
.extra-item { display: flex; flex-direction: column; gap: 6px; width: 130px; }
.extra-item .picker.small { display: block; width: 130px; max-width: 130px; }
.cat-row.small { font-size: 12px; gap: 4px; }
.cat-row.small label { padding: 3px 6px; }
#personPreview.need { border-color: var(--accent); border-style: solid; }
.check-tip { text-align: center; }
/* 账号条 + 登录/兑换弹窗 */
.account-bar { display: flex; justify-content: flex-end; align-items: center; gap: 8px; max-width: 960px; margin: 0 auto; padding: 10px 16px 0; font-size: 14px; }
.account-bar > span { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.account-bar .points { padding: 2px 10px; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 600; }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
.dialog { position: relative; width: min(360px, calc(100vw - 32px)); background: var(--card, #fff); color: var(--text); border-radius: 16px; padding: 22px 20px; display: flex; flex-direction: column; gap: 10px; }
.dialog h3 { margin: 0; }
.dialog input[type=text], .dialog input:not([type]), .dialog input[type=password] { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; background: var(--bg); color: var(--text); }
.dialog .tabs { display: flex; gap: 6px; }
.dialog .tab { flex: 1; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; cursor: pointer; }
.dialog .tab.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.dialog .agree { font-size: 13px; display: flex; gap: 6px; align-items: center; }
.dialog .small { font-size: 12px; margin: 0; }
.error-text { color: #d33; font-size: 13px; margin: 0; min-height: 1em; }
.cost { font-style: normal; color: var(--accent); font-weight: 600; margin-left: 4px; }
.dialog { padding-top: 44px; }
.dialog .lightbox-close { top: 8px; right: 8px; }
/* 一次出多条 */
.step-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.step-row .step { margin-bottom: 0; }
.multi-toggle { font-size: 13px; display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.multi-toggle:has(input:checked) { border-color: var(--accent); color: var(--accent); }
body.multi-on .template.active:not(.picked) { border-color: var(--line); }
body.multi-on .template.active:not(.picked)::after { display: none; }
.template.picked { border-color: var(--accent) !important; box-shadow: 0 0 0 2px var(--accent) inset; }
.template.picked::after { content: '✓ 已选'; position: absolute; top: 6px; left: 6px; background: var(--accent); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 6px; display: block; z-index: 2; }
/* 带货文案 */
.copy-box { margin-top: 16px; padding: 14px; border: 1px dashed var(--line); border-radius: 12px; display: flex; flex-direction: column; gap: 8px; }
.copy-head { display: flex; flex-direction: column; gap: 2px; }
.copy-inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.copy-box input[type=text], .copy-box input:not([type]) { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 14px; background: var(--bg); color: var(--text); width: 100%; box-sizing: border-box; }
.copy-box #genCopy { align-self: flex-start; }
.copy-fields { display: flex; flex-direction: column; gap: 8px; }
.copy-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.copy-fields label.chk { flex-direction: row; align-items: center; color: var(--text); }
.small { font-size: 12px; }
