/* ============================================================
   AI 虚拟试衣间 · 样式
   深色时尚科技风：近黑底 + 品红/青色双点缀，突出 16:9 视频舞台
   ============================================================ */
:root {
  --bg: #08090d;
  --bg-soft: #0e1118;
  --panel: #11141d;
  --panel-2: #161a25;
  --line: #232838;
  --text: #eef1f7;
  --text-dim: #9aa3b5;
  --text-mute: #6b7488;
  --accent: #ff4d8d;
  --accent-2: #22d3ee;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

/* 关键：本项目多处用 display:grid/flex 覆盖默认样式，
   必须强制 [hidden] 生效，否则 hidden 属性会被作者样式「盖掉」 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  /* 极淡的双色光晕，避免纯黑压抑 */
  background-image:
    radial-gradient(900px 500px at 8% -10%, rgba(255, 77, 141, 0.10), transparent 60%),
    radial-gradient(800px 480px at 100% 0%, rgba(34, 211, 238, 0.09), transparent 55%);
  background-attachment: fixed;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
}

/* ------------------------------ 网络提示条 ------------------------------ */
.net-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 20px 0;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #fde68a;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.35);
}
.net-banner-icon { font-size: 14px; }
.net-banner-close {
  margin-left: auto;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
}
.net-banner-close:hover { opacity: 1; }

/* ------------------------------ 顶栏 ------------------------------ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 12, 18, 0.82);
  backdrop-filter: blur(10px);
  flex: 0 0 auto;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  font-size: 20px;
  background: linear-gradient(135deg, rgba(255, 77, 141, 0.22), rgba(34, 211, 238, 0.18));
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-text h1 { margin: 0; font-size: 16px; letter-spacing: 0.3px; }
.brand-text p { margin: 2px 0 0; font-size: 11.5px; color: var(--text-mute); }

.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.badge {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.28);
  color: #a5f3fc;
  white-space: nowrap;
}
.badge-ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
  color: var(--text-dim);
}

/* ------------------------------ 主舞台 ------------------------------ */
.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  padding: 16px 20px;
}

/* 视频区 */
.viewport {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #05060a;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  min-height: 320px;
  display: grid;
  place-items: center;
}

