*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}

:root{
  --bg:#f5f5f7;
  --card:#fff;
  --border:#e5e5e5;
  --border-light:#f0f0f0;
  --text:#1a1a1a;
  --text2:#555;
  --text3:#999;
  --accent:#ff2442;
  --accent-light:#fff0f2;
  --accent-hover:#e61e3a;
  --sidebar-bg:#fff;
  --sidebar-w:240px;
  --topbar-h:48px;
  --radius:12px;
  --radius-sm:8px;
  --shadow:0 2px 12px rgba(0,0,0,.06);
  --shadow-hover:0 4px 20px rgba(0,0,0,.1);
  --transition:all .2s ease;
}

html{font-size:16px}
body{
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
  background:var(--bg);color:var(--text);
  line-height:1.6;
  min-height:100vh;
  overflow:hidden;
}

/* ===== Layout ===== */
.app-layout{
  display:flex;
  height:100vh;
  overflow:hidden;
}

/* ===== Sidebar ===== */
.sidebar{
  width:var(--sidebar-w);
  background:var(--sidebar-bg);
  border-right:1px solid var(--border);
  display:flex;
  flex-direction:column;
  flex-shrink:0;
  height:100vh;
  overflow:hidden;
  z-index:100;
}
.sidebar-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 14px 10px;
  border-bottom:1px solid var(--border-light);
  flex-shrink:0;
}
.sidebar-header h2{
  font-size:14px;
  font-weight:700;
  color:var(--text);
}

.sidebar-profile-list{
  flex:1;
  overflow-y:auto;
  padding:6px;
}

.sidebar-empty{
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  padding:24px;
  text-align:center;
  color:var(--text3);
  gap:12px;
}
.sidebar-empty p{font-size:13px}

