/* ── OFM Prompt Builder — Dark Glassmorphism UI ── */

:root {
  --bg-base:      #0a0a0f;
  --bg-surface:   #111118;
  --bg-card:      #1a1a25;
  --bg-hover:     #22222f;
  --bg-active:    #2a2a3f;
  --border:       rgba(255,255,255,0.07);
  --border-glow:  rgba(108,99,255,0.4);
  --text-primary: #f0f0ff;
  --text-secondary: #888899;
  --text-dim:     #555566;
  --accent:       #6C63FF;
  --accent-2:     #FF6B9D;
  --accent-3:     #06D6A0;
  --success:      #06D6A0;
  --danger:       #FF4D6D;
  --warning:      #FF9F1C;
  --glass:        rgba(255,255,255,0.03);
  --radius:       12px;
  --radius-sm:    8px;
  --radius-lg:    18px;
  --shadow:       0 8px 32px rgba(0,0,0,0.4);
  --shadow-glow:  0 0 20px rgba(108,99,255,0.2);
  --font:         'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;
}

body.light {
  --bg-base:      #f0f0f5;
  --bg-surface:   #ffffff;
  --bg-card:      #ffffff;
  --bg-hover:     #e8e8f0;
  --bg-active:    #ddddf0;
  --border:       rgba(0,0,0,0.09);
  --border-glow:  rgba(108,99,255,0.3);
  --text-primary: #111120;
  --text-secondary: #555566;
  --text-dim:     #9999aa;
  --glass:        rgba(0,0,0,0.02);
  --shadow:       0 4px 20px rgba(0,0,0,0.10);
  --shadow-glow:  0 0 20px rgba(108,99,255,0.12);
}

/* ── Theme Switch ── */
.theme-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.theme-switch-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 99px;
  transition: background 0.2s;
}
.theme-switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.2s, background 0.2s;
}
body.light .theme-switch-track {
  background: var(--accent);
  border-color: var(--accent);
}
body.light .theme-switch-track::after {
  transform: translateX(16px);
  background: #fff;
}
.theme-switch-icon {
  font-size: 14px;
  line-height: 1;
}

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

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── SCROLLBARS ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(108,99,255,0.3); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── HEADER ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 16px;
}

.header-left { display: flex; align-items: center; gap: 20px; }
.header-center { flex: 1; display: flex; justify-content: center; }
.header-right { display: flex; align-items: center; gap: 8px; }

.logo {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}
.logo span {
  color: var(--accent);
  margin-left: 2px;
}

.comfyui-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.status-dot.online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--danger); }