/* Xmax 模式的渲染层：SDK 在自己的容器里绘制画面 */
.xr-layer { position: absolute; inset: 0; z-index: 2; }
.xr-output { position: absolute; inset: 0; background: #05060a; }
.xr-output > * { width: 100% !important; height: 100% !important; }
.xr-input {
  position: absolute;
  right: 14px; bottom: 14px;
  width: 168px;
  aspect-ratio: 3 / 4;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  background: #000;
  z-index: 3;
}
.xr-input > * { width: 100% !important; height: 100% !important; }

.video-remote {
  width: 100%; height: 100%;
  object-fit: cover;
  display: none;
  background: #05060a;
}
.viewport.live .video-remote { display: block; }
.viewport.live .placeholder { display: none; }

.video-local {
  position: absolute;
  right: 14px; bottom: 14px;
  width: 168px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  display: none;
  background: #000;
  z-index: 3;
}
.viewport.camera-on .video-local { display: block; }
.viewport.live .video-local { opacity: 0.9; }

/* 空态 */
.placeholder {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 24px;
  text-align: center;
}
.placeholder-inner { max-width: 460px; }
.ph-icon { font-size: 38px; margin-bottom: 10px; opacity: 0.9; }
.placeholder h2 { margin: 0 0 12px; font-size: 22px; font-weight: 600; }
.ph-steps {
  margin: 0 auto 20px;
  padding: 0;
  list-style: none;
  counter-reset: s;
  display: grid;
  gap: 8px;
  max-width: 340px;
  text-align: left;
}
.ph-steps li {
  counter-increment: s;
  font-size: 13px;
  color: var(--text-dim);
  padding-left: 30px;
  position: relative;
  line-height: 1.55;
}
.ph-steps li::before {
  content: counter(s);
  position: absolute; left: 0; top: 0;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px;
  color: #08131a;
  background: linear-gradient(135deg, var(--accent-2), #7dd3fc);
  font-weight: 700;
}
.ph-privacy {
  margin: 16px 0 0;
  font-size: 11.5px;
  color: var(--text-mute);
  line-height: 1.6;
}

/* HUD */
.hud {
  position: absolute; left: 14px; top: 14px;
  display: flex; align-items: center; gap: 14px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(5, 6, 10, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  font-size: 12px;
  z-index: 4;
}
.hud-left { display: flex; align-items: center; gap: 7px; }
.hud-right { display: flex; align-items: center; gap: 6px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.hud-sep { opacity: 0.4; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.16); }
.dot.err { background: var(--danger); }

/* 结果层 */
.result-layer {
  position: absolute; inset: 0;
  background: rgba(4, 5, 9, 0.88);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  z-index: 10;
  padding: 20px;
}
.result-card { text-align: center; max-height: 100%; }
.result-card img {
  max-width: min(70vw, 420px);
  max-height: 68vh;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow);
}
.result-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }

/* ------------------------------ 右侧面板 ------------------------------ */
.panel {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 2px;
  scrollbar-width: thin;
}
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: #2a3143; border-radius: 8px; }

.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.card-primary { border-color: rgba(255, 77, 141, 0.28); }
.card-log { padding: 10px 12px; }

.card-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.card-head h3 { margin: 0; font-size: 13.5px; font-weight: 600; letter-spacing: 0.2px; }

.step-no {
  width: 20px; height: 20px;
  border-radius: 6px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  background: rgba(255, 77, 141, 0.16);
  color: #ffa3c4;
  border: 1px solid rgba(255, 77, 141, 0.3);
}
.step-no-alt { background: rgba(251, 191, 36, 0.14); color: #fcd34d; border-color: rgba(251, 191, 36, 0.3); }

.pill {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-mute);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 999px;
}
.pill.on { color: #6ee7b7; border-color: rgba(52, 211, 153, 0.35); background: rgba(52, 211, 153, 0.1); }
.pill-live { color: #fda4af; border-color: rgba(255, 77, 141, 0.35); background: rgba(255, 77, 141, 0.12); }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-tight { margin-top: 8px; }

/* 按钮 */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }
.btn-lg { padding: 12px 20px; font-size: 14px; font-weight: 600; flex: 1; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #ff7a3d);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 22px rgba(255, 77, 141, 0.24);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); background: linear-gradient(135deg, var(--accent), #ff7a3d); }
.btn-secondary {
  background: rgba(34, 211, 238, 0.12);
  border-color: rgba(34, 211, 238, 0.3);
  color: #a5f3fc;
}
.btn-secondary:hover:not(:disabled) { background: rgba(34, 211, 238, 0.2); }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-danger { background: rgba(248, 113, 113, 0.14); border-color: rgba(248, 113, 113, 0.35); color: #fca5a5; }

/* 上传区 */
.garment-slots { display: grid; grid-template-columns: 1fr; gap: 8px; }

.drop {
  display: grid;
  place-items: center;
  padding: 16px;
  border: 1.5px dashed #2c3446;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: rgba(255, 255, 255, 0.015);
}
.drop:hover { border-color: rgba(255, 77, 141, 0.5); background: rgba(255, 77, 141, 0.05); }
.drop-inner { display: grid; justify-items: center; gap: 3px; text-align: center; }
.drop-icon { font-size: 16px; color: var(--text-mute); }
.drop strong { font-size: 13px; font-weight: 600; }
.drop small { font-size: 11px; color: var(--text-mute); }

.drop-thumb { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.drop-thumb img { width: 100%; max-height: 150px; object-fit: contain; background: #0b0d14; display: block; }
.thumb-clear {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip {
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  cursor: pointer;
  font-family: inherit;
}
.chip:hover { color: var(--text); border-color: rgba(34, 211, 238, 0.4); background: rgba(34, 211, 238, 0.08); }

/* 表单 */
.field { display: block; }
.field-label { display: block; font-size: 11.5px; color: var(--text-mute); margin-bottom: 6px; }
textarea, .select {
  width: 100%;
  background: #0a0c13;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px;
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.55;
  resize: vertical;
}
textarea:focus, .select:focus {
  outline: none;
  border-color: rgba(34, 211, 238, 0.5);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.1);
}
.select { width: auto; padding: 8px 10px; font-size: 12px; }

.hint { margin: 8px 0 0; font-size: 11.5px; color: var(--text-mute); line-height: 1.6; }

/* 拖拽悬停高亮 */
.drop.drop-hover {
  border-color: rgba(126, 231, 255, .75) !important;
  background: rgba(126, 231, 255, .08) !important;
}

/* 内置服装库 */.lib { margin-top: 14px; }
.lib-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.lib-head span:first-child { font-size: 12.5px; color: var(--text); }
.lib-tip { font-size: 11px; color: var(--text-mute); }
.lib-cam { margin-left: auto; }
.lib-row {
  display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px;
  scrollbar-width: thin;
}
.lib-item {
  flex: none; width: 72px; background: none; border: 0; padding: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.lib-item img {
  width: 72px; height: 72px; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; transition: transform .15s, border-color .15s;
}
.lib-item:hover img { transform: translateY(-2px); border-color: rgba(126, 231, 255, .6); }
.lib-item span { font-size: 11px; color: var(--text-mute); white-space: nowrap; }
.lib-item.active img { border-color: #7ee7ff; box-shadow: 0 0 0 2px rgba(126, 231, 255, .28); }
.lib-item.active span { color: #7ee7ff; }

/* 描述即出图 */
.gen-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.gen-input {
  flex: 1; min-width: 180px; padding: 8px 10px; border-radius: 8px; font-size: 12.5px;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--line); color: var(--text);
}
.gen-input:focus { outline: none; border-color: rgba(126, 231, 255, .5); }
.gen-select {
  padding: 8px 8px; border-radius: 8px; font-size: 12.5px;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--line); color: var(--text);
}
#btn-gen:disabled { opacity: .6; cursor: progress; }

/* 搜同款（商业闭环入口） */
.shop-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.shop-tip { font-size: 11px; color: var(--text-mute); }

/* 搭配清单 */
.list-panel {
  margin-top: 14px; padding: 12px 14px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line);
}
.list-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-head strong { font-size: 13px; }
.list-count { font-size: 11.5px; color: var(--text-mute); }
.list-actions { margin-left: auto; display: flex; gap: 6px; }
.list-items { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.list-items li {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; padding: 6px 10px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}
.list-items .li-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-items .li-btn {
  border: 0; background: none; cursor: pointer; font-size: 11.5px;
  color: var(--accent, #7ee7ff); padding: 2px 4px; border-radius: 5px;
}
.list-items .li-btn:hover { background: rgba(126, 231, 255, 0.12); }
.list-items .li-del { color: var(--text-mute); }
.list-items .list-empty { background: none; color: var(--text-mute); font-size: 12px; padding: 4px 2px; }

/* 日志 */
.log {
  margin: 0;
  max-height: 118px;
  overflow: auto;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 10.5px;
  line-height: 1.7;
  color: var(--text-mute);
  white-space: pre-wrap;
  word-break: break-all;
}
.log .l-ok { color: #6ee7b7; }
.log .l-err { color: #fca5a5; }
.log .l-warn { color: #fcd34d; }

/* 进度 */
.spinner {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px;
  font-size: 12px; color: var(--text-dim);
}
.spinner span {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(34, 211, 238, 0.25);
  border-top-color: var(--accent-2);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------ 底栏 / 提示 ------------------------------ */
.footer {
  flex: 0 0 auto;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 9px 20px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-mute);
  background: rgba(8, 9, 13, 0.9);
}
.footer-right { text-align: right; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%);
  max-width: min(560px, 88vw);
  padding: 11px 16px;
  border-radius: 12px;
  background: rgba(20, 24, 34, 0.96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.55;
  z-index: 50;
  animation: rise 0.18s ease-out;
}
.toast.err { border-color: rgba(248, 113, 113, 0.45); color: #fecaca; }
.toast.ok { border-color: rgba(52, 211, 153, 0.45); color: #bbf7d0; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ------------------------------ 响应式 ------------------------------ */
@media (max-width: 1040px) {
  .stage { grid-template-columns: minmax(0, 1fr) 320px; }
}

@media (max-width: 860px) {
  .app { height: auto; min-height: 100vh; }
  .stage { grid-template-columns: 1fr; padding: 12px; }
  .viewport { min-height: 58vh; }
  .panel { overflow: visible; }
  .footer { flex-direction: column; align-items: flex-start; gap: 4px; }
  .footer-right { text-align: left; }
  .result-card img { max-width: 86vw; }
  .video-local { width: 108px; }
}

/* 工作台内嵌紧凑模式 */
body.embed .topbar { padding: 8px 14px; }
body.embed .brand-text p { display: none; }
body.embed .footer { display: none; }