/* Sidebar profile card */
.sp-card{
  display:flex;
  align-items:center;
  gap:8px;
  padding:6px 8px;
  border-radius:var(--radius-sm);
  cursor:pointer;
  transition:var(--transition);
  margin-bottom:1px;
  position:relative;
}
.sp-card:hover{background:var(--bg)}
.sp-card.active{
  background:var(--accent-light);
}
.sp-card.active::before{
  content:'';
  position:absolute;
  left:0;top:6px;bottom:6px;
  width:3px;
  background:var(--accent);
  border-radius:0 3px 3px 0;
}
.sp-card-thumb{
  width:36px;height:36px;
  border-radius:50%;
  object-fit:cover;
  flex-shrink:0;
  border:2px solid transparent;
}
.sp-card.active .sp-card-thumb{
  border-color:var(--accent);
}
.sp-card-info{
  flex:1;
  min-width:0;
}
.sp-card-name{
  font-size:13px;
  font-weight:600;
  color:var(--text);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.sp-card-meta{
  font-size:11px;
  color:var(--text3);
}
.sp-card-delete{
  width:22px;height:22px;
  background:none;border:none;
  color:var(--text3);
  font-size:13px;
  cursor:pointer;
  border-radius:50%;
  display:none;
  align-items:center;justify-content:center;
  flex-shrink:0;
}
.sp-card:hover .sp-card-delete{display:flex}
.sp-card-delete:hover{background:var(--accent-light);color:var(--accent)}

/* Sidebar overlay (mobile) */
.sidebar-overlay{
  position:fixed;inset:0;
  background:rgba(0,0,0,.4);
  z-index:90;
}

/* ===== Main Content ===== */
.main-content{
  flex:1;
  display:flex;
  flex-direction:column;
  overflow:hidden;
  min-width:0;
}

/* Top bar */
.topbar{
  display:flex;
  align-items:center;
  gap:10px;
  padding:0 20px;
  height:var(--topbar-h);
  background:var(--card);
  border-bottom:1px solid var(--border-light);
  flex-shrink:0;
}
.topbar-title{
  font-size:16px;font-weight:700;
  background:linear-gradient(135deg,var(--accent),#ff6b81);
  -webkit-background-clip:text;-webkit-text-fill-color:transparent;
  background-clip:text;
  flex:1;
}
.sidebar-toggle{display:none}
.btn-icon{
  width:32px;height:32px;
  background:none;border:none;
  display:flex;align-items:center;justify-content:center;
  border-radius:var(--radius-sm);
  cursor:pointer;
  color:var(--text2);
}
.btn-icon:hover{background:var(--bg)}

/* Topbar editor button */
.topbar-editor-btn{
  display:inline-flex;align-items:center;gap:5px;
  margin-left:auto;
}

/* Workspace sections */
.workspace-section{
  flex:1;
  overflow-y:auto;
  padding:16px 20px;
}

/* Empty state */
.ws-empty{
  display:flex;
  align-items:center;
  justify-content:center;
}
.empty-state{
  text-align:center;
  padding:40px 20px;
}
.empty-icon{font-size:48px;margin-bottom:12px;display:block}
.empty-state h2{font-size:20px;font-weight:600;margin-bottom:6px}
.empty-state p{font-size:14px;color:var(--text3);margin-bottom:20px}

/* Active model strip wrapper */
.active-model-strip-wrap{
  background:var(--card);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  margin-bottom:12px;
  overflow:hidden;
}

/* Active model strip */
.active-model-strip{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 14px;
}
.active-model-thumb{
  width:32px;height:32px;
  border-radius:50%;
  object-fit:cover;
  border:2px solid var(--accent);
}
.active-model-info{
  display:flex;
  flex-direction:column;
  flex:1;
}
.active-model-name{
  font-size:13px;
  font-weight:600;
  color:var(--text);
}
.active-model-meta{
  font-size:11px;
  color:var(--text3);
}

/* Inline profile detail */
.profile-detail-inline{
  padding:0 14px 14px;
  border-top:1px solid var(--border-light);
}
.detail-images-row{
  display:flex;align-items:flex-start;gap:12px;
  padding:12px 0 10px;
}
.detail-img-original{
  width:100px;
  border-radius:var(--radius-sm);
  object-fit:cover;
  background:var(--bg);
  flex-shrink:0;
  cursor:pointer;
}
.detail-img-refsheet{
  width:100%;flex:1;min-width:0;
  border-radius:var(--radius-sm);
  object-fit:contain;
  background:var(--bg);
  cursor:pointer;
}
.detail-refsheet-wrap{
  position:relative;
  flex-shrink:0;
}
.refsheet-regen-overlay{
  position:absolute;inset:0;
  display:flex;align-items:center;justify-content:center;
  background:rgba(255,255,255,.7);
  border-radius:var(--radius-sm);
}
.spinner-sm{
  width:20px;height:20px;
  border:2px solid var(--border);
  border-top-color:var(--accent);
  border-radius:50%;
  animation:spin 1s linear infinite;
}
.detail-fields{display:flex;flex-direction:column;gap:8px;margin-bottom:8px}
.detail-field label{font-size:12px;font-weight:600;color:var(--text3);display:block;margin-bottom:2px}
.detail-actions{display:flex;gap:8px}

/* Cards */
.card{
  background:var(--card);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:16px;
  margin-bottom:12px;
}

.section-header{
  display:flex;align-items:center;gap:10px;
  margin-bottom:12px;
}
.section-header h2{font-size:15px;font-weight:600;flex:1}
.optional-tag{font-size:12px;font-weight:400;color:var(--text3);margin-left:2px}

/* Upload */
.upload-area{
  border:2px dashed var(--border);
  border-radius:var(--radius-sm);
  padding:32px 20px;
  text-align:center;
  cursor:pointer;
  transition:var(--transition);
  position:relative;
  overflow:hidden;
}
.upload-area:hover,.upload-area.dragover{
  border-color:var(--accent);
  background:var(--accent-light);
}
.upload-area.has-image{
  border-style:solid;
  border-color:var(--border);
  padding:0;
}
.upload-icon{font-size:36px;margin-bottom:8px;display:block}
.upload-area p{color:var(--text2);font-size:14px}
.upload-area .hint{color:var(--text3);font-size:12px;margin-top:4px}

.ref-preview{
  width:100%;max-height:280px;
  object-fit:contain;
  border-radius:var(--radius-sm);
  display:block;
}
.ref-actions{
  display:flex;gap:8px;justify-content:center;
  margin-top:10px;
}

/* Reference Sheet Section */
.refsheet-section{
  margin-top:16px;
  text-align:center;
}
.refsheet-hint{margin-top:6px}
.refsheet-preview{
  margin-top:12px;
  border-radius:var(--radius-sm);
  overflow:hidden;
  background:var(--bg);
}
.refsheet-preview img{width:100%;display:block}

/* Identity Description */
.identity-desc-section{
  margin-top:12px;
  text-align:left;
}
.identity-desc-section label{
  font-size:13px;font-weight:600;
  color:var(--text2);
  display:block;margin-bottom:4px;
}
.identity-desc-input{
  width:100%;
  padding:8px 10px;
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
  font-size:13px;color:var(--text2);
  background:var(--bg);
  resize:vertical;
  font-family:inherit;line-height:1.5;
}

/* Save Profile Section */
.save-profile-section{margin-top:12px}
.save-profile-row{
  display:flex;gap:8px;align-items:center;
}
.profile-name-input{
  flex:1;
  padding:7px 10px;
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
  font-size:13px;color:var(--text);
  background:var(--card);
  outline:none;font-family:inherit;
}
.profile-name-input:focus{border-color:var(--accent)}

/* Scene grid - 3 visible rows, scroll for rest */
#scene-card .scene-grid{
  max-height:calc(3 * (133px + 6px));
  overflow-y:auto;
}

/* Wardrobe card - 4 visible rows, same card size as scene */
#wardrobe-card .scene-grid{
  max-height:calc(4 * (133px + 6px));
  overflow-y:auto;
  grid-template-columns:repeat(auto-fill, minmax(100px, 1fr));
}