.model-quick-bar {
  display: flex;
  gap: 6px;
}
.model-btn {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.model-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.model-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 0 12px rgba(108,99,255,0.4);
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: var(--font);
}
.btn-ghost {
  background: var(--glass);
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); border-color: rgba(255,255,255,0.15); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.btn-primary:hover { background: #7a72ff; box-shadow: var(--shadow-glow); }
.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #000;
  font-weight: 700;
}
.btn-success:hover { background: #08e8ac; }
.btn-preview {
  background: rgba(255, 159, 28, 0.15);
  border-color: var(--warning);
  color: var(--warning);
}
.btn-preview:hover { background: rgba(255, 159, 28, 0.28); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── MAIN LAYOUT ── */
.main-layout {
  display: grid;
  grid-template-columns: 300px 1fr 360px;
  height: calc(100vh - 56px);
  overflow: hidden;
}

/* ── LEFT PANEL ── */
.left-panel {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.cat-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}
.cat-tab:hover { color: var(--text-primary); border-color: rgba(255,255,255,0.15); }
.cat-tab.active {
  background: color-mix(in srgb, var(--cat-color) 20%, transparent);
  border-color: var(--cat-color);
  color: var(--cat-color);
  box-shadow: 0 0 8px color-mix(in srgb, var(--cat-color) 25%, transparent);
}

.blocks-search {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.blocks-search input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}
.blocks-search input:focus { border-color: var(--accent); }

.blocks-grid {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  align-content: start;
}

/* ── BLOCK CARD ── */
.block-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  text-align: center;
  user-select: none;
  min-height: 70px;
}
.block-card:hover {
  border-color: rgba(255,255,255,0.2);
  background: var(--bg-hover);
  transform: translateY(-1px);
}
.block-card.selected {
  background: color-mix(in srgb, var(--block-color, #6C63FF) 15%, transparent);
  border-color: var(--block-color, #6C63FF);
  box-shadow: 0 0 10px color-mix(in srgb, var(--block-color, #6C63FF) 20%, transparent);
}
.block-card.selected::after {
  content: "✓";
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 10px;
  color: var(--block-color, #6C63FF);
  font-weight: 900;
}
.block-card.placeholder {
  border-style: dashed;
  opacity: 0.5;
}
.block-card.placeholder:hover { opacity: 0.8; }

.block-emoji {
  font-size: 24px;
  line-height: 1;
}
.block-img {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
}
.block-name {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.2;
}
.block-card.selected .block-name {
  color: var(--text-primary);
}
.nsfw-badge {
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: 8px;
  background: rgba(255,77,109,0.3);
  color: #FF4D6D;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 700;
}

/* ── CENTER PANEL ── */
.center-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  background: var(--bg-base);
}

.character-preview {
  position: relative;
  height: 220px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  transition: height 0.3s ease;
}
/* Zone élargie quand preview visible */
.character-preview.has-preview { height: 280px; }

/* Preview overlay */
.preview-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.preview-overlay img {
  flex: 1;
  width: 100%;
  object-fit: contain;
  cursor: zoom-in;
}
.preview-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(255,159,28,0.85);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.5px;
  z-index: 2;
}
.preview-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: rgba(0,0,0,0.65);
  font-size: 11px;
  color: var(--text-secondary);
}

/* Loading state */
.preview-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 13px;
}
.preview-loading small {
  font-size: 11px;
  color: var(--text-dim);
}

.char-base-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.placeholder-content {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 2;
}
.placeholder-icon { font-size: 36px; margin-bottom: 4px; }

.char-ref {
  max-height: 196px;
  max-width: 100%;
  object-fit: contain;
  border-radius: 4px;
}
.char-overlay-controls {
  position: absolute;
  top: 8px;
  right: 8px;
}

.active-blocks-zone {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.active-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 6px;
}
.active-header h3 { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.block-count {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: 10px;
}

.active-blocks-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: start;
}

.empty-build {
  color: var(--text-dim);
  font-size: 13px;
  padding: 20px;
  text-align: center;
  width: 100%;
}
.empty-build p { line-height: 1.8; }

/* Active block chip */
.active-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: default;
  animation: chipIn 0.2s ease;
  width: 100%;
}
@keyframes chipIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
.chip-top {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.active-chip .chip-remove {
  cursor: pointer;
  opacity: 0.5;
  font-size: 10px;
  margin-left: auto;
  line-height: 1;
  background: none;
  border: none;
  color: inherit;
  padding: 0;
  font-family: var(--font);
}
.active-chip .chip-remove:hover { opacity: 1; }

/* ── CHAR CONFIG ── */
.char-config-zone {
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}
.char-config-zone h3 {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 600;
}
.char-info-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.char-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}
.char-info-label {
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
}
.char-info-value {
  color: var(--text-primary);
  font-weight: 500;
}
.trigger-badge {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.lora-name {
  color: var(--accent-3);
  font-size: 10px;
}
.char-info-note {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 4px;
}
.char-info-note code {
  color: var(--accent-2);
  font-family: var(--font-mono);
}
.model-badge-fixed {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.input-dark {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}
.input-dark:focus { border-color: var(--accent); }
.input-dark option { background: var(--bg-card); }

/* ── RIGHT PANEL ── */
.right-panel {
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.prompt-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ptab {
  flex: 1;
  padding: 10px 6px;
  font-size: 11px;
  font-weight: 500;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}
.ptab:hover { color: var(--text-secondary); }
.ptab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.prompt-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}
.tab-panel {
  display: none;
  height: 100%;
  flex-direction: column;
  padding: 10px;
  gap: 6px;
}
.tab-panel.active { display: flex; }

.prompt-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.prompt-textarea {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font);
  line-height: 1.6;
  resize: none;
  outline: none;
  width: 100%;
}
.prompt-textarea.mono {
  font-family: var(--font-mono);
  font-size: 10px;
}
.prompt-textarea:focus { border-color: var(--accent); }

.token-counter {
  font-size: 10px;
  color: var(--text-dim);
  text-align: right;
}

.settings-display {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.settings-display .dim { color: var(--text-dim); font-size: 13px; padding: 16px; text-align: center; }
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.setting-row .key { font-size: 11px; color: var(--text-secondary); }
.setting-row .value { font-size: 12px; font-weight: 600; color: var(--text-primary); font-family: var(--font-mono); }
.setting-note {
  font-size: 10px;
  color: var(--text-dim);
  padding: 6px 10px;
  background: rgba(108,99,255,0.08);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(108,99,255,0.15);
  line-height: 1.5;
}

.export-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.export-actions .btn { justify-content: center; font-size: 11px; }

.preset-actions {
  display: flex;
  gap: 6px;
  padding: 6px 10px 10px;
  flex-shrink: 0;
}
.preset-actions .input-dark { flex: 1; }
.preset-actions .btn { flex-shrink: 0; font-size: 11px; }

/* ── MODAL ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 700px;
  max-width: 95vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.modal h3 { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }

.quick-presets, .saved-presets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.preset-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.preset-card:hover { border-color: var(--accent); background: var(--bg-hover); }
.preset-card .p-emoji { font-size: 28px; margin-bottom: 6px; }
.preset-card .p-name { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.preset-card .p-desc { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.preset-card .p-delete {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.15s;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--danger);
  font-family: var(--font);
}
.preset-card:hover .p-delete { opacity: 1; }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 13px;
  color: var(--text-primary);
  z-index: 2000;
  box-shadow: var(--shadow);
  animation: toastIn 0.2s ease;
  max-width: 400px;
  text-align: center;
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.warning { border-color: var(--warning); color: var(--warning); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── CONFLICT INDICATOR ── */
.block-card.conflicted {
  opacity: 0.3;
  pointer-events: none;
}
.block-card.conflicted::before {
  content: "✗";
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 12px;
  color: var(--danger);
}

/* ── DRAG HIGHLIGHT ── */
.character-preview.drag-over {
  border: 2px dashed var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

/* ── LOADING ── */
.generating {
  opacity: 0.6;
  pointer-events: none;
}
.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── SUBCATEGORY TABS ── */
.subcategory-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 12px 4px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.subcat-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
  white-space: nowrap;
}
.subcat-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.subcat-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ── VARIANT PICKER ── */
.variant-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}
.variant-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* Color swatches */
.variant-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s, border-color 0.1s;
  flex-shrink: 0;
}
.variant-swatch:hover { transform: scale(1.2); }
.variant-swatch.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent);
  transform: scale(1.1);
}

