/* ===================================================================
   Persona — Claude-style redesign
   Warm neutrals · serif headings · pill accents · thin borders
   =================================================================== */

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

:root{
  /* warm neutrals, very low chroma */
  --bg:           oklch(98.5% 0.004 80);
  --bg-muted:     oklch(97.4% 0.004 80);
  --surface:      oklch(99.5% 0.003 80);
  --surface-2:    oklch(96.2% 0.005 80);
  --surface-3:    oklch(93%   0.006 80);
  --line:         oklch(90%   0.006 80);
  --line-2:       oklch(85%   0.008 80);

  /* ink (text) */
  --ink:          oklch(22%   0.01  80);
  --ink-2:        oklch(42%   0.01  80);
  --ink-3:        oklch(58%   0.01  80);
  --ink-4:        oklch(72%   0.008 80);

  /* legacy names still used across app.js + style rules */
  --text:         var(--ink);
  --text2:        var(--ink-2);
  --text3:        var(--ink-3);
  --card:         var(--surface);
  --card-strong:  var(--surface);
  --border:       var(--line);
  --border-light: oklch(93% 0.006 80);
  --sidebar-bg:   var(--surface);
  --sidebar-w:    72px;
  --topbar-h:     52px;

  /* single warm coral accent */
  --accent:       oklch(60% 0.17 30);
  --accent-ink:   oklch(42% 0.14 30);
  --accent-bg:    oklch(96% 0.03 30);
  --accent-hover: oklch(54% 0.18 30);
  --accent-light: oklch(96% 0.03 30);
  --accent-ring:  oklch(82% 0.09 30 / .55);

  /* state colors */
  --ok:      oklch(68% 0.12 155);
  --warn:    oklch(75% 0.15 75);
  --danger:  oklch(55% 0.19 25);

  /* radius scale */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 24px;
  --radius:    var(--r-lg);
  --radius-sm: var(--r-md);

  /* subtle shadows */
  --shadow-1: 0 1px 2px rgba(40,28,16,.04), 0 1px 1px rgba(40,28,16,.03);
  --shadow-2: 0 6px 24px rgba(40,28,16,.05), 0 2px 6px rgba(40,28,16,.04);
  --shadow-3: 0 24px 60px rgba(40,28,16,.09), 0 6px 16px rgba(40,28,16,.05);
  --shadow:        var(--shadow-1);
  --shadow-hover:  var(--shadow-2);

  /* typography */
  --font-sans:  "Inter", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  --font-serif: "Fraunces", "Noto Serif SC", "Noto Sans SC", Georgia, serif;
  --font-mono:  ui-monospace, SFMono-Regular, Menlo, "JetBrains Mono", monospace;

  --transition: background-color .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease, opacity .18s ease, color .18s ease;
}

/* ===== Base ===== */
html{font-size:16px;background:var(--bg)}
body{
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  min-height:100vh;
  overflow:hidden;
}
button{ font-family: inherit; color: inherit; background:none; border:none; cursor:pointer; }
input, textarea, select{ font-family: inherit; color: inherit; }
.hidden{display:none!important}