/* Scene grid */
.scene-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(100px, 1fr));
  gap:6px;
  margin-top:6px;
}
.scene-card-image{
  position:relative;
  border-radius:var(--radius-sm);
  overflow:hidden;
  cursor:pointer;
  aspect-ratio:3/4;
  border:2px solid transparent;
  transition:var(--transition);
  background:var(--bg);
}
.scene-card-image:hover{
  border-color:var(--accent);
  box-shadow:var(--shadow-hover);
  transform:translateY(-1px);
}
.scene-card-image:active{transform:translateY(0)}
.scene-card-image.selected{
  border-color:var(--accent);
  box-shadow:0 0 0 2px var(--accent);
}
.scene-card-image.selected::after{
  content:'\2713';
  position:absolute;
  top:4px;left:4px;
  width:18px;height:18px;
  background:var(--accent);
  color:#fff;
  border-radius:50%;
  font-size:10px;
  display:flex;align-items:center;justify-content:center;
  z-index:2;
  line-height:1;
}
.scene-card-thumb{
  width:100%;height:100%;
  object-fit:cover;
  display:block;
}
.scene-card-overlay{
  position:absolute;bottom:0;left:0;right:0;
  background:linear-gradient(transparent,rgba(0,0,0,.6));
  padding:16px 6px 5px;
}
.scene-card-overlay .scene-name{
  font-size:10px;font-weight:600;color:#fff;
  text-shadow:0 1px 3px rgba(0,0,0,.4);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}

/* Scene card inline delete */
.scene-card-delete{
  position:absolute;top:3px;right:3px;
  width:18px;height:18px;
  background:rgba(0,0,0,.5);color:#fff;
  border:none;border-radius:50%;
  font-size:10px;cursor:pointer;
  display:none;align-items:center;justify-content:center;
  z-index:3;line-height:1;
}
.scene-card-image:hover .scene-card-delete{display:flex}
.scene-card-delete:hover{background:rgba(220,38,38,.8)}

/* Scene/Wardrobe card preview button */
.scene-card-preview{
  position:absolute;top:3px;right:24px;
  width:20px;height:20px;
  background:rgba(0,0,0,.5);color:#fff;
  border:none;border-radius:50%;
  font-size:10px;cursor:pointer;
  display:none;align-items:center;justify-content:center;
  z-index:3;line-height:1;
  opacity:0;transition:opacity .2s;
}
.scene-card-image:hover .scene-card-preview{display:flex;opacity:1}
.scene-card-preview:hover{background:rgba(0,0,0,.7)}

/* Scene empty state */
.scene-empty{
  text-align:center;padding:20px;color:var(--text3);font-size:13px;
  margin-top:8px;
}

/* Scene generate bar */
.scene-generate-bar{
  margin-top:10px;
  display:flex;
  justify-content:center;
}
.btn-generate{
  min-width:200px;
  padding:10px 32px;
  font-size:14px;
  font-weight:600;
}

/* Scene grid drag-drop indicator */
.scene-grid.dragover{
  background:var(--accent-light);
  border-radius:var(--radius-sm);
  outline:2px dashed var(--accent);
  outline-offset:-2px;
}

/* Scene manager modal */
.modal-overlay{
  position:fixed;inset:0;z-index:500;
  background:rgba(0,0,0,.5);
  display:flex;align-items:center;justify-content:center;
}
.modal-content{
  background:var(--card);
  border-radius:var(--radius);
  box-shadow:0 8px 40px rgba(0,0,0,.2);
  width:90vw;max-width:560px;
  max-height:80vh;
  display:flex;flex-direction:column;
  overflow:hidden;
}
.modal-header{
  display:flex;align-items:center;justify-content:space-between;
  padding:16px 20px;
  border-bottom:1px solid var(--border-light);
  flex-shrink:0;
}
.modal-header h2{font-size:16px;font-weight:700}
.modal-close{
  width:32px;height:32px;
  background:none;border:none;
  font-size:20px;cursor:pointer;
  color:var(--text3);
  border-radius:50%;
  display:flex;align-items:center;justify-content:center;
}
.modal-close:hover{background:var(--bg);color:var(--text)}
.scene-manager-upload{
  padding:12px 20px;
  border-bottom:1px solid var(--border-light);
  flex-shrink:0;
}
.scene-manager-grid{
  padding:12px 20px;
  overflow-y:auto;flex:1;
  display:flex;flex-direction:column;gap:8px;
}
.scene-manager-item{
  display:flex;align-items:center;gap:10px;
  padding:8px;
  border-radius:var(--radius-sm);
  transition:var(--transition);
}
.scene-manager-item:hover{background:var(--bg)}
.scene-manager-item img{
  width:56px;height:56px;
  border-radius:6px;
  object-fit:cover;
  flex-shrink:0;
}
.scene-manager-info{flex:1;min-width:0}
.scene-manager-name{
  font-size:13px;font-weight:600;color:var(--text);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  display:block;
}
.scene-manager-delete{
  width:28px;height:28px;
  background:none;border:none;
  color:var(--text3);font-size:16px;
  cursor:pointer;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  flex-shrink:0;
}
.scene-manager-delete:hover{background:var(--accent-light);color:var(--accent)}
.scene-manager-empty{
  padding:32px 20px;text-align:center;color:var(--text3);font-size:14px;
}