/* Pattern chips */
.variant-chip {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px 7px;
  font-size: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.1s;
  white-space: nowrap;
}
.variant-chip:hover { border-color: var(--accent); color: var(--text-primary); }
.variant-chip.active {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── RESULT IMAGE ZONE ── */
.result-image-zone {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}
.result-generating {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px;
  color: var(--text-secondary);
  font-size: 13px;
}
.spinner-lg {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid rgba(108,99,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.result-img {
  width: 100%;
  max-width: 100%;
  max-height: 520px;
  object-fit: contain;
  display: block;
  cursor: zoom-in;
  border-radius: var(--radius) var(--radius) 0 0;
  background: #000;
}
.result-actions {
  display: flex;
  gap: 8px;
  padding: 8px;
  justify-content: center;
  border-top: 1px solid var(--border);
}

/* ── FULLSCREEN OVERLAY ── */
.fullscreen-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fullscreen-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius);
}
.fs-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  font-size: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
}
.fs-close:hover { background: rgba(255,255,255,0.2); }

/* ── MISC ── */
.no-blocks-msg {
  grid-column: 1/-1;
  text-align: center;
  padding: 24px;
  color: var(--text-dim);
  font-size: 12px;
}
.lora-val { font-size: 10px; word-break: break-all; }

/* Prompt éditable hint */
.prompt-editable-hint {
  font-size: 10px;
  color: var(--accent);
  font-weight: 400;
  margin-left: 6px;
  opacity: 0.7;
}

/* ── GALLERY TAB ── */
.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 8px;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  overflow-y: auto;
  max-height: 340px;
}
.gallery-thumb {
  position: relative;
  aspect-ratio: 9/16;
  overflow: hidden;
  border-radius: var(--radius-sm);
  cursor: zoom-in;
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
}
.gallery-thumb:hover img { transform: scale(1.03); }
.gallery-dl {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0,0,0,0.6);
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 12px;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.gallery-thumb:hover .gallery-dl { opacity: 1; }

/* ── SEED CONTROL ── */
.seed-control {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.seed-label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}
.seed-input {
  flex: 1;
  font-size: 12px;
  font-family: var(--font-mono);
  min-width: 0;
}
/* Hide number input arrows */
.seed-input::-webkit-outer-spin-button,
.seed-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.seed-input[type=number] { -moz-appearance: textfield; }
.seed-btn {
  padding: 4px 8px;
  font-size: 14px;
  flex-shrink: 0;
}
.seed-display {
  font-family: var(--font-mono);
  font-size: 11px;
  word-break: break-all;
}

/* ── Generation Progress ── */
.gen-progress {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gen-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}
.gen-progress-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--text-primary);
}
.gen-progress-steps {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
}
.gen-progress-bar-wrap {
  height: 6px;
  background: var(--bg-hover);
  border-radius: 99px;
  overflow: hidden;
}
.gen-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 99px;
  transition: width 0.3s ease;
  width: 0%;
}
.gen-progress-bar.indeterminate {
  width: 40%;
  animation: progress-slide 1.4s ease-in-out infinite;
}
@keyframes progress-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
.gen-progress-log {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  min-height: 15px;
  transition: color 0.2s;
}
.gen-progress-log.active { color: var(--accent-3); }


/* ═══════════════════════════════════════════════════════════
   SMART BATCH BUILDER
   ═══════════════════════════════════════════════════════════ */