::-webkit-scrollbar{ width:10px; height:10px; }
::-webkit-scrollbar-thumb{ background: var(--line-2); border-radius:10px; border:2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover{ background: var(--ink-4); }
::-webkit-scrollbar-track{ background: transparent; }

/* ===== App layout ===== */
.app-layout{
  display:flex;
  height:100vh;
  overflow:hidden;
  gap:0;
  position:relative;
}

/* ===== Profile strip (horizontal model chips) ===== */
.profile-strip{
  flex-shrink:0;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display:flex;
  align-items:center;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
.profile-strip::-webkit-scrollbar{ height:6px; }
.profile-strip-label{
  flex-shrink:0;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: var(--ink-4);
  letter-spacing: .05em;
  display:inline-flex; align-items:center; gap:4px;
  padding-right: 6px;
}
.profile-strip-sep{ color: var(--ink-5, var(--ink-4)); opacity:.6; }
.profile-strip-list{
  display:flex; gap: 8px; align-items:center;
  flex-shrink:0;
}

.profile-chip{
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px 4px 4px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
  white-space: nowrap;
}
.profile-chip:hover{
  border-color: var(--line-2);
  background: var(--surface-2);
  color: var(--ink);
}
.profile-chip.active{
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent-ink, var(--ink));
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.profile-chip-avatar{
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface-2);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.profile-chip-avatar img{
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.profile-chip-name{
  line-height: 1;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-chip-delete{
  position: absolute;
  top: -4px; right: -4px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--danger, #c04a3a);
  color: #fff;
  font-size: 10px; line-height: 1;
  display: none;
  align-items: center; justify-content: center;
  box-shadow: var(--shadow-1);
}
.profile-chip:hover .profile-chip-delete{ display: inline-flex; }
.profile-chip-delete:hover{ filter: brightness(.9); }

.profile-chip-new{
  padding: 0 14px;
  border-style: dashed;
  color: var(--ink-3);
  background: transparent;
}
.profile-chip-new:hover{
  border-color: var(--accent);
  color: var(--accent-ink, var(--ink));
  background: var(--accent-bg);
}
.profile-chip-new-icon{
  font-weight: 300;
  font-size: 15px;
  line-height: 1;
  margin-right: -2px;
}

.profile-strip-empty{
  font-size: 12px;
  color: var(--ink-4);
  padding-left: 2px;
}

/* legacy sidebar classes kept as no-op so CSS resolves even if referenced */
.sidebar, .sidebar-overlay, .sidebar-header, .sidebar-profile-list,
.sp-card, .sp-card-thumb, .sp-card-info, .sp-card-name, .sp-card-meta,
.sp-card-delete, .sidebar-empty, .sidebar-toggle{ display: none !important; }

/* ===== Main content ===== */
.main-content{
  flex:1; min-width:0;
  display:flex; flex-direction:column;
  overflow:hidden;
  background: var(--bg);
}

/* ===== Topbar ===== */
.topbar{
  height: var(--topbar-h);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 0 18px;
  display:flex; align-items:center; gap:10px;
  flex-shrink:0;
  position:sticky; top:0; z-index:40;
}
.topbar-title{
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--ink);
  position: relative;
  padding-left: 30px;
}
.topbar-title::before{
  content:"";
  position:absolute; left:0; top:50%; transform:translateY(-50%);
  width:22px; height:22px;
  border-radius:6px;
  background: linear-gradient(135deg, var(--accent), oklch(52% 0.18 18));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.topbar-title::after{
  content:"模特工作室";
  margin-left: 10px;
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--ink-4);
  letter-spacing: 0;
  font-weight: 400;
}

.sidebar-toggle,
.btn-icon.sidebar-toggle{ display:none; }
.btn-icon{
  width:32px; height:32px; border-radius: var(--r-sm);
  display:flex; align-items:center; justify-content:center;
  color: var(--ink-2);
  background: transparent;
  transition: var(--transition);
}
.btn-icon:hover{ background: var(--surface-2); color: var(--ink); }

.topbar-editor-btn,
.topbar-enhance-btn{
  height:30px; padding: 0 10px;
  font-size: 12px;
  color: var(--ink-2);
  border-radius: var(--r-sm);
  display:inline-flex; align-items:center; gap:5px;
  background: transparent;
}
.topbar-editor-btn:hover,
.topbar-enhance-btn:hover{ background: var(--surface-2); color: var(--ink); }

.topbar-right{
  margin-left:auto;
  display:flex; align-items:center; gap:4px;
}
.model-settings-btn{
  height:30px; padding:0 10px;
  font-size:12px;
  color: var(--ink-2);
  border-radius: var(--r-sm);
  display:inline-flex; align-items:center; gap:5px;
}
.model-settings-btn:hover{ background: var(--surface-2); color: var(--ink); }
.topbar-params-btn,
.topbar-history-btn{
  height:30px; padding:0 10px;
  font-size:12px;
  color: var(--ink-2);
  border-radius: var(--r-sm);
  display:inline-flex; align-items:center; gap:6px;
  position: relative;
}
.topbar-params-btn:hover,
.topbar-history-btn:hover{ background: var(--surface-2); color: var(--ink); }
.topbar-count-badge{
  font-size:10px; line-height:1;
  color: var(--ink-3);
  background: var(--surface-2);
  padding:2px 6px; border-radius: 99px;
  margin-left: 2px;
}

/* ===== Workspace sections ===== */
.workspace-section{
  flex:1; min-height:0;
  overflow-y:auto;
  padding: 18px;
  display:flex; flex-direction:column; gap:14px;
}
#ws-main > *{ flex-shrink: 0; }
#ws-main > .workspace-panels{
  flex: 0 0 auto;
}
.ws-empty{
  padding: 0; align-items:center; justify-content:center; min-height:100%;
}
.empty-state{
  text-align:center;
  padding: 60px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  max-width: 420px;
  width:100%;
  box-shadow: var(--shadow-1);
}
.empty-icon{ font-size:36px; margin-bottom:10px; display:block; opacity:.75; }
.empty-state h2{
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin-bottom:6px;
}
.empty-state p{
  font-size:13px;
  color: var(--ink-3);
  margin-bottom: 16px;
  line-height:1.5;
}

/* ===== Active model strip ===== */
.active-model-strip-wrap{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.active-model-strip{
  padding: 10px 14px;
  display:flex; align-items:center; gap:10px;
  cursor: pointer;
  transition: var(--transition);
}
.active-model-strip:hover{ background: var(--surface-2); }
.active-model-thumb{
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink:0;
}
.active-model-info{
  display:flex; flex-direction:column;
  line-height: 1.2;
  flex:1; min-width:0;
}
.active-model-name{
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 400;
  color: var(--ink);
}
.active-model-meta{
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-mono);
}
.strip-edit-hint{
  font-size: 11px;
  color: var(--ink-3);
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
}

.profile-detail-inline{
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  display:flex; flex-direction:column; gap: 12px;
}
.detail-images-row{
  display:flex; gap:12px; align-items:flex-start;
}
.detail-img-original{
  width: 92px; height: 116px;
  border-radius: var(--r-md);
  object-fit: cover;
  border: 1px solid var(--line);
}
.detail-img-refsheet{
  max-width: 100%;
  max-height: 180px;
  border-radius: var(--r-md);
  object-fit: contain;
  border: 1px solid var(--line);
}
.detail-refsheet-wrap{
  flex:1; min-width:0;
  position:relative;
  display:flex; align-items:center; justify-content:center;
  padding: 10px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  min-height: 120px;
}
.refsheet-regen-overlay{
  position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  background: rgba(254,252,248,.75);
  backdrop-filter: blur(2px);
  border-radius: var(--r-md);
}
.spinner-sm{
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.detail-fields{ display:flex; flex-direction:column; gap:10px; }
.detail-field{ display:flex; flex-direction:column; gap:4px; }
.detail-field label{
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: .02em;
}
.detail-field-row{ display:flex; gap:10px; }
.detail-actions{ display:flex; gap:8px; }

/* ===== Card ===== */
.card{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px;
  box-shadow: none;
}
.section-header{
  display:flex; align-items:baseline; gap:10px;
  margin-bottom: 10px;
  padding-bottom: 2px;
}
.section-header h2{
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: -0.005em;
  color: var(--ink);
  flex:1;
}
.optional-tag{
  font-size: 11px; font-weight: 400;
  color: var(--ink-4);
  font-family: var(--font-mono);
  margin-left: 4px;
}
.badge{
  font-size: 10px;
  color: var(--ink-3);
  background: var(--surface-2);
  padding: 2px 7px;
  border-radius: 999px;
  font-family: var(--font-mono);
  letter-spacing: .02em;
}

/* ===== Upload area ===== */
.upload-area{
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r-lg);
  padding: 36px 20px;
  text-align:center;
  background: var(--surface);
  cursor: pointer;
  transition: var(--transition);
  min-height: 220px;
  display:flex; align-items:center; justify-content:center;
  flex-direction:column;
  gap: 8px;
}
.upload-area:hover,
.upload-area.dragover{
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent-ink);
}
.upload-icon{ font-size:34px; opacity:.7; }
.upload-area p{ font-size:13px; color: var(--ink-2); }
.upload-area .hint{ font-size: 11px; color: var(--ink-4); }
.ref-preview{
  max-width:100%;
  max-height:260px;
  border-radius: var(--r-md);
  object-fit: contain;
}
.ref-actions{ margin-top: 8px; display:flex; gap:8px; justify-content:center; }

/* ===== Refsheet section ===== */
.refsheet-section{ margin-top:14px; display:flex; flex-direction:column; gap:10px; }
.refsheet-hint{ text-align:center; font-size:11px; color:var(--ink-4); }
.refsheet-preview img{
  width:100%;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
}
.identity-desc-section{ display:flex; flex-direction:column; gap: 4px; }
.identity-desc-section label{
  font-size: 11px; color: var(--ink-3); font-weight: 500;
}
.identity-desc-input{
  width:100%;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
  min-height: 56px;
  font-family: var(--font-sans);
}
.identity-desc-input:focus{
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.save-profile-section{ display:flex; flex-direction:column; gap:10px; margin-top:10px; }
.profile-name-input,
.bio-input,
.field-select{
  width:100%;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  font-size: 12px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
}
.profile-name-input:focus,
.bio-input:focus,
.field-select:focus{
  outline:none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.bio-input{ resize: vertical; min-height: 48px; line-height: 1.5; }
.field-row{ display:flex; gap:10px; }
.field-half{ flex:1; display:flex; flex-direction:column; gap:4px; }
.field-half label{ font-size: 11px; color: var(--ink-3); font-weight:500; }
.field-hint{ font-size: 10px; color: var(--ink-4); font-family: var(--font-mono); }

/* ===== Scene / Wardrobe grid ===== */
#scene-card .scene-grid{ --visible-rows: 3; }
#wardrobe-card .scene-grid{ --visible-rows: 4; }
.embedded-mode #scene-card .scene-grid{ --visible-rows: 2; }

.scene-grid{
  --grid-gap: 10px;
  --card-height: 148px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: var(--grid-gap);
  margin-top: 4px;
  overflow-y: auto;
  align-content: start;
  max-height: calc((var(--visible-rows, 99) * var(--card-height)) + ((var(--visible-rows, 99) - 1) * var(--grid-gap)) + 2px);
  padding: 2px;
}
.scene-card-image{
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 3/4;
  border: 1px solid var(--line);
  transition: transform .15s, border-color .15s, box-shadow .15s;
  background: var(--surface-2);
  outline: 2px solid transparent;
  outline-offset: 2px;
}
.scene-card-image:hover{
  transform: translateY(-1px);
  border-color: var(--line-2);
  box-shadow: var(--shadow-2);
}
.scene-card-image.selected{
  outline-color: var(--accent);
  border-color: transparent;
}
.scene-card-image.selected::after{
  content: "✓";
  position: absolute;
  top: 6px; right: 6px;
  width: 20px; height: 20px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
  z-index: 3;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.scene-card-thumb{
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.scene-card-overlay{
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 14px 8px 7px;
  background: linear-gradient(to top, rgba(0,0,0,.55), transparent);
}
.scene-card-overlay .scene-name{
  font-size: 11px;
  font-weight: 500;
  color: #fff;
  letter-spacing: .01em;
  text-shadow: 0 1px 3px rgba(0,0,0,.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scene-card-delete{
  position: absolute;
  top: 6px; left: 6px;
  width: 20px; height: 20px;
  background: rgba(22,16,12,.55);
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 4;
  line-height: 1;
  backdrop-filter: blur(4px);
}
.scene-card-image:hover .scene-card-delete{ display:flex; }
.scene-card-delete:hover{ background: var(--danger); }

.scene-card-preview{
  position: absolute;
  top: 6px; left: 28px;
  width: 20px; height: 20px;
  background: rgba(22,16,12,.55);
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 4;
  backdrop-filter: blur(4px);
}
.scene-card-image:hover .scene-card-preview{ display:flex; }
.scene-card-preview:hover{ background: rgba(22,16,12,.8); }

.scene-empty{
  text-align:center;
  padding: 24px;
  color: var(--ink-4);
  font-size: 12px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
  margin-top: 6px;
}

.scene-generate-bar{
  display: none !important;
}
.btn-generate{
  min-width: 220px;
  padding: 0 22px;
  height: 42px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--r-md);
}

/* ===== Generation bar (sticky: 本次生成 + 生成 button) ===== */
.generation-bar{
  position: sticky;
  bottom: 0;
  z-index: 20;
  margin-top: 4px;
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-radius: var(--r-md) var(--r-md) 0 0;
  box-shadow: 0 -6px 24px -20px rgba(22, 14, 8, .35);
}
.generation-summary{
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.generation-summary-label{
  font-size: 11px;
  color: var(--ink-4);
  letter-spacing: .04em;
  flex-shrink: 0;
}
.generation-summary-pills{
  display: inline-flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.generation-summary-count{
  margin-left: auto;
  font-size: 13px;
  color: var(--ink-3);
  white-space: nowrap;
}
.generation-summary-count #gen-summary-num{
  font-weight: 600;
  color: var(--ink);
}
.gen-pill{
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
}
.gen-pill.gen-pill-profile{
  background: #1a1613;
  color: #f5ede3;
  border-color: transparent;
  padding-left: 4px;
}
.gen-pill.gen-pill-profile.is-empty{
  background: var(--surface);
  color: var(--ink-4);
  padding-left: 12px;
}
.gen-pill.gen-pill-profile.is-empty .gen-pill-avatar{ display: none; }
.gen-pill-avatar{
  width: 22px; height: 22px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: #fff; font-size: 10px; font-weight: 600;
}
.gen-pill-avatar img{ width: 100%; height: 100%; object-fit: cover; display: block; }
.gen-pill-text{ line-height: 1; }
.gen-pill-tag{
  font-size: 11px;
  color: var(--ink-4);
  margin-left: 2px;
}
.gen-pill.gen-pill-profile .gen-pill-tag{ color: #b8ada0; }
.gen-pill.gen-pill-scene{ background: #fbe7dc; color: #7a3d2d; border-color: transparent; }
.gen-pill.gen-pill-scene .gen-pill-tag{ color: #a46650; }
.gen-pill.gen-pill-wardrobe{ background: #fde3e3; color: #7b3737; border-color: transparent; }
.gen-pill.gen-pill-wardrobe .gen-pill-tag{ color: #a35353; }
.gen-pill-x{
  color: var(--ink-4);
  font-size: 12px;
  font-weight: 300;
  margin: 0 -2px;
}

.btn-generate-primary{
  width: 100%;
  min-height: 52px;
  padding: 0 22px;
  border-radius: var(--r-md);
  background: #1a1613;
  color: #f5ede3;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: .02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid #1a1613;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn-generate-primary:hover:not(:disabled){ background: #000; }
.btn-generate-primary:active:not(:disabled){ transform: translateY(1px); }
.btn-generate-primary:disabled{
  background: var(--surface-2);
  color: var(--ink-4);
  border-color: var(--line);
  cursor: not-allowed;
}
.btn-generate-icon{
  font-size: 13px;
  opacity: .85;
}
.btn-generate-kbd{
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,.08);
  color: inherit;
  opacity: .7;
  margin-left: 6px;
  font-family: var(--font-mono, monospace);
}
.btn-generate-primary:disabled .btn-generate-kbd{
  background: transparent;
  color: var(--ink-4);
}

.scene-grid.dragover{
  outline: 2px dashed var(--accent);
  outline-offset: 4px;
  border-radius: var(--r-md);
}

/* ===== Buttons ===== */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  padding: 0 14px;
  height: 34px;
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  line-height: 1;
  white-space: nowrap;
}
.btn-sm{ height: 28px; padding: 0 10px; font-size: 11px; border-radius: var(--r-sm); }
.btn-primary{
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.btn-primary:hover{
  background: oklch(32% 0.015 80);
  border-color: oklch(32% 0.015 80);
  transform: translateY(-1px);
}
.btn-primary:disabled{
  background: var(--surface-3);
  border-color: var(--surface-3);
  color: var(--ink-4);
  cursor: not-allowed;
  transform: none;
}
.btn-ghost{
  background: transparent;
  color: var(--ink-2);
  border-color: transparent;
}
.btn-ghost:hover{
  background: var(--surface-2);
  color: var(--ink);
}
.btn-danger{
  color: var(--danger);
}

/* ===== Panels: scene+wardrobe on left, pipeline+result on right ===== */
.workspace-panels{
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-auto-rows: min-content;
  align-items: start;
  gap: 14px;
}
.panel-left{
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 2px;
}
.panel-left .card{
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.panel-left .scene-grid{
  flex: 0 0 auto;
}
.panel-right{
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  padding: 2px;
}
.panel-right .card{
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.panel-devbar{
  display:flex;
  justify-content:flex-end;
  align-items:center;
  gap:8px;
}
.dev-mode-toggle{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  letter-spacing: .02em;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: var(--transition);
}
.dev-mode-toggle:hover{ border-color: var(--line-2); }
.dev-mode-toggle input{
  width: 28px; height: 16px;
  appearance: none;
  background: var(--surface-3);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: var(--transition);
}
.dev-mode-toggle input::before{
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  background: #fff;
  border-radius: 50%;
  transition: transform .18s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.dev-mode-toggle input:checked{ background: var(--accent); }
.dev-mode-toggle input:checked::before{ transform: translateX(12px); }

.panel-placeholder{
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  display:flex; align-items:center; justify-content:center;
  min-height: 280px;
}
.placeholder-inner{
  display:flex; flex-direction:column; align-items:center; gap:10px;
  text-align:center;
  padding: 40px;
}
.placeholder-icon{
  width: 54px; height: 54px;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  display:grid; place-items:center;
  font-size: 22px;
  color: var(--ink-4);
}
.panel-placeholder p{
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--ink-2);
  font-weight: 400;
}

/* ===== Pipeline steps ===== */
.pipeline-steps{
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.pipeline-step{
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  transition: var(--transition);
}
.pipeline-step:last-child{ border-bottom: none; }
.pipeline-step.active{ background: var(--accent-bg); }
.pipeline-step.done{ background: transparent; }
.pipeline-step.error{ background: oklch(97% 0.03 25); }

.pipeline-step-header{
  display:flex; align-items:center; gap: 8px;
  font-size: 12px;
}
.pipeline-step-icon{
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--ink-3);
  font-size: 10px;
  display:grid; place-items:center;
  font-family: var(--font-mono);
  font-weight: 500;
}
.pipeline-step.active .pipeline-step-icon{
  background: var(--accent);
  color: #fff;
}
.pipeline-step.done .pipeline-step-icon{
  background: var(--ok);
  color: #fff;
}
.pipeline-step.error .pipeline-step-icon{
  background: var(--danger);
  color: #fff;
}
.pipeline-step-label{
  color: var(--ink-2);
  font-weight: 500;
  flex: 1;
}
.pipeline-step.active .pipeline-step-label{ color: var(--accent-ink); }
.pipeline-step-status{
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-mono);
}
.pipeline-step.active .pipeline-step-status{
  color: var(--accent-ink);
}
.pipeline-step-detail{
  padding-left: 26px;
  padding-top: 4px;
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.5;
}
.pipeline-step-detail:not(:empty){
  margin-top: 2px;
}
.pipeline-step-detail .clean-bg-thumb{
  width: 96px; height: 120px;
  border-radius: var(--r-sm);
  object-fit: cover;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: var(--transition);
}
.pipeline-step-detail .clean-bg-thumb:hover{
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}
.pipeline-step-detail .desc-text{
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--ink-2);
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
}

/* ===== Result area ===== */
#step-result{
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.result-images-wrap{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.result-image-wrap{
  position: relative;
  background: var(--surface-2);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
}
.result-image-wrap img{
  width: 100%;
  display: block;
  border-radius: var(--r-md);
}
.result-slot-spinner{
  min-height: 240px;
  aspect-ratio: 2 / 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--ink-3);
  font-size: 12px;
  text-align: center;
  padding: 12px;
}
.result-slot-spinner.failed{
  color: var(--accent);
}
.result-slot-text{
  max-width: 100%;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.result-actions{
  display: flex; gap: 8px; flex-wrap: wrap;
  padding-top: 4px;
}
.error-box{
  padding: 14px;
  background: oklch(97% 0.03 25);
  border: 1px solid oklch(85% 0.08 25);
  border-radius: var(--r-md);
  color: var(--danger);
  font-size: 12px;
  display:flex; flex-direction:column; gap: 8px;
  align-items: flex-start;
}

/* ===== Loading / spinner ===== */
.loading{
  padding: 40px 20px;
  display:flex; flex-direction:column; align-items:center; gap:12px;
  text-align:center;
}
.spinner{
  width: 28px; height: 28px; border-radius: 50%;
  border: 2.5px solid var(--line);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.loading-text{
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--ink-2);
  font-weight: 400;
}
.loading-hint{
  font-size: 11px;
  color: var(--ink-4);
  font-family: var(--font-mono);
}
@keyframes spin{ to{ transform: rotate(360deg); } }
@keyframes shimmer{ 0%{background-position:200% 0} 100%{background-position:-200% 0} }
@keyframes slideIn{ from{transform:translateX(20px); opacity:0} to{transform:translateX(0); opacity:1} }

/* ===== Model settings panel (参数) ===== */
.model-settings-panel{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.drawer-body .model-settings-panel{
  background: transparent;
  border: none;
  padding: 0;
  gap: 14px;
}
.ms-row{
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
}
.ms-label{
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  font-family: var(--font-mono);
  letter-spacing: .02em;
  min-width: 56px;
}
.ms-btn-group{
  display: inline-flex;
  gap: 2px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: var(--r-sm);
}
.ms-btn{
  padding: 4px 10px;
  font-size: 11px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-3);
  transition: var(--transition);
  white-space: nowrap;
  font-family: var(--font-sans);
  font-weight: 500;
}
.ms-btn:hover{ color: var(--ink); }
.ms-btn.active{
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}
.ms-hint{
  font-size: 10px;
  color: var(--ink-4);
  font-family: var(--font-mono);
}
.ms-toggle{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  min-height: 26px;
}
.ms-toggle input{
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.ms-toggle-track{
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  position: relative;
  transition: var(--transition);
}
.ms-toggle-track::after{
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: var(--transition);
}
.ms-toggle input:checked + .ms-toggle-track{
  background: var(--ink);
  border-color: var(--ink);
}
.ms-toggle input:checked + .ms-toggle-track::after{
  transform: translateX(14px);
}
.ms-toggle-text{
  font-size: 11px;
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
}

/* ===== Gallery grid ===== */
.gallery-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 4px;
}
.gallery-item{
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  aspect-ratio: 3/4;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface-2);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.gallery-item:hover{
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
  border-color: var(--line-2);
}
.gallery-item img{
  width:100%; height:100%;
  object-fit: cover;
  display: block;
}
.gallery-item-overlay{
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 14px 8px 7px;
  background: linear-gradient(to top, rgba(0,0,0,.55), transparent);
  color: #fff;
  font-size: 10px;
  font-family: var(--font-mono);
}
.gallery-item-delete{
  position: absolute;
  top: 6px; right: 6px;
  width: 22px; height: 22px;
  background: rgba(22,16,12,.55);
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
  backdrop-filter: blur(4px);
}
.gallery-item:hover .gallery-item-delete{ display: flex; }
.gallery-item-delete:hover{ background: var(--danger); }

.gallery-actions{
  margin-top: 12px;
  display: flex; justify-content: center;
}

/* ===== Developer panel ===== */
.developer-panel{
  display: flex; flex-direction: column; gap: 12px;
}
.developer-editor{ display:flex; flex-direction:column; gap: 8px; }
.developer-editor-row{
  display:flex; align-items:center; gap:10px;
}
.developer-editor-row label{
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  letter-spacing: .02em;
  min-width: 60px;
}
.developer-prompt-text{
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
}
.developer-editor-actions{
  display:flex; align-items:center; gap:8px; justify-content: flex-end;
}
.enhance-prompt-status{
  font-size: 11px; color: var(--ink-3);
  font-family: var(--font-mono);
}
.developer-trace-empty{
  padding: 20px;
  text-align: center;
  color: var(--ink-4);
  font-size: 12px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
}
.developer-trace-list{ display:flex; flex-direction:column; gap:10px; }
.developer-trace-item{
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.developer-trace-item-header{
  padding: 8px 12px;
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-2);
  display:flex; align-items:center; gap: 8px;
}
.developer-trace-item-body{
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--ink-2);
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
}

/* ===== Enhance section ===== */
.enhance-header-card{
  display: flex; flex-direction: column; gap: 10px;
}
.enhance-topbar{
  display:flex; align-items:center; gap:10px;
  flex-wrap: wrap;
}
.enhance-title-wrap{ flex: 1; min-width: 0; }
.editor-title{
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: -0.01em;
}
.enhance-topbar-actions{ display:flex; align-items:center; gap: 8px; }
.enhance-settings-shell{ }
.enhance-controls{
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(240px, 1fr);
  gap: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.enhance-prompt-field label{
  font-size: 11px; color: var(--ink-3); font-weight: 500;
  letter-spacing: .02em;
}
.enhance-prompt-row{
  display:flex; justify-content: space-between; gap: 10px;
  align-items: center; flex-wrap: wrap;
  margin-top: 4px;
}
.enhance-prompt-actions{ display:flex; gap: 6px; align-items:center; }
.enhance-control-side{ display:flex; flex-direction:column; gap: 10px; }
.enhance-note{
  font-size: 11px; color: var(--ink-4);
  font-family: var(--font-mono);
  line-height: 1.5;
}

.enhance-compare-panels{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.enhance-stage-card,
.enhance-result-card{
  display: flex; flex-direction: column; gap: 8px;
}
.enhance-upload-area{
  min-height: 320px;
}
.enhance-stage-image,
.enhance-result-image{
  width: 100%;
  max-height: 480px;
  border-radius: var(--r-md);
  object-fit: contain;
  background: var(--surface-2);
}
.enhance-result-stage{
  min-height: 320px;
  display:flex; align-items:center; justify-content:center;
  background: var(--surface-2);
  border-radius: var(--r-md);
  overflow: hidden;
  position: relative;
}
.enhance-panel-actions{ display: flex; gap: 8px; justify-content: flex-start; }
.enhance-panel-hint{ font-size: 11px; color: var(--ink-4); font-family: var(--font-mono); }
.enhance-primary-action{ display:flex; justify-content: center; }
.enhance-run-btn{
  min-width: 200px;
  height: 42px;
  padding: 0 22px;
  font-size: 13px;
  font-weight: 500;
}
.enhance-compare-bar{
  display:flex; align-items:center; gap: 10px;
}
.enhance-compare-hint{ font-size: 11px; color: var(--ink-4); }

/* ===== Editor section ===== */
.editor-topbar{
  display:flex; align-items:center; gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.editor-topbar-actions{
  margin-left:auto;
  display:flex; align-items:center; gap: 8px;
}
.editor-res-select{ height: 32px; font-size: 12px; }
.editor-panels{
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  flex: 1;
  min-height: 0;
}
.editor-canvas-area{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  position: relative;
  display:flex; align-items:center; justify-content:center;
  overflow: hidden;
  min-height: 400px;
}
.editor-empty-state{
  display:flex; flex-direction:column; align-items:center; gap: 10px;
  text-align:center;
  padding: 40px;
  color: var(--ink-3);
}
.editor-empty-icon{ opacity: .5; }
.editor-empty-title{
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--ink-2);
}
.editor-empty-hint{ font-size: 11px; color: var(--ink-4); font-family: var(--font-mono); }
.editor-canvas-wrap{
  position: relative;
}
.editor-cell-controls-layer{
  position: absolute; inset: 0; pointer-events: none;
}
.editor-cell-controls-layer > *{ pointer-events: auto; }

.editor-controls{
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto;
  min-height: 0;
}
.editor-card{ padding: 12px; }
.editor-card .section-header{ margin-bottom: 8px; }
.editor-card .section-header h2{
  font-family: var(--font-serif);
  font-size: 13px;
}
.editor-source-grid,
.editor-template-grid,
.editor-sticker-grid,
.editor-arttext-grid{
  display: grid;
  gap: 6px;
}
.editor-source-grid{
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
}
.editor-template-grid{
  grid-template-columns: repeat(3, 1fr);
}
.editor-sticker-grid,
.editor-arttext-grid{
  grid-template-columns: repeat(3, 1fr);
  max-height: 260px;
  overflow-y: auto;
}
.editor-img-actions{ display: flex; gap: 6px; margin-top: 8px; }
.editor-img-btn{ flex: 1; }

.editor-cell-toolbar{
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
}
.editor-cell-status{ font-size: 11px; color: var(--ink-3); font-family: var(--font-mono); }
.editor-cell-hint{
  margin-top: 6px;
  font-size: 10px;
  color: var(--ink-4);
  line-height: 1.5;
}
.editor-control-row{
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0;
}
.editor-control-row label{
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  min-width: 40px;
}
.editor-slider{
  flex: 1;
  appearance: none;
  height: 4px;
  background: var(--surface-3);
  border-radius: 4px;
  outline: none;
}
.editor-slider::-webkit-slider-thumb{
  appearance: none;
  width: 14px; height: 14px;
  background: var(--ink);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.editor-slider-val{
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  min-width: 28px;
  text-align: right;
}

.editor-arttext-tabs,
.editor-sticker-tabs{
  display: inline-flex;
  gap: 2px;
  background: var(--surface-2);
  padding: 2px;
  border-radius: var(--r-sm);
  margin-bottom: 8px;
}
.editor-arttext-tab,
.editor-sticker-tab{
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-3);
  font-family: var(--font-sans);
  font-weight: 500;
  transition: var(--transition);
}
.editor-arttext-tab:hover,
.editor-sticker-tab:hover{ color: var(--ink); }
.editor-arttext-tab.active,
.editor-sticker-tab.active{
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}
.editor-arttext-hint{
  margin-top: 6px;
  font-size: 10px;
  color: var(--ink-4);
  line-height: 1.5;
}
.editor-palette-section{ margin-top: 6px; }
.editor-palette-label{
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-mono);
}
.editor-color-palette{
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  margin-top: 4px;
}
.editor-color-palette button{
  width: 100%;
  aspect-ratio: 1;
  border-radius: 4px;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: var(--transition);
}
.editor-color-palette button:hover{ transform: scale(1.1); }
.editor-palette-custom{ margin-top: 4px; }
.editor-color-input-sm{
  width: 28px; height: 20px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0;
  cursor: pointer;
  background: transparent;
}
.editor-text-style-row{
  display: flex; gap: 4px; margin-top: 8px;
}
.editor-style-btn{
  width: 28px; height: 28px;
  padding: 0;
  font-size: 11px;
  border: 1px solid var(--line);
}
.editor-text-controls{ margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }

.editor-history-overlay{
  position: fixed;
  inset: 0;
  background: rgba(30,22,16,.4);
  backdrop-filter: blur(3px);
  z-index: 70;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.editor-history-panel{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px;
  width: min(800px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-3);
}
.editor-history-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}
.editor-history-actions{
  margin-top: 10px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--ink-3);
}

/* ===== Lightbox ===== */
.lightbox{
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.lightbox-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(20,15,12,.75);
  backdrop-filter: blur(4px);
}
.lightbox-content{
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.lightbox-content img{
  max-width: 100%;
  max-height: 82vh;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
}
.lightbox-close{
  position: absolute;
  top: -8px; right: -8px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,.95);
  color: var(--ink);
  font-size: 18px;
  display:grid; place-items:center;
  box-shadow: var(--shadow-2);
  line-height: 1;
}
.lightbox-close:hover{ background: #fff; }
.lightbox-meta{
  color: rgba(255,255,255,.8);
  font-family: var(--font-mono);
  font-size: 11px;
}
.lightbox-download{
  background: #fff;
  color: var(--ink);
}

/* ===== Responsive ===== */
@media(max-width:1100px){
  .enhance-controls{ grid-template-columns: minmax(0, 1.3fr) minmax(240px, 1fr); }
}
@media(max-width:900px){
  .enhance-controls,
  .enhance-compare-panels{
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }
  .enhance-upload-area,
  .enhance-result-stage{ min-height: 280px; }
  .editor-panels{
    grid-template-columns: 1fr;
  }
  .editor-controls{ max-height: none; overflow: visible; }
}
@media(max-width:768px){
  :root{
    --sidebar-w: 56px;
    --topbar-h: 48px;
  }
  .workspace-panels{
    grid-template-columns: 1fr;
  }
  .panel-left,.panel-right{ flex: none; }
  .result-actions{ justify-content: flex-start; }
  .scene-grid{ --grid-gap: 6px; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
  .gallery-grid{ gap: 6px; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .workspace-section{ padding: 12px; }
  .topbar{ padding: 0 12px; gap: 6px; }
  .topbar-title{ font-size: 16px; }
  .topbar-title::after{ display: none; }
}

@media(max-width:640px){
  .sidebar{
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.open{ transform: translateX(0); }
  .sidebar-toggle{ display: flex; }
  :root{ --sidebar-w: 0px; }
}

/* ===== Right-side drawer (params / history) ===== */
.drawer{
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
}
.drawer.hidden{ display: none; }
.drawer-overlay{
  position: absolute; inset: 0;
  background: rgba(20, 15, 12, .3);
  pointer-events: auto;
  animation: drawerFadeIn .2s ease;
}
.drawer-panel{
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(420px, 92vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-3);
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  animation: drawerSlideIn .25s ease;
}
.drawer-header{
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.drawer-header-text{ flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.drawer-title{
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  margin: 0;
  letter-spacing: -.005em;
}
.drawer-subtitle{
  font-size: 11px;
  color: var(--ink-3);
  margin: 0;
  line-height: 1.3;
}
.drawer-close{
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  color: var(--ink-3);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.drawer-close:hover{ background: var(--surface-2); color: var(--ink); }
.drawer-body{
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.drawer-footnote{
  font-size: 11px;
  color: var(--ink-3);
  margin: 0;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.gallery-shell{ display: flex; flex-direction: column; gap: 12px; }
.gallery-shell.hidden{ display: none; }
.gallery-shell .gallery-grid{
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.gallery-shell .gallery-actions{
  display: flex; justify-content: center;
  padding-top: 4px;
}

@keyframes drawerSlideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes drawerFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