/* Model select */
.model-select{
  font-size:12px;
  padding:4px 8px;
  border:1px solid var(--border);
  border-radius:6px;
  background:var(--bg);
  color:var(--text2);
  cursor:pointer;outline:none;
}
.model-select:focus{border-color:var(--accent)}

/* Loading */
.loading{text-align:center;padding:32px 0}
.spinner{
  width:36px;height:36px;
  border:3px solid var(--border);
  border-top-color:var(--accent);
  border-radius:50%;
  animation:spin 1s linear infinite;
  margin:0 auto 14px;
}
@keyframes spin{to{transform:rotate(360deg)}}
.loading-text{font-size:14px;color:var(--text);font-weight:500}
.loading-hint{font-size:12px;color:var(--text3);margin-top:4px}

/* ===== Result image: thumbnail like gallery ===== */
.result-images-wrap{
  display:flex;
  justify-content:center;
  gap:8px;
  margin-bottom:12px;
  flex-wrap:wrap;
}
.result-image-wrap{
  display:flex;
  justify-content:center;
  position:relative;
}
.result-image-wrap img{
  width:160px !important;
  height:auto !important;
  aspect-ratio:3/4;
  object-fit:cover;
  border-radius:var(--radius-sm);
  cursor:pointer;
  border:1px solid var(--border);
  background:var(--bg);
  transition:var(--transition);
  display:block;
}
.result-images-wrap.multi .result-image-wrap img{
  width:130px !important;
}
.result-image-wrap img:hover{
  box-shadow:var(--shadow-hover);
  transform:translateY(-2px);
}
/* Spinner overlay on generating image slot */
.result-image-wrap .result-slot-spinner{
  position:absolute;inset:0;
  display:flex;align-items:center;justify-content:center;
  background:var(--bg);
  border-radius:var(--radius-sm);
  border:1px solid var(--border);
  width:160px;height:213px;
}
.result-images-wrap.multi .result-slot-spinner{
  width:130px;height:173px;
}
.result-actions{
  display:flex;gap:6px;flex-wrap:wrap;justify-content:center;
}

/* Error */
.error-box{
  text-align:center;padding:16px;
  background:#fff5f5;
  border-radius:var(--radius-sm);
  border:1px solid #fecdd3;
}
.error-box p{color:#b91c1c;font-size:13px;margin-bottom:10px}

/* ===== Gallery: smaller thumbnails (half current size) ===== */
.gallery-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(90px, 1fr));
  gap:6px;
}
.gallery-item{
  aspect-ratio:3/4;
  border-radius:6px;
  overflow:hidden;cursor:pointer;
  position:relative;
}
.gallery-item img{
  width:100%;height:100%;
  object-fit:cover;
  transition:var(--transition);
}
.gallery-item:hover img{transform:scale(1.05)}
.gallery-item .gallery-delete{
  position:absolute;top:3px;right:3px;
  width:18px;height:18px;
  background:rgba(0,0,0,.5);color:#fff;
  border:none;border-radius:50%;
  font-size:11px;cursor:pointer;
  display:none;align-items:center;justify-content:center;
  line-height:1;
}
.gallery-item:hover .gallery-delete{display:flex}

.badge{
  font-size:11px;
  background:var(--bg);color:var(--text3);
  padding:1px 6px;border-radius:10px;
}