.batch-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  z-index: 1100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
}

.batch-modal {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.batch-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border);
}
.batch-modal-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

/* Config bar */
.batch-config {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.batch-intensity {
  display: flex;
  gap: 6px;
}
.int-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.int-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.int-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.batch-n-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}
.batch-n-input {
  width: 60px;
  padding: 5px 8px;
  font-size: 13px;
}

/* Plan wrap */
.batch-plan-wrap {
  display: flex;
  flex-direction: column;
}

.batch-table-scroll {
  overflow-x: auto;
  padding: 0 24px 8px;
  max-height: 55vh;
  overflow-y: auto;
}

.batch-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 4px;
  font-size: 12px;
}

.batch-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  z-index: 2;
  padding: 8px 6px 4px;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 11px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.bc-th-idx  { width: 32px; }
.bc-th-regen { width: 36px; }

.batch-table tbody tr:hover .bc-cell { border-color: var(--border-glow); }

/* Cell */
.bc-cell {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  background: color-mix(in srgb, var(--bcc, #6C63FF) 10%, var(--bg-card));
  border: 1px solid color-mix(in srgb, var(--bcc, #6C63FF) 25%, transparent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.12s;
  min-width: 90px;
  max-width: 130px;
  position: relative;
  user-select: none;
}
.bc-cell:hover {
  background: color-mix(in srgb, var(--bcc, #6C63FF) 18%, var(--bg-card));
  border-color: var(--bcc, #6C63FF);
}
.bc-cell-empty {
  background: var(--bg-card);
  border-color: var(--border);
  opacity: 0.5;
}
.bc-locked {
  border-style: dashed;
  opacity: 0.9;
}

.bc-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.2);
}

.bc-name {
  flex: 1;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
}
.bc-empty-label { color: var(--text-dim); }

.bc-lock-icon {
  font-size: 10px;
  opacity: 0;
  transition: opacity 0.1s;
  cursor: pointer;
  flex-shrink: 0;
}
.bc-cell:hover .bc-lock-icon,
.bc-locked .bc-lock-icon { opacity: 1; }

.bc-idx {
  color: var(--text-dim);
  font-size: 11px;
  padding: 0 8px 0 0;
  text-align: right;
  user-select: none;
}

.bc-regen {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.12s;
}
.bc-regen:hover { background: var(--bg-hover); }

/* Batch footer */
.batch-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.batch-footer-info {
  font-size: 11px;
  color: var(--text-dim);
  flex: 1;
}

/* Cell picker popover */
.bc-picker {
  position: absolute;
  z-index: 1200;
  background: var(--bg-surface);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 220px;
  max-width: 320px;
  padding: 8px;
}

.bc-picker-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  padding: 2px 4px 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.bc-picker-none {
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  margin-bottom: 6px;
  transition: background 0.1s;
}
.bc-picker-none:hover, .bc-picker-none-active {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.bc-picker-grid {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 240px;
  overflow-y: auto;
}

.bc-pick-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 11px;
  color: var(--text-primary);
  border: 1px solid transparent;
  transition: all 0.1s;
  background: color-mix(in srgb, var(--bcc, #6C63FF) 8%, transparent);
}
.bc-pick-chip:hover {
  background: color-mix(in srgb, var(--bcc, #6C63FF) 18%, var(--bg-card));
  border-color: var(--bcc, #6C63FF);
}
.bc-pick-active {
  background: color-mix(in srgb, var(--bcc, #6C63FF) 25%, var(--bg-card));
  border-color: var(--bcc, #6C63FF);
  font-weight: 600;
}

/* ── Batch questionnaire ── */
.batch-questionnaire {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 24px;
  overflow-y: auto;
  max-height: 55vh;
}

.bq-question {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.bq-question:last-child { border-bottom: none; }

.bq-q-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.bq-q-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.bq-multi-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 20px;
  padding: 2px 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bq-q-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.bq-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bq-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.12s;
  min-width: 130px;
  user-select: none;
}
.bq-opt:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-card));
}
.bq-selected {
  border-color: var(--accent) !important;
  background: color-mix(in srgb, var(--accent) 15%, var(--bg-card)) !important;
  box-shadow: 0 0 0 1px var(--accent);
}

.bq-opt-emoji {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}

.bq-opt-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bq-opt-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.bq-opt-sub {
  font-size: 10px;
  color: var(--text-dim);
}

/* Batch QA footer */
.batch-qa-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  gap: 12px;
}

.batch-n-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
}

.batch-n-input {
  width: 64px;
  padding: 6px 8px;
  font-size: 13px;
}

/* Pose dual display in batch table */
.bc-pose-duo {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow: hidden;
}
.bc-pose-main {
  font-size: 11px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bc-pose-alt {
  font-size: 10px;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.85;
}