/* Buttons */
.btn{
  display:inline-flex;align-items:center;justify-content:center;
  padding:8px 16px;
  border:none;border-radius:var(--radius-sm);
  font-size:13px;font-weight:500;
  cursor:pointer;transition:var(--transition);
  text-decoration:none;
}
.btn-primary{background:var(--accent);color:#fff}
.btn-primary:hover{background:var(--accent-hover)}
.btn-ghost{
  background:var(--bg);color:var(--text2);
  border:1px solid var(--border);
}
.btn-ghost:hover{border-color:var(--text3)}
.btn-danger{color:#b91c1c}
.btn-danger:hover{background:#fff5f5}
.btn-sm{padding:5px 10px;font-size:12px}
.btn:disabled{opacity:.5;cursor:not-allowed}

/* Lightbox */
.lightbox{
  position:fixed;inset:0;z-index:1000;
  display:flex;align-items:center;justify-content:center;
}
.lightbox-backdrop{
  position:absolute;inset:0;background:rgba(0,0,0,.85);
}
.lightbox-content{
  position:relative;max-width:90vw;max-height:90vh;
}
.lightbox-content img{
  max-width:90vw;max-height:85vh;
  object-fit:contain;border-radius:var(--radius);
}
.lightbox-close{
  position:absolute;top:-12px;right:-12px;
  width:32px;height:32px;
  background:#fff;color:var(--text);
  border:none;border-radius:50%;
  font-size:18px;cursor:pointer;
  box-shadow:var(--shadow);
  display:flex;align-items:center;justify-content:center;
}
.lightbox-content .btn{
  position:absolute;bottom:-44px;
  left:50%;transform:translateX(-50%);
}

/* Utility */
.hidden{display:none !important}

/* ===== Responsive ===== */
@media(max-width:768px){
  .sidebar{
    position:fixed;
    left:calc(-1 * var(--sidebar-w));
    top:0;bottom:0;
    transition:left .25s ease;
    z-index:200;
    box-shadow:none;
  }
  .sidebar.open{
    left:0;
    box-shadow:4px 0 20px rgba(0,0,0,.15);
  }
  .sidebar-toggle{display:flex}

  .workspace-section{padding:12px 10px}
  .scene-grid{gap:6px}
  .scene-card{padding:10px 8px}
  .gallery-grid{gap:4px}
}

@media(min-width:769px){
  .sidebar-toggle{display:none}
  .sidebar-overlay{display:none !important}
}


/* Bio input */
.bio-input{
  width:100%;padding:7px 10px;
  border:1px solid var(--border);border-radius:var(--radius-sm);
  font-size:13px;color:var(--text);background:var(--card);
  resize:vertical;font-family:inherit;line-height:1.5;
}
.bio-input:focus{border-color:var(--accent);outline:none}

/* Field select (MBTI / Fashion) */
.field-select{
  width:100%;padding:7px 10px;border:1px solid var(--border);border-radius:var(--radius-sm);
  font-size:13px;color:var(--text2);background:var(--card);cursor:pointer;font-family:inherit;
}
.field-select:focus{border-color:var(--accent);outline:none}

/* Field hint */
.field-hint{
  display:block;font-size:11px;color:var(--text3);margin-top:2px;
}

/* Two-column field row */
.field-row,.detail-field-row{
  display:flex;gap:12px;
}
.field-half{
  flex:1;min-width:0;
}
.field-half label{
  font-size:12px;font-weight:600;color:var(--text3);display:block;margin-bottom:2px;
}

/* Gallery model badge */
.gallery-badge{
  position:absolute;bottom:3px;left:3px;
  background:rgba(0,0,0,.6);color:#fff;
  font-size:9px;padding:1px 4px;border-radius:3px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:calc(100% - 6px);
}

/* Lightbox meta */
.lightbox-meta{
  position:absolute;top:-32px;left:50%;transform:translateX(-50%);
  background:rgba(255,255,255,.9);color:var(--text);
  font-size:12px;padding:3px 10px;border-radius:6px;
  white-space:nowrap;
}

/* Strip edit hint - button style */
.strip-edit-hint{
  font-size:11px;color:var(--text2);flex-shrink:0;
  padding:3px 10px;
  border-radius:6px;
  border:1px solid var(--border);
  background:var(--bg);
  transition:var(--transition);
  cursor:pointer;
}
.active-model-strip:hover .strip-edit-hint{
  border-color:var(--accent);
  color:var(--accent);
  background:var(--accent-light);
}
.active-model-strip{cursor:pointer;transition:var(--transition)}
.active-model-strip:hover{background:var(--bg)}

/* ===== Pipeline Steps ===== */
.pipeline-steps{
  display:flex;flex-direction:column;
  gap:2px;
  margin-bottom:12px;
}
.pipeline-step{
  padding:8px 10px;
  border-radius:var(--radius-sm);
  background:var(--bg);
  transition:var(--transition);
}
.pipeline-step.active{
  background:var(--accent-light);
}
.pipeline-step.done{
  background:var(--bg);
}
.pipeline-step.error{
  background:#fff5f5;
}
.pipeline-step-header{
  display:flex;align-items:center;gap:6px;
}
.pipeline-step-icon{
  font-size:13px;font-weight:700;
  color:var(--text3);
  width:20px;text-align:center;
  flex-shrink:0;
}
.pipeline-step.active .pipeline-step-icon{
  color:var(--accent);
}
.pipeline-step.done .pipeline-step-icon{
  color:#22c55e;
}
.pipeline-step.error .pipeline-step-icon{
  color:#ef4444;
}
.pipeline-step-label{
  font-size:13px;font-weight:600;
  color:var(--text);flex:1;
}
.pipeline-step-status{
  font-size:11px;color:var(--text3);
  flex-shrink:0;
}
.pipeline-step.active .pipeline-step-status{
  color:var(--accent);
}
.pipeline-step-detail{
  margin-top:4px;
  font-size:12px;color:var(--text3);
  line-height:1.5;
  display:none;
}
.pipeline-step-detail:not(:empty){
  display:block;
}
.clean-bg-result{
  display:flex;
  align-items:center;
  gap:8px;
  margin-top:4px;
}
.pipeline-step-detail .clean-bg-thumb{
  width:72px;height:54px;
  object-fit:cover;
  border-radius:4px;
  border:1px solid var(--border);
  cursor:pointer;
  transition:var(--transition);
}
.pipeline-step-detail .clean-bg-thumb:hover{
  border-color:var(--accent);
  box-shadow:0 2px 8px rgba(0,0,0,.1);
}
.save-scene-btn{
  font-size:11px !important;
  padding:3px 8px !important;
}
.pipeline-step-detail .desc-text{
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
  word-break:break-all;
  flex:1;
}
/* Inline regen button in pipeline steps */
.btn-regen-inline{
  display:inline-flex;
  align-items:center;justify-content:center;
  width:22px;height:22px;
  background:none;border:1px solid var(--border);
  border-radius:50%;
  font-size:14px;
  color:var(--text3);
  cursor:pointer;
  transition:var(--transition);
  flex-shrink:0;
  margin-left:6px;
  vertical-align:middle;
  line-height:1;
}
.btn-regen-inline:hover{
  border-color:var(--accent);
  color:var(--accent);
  background:var(--accent-light);
}
/* Pipeline spinner (inline) */
.pipeline-spinner{
  display:inline-block;
  width:12px;height:12px;
  border:2px solid var(--border);
  border-top-color:var(--accent);
  border-radius:50%;
  animation:spin .8s linear infinite;
  vertical-align:middle;
  margin-right:4px;
}

/* ===== Two-Panel Layout ===== */
.workspace-panels{
  display:flex;
  gap:12px;
  flex:1;
  min-height:0;
}
.panel-left{
  flex:1;
  min-width:0;
  display:flex;
  flex-direction:column;
}
/* Wardrobe card in panel-left */
#wardrobe-card{
  flex:none;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.panel-left .card{
  flex:1;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}
.panel-left .scene-grid{
  flex:1;
  overflow-y:auto;
}
.panel-right{
  flex:1;
  min-width:0;
  display:flex;
  flex-direction:column;
}
.panel-right .card{
  flex:1;
  overflow-y:auto;
}
.panel-placeholder{
  flex:1;
  display:flex;
  align-items:center;
  justify-content:center;
  background:var(--card);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  min-height:200px;
}
.placeholder-inner{
  text-align:center;
  color:var(--text3);
}
.placeholder-icon{
  font-size:36px;
  margin-bottom:8px;
  display:block;
}
.placeholder-inner p{
  font-size:14px;
}

/* ===== Model Settings Panel (button groups) ===== */
.model-settings-btn{
  display:inline-flex;
  align-items:center;
  gap:5px;
  background:#DA7756 !important;
  color:#fff !important;
  border:none !important;
}
.model-settings-btn:hover{
  background:#C4674A !important;
}
.model-settings-btn svg{
  stroke:#fff;
}
.model-settings-panel{
  background:var(--card);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:10px 14px;
  margin-bottom:12px;
  display:flex;
  flex-direction:column;
  gap:6px;
}
.ms-row{
  display:flex;
  align-items:center;
  gap:8px;
}
.ms-label{
  font-size:11px;
  font-weight:600;
  color:var(--text3);
  min-width:56px;
  flex-shrink:0;
}
.ms-btn-group{
  display:flex;
  gap:3px;
  flex-wrap:wrap;
}
.ms-btn{
  padding:2px 8px;
  font-size:11px;
  border:1px solid var(--border);
  border-radius:4px;
  background:var(--bg);
  color:var(--text2);
  cursor:pointer;
  transition:var(--transition);
  white-space:nowrap;
  line-height:1.4;
}
.ms-btn:hover{
  border-color:#DA7756;
  color:#DA7756;
}
.ms-btn.active{
  background:#DA7756;
  color:#fff;
  border-color:#DA7756;
}
.ms-hint{
  font-size:10px;
  color:var(--text3);
  white-space:nowrap;
}
.topbar-right{
  display:flex;
  align-items:center;
  gap:4px;
}

/* ===== Responsive: panels stack on mobile ===== */
@media(max-width:768px){
  .workspace-panels{
    flex-direction:column;
  }
  .panel-left,.panel-right{
    flex:none;
  }
}

/* ===== Editor (ws-editor) ===== */
#ws-editor{
  padding:0;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}
#ws-editor.hidden{display:none !important}

.editor-topbar{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 16px;
  background:var(--card);
  border-bottom:1px solid var(--border-light);
  flex-shrink:0;
}
.editor-title{
  font-size:15px;font-weight:600;flex:1;
}
.editor-topbar-actions{
  display:flex;align-items:center;gap:8px;
}
.editor-res-select{
  width:auto;font-size:12px;padding:4px 8px;
}

.editor-panels{
  display:flex;
  flex:1;
  overflow:hidden;
}
.editor-canvas-area{
  flex:2;
  display:flex;
  align-items:center;
  justify-content:center;
  background:#e8e8e8;
  overflow:hidden;
  position:relative;
}
.editor-canvas-wrap{
  position:relative;
  box-shadow:0 4px 24px rgba(0,0,0,.15);
}
.editor-canvas-wrap canvas{
  display:block;
}

.editor-controls{
  flex:1;
  max-width:320px;
  min-width:240px;
  overflow-y:auto;
  padding:10px;
  background:var(--bg);
  border-left:1px solid var(--border-light);
  display:flex;
  flex-direction:column;
  gap:0;
}
.editor-card{
  margin-bottom:8px;
  padding:12px;
}
.editor-card .section-header{margin-bottom:8px}
.editor-card .section-header h2{font-size:13px}

/* Editor empty state */
.editor-empty-state{
  display:flex;flex-direction:column;
  align-items:center;justify-content:center;
  gap:10px;
  padding:40px;
  text-align:center;
  color:var(--text3);
}
.editor-empty-icon{margin-bottom:4px}
.editor-empty-title{font-size:16px;font-weight:600;color:var(--text2)}
.editor-empty-hint{font-size:13px;color:var(--text3);margin-bottom:8px}
.editor-canvas-area.dragover{
  background:var(--accent-light) !important;
  outline:3px dashed var(--accent);
  outline-offset:-3px;
}

/* Editor image actions */
.editor-img-actions{
  display:flex;gap:6px;margin-top:8px;
}
.editor-img-btn{
  flex:1;font-size:12px !important;
}

/* Editor source grid items with remove button */
.editor-source-item{
  aspect-ratio:3/4;
  border-radius:6px;
  overflow:hidden;
  border:2px solid var(--border);
  cursor:pointer;
  position:relative;
}
.editor-source-item img{
  width:100%;height:100%;object-fit:cover;
}
.editor-source-remove{
  position:absolute;top:2px;right:2px;
  width:18px;height:18px;
  background:rgba(0,0,0,.5);color:#fff;
  border:none;border-radius:50%;
  font-size:10px;cursor:pointer;
  display:none;align-items:center;justify-content:center;
  line-height:1;z-index:2;
}
.editor-source-item:hover .editor-source-remove{display:flex}
.editor-source-remove:hover{background:rgba(220,38,38,.8)}

/* History picker overlay */
.editor-history-overlay{
  position:absolute;inset:0;
  background:rgba(0,0,0,.5);
  z-index:50;
  display:flex;
  align-items:center;justify-content:center;
}
.editor-history-panel{
  background:var(--card);
  border-radius:var(--radius);
  box-shadow:0 8px 40px rgba(0,0,0,.2);
  width:90%;max-width:640px;
  max-height:80vh;
  display:flex;flex-direction:column;
  overflow:hidden;
  padding:16px;
}
.editor-history-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(90px, 1fr));
  gap:6px;
  overflow-y:auto;
  flex:1;
  margin:8px 0;
  max-height:50vh;
}
.editor-history-item{
  aspect-ratio:3/4;
  border-radius:6px;
  overflow:hidden;
  cursor:pointer;
  border:3px solid transparent;
  transition:var(--transition);
  position:relative;
}
.editor-history-item img{width:100%;height:100%;object-fit:cover}
.editor-history-item.selected{
  border-color:var(--accent);
  box-shadow:0 0 0 1px var(--accent);
}
.editor-history-item.selected::after{
  content:'\2713';
  position:absolute;top:3px;right:3px;
  width:18px;height:18px;
  background:var(--accent);color:#fff;
  border-radius:50%;font-size:10px;
  display:flex;align-items:center;justify-content:center;
  z-index:2;
}
.editor-history-actions{
  display:flex;align-items:center;justify-content:space-between;
  padding-top:8px;
  border-top:1px solid var(--border-light);
}
.editor-history-actions span{
  font-size:13px;color:var(--text2);
}

/* Template grid - better visibility */
.editor-template-grid{
  display:grid;
  grid-template-columns:repeat(5,1fr);
  gap:6px;
}
.editor-tpl-item{
  aspect-ratio:1;
  border:2px solid var(--border);
  border-radius:6px;
  cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  transition:var(--transition);
  background:var(--bg);
  padding:4px;
}
.editor-tpl-item:hover{border-color:var(--accent)}
.editor-tpl-item.active{
  border-color:var(--accent);
  background:var(--accent-light);
  box-shadow:0 0 0 1px var(--accent);
}
.editor-tpl-item svg{width:100%;height:100%}

/* Sliders & controls */
.editor-control-row{
  display:flex;
  align-items:center;
  gap:8px;
  margin-bottom:6px;
}
.editor-control-row label{
  font-size:12px;color:var(--text3);
  min-width:36px;flex-shrink:0;
}
.editor-slider{
  flex:1;
  -webkit-appearance:none;appearance:none;
  height:4px;
  background:var(--border);
  border-radius:2px;
  outline:none;
}
.editor-slider::-webkit-slider-thumb{
  -webkit-appearance:none;
  width:14px;height:14px;
  background:var(--accent);
  border-radius:50%;
  cursor:pointer;
}
.editor-slider-val{
  font-size:11px;color:var(--text3);
  min-width:22px;text-align:right;
}
.editor-color-input{
  width:28px;height:28px;
  border:1px solid var(--border);
  border-radius:4px;
  padding:0;cursor:pointer;
  background:none;
}

/* Color palette */
.editor-palette-section{
  margin-bottom:6px;
}
.editor-palette-label{
  font-size:12px;color:var(--text3);
  display:block;margin-bottom:4px;
}
.editor-color-palette{
  display:flex;
  flex-wrap:wrap;
  gap:4px;
}
.editor-color-swatch{
  width:22px;height:22px;
  border-radius:50%;
  border:2px solid transparent;
  cursor:pointer;
  transition:all .15s ease;
  box-sizing:border-box;
  flex-shrink:0;
}
.editor-color-swatch:hover{
  transform:scale(1.2);
  box-shadow:0 1px 6px rgba(0,0,0,.15);
}
.editor-color-swatch.active{
  border-color:var(--accent);
  box-shadow:0 0 0 2px var(--accent);
  transform:scale(1.15);
}
/* Light colors need a visible outline */
.editor-color-swatch.light-color{
  box-shadow:inset 0 0 0 1px rgba(0,0,0,.12);
}
.editor-color-swatch.light-color:hover{
  box-shadow:inset 0 0 0 1px rgba(0,0,0,.12), 0 1px 6px rgba(0,0,0,.15);
}
.editor-color-swatch.light-color.active{
  box-shadow:inset 0 0 0 1px rgba(0,0,0,.12), 0 0 0 2px var(--accent);
}
.editor-palette-custom{
  display:flex;
  align-items:center;
  gap:6px;
  margin-top:5px;
}
.editor-color-input-sm{
  width:22px;height:22px;
  border:1px solid var(--border);
  border-radius:50%;
  padding:0;cursor:pointer;
  background:none;
  -webkit-appearance:none;
  appearance:none;
}
.editor-color-input-sm::-webkit-color-swatch-wrapper{
  padding:0;
}
.editor-color-input-sm::-webkit-color-swatch{
  border:none;
  border-radius:50%;
}

/* Text controls */
.editor-text-controls{
  display:flex;flex-direction:column;gap:4px;
}
.editor-text-style-row{
  display:flex;gap:4px;margin-top:4px;
}
.editor-style-btn{
  width:30px;height:30px;
  padding:0;
  display:flex;align-items:center;justify-content:center;
  font-size:13px;
}
.editor-style-btn.active{
  background:var(--accent-light);
  border-color:var(--accent);
  color:var(--accent);
}

/* Sticker tabs & grid */
.editor-sticker-tabs{
  display:flex;gap:4px;margin-bottom:8px;
}
.editor-sticker-tab{
  padding:3px 10px;
  font-size:12px;
  border:1px solid var(--border);
  border-radius:12px;
  background:none;
  cursor:pointer;
  color:var(--text2);
  transition:var(--transition);
}
.editor-sticker-tab.active{
  background:var(--accent);color:#fff;border-color:var(--accent);
}
.editor-sticker-grid{
  display:grid;
  grid-template-columns:repeat(6,1fr);
  gap:4px;
}
.editor-sticker-item{
  aspect-ratio:1;
  display:flex;align-items:center;justify-content:center;
  font-size:22px;
  border-radius:6px;
  cursor:pointer;
  transition:var(--transition);
  border:1px solid transparent;
  user-select:none;
}
.editor-sticker-item:hover{
  background:var(--accent-light);
  border-color:var(--accent);
  transform:scale(1.1);
}

/* Source images grid */
.editor-source-grid{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:4px;
}

/* Gallery multi-select mode */
.gallery-item.selectable{cursor:pointer}
.gallery-item.selected-for-editor{
  box-shadow:0 0 0 3px var(--accent);
  border-radius:8px;
}
.gallery-item.selected-for-editor::after{
  content:'\2713';
  position:absolute;top:4px;right:4px;
  width:20px;height:20px;
  background:var(--accent);color:#fff;
  border-radius:50%;font-size:11px;
  display:flex;align-items:center;justify-content:center;
  z-index:2;
}

/* Create collage bar */
.gallery-collage-bar{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  padding:8px;
  background:var(--accent);
  border-radius:var(--radius-sm);
  margin-bottom:8px;
}
.gallery-collage-bar span{
  color:#fff;font-size:13px;font-weight:500;
}
.gallery-collage-bar .btn{
  background:#fff;color:var(--accent);font-weight:600;
}
.gallery-collage-bar .btn:hover{
  background:#ffe0e5;
}
.gallery-collage-bar .btn-cancel{
  background:transparent;color:#fff;border:1px solid rgba(255,255,255,.5);
}

/* Export overlay */
.editor-export-overlay{
  position:absolute;inset:0;
  background:rgba(255,255,255,.85);
  display:flex;align-items:center;justify-content:center;
  flex-direction:column;gap:10px;
  z-index:10;
  border-radius:var(--radius);
}
.editor-export-overlay .spinner{
  width:28px;height:28px;
  border-width:2px;
}
.editor-export-overlay p{
  font-size:13px;color:var(--text2);
}

/* ===== Editor responsive ===== */
@media(max-width:768px){
  .editor-panels{
    flex-direction:column;
  }
  .editor-canvas-area{
    flex:none;
    min-height:50vh;
  }
  .editor-controls{
    flex:none;
    max-width:none;
    border-left:none;
    border-top:1px solid var(--border-light);
  }
}
